Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
feat(webui): add PWA support for mobile home screen installation
zpljd25843ca12960b7a
diff --git a/webui/index.html b/webui/index.htmlindex d642c8d98..070e9966d 100644--- a/webui/index.html+++ b/webui/index.html@@ -14,6 +14,7 @@<link rel="icon" type="image/svg+xml" href="/brand/nanobot_mark.svg" /><link rel="alternate icon" type="image/png" sizes="32x32" href="/brand/nanobot_favicon_32.png" /><link rel="apple-touch-icon" sizes="180x180" href="/brand/nanobot_apple_touch.png" />+ <link rel="manifest" href="/manifest.json" /><style>html,body,diff --git a/webui/public/brand/nanobot_icon_192.png b/webui/public/brand/nanobot_icon_192.pngnew file mode 100644index 000000000..0559e9133Binary files /dev/null and b/webui/public/brand/nanobot_icon_192.png differdiff --git a/webui/public/brand/nanobot_icon_512.png b/webui/public/brand/nanobot_icon_512.pngnew file mode 100644index 000000000..3b11e435cBinary files /dev/null and b/webui/public/brand/nanobot_icon_512.png differdiff --git a/webui/public/brand/nanobot_icon_maskable.png b/webui/public/brand/nanobot_icon_maskable.pngnew file mode 100644index 000000000..3bcea79d3Binary files /dev/null and b/webui/public/brand/nanobot_icon_maskable.png differdiff --git a/webui/public/manifest.json b/webui/public/manifest.jsonnew file mode 100644index 000000000..aedf679af--- /dev/null+++ b/webui/public/manifest.json@@ -0,0 +1,33 @@+{+ "name": "nanobot",+ "short_name": "nanobot",+ "description": "nanobot AI assistant",+ "start_url": "/",+ "display": "standalone",+ "background_color": "#161618",+ "theme_color": "#161618",+ "orientation": "any",+ "icons": [+ {+ "src": "/brand/nanobot_apple_touch.png",+ "sizes": "180x180",+ "type": "image/png"+ },+ {+ "src": "/brand/nanobot_icon_192.png",+ "sizes": "192x192",+ "type": "image/png"+ },+ {+ "src": "/brand/nanobot_icon_512.png",+ "sizes": "512x512",+ "type": "image/png"+ },+ {+ "src": "/brand/nanobot_icon_maskable.png",+ "sizes": "512x512",+ "type": "image/png",+ "purpose": "maskable"+ }+ ]+}diff --git a/webui/public/sw.js b/webui/public/sw.jsnew file mode 100644index 000000000..4ebaa63b4--- /dev/null+++ b/webui/public/sw.js@@ -0,0 +1,72 @@+const CACHE_NAME = "nanobot-static-v1";+const PRECACHE = ["/", "/manifest.json"];++self.addEventListener("install", (event) => {+ event.waitUntil(+ caches.open(CACHE_NAME).then((cache) => cache.addAll(PRECACHE))+ );+ self.skipWaiting();+});++self.addEventListener("activate", (event) => {+ event.waitUntil(+ caches.keys().then((keys) =>+ Promise.all(+ keys+ .filter((k) => k !== CACHE_NAME)+ .map((k) => caches.delete(k))+ )+ )+ );+ self.clients.claim();+});++self.addEventListener("fetch", (event) => {+ const { request } = event;++ // Only handle same-origin GET requests+ if (request.method !== "GET") return;+ if (new URL(request.url).origin !== self.location.origin) return;++ const url = new URL(request.url);+ const path = url.pathname;++ // Never cache API, auth, WebSocket, or HMR paths+ if (+ path.startsWith("/api") ||+ path.startsWith("/auth") ||+ path.startsWith("/__nanobot")+ ) {+ return;+ }++ // Static assets: cache-first (immutable by gateway)+ if (/\.(js|css|png|webp|ico|svg|woff2?|ttf|eot)$/.test(path)) {+ event.respondWith(+ caches.match(request).then((cached) => {+ if (cached) return cached;+ return fetch(request).then((response) => {+ if (response.ok) {+ const clone = response.clone();+ caches.open(CACHE_NAME).then((c) => c.put(request, clone));+ }+ return response;+ });+ })+ );+ return;+ }++ // Everything else: network-first (index.html, manifest, etc.)+ event.respondWith(+ fetch(request)+ .then((response) => {+ if (response.ok) {+ const clone = response.clone();+ caches.open(CACHE_NAME).then((c) => c.put(request, clone));+ }+ return response;+ })+ .catch(() => caches.match(request))+ );+});diff --git a/webui/src/main.tsx b/webui/src/main.tsxindex 2fc96fd80..24fc02fbb 100644--- a/webui/src/main.tsx+++ b/webui/src/main.tsx@@ -28,3 +28,11 @@ initializeLoopbackRuntimeHost();/* StrictMode disabled: dev double-invokes state updaters; delta accumulation must stay pure — see useNanobotStream. */ReactDOM.createRoot(root).render(<App />);++if ("serviceWorker" in navigator) {+ window.addEventListener("load", () => {+ navigator.serviceWorker.register("/sw.js", {+ updateViaCache: "none",+ });+ });+}