Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

prompt + bios: drop SW module cache the moment a new deploy is detected

The piece-runs telemetry from the iPhone showed a familiar pattern:
prompt.mjs's version poll surfaces "๐Ÿ“ฆ New deployment detected: <hash>"
within ~1s of cap loading, but the page is still running last-deploy's
cached bios.mjs / disk.mjs (so the new bios's camera:debug events
never get sent โ€” and any rotation/UX fixes don't take effect).

Now when prompt sees the version flip:

- prompt.mjs send()s a new "sw:clear-cache" message to the main thread
(it can't talk to the SW directly because it runs in a Web Worker).
- bios.mjs catches it in receivedChange and calls
navigator.serviceWorker.controller.postMessage("clearCache"), which
the SW already knows how to handle (caches.delete(CACHE_NAME)).

We don't auto-reload โ€” that'd interrupt mid-task โ€” but the cache
eviction means the user's next manual reload pulls genuinely fresh
modules instead of stale-while-revalidating for up to an hour.

Should noticeably tighten the fix-deploy-test loop, especially on the
iOS app where WKWebView's HTTP cache compounds with the SW's.

+26
+13
system/public/aesthetic.computer/bios.mjs
··· 5963 5963 return; 5964 5964 } 5965 5965 5966 + if (type === "sw:clear-cache") { 5967 + // Forwarded from prompt.mjs's deployment poll. Tell the active SW 5968 + // to drop its module cache so the next page load fetches fresh 5969 + // bios.mjs / disk.mjs etc. instead of stale-while-revalidating. 5970 + try { 5971 + navigator.serviceWorker?.controller?.postMessage("clearCache"); 5972 + console.log("๐Ÿ”ง Main thread: requested SW cache clear"); 5973 + } catch (e) { 5974 + console.warn("๐Ÿ”ง Could not post clearCache to SW:", e); 5975 + } 5976 + return; 5977 + } 5978 + 5966 5979 // Helper function to ensure fonts are loaded before use 5967 5980 let fontsLoaded = false; 5968 5981 async function ensureFontsLoaded() {
+13
system/public/aesthetic.computer/disks/prompt.mjs
··· 822 822 recentCommits = data.recentCommits || []; 823 823 needsPaint(); 824 824 console.log("๐Ÿ“ฆ New deployment detected:", data.deployed); 825 + // Tell the active service worker (via the main thread, since we 826 + // run inside a Web Worker and don't have direct access to 827 + // navigator.serviceWorker) to evict its module cache. The 828 + // user's NEXT navigation/reload then pulls fresh bios.mjs + 829 + // disk.mjs instead of stale-while-revalidating for up to an 830 + // hour. We don't auto-reload here โ€” that would interrupt the 831 + // user mid-task โ€” but the cache eviction makes a manual 832 + // reload propagate the new build immediately. 833 + try { 834 + send({ type: "sw:clear-cache" }); 835 + } catch (e) { 836 + console.warn("๐Ÿ“ฆ Could not request SW cache clear:", e); 837 + } 825 838 break; // Stop polling โ€” update is available 826 839 } catch (e) { 827 840 if (e.name === "AbortError") break;