bug(ux): update context percentage when /clear command is run (#4162)

Co-authored-by: matt korwel <matt.korwel@gmail.com>
This commit is contained in:
Nick Salerni
2025-07-17 07:14:35 -07:00
committed by GitHub
parent ac8e98511e
commit 0d64355be6
4 changed files with 160 additions and 7 deletions

View File

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