@raingor/pi-web-switch 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -1
- package/public/sw.js +28 -5
- package/server/agent-session-manager.ts +827 -0
- package/server/chat-api-plugin.ts +488 -0
- package/server/pi-reader.ts +242 -1
- package/src/App.tsx +2 -0
- package/src/components/chat/ChatInput.tsx +863 -0
- package/src/components/chat/ChatPage.tsx +617 -0
- package/src/components/chat/ChatWindow.tsx +338 -0
- package/src/components/chat/MessageView.tsx +595 -0
- package/src/components/dashboard/DashboardPage.tsx +45 -5
- package/src/components/layout/AppShell.tsx +12 -5
- package/src/components/layout/Sidebar.tsx +2 -0
- package/src/components/providers/ProvidersModelsPage.tsx +28 -10
- package/src/components/sessions/SessionsPage.tsx +466 -148
- package/src/hooks/useAgentSession.ts +1104 -0
- package/src/index.css +24 -0
- package/src/lib/translations/en.ts +69 -0
- package/src/lib/translations/ja.ts +69 -0
- package/src/lib/translations/zh-CN.ts +69 -0
- package/src/lib/translations/zh-TW.ts +69 -0
- package/src/main.tsx +4 -2
- package/src/store/config-store.ts +41 -0
- package/src/types/chat.ts +217 -0
- package/vite.config.ts +141 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raingor/pi-web-switch",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist-electron/main.js",
|
|
7
7
|
"description": "Web UI for pi coding agent — live configuration management, session browser, and memory viewer",
|
|
@@ -52,6 +52,10 @@
|
|
|
52
52
|
]
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
+
"@earendil-works/pi-agent-core": "^0.83.0",
|
|
56
|
+
"@earendil-works/pi-ai": "^0.83.0",
|
|
57
|
+
"@earendil-works/pi-coding-agent": "^0.83.0",
|
|
58
|
+
"@earendil-works/pi-tui": "^0.83.0",
|
|
55
59
|
"lucide-react": "^0.487.0",
|
|
56
60
|
"react": "^19.1.0",
|
|
57
61
|
"react-dom": "^19.1.0",
|
package/public/sw.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
// ─── pi-web-switch Service Worker ───────────────────────
|
|
2
|
-
//
|
|
3
|
-
//
|
|
2
|
+
// Strategy:
|
|
3
|
+
// - HTML navigation (index.html / SPA routes): NETWORK-FIRST.
|
|
4
|
+
// Every refresh must hit the network so deploys show up on a plain
|
|
5
|
+
// Cmd+R reload; the cached copy is only a fallback for offline use.
|
|
6
|
+
// - Static assets (hashed js/css): CACHE-FIRST — safe because Vite
|
|
7
|
+
// fingerprints filenames, so a new deploy means new URLs.
|
|
8
|
+
// - API calls: NETWORK-FIRST, fallback to cache.
|
|
9
|
+
// Bump CACHE_VERSION when the SW logic changes to purge old caches.
|
|
4
10
|
|
|
5
|
-
const CACHE_VERSION = "pi-web-switch-
|
|
11
|
+
const CACHE_VERSION = "pi-web-switch-v2";
|
|
6
12
|
const STATIC_CACHE = `${CACHE_VERSION}-static`;
|
|
7
13
|
const RUNTIME_CACHE = `${CACHE_VERSION}-runtime`;
|
|
8
14
|
|
|
15
|
+
// NOTE: index.html is intentionally NOT precached. Pre-caching it would
|
|
16
|
+
// make Cmd+R reloads serve the stale page after a deploy.
|
|
9
17
|
const PRECACHE_URLS = [
|
|
10
|
-
"/",
|
|
11
|
-
"/index.html",
|
|
12
18
|
"/manifest.webmanifest",
|
|
13
19
|
"/icon-192.png",
|
|
14
20
|
"/icon-512.png",
|
|
@@ -64,6 +70,23 @@ self.addEventListener("fetch", (event) => {
|
|
|
64
70
|
return;
|
|
65
71
|
}
|
|
66
72
|
|
|
73
|
+
// HTML navigation: network-first so a plain refresh always gets the
|
|
74
|
+
// latest build. Fall back to the last cached copy only when offline.
|
|
75
|
+
if (request.mode === "navigate") {
|
|
76
|
+
event.respondWith(
|
|
77
|
+
fetch(request)
|
|
78
|
+
.then((response) => {
|
|
79
|
+
if (response && response.status === 200 && response.type === "basic") {
|
|
80
|
+
const copy = response.clone();
|
|
81
|
+
caches.open(RUNTIME_CACHE).then((cache) => cache.put("/index.html", copy));
|
|
82
|
+
}
|
|
83
|
+
return response;
|
|
84
|
+
})
|
|
85
|
+
.catch(() => caches.match("/index.html"))
|
|
86
|
+
);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
67
90
|
// Static assets: cache-first, then network (and cache the result).
|
|
68
91
|
event.respondWith(
|
|
69
92
|
caches.match(request).then((cached) => {
|