From f914f8fca14dd79d4dbf285f9676247ac41b18a4 Mon Sep 17 00:00:00 2001 From: Jagjeevan Kashid Date: Thu, 19 Feb 2026 23:31:21 +0530 Subject: [PATCH 1/3] fix: use full paths for ACP diff payloads Signed-off-by: Jagjeevan Kashid --- packages/cli/src/zed-integration/zedIntegration.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/zed-integration/zedIntegration.ts b/packages/cli/src/zed-integration/zedIntegration.ts index 44b1890ce22..42674e9976a 100644 --- a/packages/cli/src/zed-integration/zedIntegration.ts +++ b/packages/cli/src/zed-integration/zedIntegration.ts @@ -680,7 +680,7 @@ export class Session { if (confirmationDetails.type === 'edit') { content.push({ type: 'diff', - path: confirmationDetails.fileName, + path: confirmationDetails.filePath, oldText: confirmationDetails.originalContent, newText: confirmationDetails.newContent, }); @@ -1200,7 +1200,9 @@ function toToolCallContent(toolResult: ToolResult): acp.ToolCallContent | null { if ('fileName' in toolResult.returnDisplay) { return { type: 'diff', - path: toolResult.returnDisplay.fileName, + path: + toolResult.returnDisplay.filePath ?? + toolResult.returnDisplay.fileName, oldText: toolResult.returnDisplay.originalContent, newText: toolResult.returnDisplay.newContent, }; From de71bff33cd6170d164c283a2369a90aa879bd97 Mon Sep 17 00:00:00 2001 From: Jagjeevan Kashid Date: Thu, 19 Feb 2026 23:33:07 +0530 Subject: [PATCH 2/3] test: cover ACP diff path Signed-off-by: Jagjeevan Kashid --- .../zed-integration/zedIntegration.test.ts | 127 ++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/packages/cli/src/zed-integration/zedIntegration.test.ts b/packages/cli/src/zed-integration/zedIntegration.test.ts index cc71dd9309b..f3ae9146c5f 100644 --- a/packages/cli/src/zed-integration/zedIntegration.test.ts +++ b/packages/cli/src/zed-integration/zedIntegration.test.ts @@ -574,6 +574,133 @@ describe('Session', () => { ); }); + it('should use filePath for ACP diff content in permission request', async () => { + const confirmationDetails = { + type: 'edit', + title: 'Confirm Write: test.txt', + fileName: 'test.txt', + filePath: '/tmp/test.txt', + originalContent: 'old', + newContent: 'new', + onConfirm: vi.fn(), + }; + mockTool.build.mockReturnValue({ + getDescription: () => 'Test Tool', + toolLocations: () => [], + shouldConfirmExecute: vi.fn().mockResolvedValue(confirmationDetails), + execute: vi.fn().mockResolvedValue({ llmContent: 'Tool Result' }), + }); + + mockConnection.requestPermission.mockResolvedValue({ + outcome: { + outcome: 'selected', + optionId: ToolConfirmationOutcome.ProceedOnce, + }, + }); + + const stream1 = createMockStream([ + { + type: StreamEventType.CHUNK, + value: { + functionCalls: [{ name: 'test_tool', args: {} }], + }, + }, + ]); + const stream2 = createMockStream([ + { + type: StreamEventType.CHUNK, + value: { candidates: [] }, + }, + ]); + + mockChat.sendMessageStream + .mockResolvedValueOnce(stream1) + .mockResolvedValueOnce(stream2); + + await session.prompt({ + sessionId: 'session-1', + prompt: [{ type: 'text', text: 'Call tool' }], + }); + + expect(mockConnection.requestPermission).toHaveBeenCalledWith( + expect.objectContaining({ + toolCall: expect.objectContaining({ + content: [ + { + type: 'diff', + path: '/tmp/test.txt', + oldText: 'old', + newText: 'new', + }, + ], + }), + }), + ); + }); + + it('should use filePath for ACP diff content in tool result', async () => { + mockTool.build.mockReturnValue({ + getDescription: () => 'Test Tool', + toolLocations: () => [], + shouldConfirmExecute: vi.fn().mockResolvedValue(null), + execute: vi.fn().mockResolvedValue({ + llmContent: 'Tool Result', + returnDisplay: { + fileName: 'test.txt', + filePath: '/tmp/test.txt', + originalContent: 'old', + newContent: 'new', + }, + }), + }); + + const stream1 = createMockStream([ + { + type: StreamEventType.CHUNK, + value: { + functionCalls: [{ name: 'test_tool', args: {} }], + }, + }, + ]); + const stream2 = createMockStream([ + { + type: StreamEventType.CHUNK, + value: { candidates: [] }, + }, + ]); + + mockChat.sendMessageStream + .mockResolvedValueOnce(stream1) + .mockResolvedValueOnce(stream2); + + await session.prompt({ + sessionId: 'session-1', + prompt: [{ type: 'text', text: 'Call tool' }], + }); + + const updateCalls = mockConnection.sessionUpdate.mock.calls.map( + (call) => call[0], + ); + const toolCallUpdate = updateCalls.find( + (call) => call.update?.sessionUpdate === 'tool_call_update', + ); + + expect(toolCallUpdate).toEqual( + expect.objectContaining({ + update: expect.objectContaining({ + content: [ + { + type: 'diff', + path: '/tmp/test.txt', + oldText: 'old', + newText: 'new', + }, + ], + }), + }), + ); + }); + it('should handle tool call cancellation by user', async () => { const confirmationDetails = { type: 'info', From e79b67cac4b1bb80508058703db326b48ffcaf0a Mon Sep 17 00:00:00 2001 From: Jagjeevan Kashid Date: Sat, 28 Feb 2026 17:54:06 +0530 Subject: [PATCH 3/3] test(acp): relax diff path assertions Signed-off-by: Jagjeevan Kashid --- .../src/zed-integration/zedIntegration.test.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/cli/src/zed-integration/zedIntegration.test.ts b/packages/cli/src/zed-integration/zedIntegration.test.ts index 486b754ea55..f3586b17f8d 100644 --- a/packages/cli/src/zed-integration/zedIntegration.test.ts +++ b/packages/cli/src/zed-integration/zedIntegration.test.ts @@ -676,14 +676,14 @@ describe('Session', () => { expect(mockConnection.requestPermission).toHaveBeenCalledWith( expect.objectContaining({ toolCall: expect.objectContaining({ - content: [ - { + content: expect.arrayContaining([ + expect.objectContaining({ type: 'diff', path: '/tmp/test.txt', oldText: 'old', newText: 'new', - }, - ], + }), + ]), }), }), ); @@ -739,14 +739,14 @@ describe('Session', () => { expect(toolCallUpdate).toEqual( expect.objectContaining({ update: expect.objectContaining({ - content: [ - { + content: expect.arrayContaining([ + expect.objectContaining({ type: 'diff', path: '/tmp/test.txt', oldText: 'old', newText: 'new', - }, - ], + }), + ]), }), }), );