diff options
Diffstat (limited to 'packages/cli/src/ui/commands/clearCommand.ts')
| -rw-r--r-- | packages/cli/src/ui/commands/clearCommand.ts | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/packages/cli/src/ui/commands/clearCommand.ts b/packages/cli/src/ui/commands/clearCommand.ts index e5473b5b..1c409359 100644 --- a/packages/cli/src/ui/commands/clearCommand.ts +++ b/packages/cli/src/ui/commands/clearCommand.ts @@ -4,14 +4,25 @@ * SPDX-License-Identifier: Apache-2.0 */ +import { uiTelemetryService } from '@google/gemini-cli-core'; import { SlashCommand } from './types.js'; export const clearCommand: SlashCommand = { name: 'clear', description: 'clear the screen and conversation history', action: async (context, _args) => { - context.ui.setDebugMessage('Clearing terminal and resetting chat.'); - await context.services.config?.getGeminiClient()?.resetChat(); + const geminiClient = context.services.config?.getGeminiClient(); + + if (geminiClient) { + context.ui.setDebugMessage('Clearing terminal and resetting chat.'); + // If resetChat fails, the exception will propagate and halt the command, + // which is the correct behavior to signal a failure to the user. + await geminiClient.resetChat(); + } else { + context.ui.setDebugMessage('Clearing terminal.'); + } + + uiTelemetryService.resetLastPromptTokenCount(); context.ui.clear(); }, }; |
