diff --git a/tests/web/pi-adapter.test.ts b/tests/web/pi-adapter.test.ts index af2f7476..ea88a01a 100644 --- a/tests/web/pi-adapter.test.ts +++ b/tests/web/pi-adapter.test.ts @@ -101,9 +101,33 @@ test("snapshot pins current and selected sessions while bounding the projection" (session) => session.id === current.getSessionId(), ), ); + const currentSummary = snapshot.sessions.find( + (session) => session.id === current.getSessionId(), + ); + assert.deepEqual( + { + source: currentSummary?.source, + origin: currentSummary?.origin, + controller: currentSummary?.controller, + readOnly: currentSummary?.readOnly, + }, + { + source: "web-session", + origin: "web", + controller: "web", + readOnly: false, + }, + ); assert.ok( snapshot.sessions.some((session) => session.path === selectedPath), ); + const selectedSummary = snapshot.sessions.find( + (session) => session.path === selectedPath, + ); + assert.equal(selectedSummary?.source, "web-session"); + assert.equal(selectedSummary?.origin, "web"); + assert.equal(selectedSummary?.controller, "none"); + assert.equal(selectedSummary?.readOnly, false); assert.equal(snapshot.selectedSession?.path, selectedPath); assert.equal( ( diff --git a/web/adapter/pi-adapter.ts b/web/adapter/pi-adapter.ts index fb4c0bc9..fe604a90 100644 --- a/web/adapter/pi-adapter.ts +++ b/web/adapter/pi-adapter.ts @@ -341,6 +341,10 @@ export class PiWebAdapter { id: session.id, path: session.path, cwd: resolve(session.cwd), + source: "web-session" as const, + origin: "web" as const, + controller: session.id === currentId ? ("web" as const) : ("none" as const), + readOnly: false as const, ...(session.name ? { name: boundedText(session.name, WEB_MAX_SESSION_PREVIEW) } : {}), @@ -378,6 +382,10 @@ export class PiWebAdapter { id: currentId, path: currentPath, cwd: resolve(this.runtime.cwd), + source: "web-session" as const, + origin: "web" as const, + controller: "web" as const, + readOnly: false as const, ...(this.runtime.sessionManager.getSessionName() ? { name: boundedText( diff --git a/web/protocol/types.ts b/web/protocol/types.ts index a7429b6e..60addc90 100644 --- a/web/protocol/types.ts +++ b/web/protocol/types.ts @@ -27,6 +27,10 @@ export interface WebSessionSummary { id: string; path: string; cwd: string; + source: "web-session"; + origin: "web"; + controller: "web" | "none"; + readOnly: false; name?: string; modified: string; created: string;