8000 fix(pwa): install overlay can no longer hang the app indefinitely by johannboehme · Pull Request #5 · johannboehme/tk-1 · GitHub
[go: up one dir, main page]

Skip to content

fix(pwa): install overlay can no longer hang the app indefinitely - #5

Merged
johannboehme merged 1 commit into
mainfrom
claude/fervent-proskuriakova-8dfd63
May 1, 2026
Merged

johannboehme merged 1 commit into
mainfrom
claude/fervent-proskuriakova-8dfd63

Conversation

@johannboehme
@johannboehme johannboehme commented May 1, 2026 •
Copy link
Copy Markdown
Owner

Summary

Layered on top of #3, which already addressed the repeat-visit case (sw.ready + controllerchange lifecycle hooks). This PR adds the cases #3 doesn't cover:

  • Dev mode: vite-plugin-pwa has devOptions.enabled: false, so no SW gets registered. sw.ready never resolves, controllerchange never fires, offlineReady never flips — the overlay would gate the UI forever on every dev visit. The InstallProgressOverlay now passes disabled: import.meta.env.DEV, skipping the overlay entirely in dev.
  • Final safety net (prod): a maxWaitMs hard timeout (default 120 s) auto-dismisses the overlay if all the lifecycle signals fail to fire — e.g. SW registration crashing in a way the browser doesn't surface as a controller event. The SW continues caching in the background, so losing the overlay doesn't lose the install. The 90 s slow-mode warning still shows first; the user gets ~30 s to read it before the hard dismiss.
  • Translation: the overlay's German strings ("Installiere TK-1", "Spulen … vor", "Falls das hängt") are now English to match the rest of the UI.

After this lands, three independent ways the overlay closes:

  1. The happy path (offlineReady flips, or sw.ready/controllerchange fires — both from fix(pwa): install overlay no longer hangs on repeat visits #3)
  2. Dev mode never opens it in the first place
  3. Hard timeout as a final safety net

Test plan

  • vitest run --project=unit src/pwa — 19/19 passing (10 in useInstallProgress.test.ts: 6 pre-existing + 2 from fix(pwa): install overlay no longer hangs on repeat visits #3 covering sw.ready/controllerchange, plus 2 new ones for maxWaitMs auto-dismiss and disabled: true)
  • tsc --noEmit — clean
  • Manual: load the dev server on a fresh port (e.g. when 5173 is busy and Vite falls back to 5174). Overlay should not appear.
  • Manual: in production, simulate a stuck SW registration → overlay should auto-dismiss after ~120 s (slow-mode warning at 90 s still appears beforehand).

🤖 Generated with Claude Code

In dev mode the SW plugin is disabled, so `offlineReady` never flips
true and the overlay gated the UI forever — reloading didn't help, each
reload restarted the same dead wait. The same trap exists in prod if
the SW genuinely fails to register.

Three independent ways out now:
- `disabled` option on the hook; the overlay passes
  `import.meta.env.DEV` so dev never gates.
- `maxWaitMs` hard timeout (default 120 s) auto-dismisses if SW doesn't
  finish — the SW continues caching in the background, so losing the
  overlay does not lose the install.
- Existing happy path (`offlineReady → visible: false`) unchanged.

Also translated the German strings on the overlay to English for
consistency with the rest of the UI.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@johannboehme
johannboehme force-pushed the claude/fervent-proskuriakova-8dfd63 branch from f559f77 to e0f608b Compare May 1, 2026 18:54
@johannboehme
johannboehme merged commit 7a79bd1 into main May 1, 2026
1 check passed
@johannboehme
johannboehme deleted the claude/fervent-proskuriakova-8dfd63 branch May 1, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0