summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/commands/clearCommand.ts
diff options
context:
space:
mode:
authorNick Salerni <[email protected]>2025-07-17 07:14:35 -0700
committerGitHub <[email protected]>2025-07-17 14:14:35 +0000
commit0d64355be6f69beb09c6c2f9fb1d08eb42f5f8e7 (patch)
tree1fa9739b909ef67b20d2797f311b6dd596dada90 /packages/cli/src/ui/commands/clearCommand.ts
parentac8e98511edc89533cf906f87835752c4531423a (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.ts15
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();
},
};