diff options
| author | Nick Salerni <[email protected]> | 2025-07-17 07:14:35 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-17 14:14:35 +0000 |
| commit | 0d64355be6f69beb09c6c2f9fb1d08eb42f5f8e7 (patch) | |
| tree | 1fa9739b909ef67b20d2797f311b6dd596dada90 /packages/cli/src/ui/commands/clearCommand.ts | |
| parent | ac8e98511edc89533cf906f87835752c4531423a (diff) | |
bug(ux): update context percentage when /clear command is run (#4162)
Co-authored-by: matt korwel <[email protected]>
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(); }, }; |
