From 45de0e7b22a29d9453dea1a8829efe28e2d09e71 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Tue, 7 Jul 2026 11:15:06 +0100 Subject: [PATCH] forward session update event --- src/acp/session.ts | 12 ++++++++++++ test/component/session-events.test.ts | 24 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/acp/session.ts b/src/acp/session.ts index 2f40e46f..f5f41b54 100644 --- a/src/acp/session.ts +++ b/src/acp/session.ts @@ -822,6 +822,18 @@ export class PiAcpSession { break } + case 'session_info_changed': { + const name = stringProp(ev, 'name')?.trim() + if (name) { + this.emit({ + sessionUpdate: 'session_info_update', + title: name, + updatedAt: new Date().toISOString() + }) + } + break + } + case 'turn_end': { // pi uses `turn_end` for sub-steps (e.g. tool_use) and will often start another turn. // Do NOT resolve the ACP `session/prompt` here; wait for `agent_end`. diff --git a/test/component/session-events.test.ts b/test/component/session-events.test.ts index de921a00..20dcc509 100644 --- a/test/component/session-events.test.ts +++ b/test/component/session-events.test.ts @@ -34,6 +34,30 @@ test('PiAcpSession: emits agent_message_chunk for text_delta', async () => { }) }) +test('PiAcpSession: forwards pi session_info_changed as ACP session_info_update', async () => { + const conn = new FakeAgentSideConnection() + const proc = new FakePiRpcProcess() + + new PiAcpSession({ + sessionId: 's1', + cwd: process.cwd(), + mcpServers: [], + proc: proc as any, + conn: asAgentConn(conn), + fileCommands: [] + }) + + proc.emit({ type: 'session_info_changed', name: 'Auto Named Session' }) + + await new Promise(r => setTimeout(r, 0)) + + assert.equal(conn.updates.length, 1) + assert.equal(conn.updates[0]!.sessionId, 's1') + assert.equal(conn.updates[0]!.update.sessionUpdate, 'session_info_update') + assert.equal((conn.updates[0]!.update as any).title, 'Auto Named Session') + assert.match((conn.updates[0]!.update as any).updatedAt, /^\d{4}-\d{2}-\d{2}T/) +}) + test('PiAcpSession: emits agent_thought_chunk for thinking_delta', async () => { const conn = new FakeAgentSideConnection() const proc = new FakePiRpcProcess()