feat: clear should also clear chat history (#1008)

This commit is contained in:
Abhi
2025-06-16 02:33:59 -04:00
committed by GitHub
parent dd679a6cdb
commit 6af7a5c589
4 changed files with 58 additions and 3 deletions

View File

@@ -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;

View File

@@ -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();
},