bug: GM sees no walls after reconnect/reload #87

Closed
opened 2026-11-21 23:23:42 +01:00 by SirStone · 1 comment
Owner

Part of #63

Problem

GM walls vanish from the client after a GM tab reload/reconnect even though the server still holds them (it still blocks player sight). In a browser dry-run: create walls, reload the GM tab -> canvas.dataset.walls === '0', no lines, and the GM cannot select, open or delete any wall. A fresh GM WebSocket does receive a walls snapshot, so the data exists.

Cause

DESIGN §6.1 fixes the frame shape: the walls snapshot is {t:"walls", scene, walls:[{id, a, b, ...}]} — scene lives on the frame and each entry carries only the wall fields; the wall delta is {t:"wall", scene, id, a, b, ...}.

The server follows DESIGN (wallsFrame carries the frame scene; wallObjectOf entries deliberately omit it), but the client deviates: wallViewFromFrame requires scene on the object it parses and the walls reducer passes each snapshot entry, so every entry fails validation and the wall slice stays empty. Deltas work because they are parsed from the whole frame.

Fix direction

Bring the client back to DESIGN §6.1, not the server: parse a walls entry with the enclosing frame's scene (and remain tolerant of an entry that carries its own scene). No change to wall data a player may receive.

Acceptance

  • Client reducer test fed a real walls snapshot frame (frame-level scene, entries without scene) loads every wall.
  • WS black-box test pins the snapshot entry shape to the delta wall-record shape (same wall fields; scene only at frame level).
  • E2E: GM creates walls, reloads the tab -> walls are drawn, selectable, and a door still opens/closes; a server-restart variant reconnects to the same walls.
  • Explain why the existing E2E missed it (all wall tests built walls in-session and never reloaded) and close that gap.
  • Leakcheck: a player still never receives wall data (only the allowed marker).

Proven at

WS black-box + client reducer + e2e (devbox run test, devbox run client-test, devbox run e2e).

Part of #63 ## Problem GM walls vanish from the client after a GM tab reload/reconnect even though the server still holds them (it still blocks player sight). In a browser dry-run: create walls, reload the GM tab -> `canvas.dataset.walls === '0'`, no lines, and the GM cannot select, open or delete any wall. A fresh GM WebSocket does receive a `walls` snapshot, so the data exists. ## Cause DESIGN §6.1 fixes the frame shape: the `walls` snapshot is `{t:"walls", scene, walls:[{id, a, b, ...}]}` — `scene` lives on the frame and each entry carries only the wall fields; the `wall` delta is `{t:"wall", scene, id, a, b, ...}`. The server follows DESIGN (`wallsFrame` carries the frame `scene`; `wallObjectOf` entries deliberately omit it), but the client deviates: `wallViewFromFrame` requires `scene` on the object it parses and the `walls` reducer passes each snapshot entry, so every entry fails validation and the wall slice stays empty. Deltas work because they are parsed from the whole frame. ## Fix direction Bring the client back to DESIGN §6.1, not the server: parse a `walls` entry with the enclosing frame's `scene` (and remain tolerant of an entry that carries its own `scene`). No change to wall data a player may receive. ## Acceptance - [ ] Client reducer test fed a real `walls` snapshot frame (frame-level `scene`, entries without `scene`) loads every wall. - [ ] WS black-box test pins the snapshot entry shape to the delta wall-record shape (same wall fields; `scene` only at frame level). - [ ] E2E: GM creates walls, reloads the tab -> walls are drawn, selectable, and a door still opens/closes; a server-restart variant reconnects to the same walls. - [ ] Explain why the existing E2E missed it (all wall tests built walls in-session and never reloaded) and close that gap. - [ ] Leakcheck: a player still never receives wall data (only the allowed marker). ## Proven at WS black-box + client reducer + e2e (`devbox run test`, `devbox run client-test`, `devbox run e2e`).
SirStone added the ready-for-agentbug labels 2026-11-21 23:23:42 +01:00
SirStone added a new dependency 2026-11-21 23:23:52 +01:00
Author
Owner

Fixed on main in b938e6f.

Decision: DESIGN §6.1 is explicit: the walls snapshot is {t:"walls", scene, walls:[{id, a, b, ...}]} — scene on the frame, entries carry only the wall record — while a wall delta is {t:"wall", scene, id, a, b, ...}. The server matched DESIGN; the client deviated. So the fix is client-side: wallViewFromFrame takes the enclosing frame's scene, with an entry's own scene as the tolerant fallback. No wire shape changed.

Tests: client reducer fed a real snapshot frame (frame-level scene, scene-less entries); WS black-box pin that each snapshot entry equals the delta wall record; e2e GM draws walls, reloads, selects the door and toggles it, then a same-state-dir server restart reconnects to the same two walls.

Why e2e missed it: all wall e2e paths built walls in the same live session, so they exercised deltas only and never the snapshot→reducer path; the client unit test's snapshot fixture wrongly put scene inside each entry, so it passed against the client's deviation. Both gaps are now covered.

Leak check unchanged: players still receive no walls/wall/wall_gone or wall fields; the wall wire is GM-only except the allowed marker. Full gate green (test, client-test, e2e) plus mutation.

Fixed on main in `b938e6f`. **Decision:** DESIGN §6.1 is explicit: the `walls` snapshot is `{t:"walls", scene, walls:[{id, a, b, ...}]}` — `scene` on the frame, entries carry only the wall record — while a `wall` delta is `{t:"wall", scene, id, a, b, ...}`. The server matched DESIGN; the client deviated. So the fix is client-side: `wallViewFromFrame` takes the enclosing frame's `scene`, with an entry's own `scene` as the tolerant fallback. No wire shape changed. **Tests:** client reducer fed a real snapshot frame (frame-level scene, scene-less entries); WS black-box pin that each snapshot entry equals the delta wall record; e2e GM draws walls, reloads, selects the door and toggles it, then a same-state-dir server restart reconnects to the same two walls. **Why e2e missed it:** all wall e2e paths built walls in the same live session, so they exercised deltas only and never the snapshot→reducer path; the client unit test's snapshot fixture wrongly put `scene` inside each entry, so it passed against the client's deviation. Both gaps are now covered. Leak check unchanged: players still receive no `walls`/`wall`/`wall_gone` or wall fields; the wall wire is GM-only except the allowed marker. Full gate green (`test`, `client-test`, `e2e`) plus `mutation`.
Sign in to join this conversation.