LWC-proposal 设计#6
Conversation
| @@ -0,0 +1,215 @@ | |||
| # 产品 Proposal —— AI 桌游主持人平台(AI DM) | |||
There was a problem hiding this comment.
This file contains Markdown, but the filename has no .md extension. That makes it easy for GitHub and local documentation tooling to treat it as a plain blob instead of rendered Markdown, and it also keeps it out of common *.md documentation searches. Please rename it to a Markdown filename, for example 产品 proposal-ai 桌游主持人.md, or place it under a docs path with a .md suffix.
|
|
||
| ## 六、基本概念与信息结构(交付给架构设计的输入) | ||
|
|
||
| 领域核心概念(详细类型见架构设计文档): |
There was a problem hiding this comment.
This sends readers to an architecture design document for the detailed domain types, but this PR does not add that document, link to it, or identify the issue that owns it. Since the acceptance criteria later depend on the same architecture document for the walking skeleton sequence, reviewers and implementers cannot verify the handoff from this proposal alone. Please add a concrete link/reference or move the required minimum type/sequence details into this proposal.
6 authoritative architecture/data design docs plus the COC 7th edition rules reference spreadsheet, for the frontend teammate to review. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This is the first real commit of the backend code (packages/ has been
sitting untracked locally for weeks) and the first time trpg-app/ is
tracked in this repo at all (previously .gitignore'd as "just a
teammate snapshot" — it now carries real integration work on top of
that snapshot, so it belongs here).
Backend (packages/):
- FastAPI REST + WebSocket server (server/main.py, server/rest/*,
server/ws/gateway.py).
- Real auth: bcrypt password hashing, opaque server-side session
tokens (not JWT) stored in a new user_sessions table.
- Real lobby: create room (host auto-joins), select module, room
preview by code, and a new POST /rooms/{room_code}/join endpoint
so a second player can join an existing room by code (not just the
host) — the WS room.join handler already supported this once a
PlayerRow exists, this REST endpoint is what creates that row for
guests.
- Real two-stage character creation (draft -> PATCH -> complete),
restricted to the player themself, occupation/skill data sourced
from the existing frontend COC7 dataset (verified against the
reference xlsx) rather than re-implemented server-side.
- Real WS session lifecycle: room.join / player.ready / game.start,
plus action.submit routed through Orchestrator -> RulesEngine ->
Narrator (real DeepSeek calls via the OpenAI-compatible SDK,
streaming) and view.private for per-player clue visibility.
- SqlAlchemy (async) + Alembic persistence for all of the above
(9 core tables), replacing the earlier walking-skeleton stubs.
- A hand-authored demo module ("惠特利旧宅" / The Whateley Estate,
4 scenes, seeded via scripts/seed_demo_module.py) standing in for
real module import, which is out of scope for now.
Frontend (trpg-app/):
- Real fetch/WebSocket client (api-client.ts) replacing the
mock-mode stub; auth token persisted via localStorage; WS connect
is idempotent so navigating between pages / React StrictMode's
double-mount doesn't open duplicate connections.
- Real register/login form kept and merged into the teammate's
redesigned entry screen (menu of join/create/browse) so both the
new UI and the auth requirement survive together.
- Create-room and join-room pages (new in the teammate's redesign)
wired to the real endpoints above; join room code input widened
from "1-4 digit numeric" to the actual 6-char alnum format the
backend generates.
- Character creation, lobby ready-up/start, and in-room chat wired
to the real REST/WS calls end to end.
- Fixed two pre-existing bugs in the teammate's redesign while
wiring it up: CreateRoomPage reset the "return from game select"
flag it had just set (wrong call order), and ScenarioSelectionPage
had no navigation fallback for the non-"return to create" path.
Repo/config:
- .gitignore no longer excludes trpg-app/.
- Added .env.example at repo root and trpg-app/ (real .env stays
untracked; trpg-app/.gitignore now also excludes .env explicitly).
- README documents env setup, the shared-server DB SSH tunnel
(address/port intentionally left as placeholders — ask the project
owner directly, not stored in git), and how to run both backend
and frontend locally.
Verified via full manual browser click-through (not just API/script
testing): register -> create room (pick game/module) -> build a
character -> ready up in lobby -> start game -> chat with the AI
keeper and receive a real, contextually accurate DeepSeek-generated
reply; separately verified the join-by-code path with a second
account.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
CreateRoomPage kept roomName/roomCode/maxPlayers in local component useState. Navigating to /games (and back) or hitting "back" from the next screen unmounts the component, wiping that local state — pure frontend bug, backend never even receives these three fields. Moved them into game-store.ts as roomNameDraft/roomCodeDraft/ maxPlayersDraft, alongside the existing gameId/systemId/sceneId which already survived this same navigation. Kept them out of reset() (which the game-selection flow calls to clear gameId/ systemId/sceneId) so selecting a game doesn't also wipe the room draft. Added clearRoomDraft(), called once the room is actually created. Verified in browser: fill the form, go through game/system/module selection, come back — all three fields still there. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Backend: extend GET /rooms/{room_code} to return a real per-player
list (nickname/isHost/ready/hasCharacter) for polling-based room
state instead of a WS broadcast.
- Frontend: rebuild lobby as waiting-screen ① (real player list,
auto-advance once everyone is ready) and add CharacterReadyPage as
waiting-screen ② (real per-player character-completion status,
host-gated start, auto-advance once InGame). Guests now route
through the lobby like hosts, fixing the missing WS connection bug.
- "浏览已有游戏" now stops at system selection instead of continuing
into character creation.
- Split LoginPage/HomePage into two guarded routes instead of one
component branching on auth state.
- Misc fixes: RoomPage shows real player list/character data,
friendlyErrorMessage translation layer, room-store persisted to
sessionStorage, StoryPage scene fallback for guests.
- Dev server now tool-managed via .claude/launch.json (vite port
reads PORT env var).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
产品 proposal 的设计