Merge pull request #2631 from QwenLM/fix/issue-1203-subagent-diff-tab-stuck
Some checks are pending
Qwen Code CI / Lint (push) Waiting to run
Qwen Code CI / Test (push) Blocked by required conditions
Qwen Code CI / Test-1 (push) Blocked by required conditions
Qwen Code CI / Test-2 (push) Blocked by required conditions
Qwen Code CI / Test-3 (push) Blocked by required conditions
Qwen Code CI / Test-4 (push) Blocked by required conditions
Qwen Code CI / Test-5 (push) Blocked by required conditions
Qwen Code CI / Test-6 (push) Blocked by required conditions
Qwen Code CI / Test-7 (push) Blocked by required conditions
Qwen Code CI / Test-8 (push) Blocked by required conditions
Qwen Code CI / Post Coverage Comment (push) Blocked by required conditions
Qwen Code CI / CodeQL (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:docker (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:none (push) Waiting to run
E2E Tests / E2E Test - macOS (push) Waiting to run

fix(acp-integration/agent): clear stale subagent diff confirmation after IDE accept
This commit is contained in:
Mingholy 2026-03-26 21:44:16 +08:00 committed by GitHub
commit 26e0128dc6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 414 additions and 12 deletions

View file

@ -623,7 +623,7 @@ export class Session implements SessionContext {
if (confirmationDetails.type === 'edit') {
content.push({
type: 'diff',
path: confirmationDetails.fileName,
path: confirmationDetails.filePath || confirmationDetails.fileName,
oldText: confirmationDetails.originalContent,
newText: confirmationDetails.newContent,
});

View file

@ -531,6 +531,86 @@ describe('SubAgentTracker', () => {
expect(respondSpy).toHaveBeenCalledWith(ToolConfirmationOutcome.Cancel);
});
});
it('should use filePath over fileName for diff content path', async () => {
tracker.setup(eventEmitter, abortController.signal);
const respondSpy = vi.fn().mockResolvedValue(undefined);
const event = createApprovalEvent({
name: 'edit_file',
callId: 'call-path-test',
description: 'Editing file',
confirmationDetails: createEditConfirmation({
fileName: 'test.ts',
filePath: '/workspace/src/test.ts',
originalContent: 'old content',
newContent: 'new content',
}),
respond: respondSpy,
});
eventEmitter.emit(AgentEventType.TOOL_WAITING_APPROVAL, event);
await vi.waitFor(() => {
expect(requestPermissionSpy).toHaveBeenCalled();
});
expect(requestPermissionSpy).toHaveBeenCalledWith(
expect.objectContaining({
toolCall: expect.objectContaining({
content: [
{
type: 'diff',
path: '/workspace/src/test.ts',
oldText: 'old content',
newText: 'new content',
},
],
}),
}),
);
});
it('should fall back to fileName when filePath is not available', async () => {
tracker.setup(eventEmitter, abortController.signal);
const respondSpy = vi.fn().mockResolvedValue(undefined);
const event = createApprovalEvent({
name: 'edit_file',
callId: 'call-fallback-test',
description: 'Editing file',
confirmationDetails: {
type: 'edit' as const,
title: 'Edit file',
fileName: 'fallback.ts',
fileDiff: '',
originalContent: 'old',
newContent: 'new',
} as Omit<ToolEditConfirmationDetails, 'onConfirm'>,
respond: respondSpy,
});
eventEmitter.emit(AgentEventType.TOOL_WAITING_APPROVAL, event);
await vi.waitFor(() => {
expect(requestPermissionSpy).toHaveBeenCalled();
});
expect(requestPermissionSpy).toHaveBeenCalledWith(
expect.objectContaining({
toolCall: expect.objectContaining({
content: [
{
type: 'diff',
path: 'fallback.ts',
oldText: 'old',
newText: 'new',
},
],
}),
}),
);
});
});
describe('permission options', () => {

View file

@ -226,12 +226,13 @@ export class SubAgentTracker {
const editDetails = event.confirmationDetails as unknown as {
type: 'edit';
fileName: string;
filePath: string;
originalContent: string | null;
newContent: string;
};
content.push({
type: 'diff',
path: editDetails.fileName,
path: editDetails.filePath || editDetails.fileName,
oldText: editDetails.originalContent ?? '',
newText: editDetails.newContent,
});