# X-Haven Web — Implementation Plan **Status:** APPROVED — implementation in progress (Phase 0 started 2026-11-08). **Last updated:** 2026-11-16 Progress is tracked in this file: mark steps `- [x]` as they are completed and record milestones in §6. The reference app (`FrosthavenAssistant/`) is read-only; all new code lives in `server/` and `web/`. --- ## 1. Goals Re-architect X-haven Assistant as a **server-driven web app** (intent in `README.md`): - The web server owns **all** game state and is the single source of truth. - Player browsers submit **input only** — they carry no game state. - **Spectator** clients open the same page, read-only. - **Secret per-player data** (canonically: initiative values) is gated **by the server, per connection**, until the draw action reveals it to everyone. - **Full feature parity** with the reference app, with a **faithful reproduction** of its look and layout (restyled for the browser). ## 2. Decisions | Topic | Decision | Rationale | |---|---|---| | Server language | **Dart** (single package, WebSocket server) | ~12k lines of game logic (commands, state, methods, line parser) already exist in Dart and port nearly 1:1; the test suite ports too | | Client | **TypeScript + Svelte 5** (Vite-built static SPA) | decided; SPA served by the Dart server, no Node runtime in production | | Transport | **WebSocket** (single endpoint), JSON messages | server push + player input; no need for the old `S3nD:[EOM]` TCP framing | | State sync | **full-state push on every action** + monotonic index + full resync on reconnect | proven model from the reference app (`{i,d,e,s}` envelope); state is a few KB, tables are small | | Command execution | **server is the only executor** — clients send command name + args | matches "clients send input only"; cleaner than the reference app's client-executes-server-arbitrates model | | Deployment | one server process = one game (as today); default port **4567** | faithful to the original | | License | **AGPLv3** (inherited — ports reference-app code and ships its data/art assets) | upstream license | | Old server package | `frosthaven_assistant_server` (GameServer/TCP protocol) is **superseded** — we reuse its *concepts* (monotonic index, full-state push, resync, ping), not its code | the new protocol is native to WebSocket | ## 3. Architecture ### 3.1 Repo layout ``` whaven/ ├── PLAN.md # this file (progress tracked here) ├── server/ # Dart package: the game server (all game logic lives here) │ ├── bin/main.dart # entry: load data + save, serve static, open WS │ ├── lib/ │ │ ├── core/ # ported game logic (from frosthaven_assistant/lib/Resource/) │ │ │ ├── models/ # from lib/Model/ (immutable campaign/scenario/monster models) │ │ │ ├── state/ # GameState + part files → plain fields + toJson/fromJson │ │ │ ├── commands/ # all 84 command files + registry (wire name + args ↔ ctor) │ │ │ ├── methods/ # game/round/scenario/character/monster/deck/element methods │ │ │ ├── line_builder/ # Frosthaven ability-line parser │ │ │ ├── game_data.dart # loads server/assets/data from disk (was rootBundle) │ │ │ └── action_handler.dart │ │ ├── net/ # WS server, protocol codec, sessions, roles, visibility │ │ └── persist/ # save/load (single save now, multi-save in Phase 6) │ ├── test/ # ported test suite + new protocol/session/secret tests │ └── assets/ # COPIED from reference app: data/, images/, i18n/, fonts/ ├── web/ # Svelte SPA (TypeScript) │ └── src/ │ ├── lib/ │ │ ├── protocol/ # WS client, message types, reconnect + resync │ │ ├── state/ # stores: game state, session/seats, connection status │ │ ├── i18n/ # UI strings (ported .arb) + in-game ability-text translations │ │ └── components/ # faithful UI: top/bottom bar, main list, rows, cards, │ │ # decks, initiative widget, menus (dialogs) │ └── routes/ # the single game page └── (FrosthavenAssistant/ — read-only reference, gitignored) ``` ### 3.2 Server game core (port of `Resource/`) - `ValueNotifier`s are dropped — the server no longer needs local observers; browsers receive state over WebSocket. Everything else keeps the reference app's structure. - The `_StateModifier` capability token pattern is **kept**: commands remain the only mutation path. - **Command registry (new):** every command gains a wire descriptor — a short name plus serializable args — so the server can execute incoming player input (e.g. `{name:"draw", args:{}}`). The reference app builds commands directly in UI code and has no registry; this is the main structural addition to the port. - `ActionHandler`: execute command → increment index → record `describe()` → snapshot into undo history (250 deep) → persist to disk → broadcast per-connection state to all sessions. `undo`/`redo` run server-side on request. - `GameData` loads from `server/assets/data/` on disk (test data from the testData mirror). ### 3.3 Sessions, roles, ownership - Each connection gets a **persistent session id** (cookie) — survives page refresh, so a player keeps their seat. - Roles: - **Spectator** (default): receives state; cannot submit commands. - **Player**: a session that claims a character. The session that issues `AddCharacterCommand` owns the new character; previously-added characters can be claimed via a `claim` message. - A character has **at most one owning session**. When the owner's session disconnects, the character becomes unclaimed and any player session may claim it. - Any player may request undo/redo (the server plays the "host" role of the reference app). - Seat assignments (who owns which character) are broadcast as `seats` messages; the UI uses them to enable inputs only on the owning player's screen. ### 3.4 Secret data model (server-gated per connection) Generalizes the reference app's UI-only `??` mask (where every device actually held all initiative values) into real server-side gating: - State is serialized **per connection**: `serializeState(state, session)`. - During `chooseInitiative`: each character's initiative value is included **only** in the serialization sent to its owning session; every other connection (players and spectators) receives `??`/null. - Once `playTurns` starts (the `DrawCommand` transition): initiative is public in every serialization. - Implemented as a small **visibility layer** inside the serializer — a list of rules `(secret field, owner, revealed-when)`. Initiative is rule #1; any future secret is added as a new rule rather than a special case. - Secrets never exist on any connection other than the owner's — a strict improvement over the reference app. ### 3.5 Wire protocol (WebSocket, JSON) Client → server: ```jsonc { "t": "hello", "v": 1 } // first message (session id comes from cookie) { "t": "claim", "characterId": "..." } // claim a character seat { "t": "cmd", "name": "draw", "args": {} } // execute command (players only) { "t": "undo" } { "t": "redo" } // players only { "t": "ping" } ``` Server → client: ```jsonc { "t": "welcome", "v": 1, "session": "...", "role": "player|spectator", "index": 42, "description": "…", "event": {…}, "state": {…}, "seats": {…} } { "t": "update", "index": 43, "description": "…", "event": {…}, "state": {…} } // per-connection state { "t": "seats", "seats": {…} } { "t": "error", "code": "rejected|badRequest|…", "message": "…" } { "t": "pong" } ``` - `state` is a full JSON snapshot, **already masked for that connection** (3.4) — the equivalent of the reference app's `{i, d, e, s}` envelope. - The index is strictly monotonic; the server executes commands sequentially in arrival order. A command that fails validation (e.g. a second draw) is rejected with an `error` to the sender only — no client-side lockouts needed (replaces the reference app's 300 ms draw-button lockout). - Reconnect: the client re-sends `hello` with its session cookie → the server answers with a full `welcome` (latest state). No command replay, no drift recovery protocol needed. - Protocol version in the handshake (reference app precedent); mismatches get a clear error. ### 3.6 Persistence - After **every** action (faithful to the reference app): write the authoritative snapshot — GameState JSON + description history + seat ownership — to `server/saves/`. - On startup: restore the most recent save. Multi-save + character saves land in Phase 6. ## 4. Phased plan **M1** engine runs headless · **M2** multiplayer + secrets over WS · **M3** playable in a browser · **M4** card play complete · **M5** full feature set · **M6** settings/saves/locale parity · **M7** release. Note on effort: the engine port (Phase 1) is mechanical but large (~12k lines + test suite). The UI phases (3–5) are the biggest chunk overall — reproducing ~19k lines of Flutter UI faithfully in Svelte. ### Phase 0 — Scaffolding ✅ (2026-11-08) - [x] `server/` Dart package (SDK ≥ 3.11, matching the reference app): `bin/main.dart`, pubspec, analysis options - [x] `web/` Vite + Svelte 5 + TypeScript project; dev server proxies WS to the Dart server - [x] Copy assets from the reference app into `server/assets/`: `data/` (editions, rooms, summons — 3.3 MB JSON), `images/` (66 MB PNG), `i18n/` (in-game text, 10 locales), `fonts/` (+ `testData/` for the Phase 1 test loader) - [x] `LICENSE` (AGPLv3) + root `README.md` updated to describe the web app and how to run it - [x] `.gitignore` additions (Dart: `.dart_tool/`, `pubspec.lock`, `saves/`; web: `node_modules/`, `dist/`) - [x] CI script: `dart analyze && dart test` for the server; `tsc && vitest && vite build` for the web app (web typecheck is `svelte-check`, the Svelte-appropriate equivalent of `tsc` that also checks `.svelte` files) - [x] Smoke: server serves the built SPA at `/` and answers a WS `hello` with `welcome` (verified: `curl /healthz`, `curl /` → SPA, WS hello → welcome from a real client) Tooling notes (fixed during implementation): - Web deps pinned to a compatible set: vite 8 + `@sveltejs/vite-plugin-svelte` 7 + vitest 5 + svelte-check 4 (svelte-check 4.7's config loader requires the plugin 7 `vite-plugin-svelte:config` plugin name; plugin 5 + vite 6 is an incompatible combination). - Server logging uses `package:logging` — `Logger` is no longer in `dart:developer`/`dart:io` in SDK 3.13. ### Phase 1 — Game core on the server (headless) Port of the complete engine — all of it, so later phases are UI-only: - [x] `lib/Model/` → `server/lib/core/models/` - [x] `Resource/line_builder/` (ability-line parser) - [x] `Resource/game_data.dart` (disk-based loading) + test data loader - [x] `Resource/state/` → GameState and all part files (plain fields + toJson/fromJson, keep the `GameSaveState` snapshot structure) - [x] All 84 command files → `core/commands/` + **command registry** (wire name + args ↔ constructor, incl. args validation) - [x] All `*Methods` classes, `game_event.dart`, `stat_calculator.dart`, `card_stack.dart`, `enums.dart` - [x] `action_handler.dart`: index, 250-deep history, save after every action, undo/redo - [x] Port unit tests (`test/command/*`, `test/resource/*`, model tests) to the new core - [x] Headless integration test: full round driven by command invocations — scenario setup → characters → initiative → draw → turns → next round → round 2 **Milestone M1** — engine runs headless; ported test suite green. ### Phase 2 — Networking, sessions, secrets ✅ (2026-11-12) - [x] WS server: `hello`/`welcome` handshake, protocol version check, `ping`/`pong`, connection lifecycle (dead-connection cleanup) - [x] Sessions + roles: cookie session ids, spectator default, player on claim - [x] Character ownership: assignment on add, `claim`, re-claim after owner disconnects, `seats` broadcasts - [x] Per-connection state serialization with the visibility layer (initiative rule) — **the server never sends a secret to a non-owner** - [x] Command execution path: player-role check → args validation → execute → per-connection `update` broadcast; `error` responses for rejects; undo/redo on request - [x] Persistence: save on every action, restore on startup - [x] Tests (fake WS clients): two players + one spectator — secret initiative never reaches non-owners; reveal on draw; reconnect resync; rejected duplicate draw; claim/lose seat; snapshot restored across a server restart **Milestone M2** — complete multiplayer + server-gated secrets + persistence over WS, no UI. ### Phase 3 — Web UI: core loop ✅ (2026-11-15) - [x] Theme/design tokens matching the app's look (dark base, the three style themes) - [x] Page layout: TopBar (campaign/scenario/round info), MainList, BottomBar (draw button) - [x] MainList rows: CharacterRow (art, HP bar, conditions, initiative input), MonsterRow (art, HP, standees, state), placeholder for NoteRow - [x] Initiative widget: shows own value while entering, `??` for others, reveals on draw; input enabled only on the owning player's screen - [x] Menus (dialogs, faithful flows): select scenario (campaign → scenario → level/ difficulty), add/remove character, character level, stat changes (health, max, xp, bless/curse/empower/enfeeble), conditions, elements (use/imbue), turn done - [x] Room sections: add-section menu, auto-add standees - [x] Player vs spectator UI: inputs only for owned characters; spectator view read-only - [x] Connection UX: connecting/reconnecting banner, auto-resync, offline indicator - [x] UI i18n: English first (ported from the app's `.arb` files); locale plumbing in place - [x] Client unit tests: protocol client, state stores **Milestone M3** — playable in a browser: setup, secret initiative, draw, turns, stat changes, room sections, spectator view. *First end-to-end moment.* ### Phase 4 — Cards and decks ✅ (2026-11-16) - [x] Ability-line rendering (line_builder output: tokens, emphasis, range markers) with in-game translations (client-side equivalent of `TranslationService`) - [x] Monster ability decks (monsters only — the reference has no character ability decks): per-monster draw/discard piles + `lastRoundDrawn`, card slot in the monster row, deck menu (reveal top cards, draw extra, shuffle, activate/inactivate, drag-reorder, remove), card zoom - [x] Modifier decks: party (monster) / ally / per-character decks; full AMD rules (imbue 1/2, ±1/−2/+0, reveal, bad omen, corrosive spew, faction cards, perks, Hail/Cassandra specials, CS sanctuary/party cards), deck widget + menu + zoom - [x] Loot deck: draw/return/enhance, ownership, special cards 1418/1419, add cards, per-character loot totals, enhancement menu - [x] Card UI: faithful stat cards / ability cards / modifier cards / loot cards (images + rendered text), deck widgets, bottom deck area (loot deck left; character-deck toggle with the reference open-state cycling; ally + global decks) - [x] Server: registry entries for all deck/loot/modifier commands (built in Phases 1–2) + tests (server `modifier_deck_test.dart` / command tests; client helper tests in `web/test/deckHelpers.test.ts`) **Milestone M4** — full card play in the browser. ### Phase 5 — Campaign meta, notes, special rules - [x] Note rows: add/remove, text/color/link editing, reorder - [x] Special scenario rules: timed spawns, battle goals, initial scenario message - [x] Campaign meta: Crimson Scales party cards, faction cards, sanctuary donations - [x] Special monster handling: Ice Wraith form change, Bad Omen, Corrosive Spew, standee tracking, summons - [x] Solo mode, ally deck (OG Gloom), auto-level adjustment, difficulty variants, unlock-special - [x] Remaining commands in the registry + ported tests; server feature list cross-checked against the reference app **Milestone M5** — full game feature set. ### Phase 6 — Settings, saves, localization parity - [x] Settings split: **server-side, game-relevant** (noInit, noStandees, randomStandees, expireConditions, autoAddStandees/autoAddSpawns, hideLootDeck, style) vs **client-side** (UI scaling, full-screen, wake/Power-mode equivalents → browser `localStorage`) - [x] Multi-save save/load + character saves (load character save command) - [x] Undo/redo UI (player sessions) - [x] All 10 locales: port the gen-l10n `.arb` files to client i18n; server-localized command descriptions (ported `command_l10n`); locale selector in settings - [x] Settings menu (faithful) **Milestone M6** — feature parity with the reference app. ### Phase 7 — Hardening and shipping - [x] E2E (Playwright): two players + one spectator, a full round including secret initiative, claim/re-claim, reconnect - [x] Resilience: stale tabs, late updates, slow networks, server restart mid-game - [x] Performance: state payload size, WS bandwidth under a full table, asset caching headers for the 66 MB image set - [x] `Dockerfile` (server + built web) + deployment notes - [x] User-facing quickstart/README, smoke-test list - [x] Final cross-check pass against the reference app (feature list from Phase 5) **Milestone M7** — release. ## 5. Test strategy - **Server** (Dart `test`): ported command/state tests from the reference app; new tests for the command registry, sessions, seat claiming, per-connection serialization (secret gating), persistence, and WS integration (fake clients drive full rounds — mirroring the reference app's `network_sync_test.dart` approach, which already proved the protocol can be driven by an external client). - **Client** (Vitest): protocol client (frame handling, reconnect, resync), state stores, i18n fallbacks. - **E2E** (Playwright, Phase 7): the whole table experience in real browsers. ## 6. Progress log | Date | Event | |---|---| | 2026-11-08 | Plan drafted. Decisions fixed: Dart server, TS+Svelte client, full parity, faithful UI. | | 2026-11-08 | Plan approved. | | 2026-11-08 | **Phase 0 complete** — server package (shelf + WS, hello/welcome handshake, smoke tests 5/5), web app (Svelte 5 + TS, protocol client, svelte-check clean, build OK), assets copied (73 MB), AGPL license, README, .gitignore, CI script passing end-to-end. | | 2026-11-12 | **Phase 1 complete / M1 reached** — full engine ported to `server/lib/core/` (models, state + 18 part files, 7 methods classes, game_methods, 79 command files, enums, card_stack, stat_calculator, action_handler, disk-based game_data, l10n, minimal line_builder per conventions §8b). Command registry: 82 entries (wire name ↔ constructor + arg validation; enum/object args resolved against live state). Ported test suite: 81 test files, **562 tests green** (command tests 1:1 with the reference; resource/action-handler/stat-calculator/modifier-deck tests; registry smoke tests). New headless integration test drives a full round (setup → characters + standee → initiative gate → draw → every figure's turn incl. undo/redo → next round → round 2 → round 3). `dart analyze` warning-free. Porting conventions in `server/PORTING.md`. Notable porting fix found by tests: removable-card physical sync had to stay gated to the ten initial counters (reference listener semantics). | | 2026-11-12 | **Phase 2 complete / M2 reached** — networking, sessions, and server-gated secrets over WebSocket, no UI. New `server/lib/net/`: `protocol.dart` (JSON wire protocol, v1: `hello`/`welcome`/`update`/`seats`/`error`/`pong` + `claim`/`cmd`/`undo`/`redo`/`ping`), `sessions.dart` (32-hex session ids; role derived from seat ownership; `resolve()` adopts a well-formed cookie id so a browser keeps its seat across restarts), `seat_store.dart` (seat table in `saves/seats.json`, next to the state snapshot), `visibility.dart` (per-connection state serialization; the initiative rule masks every non-owned character's initiative to `null` until the round is drawn — **the server never sends a secret to a non-owner**), `game_server.dart` (the command execution path: role check → game-rule guard → registry build → execute → per-connection `update` broadcast; seat assign/claim/release + `seats` broadcasts; heartbeat sweep), `ws_upgrade.dart` (custom upgrade handler so the server can read the `x-haven-session` cookie — `shelf_web_socket` hides the `Request`), `app.dart` (shelf composition). `bin/main.dart` wires it together. Notable decisions: a server-side `_guard` replaces the reference app's 300 ms draw-button lockout (sequential execution makes a duplicate draw deterministically lose, the loser gets a clear `error`); the session that adds a character owns it and becomes a player; spectators may only `claim`/`addCharacter`; the command index resets to −1 on restart (the snapshot carries state, not undo history); dead-connection sweep defaults 20 s / 90 s. **Persistence bug found & fixed by the kill −9 test:** both file stores did fire-and-forget async `writeAsString`, so a write could land after the reboot's read — made `FileSaveStore.write`/`FileSeatStore.write` synchronous (`writeAsStringSync`) so "written through on every change" is actually on disk when `write` returns. Tests: **34 new network tests** (sessions 9, visibility 5, app 9, multiplayer 9, persistence 2) using a real WS stack on an ephemeral port — secret initiative never reaches non-owners, reveal on draw, reconnect resync, rejected duplicate draw, claim/lose/re-claim seat, undo/redo broadcast to every screen, dead-connection cleanup with seat release, snapshot + seat file restored across a restart. Full suite **591 tests green**; `dart analyze` warning-free; web typecheck/tests/build unaffected (Phase 2 is server-only). | | 2026-11-15 | **Phase 3 complete / M3 reached** — the web UI core loop: theme tokens + the three style themes, TopBar/MainList/BottomBar layout, character/monster/note rows, the secret-initiative widget (server-masked `null` → `??`), all figure menus (scenario, characters, level, stats, conditions, elements, turn done), room sections, player/spectator input gating, connection banner, English i18n, client tests (connection, protocol, state, level values). | | 2026-11-16 | **Phase 4 complete / M4 reached** — full card play in the browser. Client: the line renderer + in-game translations (`$lib/game/line/`, `gameI18n.ts`), card components (stat / monster-ability / modifier / loot, `ModifierCard` gfx resolver incl. `P` perk graphics), monster ability decks (row card slot, deck menu — reveal top cards, draw extra, extra shuffle, activate/inactivate, drag-reorder, remove — and card zoom), the full AMD suite (`ModifierDeckWidget` + `ModifierDeckHeader` + `ModifierDeckMenu` with the six submenus — send-to-bottom, remove AMD, removed pile, faction cards, perks, plus zoom; imbue 1/2, ±1/−2/+0, reveal with the Cassandra 8-button cap, bad omen, corrosive spew, Hail/Cassandra specials, faction unlock, CS sanctuary/party cards), the loot deck (widget, cards menu — set owner, per-character loot totals, add card, enhance with the reference material/herb/coin splits, special cards 1418/1419, return top/bottom), and the bottom `DeckArea` (loot deck left; character-deck toggle with the reference open-state cycling; ally deck behind `shouldShowAlliesDeck`; global deck). Pure helper modules (`rules.ts`, `modifierDeck.ts`, `perks.ts`, `cards/lootCard.ts`) ported from the reference with unit tests. Server: all deck/loot/modifier/ability commands were already registered and tested in Phases 1–2 (592 tests green). `svelte-check` 0 errors; web build OK; 177 client tests green. | | 2026-11-17 | **Phase 5 complete / M5 reached** — full game feature set. Web: note rows end-to-end (create/edit menu — text, 12-swatch colour palette, link to player/monster with per-standee selection, delete — with the reference's create-vs-edit commit semantics; row rendering with the target's class colour / red-blue monster bases, lighten-toward-white gradient, link indent + connector, standee "N:"/"All:" prefixes, luminance-based text colour, tap-to-edit; whole-list drag-to-reorder → `reorderList`; quick per-figure note via `setFigureNote` from the status menu), special monster handling (Ice Wraith "Switch Form" behind the `deck == "Ice Wraith"` gate; summon mark toggle with the round-green / summon-gfx standee artwork + standee-nr badges and per-owner grayscale; character summon boxes above the row + AddSummonMenu — class summons gated by level and standee cap, item summons from `summons.json`, colour swatches + standee numbers → `addStandee … addAsSummon`), ally deck show/hide in the main menu (gated by `shouldShowAlliesDeck`), settings "clear unlocked" + Special Unlocks menu (4 unlockables, "???" while locked), and AddSectionMenu parity (case-insensitive search, the `findNrFromScenarioName` numeric ordering with string-compare fallback, added sections greyed + no-op, "Add Random Dungeon Card" label). Data layer: `SummonModel` + `ClassData.summons` + `summons()` fetch in `gameData.ts`. Server: added `unlock_special_command_test` (the only command missing a test — ally-deck-hide and remove-sanctuary were already covered in their consolidated files). Cross-check against the reference confirmed scenario rules are complete server-side (Timer round-1 spawns merged into the start room via `_applyRound1Spawns`, Timer notes, battle-goal reminder, `initialMessage` → `toastMessage` → web toast, Objective/Escort/AllyDeck/ResetRound/Unlock/RandomSections all handled). Verification: web 177/177 tests, `svelte-check` 0 errors; server suite green; full CI (dart analyze + test, web check + test + build) passing. | | 2026-11-19 | **Phase 6 complete / M6 reached** — settings, saves, localization parity. Server: `Settings.forClient()` payload (11 game fields + `style` enum index + `locale` + `saves`/`characterSaves` name lists — save content never crosses the wire), player-gated settings/save commands behind new wire messages (`setSetting` / `save` / `loadSave` / `deleteSave` / `saveCharacter` / `loadCharacterSave` / `deleteCharacterSave` + a `settings` broadcast), `historyLength` + `undoDescription`/`redoDescription` on `welcome`/`update`, and the ported 10-locale command descriptions. Web: `settings.ts` split (`serverSettings` from the wire vs `clientSettings` → `localStorage` with a corrupt/partial-tolerant, field-by-field typed merge), the settings menu rebuilt faithfully (locale selector with native names — locale change also syncs the server; style radios; scaling sliders; power-mode radios + ⓘ info; ally-deck toggle via `setAllyDeckInOgGloom`; clear-unlocked + special unlocks; the Load/Save State entry), multi-save menus (`SaveMenu` + `SaveModalMenu` — suggested name `campaign+nr`, rename = delete-then-save, load is the undoable `LoadSaveCommand`) and character saves (`SaveCharacterMenu` + `SaveCharacterModalMenu`, entered from the add/remove-character menus via class icons, restore = identity only with fresh battle state), undo/redo buttons labeled from the server history metadata (`undoWithDescription`), all 10 locale tables ported (new `i18n.test.ts` parity suite), the idle dimmer (15 s → 0.65 scrim, 1.2 s fade, any input/tap/visibility wakes it), scaling via CSS variables (`--list-scale`/`--bar-scale`), reduce-power mode (`[data-power='reduce']` kills box-shadows), and the visibility gates (`hideLootDeck`, `showAmdDeck` ↔ client `showCharacterAMD`, `showScenarioNames`, `showCustomContent` in the campaign picker and the custom conditions). Documented web adaptations: bar scaling via CSS `zoom` instead of a constrained content width, a 400px list baseline (reference: 740px on full-screen mobile), bar-scaling default 1.0, three style radios (reference offers two, the shared `Style` enum has three), locale synced through the settings dropdown. Omitted reference entries (no web analogue): dark-mode toggle, soft numpad, health wheel, network section. Verification: **web 195/195 tests** (14 files, incl. new `settings.test.ts` and `i18n.test.ts`), `svelte-check` 0 errors (94 pre-existing idiomatic warnings), `vite build` OK; server **604 tests green** (13 new in `test/net/settings_test.dart`). | | 2026-11-22 | **Phase 7 complete / M7 reached** — hardening and shipping. **E2E** (Playwright, `e2e/`): a `table` fixture boots a real compiled server per test (temp saves dir, free port, `workers: 1`) and a `Tab` helper drives the real UI (menus, rows, initiative, draw, seats) against one real WS per fresh browser context (= one session). **9 specs green**: a full round (onboarding, secret initiative masked to `??` per connection, draw revealing on every screen, turns, next round, round-2 secrecy); seat claim / re-claim / reload (owner-leave releases the seat for re-claim; a reload keeps the session and re-claims; two sessions can't own one character); resilience (a dropped tab resyncs on reconnect — no drift; a SIGKILL'd server restarts with state **and** seats surviving, incl. the owner's secret initiative and enabled draw; a throttled tab converges on the same state as the fast tabs; a double-tapped draw runs once with the error sent only to the sender); and character level + rename from the status menu. **Session persistence (root-cause fix found by the restart test):** a client never learned its session id before the first `welcome`, so a reconnect minted a new id and orphaned the persisted/restored seat — fixed with `establishSessionCookie()` (a `GET /session` before the WS upgrade, with a vite `/session` proxy) so the upgrade carries the `x-haven-session` cookie and the server's `resolve()` re-adopts the restored seat. Also seeded the initiative input from re-synced state (the `CharacterRow` prefill `$effect`, guarded against clobbering a live edit) so a reload/reconnect doesn't blank an entry. **Cross-check vs the reference** (registry ↔ UI command-surface diff): every one of the 82 registered commands is reachable from the web UI (incl. `changeHealth`/`changeMaxHealth`/`changeXP`/`addCondition`/`removeCondition` via the StatusMenu `change()`/`toggleCondition()` helpers, amdImbue*/corrosiveSpew in the AMD header, and `trackStandees` via the `noStandees` setting). Four genuine gaps closed: `setCharacterLevel` + `changeName` (level pills + a name field in the StatusMenu, mirroring the reference `SetCharacterLevelMenu`) and the draw-pile-only "send to bottom" (`reorderAbilityList` → index 0) + "shuffle undrawn cards" (`shuffleDrawnAbilityCard`) in the ability-card removal confirm (mirroring `RemoveCardMenu`). **Resilience / deployment:** `Dockerfile` (3-stage: server + built web), `docs/DEPLOYMENT.md` (incl. a measured performance table via `server/tool/perf_measure.dart` and a 10-step smoke-test list), README quickstart + production/Docker/testing sections, and immutable asset-cache headers for the image set. Verification: **web 196/196 tests**, `svelte-check` 0 errors (93 pre-existing idiomatic warnings), `vite build` OK; **E2E 9/9 green** (~17 s). | ## 7. Risks and open items - **UI volume is the dominant cost.** ~19k lines of Flutter UI to reproduce faithfully in Svelte. Mitigation: faithful *flows and layout*, not pixel-perfect; menus are built once as a reusable dialog primitive. - **Command args coverage.** Every command's constructor args must be fully serializable (e.g. `AddMonsterCommand` with standee selection). Resolved in Phase 1 by the registry: live-object args (loot card, ability card, character/monster lists) travel as id/name/nr and are resolved against live state; enums by name; injected singletons never serialize. The registry remains the enforcement point in Phase 2. - **66 MB of images** — served statically with caching; no processing. Watch initial paint. - **Concurrent players.** Sequential server-side execution resolves races deterministically; the losing side gets a clear `error` (e.g. "round already drawn"). - **License.** AGPLv3 inheritance is assumed; if the app is ever offered as a managed service, AGPL §13 source-availability applies to network interaction — a legal call for the project owner, not a build blocker. - **Manual discrepancy** (found during survey): `docs/manual/09-multiplayer.html` §9.6 claims per-table configurable secrecy — no such setting exists in the code. The web version implements the actual behavior: initiative is always secret until draw.