Add PWA update prompt instead of silent stale caching

Previously the service worker used registerType: 'autoUpdate' with
the default injected register script - a new deploy would install
and activate a new SW in the background, but an already-open tab
kept running the old JS/CSS from memory with no indication a newer
version existed, short of a manual hard reload (or clearing SW/
caches by hand, which we had to do repeatedly while verifying
deploys this session).

Switch to registerType: 'prompt' and register the SW ourselves via
virtual:pwa-register/react (useRegisterSW), showing a small "new
version available" toast with a reload button when an update is
waiting. Also poll registration.update() hourly so long-lived tabs
notice updates without needing a fresh navigation.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
MoepchiandClaude Sonnet 5 committed 2026-09-10 09:13:15 +02:00
1 parent dc35526727
commit 5b5f4caf79
5 files changed
+88 -1

No files matched your search

+36
View File
@@ -3457,6 +3457,42 @@
max-width: 90vw;
}
.ts-update-toast {
position: fixed;
left: 50%;
bottom: 1.25rem;
transform: translateX(-50%);
z-index: 600;
display: flex;
align-items: center;
gap: 0.6rem;
background: var(--panel-bg, #23262e);
color: var(--text, #eee);
border: 1px solid var(--border);
border-radius: 0.5rem;
padding: 0.6rem 0.7rem 0.6rem 0.9rem;
font-size: 13px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.ts-update-toast button {
border: 1px solid var(--border);
border-radius: 0.35rem;
background: var(--accent, #4a7dfc);
color: #fff;
font-size: 12px;
padding: 0.3rem 0.6rem;
cursor: pointer;
}
.ts-update-toast-dismiss {
background: transparent !important;
color: var(--text-muted, #999) !important;
border: none !important;
padding: 0 0.2rem !important;
font-size: 12px;
}
.ts-feedback-fab-wrap {
position: fixed;
right: 1.25rem;