diff --git a/packages/cli/src/acp-integration/session/Session.test.ts b/packages/cli/src/acp-integration/session/Session.test.ts index b8dadfd92c1..c56e16f042e 100644 --- a/packages/cli/src/acp-integration/session/Session.test.ts +++ b/packages/cli/src/acp-integration/session/Session.test.ts @@ -18347,6 +18347,48 @@ describe('Session', () => { ).toBe(false); }); + it('consumes a same-turn shell result without an automatic rerun', async () => { + const notifyShell = mockBackgroundShellRegistry.setNotificationCallback + .mock.calls[0][0] as ( + display: string, + model: string, + meta: { + shellId: string; + status: string; + sourceTurnId?: string; + }, + ) => void; + mockChat.sendMessageStream = vi + .fn() + .mockImplementationOnce(async () => { + notifyShell('shell complete', 'SAME_TURN_SHELL_RESULT', { + shellId: 'same-shell', + status: 'completed', + sourceTurnId: core.promptIdContext.getStore(), + }); + return completedText('Initial response'); + }) + .mockResolvedValue(completedText('Shell result incorporated')); + await session.prompt({ + sessionId: 'test-session-id', + prompt: [{ type: 'text', text: 'start' }], + }); + expect( + session + .collectActiveWorkHolds() + .some((hold) => hold.category === 'shell'), + ).toBe(false); + expect(mockChat.sendMessageStream).toHaveBeenCalledTimes(2); + expect( + vi.mocked(mockChat.sendMessageStream).mock.calls[1][1].message, + ).toEqual(expect.arrayContaining([{ text: 'SAME_TURN_SHELL_RESULT' }])); + expect( + vi + .mocked(mockClient.extMethod) + .mock.calls.some(([method]) => method === '_qwencode/start_turn'), + ).toBe(false); + }); + it('leaves an earlier-turn result for a separately admitted automatic execution', async () => { const notify = notification(); mockChat.sendMessageStream = vi