diff options
| author | Abhi <[email protected]> | 2025-06-16 02:33:59 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-16 06:33:59 +0000 |
| commit | 6af7a5c58934c9a09774f0d38c3b87c2c877ecc5 (patch) | |
| tree | e1cdd65a2ffab1a258cb341570556e35d5059ccc /packages/cli/src | |
| parent | dd679a6cdbf9a58647057adc8cb28ebfbcc53e7e (diff) | |
feat: clear should also clear chat history (#1008)
Diffstat (limited to 'packages/cli/src')
| -rw-r--r-- | packages/cli/src/ui/hooks/slashCommandProcessor.test.ts | 21 | ||||
| -rw-r--r-- | packages/cli/src/ui/hooks/slashCommandProcessor.ts | 7 |
2 files changed, 25 insertions, 3 deletions
diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts index d9712d6e..68dc3ea9 100644 --- a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts +++ b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts @@ -340,6 +340,27 @@ describe('useSlashCommandProcessor', () => { expect(commandResult).toBe(true); }); + it('/clear should clear items, reset chat, and refresh static', async () => { + const mockResetChat = vi.fn(); + mockConfig = { + ...mockConfig, + getGeminiClient: () => ({ + resetChat: mockResetChat, + }), + } as unknown as Config; + + const { handleSlashCommand } = getProcessor(); + let commandResult: SlashCommandActionReturn | boolean = false; + await act(async () => { + commandResult = await handleSlashCommand('/clear'); + }); + + expect(mockClearItems).toHaveBeenCalled(); + expect(mockResetChat).toHaveBeenCalled(); + expect(mockRefreshStatic).toHaveBeenCalled(); + expect(commandResult).toBe(true); + }); + it('/editor should open editor dialog and return true', async () => { const { handleSlashCommand } = getProcessor(); let commandResult: SlashCommandActionReturn | boolean = false; diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.ts index 11e1247f..916af3e7 100644 --- a/packages/cli/src/ui/hooks/slashCommandProcessor.ts +++ b/packages/cli/src/ui/hooks/slashCommandProcessor.ts @@ -181,10 +181,11 @@ export const useSlashCommandProcessor = ( }, { name: 'clear', - description: 'clear the screen', - action: (_mainCommand, _subCommand, _args) => { - onDebugMessage('Clearing terminal.'); + description: 'clear the screen and conversation history', + action: async (_mainCommand, _subCommand, _args) => { + onDebugMessage('Clearing terminal and resetting chat.'); clearItems(); + await config?.getGeminiClient()?.resetChat(); console.clear(); refreshStatic(); }, |
