PWA: a new version reaches a reloaded tab (#132) #164

Closed
kayg wants to merge 0 commits from issue/132-pwa-merge into dev
Owner

Closes #132.

A waiting service worker used to take over only when no tab of the old version was left, which a Safari reload never reaches. Now, keeping "never swap code under someone typing":

  • Startup, before mount (main.ts -> applyWaitingAtStartup): a waiting version is activated and the page reloads once. Loop guard: at most one automatic reload per 20 s (sessionStorage), and the takeover message is re-sent a few times if the browser is slow to hand over.
  • Nobody can be typing: signed out (sign-in/setup), or no note open and nothing unsaved, applies at once.
  • Note open: the quiet "Update ready" offer stays; it also applies when the app returns to the front (visibilitychange) with nothing unsaved.
  • The editor reports open/unsaved through watchNote() (same NoteSession.status that drives "Saved"; anything but saved counts as unsaved).

Tests: apps/web/e2e/pwa-update.spec.ts (Chromium, on the app as production serves it; a deploy is faked by rewriting dist-served/sw.js): reload after a deploy shows the new version; coming back to the front applies it; an open note with unsaved typing is never swapped (socket held back so typing stays unsaved), then applies once saved; signed out applies at once. Existing pwa.spec passes.

Note: the machine was at load ~100 during testing, so timeouts in the new spec are generous.

🤖 Generated with Claude Code

https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T

(Replaces #163, merged with current dev. Review on #163.)

Closes #132. A waiting service worker used to take over only when no tab of the old version was left, which a Safari reload never reaches. Now, keeping "never swap code under someone typing": - **Startup, before mount** (`main.ts` -> `applyWaitingAtStartup`): a waiting version is activated and the page reloads once. Loop guard: at most one automatic reload per 20 s (sessionStorage), and the takeover message is re-sent a few times if the browser is slow to hand over. - **Nobody can be typing:** signed out (sign-in/setup), or no note open and nothing unsaved, applies at once. - **Note open:** the quiet "Update ready" offer stays; it also applies when the app returns to the front (`visibilitychange`) with nothing unsaved. - The editor reports open/unsaved through `watchNote()` (same `NoteSession.status` that drives "Saved"; anything but `saved` counts as unsaved). Tests: `apps/web/e2e/pwa-update.spec.ts` (Chromium, on the app as production serves it; a deploy is faked by rewriting `dist-served/sw.js`): reload after a deploy shows the new version; coming back to the front applies it; an open note with unsaved typing is never swapped (socket held back so typing stays unsaved), then applies once saved; signed out applies at once. Existing pwa.spec passes. Note: the machine was at load ~100 during testing, so timeouts in the new spec are generous. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T (Replaces #163, merged with current dev. Review on #163.)
PWA: a new version reaches a reloaded tab (#132)
Some checks failed
CI / rust (pull_request) Failing after 28s
CI / web (pull_request) Failing after 7m59s
672a162fd4
A waiting version now takes over at startup, when signed out or no note is
open, and when the app returns to the front with nothing unsaved. An open
note with unsaved typing is never swapped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Merge remote-tracking branch 'origin/dev' into issue/132-pwa-update-reload
Some checks failed
CI / rust (pull_request) Failing after 25s
CI / web (pull_request) Failing after 1m57s
4445a5b160
Author
Owner

Closing: this branch is already fully contained in dev (it landed through a merge train). Branch cleanup, 2026-10-15.

Closing: this branch is already fully contained in `dev` (it landed through a merge train). Branch cleanup, 2026-10-15.
kayg closed this pull request 2026-10-15 08:34:52 +00:00
Some checks failed
CI / rust (pull_request) Failing after 25s
CI / web (pull_request) Failing after 1m57s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal!164
No description provided.