swarm-ui: PWA follow-ups from review

- manifest.webmanifest: mara — "name should be hyperhive", was
  "hyperhive swarm".
- sw.js: argus — cache-write path didn't check response.ok before
  caching; an error response would get served back as if it were the
  real asset on the next offline/failed fetch.
This commit is contained in:
iris 2026-09-12 01:05:30 +02:00 committed by mara
commit 1353bea7e1
2 changed files with 9 additions and 3 deletions

View file

@ -1,5 +1,5 @@
{ {
"name": "hyperhive swarm", "name": "hyperhive",
"short_name": "swarm", "short_name": "swarm",
"description": "Swarm-level operator UI — agent roster, hives, jobs, issues across the swarm.", "description": "Swarm-level operator UI — agent roster, hives, jobs, issues across the swarm.",
"start_url": "/", "start_url": "/",

View file

@ -100,8 +100,14 @@ self.addEventListener("fetch", (event) => {
event.respondWith( event.respondWith(
fetch(event.request) fetch(event.request)
.then((response) => { .then((response) => {
const copy = response.clone(); // Only a genuinely good response is worth caching — an error
caches.open(CACHE_NAME).then((cache) => cache.put(event.request, copy)); // response (a 404/500, or a proxy hiccup wearing a 2xx-adjacent
// status) would otherwise get served back as if it were the real
// asset on the next offline/failed fetch.
if (response.ok) {
const copy = response.clone();
caches.open(CACHE_NAME).then((cache) => cache.put(event.request, copy));
}
return response; return response;
}) })
.catch(() => caches.match(event.request)), .catch(() => caches.match(event.request)),