From 1011918d50154a6946c913776d4885a0a9975f44 Mon Sep 17 00:00:00 2001 From: nesquena-hermes Date: Thu, 23 Apr 2026 15:14:21 -0700 Subject: [PATCH] feat: add PWA support (manifest, service worker, install prompt) (#920) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add PWA support (manifest, service worker, install prompt) (v0.50.178, #911) Co-authored-by: bsgdigital Closes #685 * fix(sw): await caches.match() before `|| fallback` so offline HTML actually shows The offline-navigation fallback was dead code: return caches.match('./') || new Response('...', ...); `caches.match()` returns a Promise, and Promise objects are always truthy in a `||` check — so the `new Response(...)` branch was never taken. On actual offline, `caches.match('./')` resolves to undefined (no cache hit for the root), the SW returns undefined, and the browser falls back to its own default offline page. The custom "Hermes requires a server connection" HTML was unreachable. Fix by threading the match through `.then()` so the resolved value (not the Promise object) feeds the `||`: return caches.match('./').then((cached) => cached || new Response(...)); Added 13 regression tests in tests/test_pwa_manifest_sw.py covering: - manifest.json validity + required PWA fields + icon existence - sw.js cache-version placeholder + API/stream bypass + correct offline pattern (explicitly rejects the broken `|| new Response` shape so it can't regress) - /manifest.json + /sw.js routes serve correct Content-Type, Cache-Control, Service-Worker-Allowed headers and inject WEBUI_VERSION - index.html links manifest, registers SW, has iOS PWA meta tags Co-Authored-By: Claude Opus 4.7 (1M context) --------- Co-authored-by: nesquena-hermes Co-authored-by: Nathan Esquenazi Co-authored-by: Claude Opus 4.7 (1M context) --- CHANGELOG.md | 4 + api/routes.py | 35 ++++++++ static/index.html | 16 ++++ static/manifest.json | 23 +++++ static/sw.js | 106 ++++++++++++++++++++++++ tests/test_pwa_manifest_sw.py | 152 ++++++++++++++++++++++++++++++++++ 6 files changed, 336 insertions(+) create mode 100644 static/manifest.json create mode 100644 static/sw.js create mode 100644 tests/test_pwa_manifest_sw.py diff --git a/CHANGELOG.md b/CHANGELOG.md index b170c82..b768977 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,10 @@ ### Fixed - **Settings dialog and message controls unusable on mobile** — three mobile usability fixes: (1) settings tab strip replaced by a native `