fix(daemon): forward snapshot entries and map workspace errors

- Preserve the snapshot entries tail in the cache and WS frames (cold,
  cached and bus paths), so the browser receives {state, entries}.
- Await a plugin snapshot on the first subscribe of a fresh session.
- Return E_FORBIDDEN (403) for workspace paths outside PI2_WORKSPACE_ROOTS.
- Mint cli.token only after the singleton lock is held, so a second daemon
  cannot invalidate the running one.
- Add hostname/os/version/uptimeMs/pid/port to /api/v1/info and make
  /health reflect instance, workspace and auth state.
This commit is contained in:
yuez committed 2026-10-21 20:42:02 +08:00
1 parent 31f36302bd
commit 5572ac0d84
15 files changed
+661 -22

No files matched your search

+9
View File
@@ -39,6 +39,15 @@ describe("static file surface", () => {
expect(await res.text()).toContain("<div id=app>");
});
it("serves the SPA shell for pairing deep links", async () => {
for (const path of ["/pair/ABCD1234", "/pair"]) {
const res = await fetch(`${h.url}${path}`);
expect(res.status).toBe(200);
expect(res.headers.get("cache-control")).toBe("no-store");
expect(await res.text()).toContain("<div id=app>");
}
});
it("returns 404 for a missing asset with an extension", async () => {
const res = await fetch(`${h.url}/assets/missing-deadbeef.js`);
expect(res.status).toBe(404);