diff --git a/system/public/aesthetic.computer/bios.mjs b/system/public/aesthetic.computer/bios.mjs index 5a9d63a809..002de39809 100644 --- a/system/public/aesthetic.computer/bios.mjs +++ b/system/public/aesthetic.computer/bios.mjs @@ -5963,6 +5963,19 @@ async function boot(parsed, bpm = 60, resolution, debug) { return; } + if (type === "sw:clear-cache") { + // Forwarded from prompt.mjs's deployment poll. Tell the active SW + // to drop its module cache so the next page load fetches fresh + // bios.mjs / disk.mjs etc. instead of stale-while-revalidating. + try { + navigator.serviceWorker?.controller?.postMessage("clearCache"); + console.log("🔧 Main thread: requested SW cache clear"); + } catch (e) { + console.warn("🔧 Could not post clearCache to SW:", e); + } + return; + } + // Helper function to ensure fonts are loaded before use let fontsLoaded = false; async function ensureFontsLoaded() { diff --git a/system/public/aesthetic.computer/disks/prompt.mjs b/system/public/aesthetic.computer/disks/prompt.mjs index ce9645f136..fde3f7eae5 100644 --- a/system/public/aesthetic.computer/disks/prompt.mjs +++ b/system/public/aesthetic.computer/disks/prompt.mjs @@ -822,6 +822,19 @@ async function boot({ recentCommits = data.recentCommits || []; needsPaint(); console.log("📦 New deployment detected:", data.deployed); + // Tell the active service worker (via the main thread, since we + // run inside a Web Worker and don't have direct access to + // navigator.serviceWorker) to evict its module cache. The + // user's NEXT navigation/reload then pulls fresh bios.mjs + + // disk.mjs instead of stale-while-revalidating for up to an + // hour. We don't auto-reload here — that would interrupt the + // user mid-task — but the cache eviction makes a manual + // reload propagate the new build immediately. + try { + send({ type: "sw:clear-cache" }); + } catch (e) { + console.warn("📦 Could not request SW cache clear:", e); + } break; // Stop polling — update is available } catch (e) { if (e.name === "AbortError") break;