fix: PWA improvements — clean up SW, fix chin bar, add shortcuts, improve mobile support

- Remove dead precache manifest from SW (no fetch handler to consume it)
- Set empty globPatterns in vite-plugin-pwa config
- Fix bottom chin bar padding: use scaled safe-area token instead of raw inset
- Add 'New Session' PWA shortcut (client + server manifest)
- Add PWA meta tags to mobile.html (manifest, Apple icons, theme-color)
- Fix static site.webmanifest: add id/scope, correct description
- Remove duplicate apple-mobile-web-app-title from index.html
- Move SW registration to module scope (earlier, no window.load delay)
- Update manifest route tests for new shortcut order
This commit is contained in:
2026-09-07 21:37:06 +00:00
parent 4b95b327dd
commit b464500310
9 changed files with 69 additions and 27 deletions
+10 -11
View File
@@ -63,17 +63,16 @@ const runWhenDocumentCanRegisterServiceWorker = (task: () => void): void => {
};
const registerPwaServiceWorker = (): void => {
runWhenDocumentCanRegisterServiceWorker(() => {
try {
registerSW({
onRegisterError(error: unknown) {
console.warn('[PWA] service worker registration skipped:', error);
},
});
} catch (error) {
console.warn('[PWA] service worker registration skipped:', error);
}
});
if (!canUseServiceWorker()) return;
try {
registerSW({
onRegisterError(error: unknown) {
console.warn('[PWA] service worker registration skipped:', error);
},
});
} catch (error) {
console.warn('[PWA] service worker registration skipped:', error);
}
};
const unregisterDevelopmentServiceWorkers = (): void => {
+5 -10
View File
@@ -1,16 +1,11 @@
/// <reference lib="webworker" />
// NOTE: keep the Workbox injection point so vite-plugin-pwa can build.
// We intentionally do not use Workbox runtime helpers here: iOS Safari can be
// fragile with more complex SW bundles. For push notifications we only need a
// minimal SW.
// Minimal service worker: push notifications and click routing only.
// No fetch handler, no precache — the app relies on the server for assets
// and the event pipeline handles reconnection. iOS Safari is fragile with
// complex SW bundles, so we keep this as lean as possible.
declare const self: ServiceWorkerGlobalScope & {
__WB_MANIFEST: Array<string | { url: string; revision?: string }>;
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const __precacheManifest = self.__WB_MANIFEST;
declare const self: ServiceWorkerGlobalScope;
type PushPayload = {
title?: string;