From f2393903ecbd031583e26f5b12c8c27f86bb2a90 Mon Sep 17 00:00:00 2001 From: claude-code-best Date: Fri, 5 Jun 2026 10:49:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20ACP=20prompt=20=E6=9C=AA=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E5=85=A8=E5=B1=80=20sessionId=20=E5=AF=BC=E8=87=B4=20?= =?UTF-8?q?transcript=20=E5=86=99=E5=85=A5=E9=94=99=E8=AF=AF=E4=BC=9A?= =?UTF-8?q?=E8=AF=9D=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit prompt() 在调用 submitMessage 前没有 switchSession,recordTranscript 依赖全局 getSessionId() 确定写入路径,多会话场景下新会话内容会覆盖旧会话。 --- src/services/acp/__tests__/agent.test.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/services/acp/__tests__/agent.test.ts b/src/services/acp/__tests__/agent.test.ts index e1b0b1dac..6b9b33721 100644 --- a/src/services/acp/__tests__/agent.test.ts +++ b/src/services/acp/__tests__/agent.test.ts @@ -812,19 +812,20 @@ describe('AcpAgent', () => { ) }) - test('prompt does not trigger additional switchSession for multi-session', async () => { + test('prompt switches global sessionId to the correct session', async () => { const agent = new AcpAgent(makeConn()) await agent.newSession({ cwd: '/tmp' } as any) await agent.newSession({ cwd: '/tmp' } as any) mockSwitchSession.mockClear() - // Prompts should not call switchSession — alignment happens at session creation + // Prompts must switch global state so recordTranscript writes to + // the correct session file in multi-session scenarios. const s1 = agent.sessions.keys().next().value await agent.prompt({ sessionId: s1, prompt: [{ type: 'text', text: 'hello' }], } as any) - expect(mockSwitchSession).not.toHaveBeenCalled() + expect(mockSwitchSession).toHaveBeenCalledWith(s1, null) }) }) })