fix(offline): zero tile weights on cold boot + wrong-mode game in the lobby #208
Reference in New Issue
Block a user
Delete Branch "fix/offline-alphabet-and-lobby"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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/alphabetcache, 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 seedslib/alphabetfrom 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 anawaitwith no generation guard, so a slow onlinegamesList()finishing after a fast offlinelist()(or vice versa) left the wrong mode games on screen. Fix: tag the snapshot withofflineand gategetLobby()on it; add a load-sequence guard so only the latestload()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.