feat(client): service-worker update toast (new version available — reload) #225
Labels
No labels
area:auth
area:ci
area:db
area:infra
area:native
area:pwa
area:service
epic
feature
foundation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
james/carol#225
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Context
#208 (PR #223) shipped a hand-rolled service worker at
apps/client/public/sw.jsthat handles cache invalidation via aCACHE_VERSIONconstant — bumping it clears prior caches on the SW'sactivateevent. That works for purging stale assets, but it doesn't tell the user a new version is available.When Carol's deploy cadence picks up, a long-running installed PWA could keep serving a stale shell indefinitely until the user happens to refresh — and even then there's a brief race where the old SW serves cached content before the new one activates. A small in-app toast offering "Carol has a new version — reload?" closes both gaps.
Source
Follow-up flagged in #223.
Scope
apps/client/app/+html.tsx(or a sibling registration helper), listen for the SW'supdatefoundevent on the active registration.installedstate with a previous controller present (= new version waiting), expose the fact via a TanStack Query helper or a smalluseServiceWorkerUpdatehook.registration.waiting?.postMessage({ type: "SKIP_WAITING" })andwindow.location.reload()after the new SW takes control. Handle theSKIP_WAITINGmessage insw.js.useTheme(); strings viareact-i18next.Acceptance criteria
CACHE_VERSION, the installed PWA shows the toast within a minute or so of the next route navigation (when the SW's update check fires).Out of scope
Composes with
Part of
#176