diff options
Diffstat (limited to 'packages/cli/src/ui/hooks/atCommandProcessor.test.ts')
| -rw-r--r-- | packages/cli/src/ui/hooks/atCommandProcessor.test.ts | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/packages/cli/src/ui/hooks/atCommandProcessor.test.ts b/packages/cli/src/ui/hooks/atCommandProcessor.test.ts index 7403f788..837e0d32 100644 --- a/packages/cli/src/ui/hooks/atCommandProcessor.test.ts +++ b/packages/cli/src/ui/hooks/atCommandProcessor.test.ts @@ -98,10 +98,6 @@ describe('handleAtCommand', () => { processedQuery: [{ text: query }], shouldProceed: true, }); - expect(mockAddItem).toHaveBeenCalledWith( - { type: 'user', text: query }, - 123, - ); }); it('should pass through original query if only a lone @ symbol is present', async () => { @@ -120,10 +116,6 @@ describe('handleAtCommand', () => { processedQuery: [{ text: queryWithSpaces }], shouldProceed: true, }); - expect(mockAddItem).toHaveBeenCalledWith( - { type: 'user', text: queryWithSpaces }, - 124, - ); expect(mockOnDebugMessage).toHaveBeenCalledWith( 'Lone @ detected, will be treated as text in the modified query.', ); @@ -157,10 +149,6 @@ describe('handleAtCommand', () => { shouldProceed: true, }); expect(mockAddItem).toHaveBeenCalledWith( - { type: 'user', text: query }, - 125, - ); - expect(mockAddItem).toHaveBeenCalledWith( expect.objectContaining({ type: 'tool_group', tools: [expect.objectContaining({ status: ToolCallStatus.Success })], @@ -198,10 +186,6 @@ describe('handleAtCommand', () => { ], shouldProceed: true, }); - expect(mockAddItem).toHaveBeenCalledWith( - { type: 'user', text: query }, - 126, - ); expect(mockOnDebugMessage).toHaveBeenCalledWith( `Path ${dirPath} resolved to directory, using glob: ${resolvedGlob}`, ); @@ -236,10 +220,6 @@ describe('handleAtCommand', () => { ], shouldProceed: true, }); - expect(mockAddItem).toHaveBeenCalledWith( - { type: 'user', text: query }, - 128, - ); }); it('should correctly unescape paths with escaped spaces', async () => { @@ -271,10 +251,6 @@ describe('handleAtCommand', () => { shouldProceed: true, }); expect(mockAddItem).toHaveBeenCalledWith( - { type: 'user', text: query }, - 125, - ); - expect(mockAddItem).toHaveBeenCalledWith( expect.objectContaining({ type: 'tool_group', tools: [expect.objectContaining({ status: ToolCallStatus.Success })], @@ -1090,4 +1066,37 @@ describe('handleAtCommand', () => { }); }); }); + + it("should not add the user's turn to history, as that is the caller's responsibility", async () => { + // Arrange + const fileContent = 'This is the file content.'; + const filePath = await createTestFile( + path.join(testRootDir, 'path', 'to', 'another-file.txt'), + fileContent, + ); + const query = `A query with @${filePath}`; + + // Act + await handleAtCommand({ + query, + config: mockConfig, + addItem: mockAddItem, + onDebugMessage: mockOnDebugMessage, + messageId: 999, + signal: abortController.signal, + }); + + // Assert + // It SHOULD be called for the tool_group + expect(mockAddItem).toHaveBeenCalledWith( + expect.objectContaining({ type: 'tool_group' }), + 999, + ); + + // It should NOT have been called for the user turn + const userTurnCalls = mockAddItem.mock.calls.filter( + (call) => call[0].type === 'user', + ); + expect(userTurnCalls).toHaveLength(0); + }); }); |
