From 6b3840b6ac97e8ae7fb43034ffe1522851cea882 Mon Sep 17 00:00:00 2001 From: iris Date: Sat, 12 Sep 2026 11:48:57 +0200 Subject: [PATCH] swarm-ui: content-hash main/theme/swarm-ui-css filenames for real cache-busting Every redeploy currently changes the nix store path serving swarm-ui's JS/CSS but never the URL the browser requested (main.js, main.css, theme.css, swarm-ui.css are all fixed filenames) -- so a browser can get stuck serving yesterday's bundle after a deploy until someone clears the cache by hand. build.mjs now hashes main.tsx's JS bundle + its companion CSS output, plus theme.css and swarm-ui.css, via esbuild's own metafile (not a guessed hash algorithm), and rewrites the real URLs into index.html and sw.js after the build. colors.css deliberately stays unhashed: nix/host-modules/swarm-ui.nix's stylix theming swaps that exact fixed path via an `= /static/colors.css` nginx location override with no npm/esbuild rebuild involved. Hashing it would silently break that swap on a themed host. sw.js's CACHE_VERSION is now derived from the real hashed URLs instead of a hand-bumped literal, so any shell-asset change gets a fresh cache name and the SW's own activate-time sweep evicts the previous one in full -- fulfilling a promise its own prior comment already made. Scope: swarm-ui only, per mara's call on hyperhive#4283 ("this is about swarm ui - everything else will eventually migrate over"). dashboard and agent are untouched. --- frontend/packages/swarm-ui/build.mjs | 183 ++++++++++++++++++++++----- frontend/packages/swarm-ui/src/sw.js | 35 ++--- 2 files changed, 170 insertions(+), 48 deletions(-) diff --git a/frontend/packages/swarm-ui/build.mjs b/frontend/packages/swarm-ui/build.mjs index 41f8a1c1..f14bb7da 100644 --- a/frontend/packages/swarm-ui/build.mjs +++ b/frontend/packages/swarm-ui/build.mjs @@ -1,25 +1,51 @@ // esbuild build for @hive/swarm-ui (project-bootstrap scope). Output // layout (`dist/`): // -// dist/index.html served at GET / -// dist/static/main.js served at /static/main.js (ESM bundle, -// Preact + wouter-preact) -// dist/static/main.js.map source map sibling -// dist/static/main.css every component's own `import +// dist/index.html served at GET / — its asset / +//