feat(offline): gate the offline toggle on dictionary readiness #205

Merged
developer merged 1 commits from feature/offline-toggle-readiness into development 2026-07-06 18:12:02 +00:00
Owner

Fast-follow (b) from the offline plan: the Settings offline toggle now enforces dictionary readiness before entering offline mode, so you cannot land in a half-baked offline (no dawg -> cannot create/play a local vs_ai game) when the background preload has not finished yet.

Behaviour (round-3 design): flipping to offline fetches the enabled variants dictionaries cache-first (instant when already warm) and waits at most ~5 s, greying the toggle meanwhile. Ready -> enters offline (deliberate, persisted). Not ready in time -> stays online with a needs internet note, while the fetch keeps warming the cache in the background so a later flip is instant. Leaving offline (-> online) is never gated.

Shape:

  • offline.ts raceOfflineReady (pure, injected sleep) — unit-tested red->green (ready / still-failed / timeout).
  • dict/offlineready.ts ensureOfflineDicts — cache-first preloadDicts, lazy chunk (kept out of the main bundle).
  • offline.svelte.ts requestOffline (+ TOGGLE_READY_BUDGET_MS).
  • Settings.sveltechecking/needsData state, disabled toggle during the wait, inline note.
  • i18n settings.offlineChecking / settings.offlineNeedsData (en+ru).
  • Docs baked: FUNCTIONAL(+_ru) offline story + ARCHITECTURE offline paragraph.

Verified local: check 0 / unit 482 / e2e 196 / app entry 113.8/114 KB. Not reachable in the mock e2e (the toggle is PWA-gated) — contour review needed.

Fast-follow (b) from the offline plan: the Settings offline toggle now enforces dictionary readiness before entering offline mode, so you cannot land in a half-baked offline (no dawg -> cannot create/play a local vs_ai game) when the background preload has not finished yet. **Behaviour (round-3 design):** flipping **to** offline fetches the enabled variants dictionaries cache-first (instant when already warm) and waits at most ~5 s, greying the toggle meanwhile. Ready -> enters offline (deliberate, persisted). Not ready in time -> stays online with a *needs internet* note, while the fetch keeps warming the cache in the background so a later flip is instant. Leaving offline (-> online) is never gated. **Shape:** - `offline.ts` `raceOfflineReady` (pure, injected sleep) — unit-tested red->green (ready / still-failed / timeout). - `dict/offlineready.ts` `ensureOfflineDicts` — cache-first `preloadDicts`, lazy chunk (kept out of the main bundle). - `offline.svelte.ts` `requestOffline` (+ `TOGGLE_READY_BUDGET_MS`). - `Settings.svelte` — `checking`/`needsData` state, disabled toggle during the wait, inline note. - i18n `settings.offlineChecking` / `settings.offlineNeedsData` (en+ru). - Docs baked: FUNCTIONAL(+_ru) offline story + ARCHITECTURE offline paragraph. Verified local: check 0 / unit 482 / e2e 196 / app entry 113.8/114 KB. Not reachable in the mock e2e (the toggle is PWA-gated) — contour review needed.
developer added 1 commit 2026-07-06 18:03:29 +00:00
feat(offline): gate the offline toggle on dictionary readiness
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 1m10s
CI / conformance (pull_request) Successful in 9s
CI / gate (pull_request) Successful in 1s
CI / deploy (pull_request) Successful in 1m44s
30770a759b
Flipping the Settings toggle to offline now checks that every enabled variant's
dictionary is on the device before entering offline mode: it fetches missing ones
cache-first and waits up to ~5 s (raceOfflineReady + the lazy dict/offlineready),
greying the toggle meanwhile. If they cannot be readied in time it stays online and
shows a 'needs internet' note, while the fetch keeps warming the cache in the
background so a later flip is instant. Leaving offline is never gated.

Prevents entering a half-baked offline mode (no dawg -> cannot create/play a local
game) when the background preload has not finished (poor connection, or an immediate
flip right after install).

- offline.ts: raceOfflineReady (pure, injected sleep; unit-tested red->green)
- dict/offlineready.ts: ensureOfflineDicts (cache-first preloadDicts, lazy chunk)
- offline.svelte.ts: requestOffline + TOGGLE_READY_BUDGET_MS
- Settings.svelte: checking/needsData state, disabled toggle, inline note
- i18n: settings.offlineChecking / settings.offlineNeedsData (en+ru)
- docs: FUNCTIONAL(+_ru) offline story + ARCHITECTURE offline paragraph
owner approved these changes 2026-07-06 18:11:50 +00:00
developer merged commit 8fbbb3c5ef into development 2026-07-06 18:12:02 +00:00
developer deleted branch feature/offline-toggle-readiness 2026-07-06 18:12:02 +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#205