fix(offline): zero tile weights on cold boot + wrong-mode game in the lobby #208

Merged
developer merged 1 commits from fix/offline-alphabet-and-lobby into development 2026-07-06 21:21:19 +00:00
Owner

Two pre-existing offline bugs the owner hit on the contour — both exposed once offline mode became usable (cold boot + toggling). Independent of #207 (hint gate); branched off development.

Bug 1 — offline tiles show weight 0. The rack/board read tile values from the lib/alphabet cache, populated only by the online wire codec (server-sent alphabet) or the mock — so the mock e2e masked it. A local game never goes through the codec, so on a cold offline boot with no prior online session the cache is empty and every value reads 0 (scores stay correct — they come from the offline ruleset). Fix: the local source seeds lib/alphabet from the static offline ruleset (letters + values) when it builds a game view.

Bug 2 — the lobby showed (and could open) the other mode game after a toggle. Two causes: (a) the lobby cache was not mode-tagged, so getLobby() instant-rendered the last snapshot regardless of mode; (b) load() wrote the module list after an await with no generation guard, so a slow online gamesList() finishing after a fast offline list() (or vice versa) left the wrong mode games on screen. Fix: tag the snapshot with offline and gate getLobby() on it; add a load-sequence guard so only the latest load() writes.

Verified: check 0 / unit 485 / e2e 198 / app entry 113.8/114 KB. New tests: alphabet-seed (source.test), getLobby mode-awareness (lobbycache.test).

Note: this and #207 both touch source.ts in different regions; the second to merge will need a trivial source.ts reconcile.

Two **pre-existing** offline bugs the owner hit on the contour — both exposed once offline mode became usable (cold boot + toggling). Independent of #207 (hint gate); branched off development. **Bug 1 — offline tiles show weight 0.** The rack/board read tile values from the `lib/alphabet` cache, populated only by the online wire codec (server-sent alphabet) or the mock — so the mock e2e masked it. A local game never goes through the codec, so on a cold offline boot with no prior online session the cache is empty and every value reads 0 (scores stay correct — they come from the offline ruleset). **Fix:** the local source seeds `lib/alphabet` from the static offline ruleset (letters + values) when it builds a game view. **Bug 2 — the lobby showed (and could open) the other mode game after a toggle.** Two causes: (a) the lobby cache was not mode-tagged, so `getLobby()` instant-rendered the last snapshot regardless of mode; (b) `load()` wrote the module list after an `await` with no generation guard, so a slow online `gamesList()` finishing after a fast offline `list()` (or vice versa) left the wrong mode games on screen. **Fix:** tag the snapshot with `offline` and gate `getLobby()` on it; add a load-sequence guard so only the latest `load()` writes. Verified: check 0 / unit 485 / e2e 198 / app entry 113.8/114 KB. New tests: alphabet-seed (source.test), getLobby mode-awareness (lobbycache.test). Note: this and #207 both touch source.ts in different regions; the second to merge will need a trivial source.ts reconcile.
developer added 1 commit 2026-07-06 21:11:48 +00:00
fix(offline): zero tile weights on cold boot + wrong-mode game in the lobby
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 1m29s
CI / conformance (pull_request) Successful in 10s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m43s
359af83c34
Two pre-existing offline bugs, both exposed once offline mode became usable (cold boot +
toggling), owner-reported on the contour.

Bug 1 -- offline tiles render weight 0. The rack/board read tile values from the
lib/alphabet cache, populated only by the online wire codec (server-sent alphabet) or the
mock (so the e2e masked it). A local game never goes through the codec, so on a cold
offline boot with no prior online session the cache was empty and every value read 0
(scores stayed correct -- they come from the offline ruleset). Fix: the local source
seeds lib/alphabet from the static offline ruleset (letters + values) when it builds a
game view.

Bug 2 -- the lobby showed (and could open) the other mode's game after a toggle. Two
causes: (a) the lobby cache was not mode-tagged, so getLobby() instant-rendered the last
snapshot regardless of mode; (b) load() wrote the module list after an await with no
generation guard, so a slow online gamesList() finishing after a fast offline list() (or
vice versa) left the wrong mode's games on screen. Fix: tag the snapshot with offline and
gate getLobby() on it; add a load-sequence guard so only the latest load() writes.

- localgame/source.ts: ensureAlphabet from the ruleset in gameView (+ unit test).
- lobbycache.ts: LobbySnapshot.offline + getLobby(offline) mode check (+ tests).
- Lobby.svelte: setLobby tags the mode; load() carries a generation guard.

check 0 / unit 485 / e2e 198 / app entry 113.8/114.
owner approved these changes 2026-07-06 21:18:32 +00:00
developer merged commit 8c991429c6 into development 2026-07-06 21:21:19 +00:00
developer deleted branch fix/offline-alphabet-and-lobby 2026-07-06 21:21:19 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: developer/scrabble-game#208