Login landed on an empty "Pick a claw" stub — the integrated dashboard from the design comp was never assembled as the home. Now `/` IS the dashboard. - public/sw.js: cache v2→v3; RegisterServiceWorker reloads once when a new worker activates, so deploys are picked up without a manual hard-refresh - (workspace)/layout: ShellChrome renders the dashboard bare on "/" (it's self-contained) and the shared TopBar/LeftRail/StatusBar on every other route - components/dashboard: Dashboard (state machine + data) — top bar w/ breadcrumb, ORG/CO/TEAM/CLAW tier rail, tier-aware context list, TopologyCanvas (6-mode view-as selector, generalized layouts), and the agent "computer" slide-out (cm-fade) wrapping the existing ComputerPanel; status bar - motion.css: cm-fade keyframe Wired to existing endpoints (/api/teams|companies|orgs, /api/structure/*, /api/team/claws, /api/structure/stats, + ComputerPanel's apps/runtime-config/ routines). Defaults to the most-recent team; claw click opens the slide-out. Co-Authored-By: Claude Opus 4.8 <[email protected]>
61 lines
1.8 KiB
JavaScript
61 lines
1.8 KiB
JavaScript
// Clawmates service worker (§16 PWA). Hand-rolled on purpose: ~50 lines we
|
|
// fully control beats a build-tool plugin. Strategy:
|
|
// /api/** -> NEVER touched (approvals + SSE must be live)
|
|
// /_next/static/** -> cache-first (content-hashed, immutable)
|
|
// navigations -> network-first, cache fallback for offline shell
|
|
const STATIC_CACHE = "tc-static-v3";
|
|
const PAGE_CACHE = "tc-pages-v3";
|
|
|
|
self.addEventListener("install", () => {
|
|
self.skipWaiting();
|
|
});
|
|
|
|
self.addEventListener("activate", (event) => {
|
|
event.waitUntil(
|
|
(async () => {
|
|
const keep = [STATIC_CACHE, PAGE_CACHE];
|
|
for (const key of await caches.keys()) {
|
|
if (!keep.includes(key)) await caches.delete(key);
|
|
}
|
|
await self.clients.claim();
|
|
})(),
|
|
);
|
|
});
|
|
|
|
self.addEventListener("fetch", (event) => {
|
|
const url = new URL(event.request.url);
|
|
if (url.origin !== self.location.origin) return;
|
|
if (url.pathname.startsWith("/api/")) return;
|
|
|
|
if (url.pathname.startsWith("/_next/static/")) {
|
|
event.respondWith(
|
|
(async () => {
|
|
const cache = await caches.open(STATIC_CACHE);
|
|
const hit = await cache.match(event.request);
|
|
if (hit) return hit;
|
|
const response = await fetch(event.request);
|
|
if (response.ok) cache.put(event.request, response.clone());
|
|
return response;
|
|
})(),
|
|
);
|
|
return;
|
|
}
|
|
|
|
if (event.request.mode === "navigate") {
|
|
event.respondWith(
|
|
(async () => {
|
|
const cache = await caches.open(PAGE_CACHE);
|
|
try {
|
|
const response = await fetch(event.request);
|
|
if (response.ok) cache.put(event.request, response.clone());
|
|
return response;
|
|
} catch {
|
|
const hit = await cache.match(event.request);
|
|
if (hit) return hit;
|
|
throw new Error("offline and not cached");
|
|
}
|
|
})(),
|
|
);
|
|
}
|
|
});
|