Skip to content

feat(frontend): demo mode with labelled sample data; Chinese-first titles - #36

Open
LeoLin990405 wants to merge 1 commit into
mainfrom
feat/demo-mode
Open

LeoLin990405 wants to merge 1 commit into
mainfrom
feat/demo-mode

Conversation

@LeoLin990405

Copy link
Copy Markdown
Owner

What

A clearly labelled demo mode so the dashboard can be opened, screenshotted and recorded with no backend:

  • ?demo=1 (or build with VITE_DEMO=1) answers all /api/* GETs from frontend/src/demo/fixtures.json; Live Court replays a finished sample transcript over a fake EventSource (one event every ~0.7 s, then stops).
  • The fixture is not hand-typed JSON: frontend/scripts/build-demo-fixtures.mjs runs the real server routes in-process against examples/demo-state/ with a throwaway HOME, so payload shapes are whatever the server really returns (including the honest 503 "Database not available" for analytics/history, which have no sample DB).
  • Fixture chunk is lazy-loaded only in demo mode; the normal bundle is unchanged apart from the banner/title code.

Honesty rules

  • Regime catalog / identity / topology / skill stats / scenarios = real regimes/ data.
  • Tournament demo-t-001, matches demo-m-*, Live Court transcript and rankings = hand-written samples: demo: true, backend demo-fixture, judge provider demo-fixture (no model), every line prefixed 【示例数据】 / [DEMO].
  • Fixed, non-dismissable "DEMO · 示例数据" banner. In demo mode the sidebar shows ● DEMO 示例 / 未连接 (fixtures) instead of the hardcoded ● ONLINE localhost:3001.
  • Non-GET requests return 403 (nothing written); "launch" returns the sample tournament id and runs nothing.

Small visual fixes

  • Page + nav titles are Chinese-first (实时朝堂 LIVE COURT) with a small English label, matching the court theme; one tabs.ts source of truth.
  • Title uses solid text instead of background-clip gradient (CJK glyphs rendered blurry/washed with it).
  • CJK SC fallbacks in the body font stack; <html lang="zh-CN"> so browsers pick Simplified glyph variants.

Observed, not changed

  • With a single sample tournament, /api/stats/rankings marks every pairwise cell significant: true (CI collapses to a point when n=1). The UI does show "样本不足(1 < 5)", but the significance flag itself may deserve a games >= MIN_SAMPLE guard in engine/v5/stats.mjs.
  • Rankings chart: row labels sit underneath the vertical gridlines.

Checks

  • cd frontend && npx tsc -b && npx vite build ✓
  • npx vitest run ✓ (11 files / 28 tests incl. new src/demo/__tests__/demoMode.test.ts)
  • npx eslint . — 0 errors (6 pre-existing warnings)

Try: cd frontend && npm run dev → http://localhost:5173/?demo=1

… Chinese-first titles

- ?demo=1 / VITE_DEMO=1 serves /api/* from src/demo/fixtures.json and replays a
  finished sample Live Court transcript over a fake EventSource. No backend needed.
- fixtures.json is produced by frontend/scripts/build-demo-fixtures.mjs, which runs
  the real server routes in-process against examples/demo-state/ (throwaway HOME).
- Regime data is real; tournament/matches/rankings are hand-written samples, all
  flagged demo:true / backend demo-fixture / 【示例数据】. Fixed DEMO banner; sidebar
  no longer claims 'ONLINE localhost:3001' in demo mode. Writes refused.
- Page and nav titles Chinese-first with small English labels; solid title text
  instead of gradient clip; CJK SC font fallbacks; html lang=zh-CN.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant