mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-14 23:31:13 -07:00
fix: clean up /clear and /resume (#22007)
This commit is contained in:
@@ -23,10 +23,6 @@ export const clearCommand: SlashCommand = {
|
||||
action: async (context, _args) => {
|
||||
const geminiClient = context.services.config?.getGeminiClient();
|
||||
const config = context.services.config;
|
||||
const chatRecordingService = context.services.config
|
||||
?.getGeminiClient()
|
||||
?.getChat()
|
||||
.getChatRecordingService();
|
||||
|
||||
// Fire SessionEnd hook before clearing
|
||||
const hookSystem = config?.getHookSystem();
|
||||
@@ -34,6 +30,18 @@ export const clearCommand: SlashCommand = {
|
||||
await hookSystem.fireSessionEndEvent(SessionEndReason.Clear);
|
||||
}
|
||||
|
||||
// Reset user steering hints
|
||||
config?.userHintService.clear();
|
||||
|
||||
// Start a new conversation recording with a new session ID
|
||||
// We MUST do this before calling resetChat() so the new ChatRecordingService
|
||||
// initialized by GeminiChat picks up the new session ID.
|
||||
let newSessionId: string | undefined;
|
||||
if (config) {
|
||||
newSessionId = randomUUID();
|
||||
config.setSessionId(newSessionId);
|
||||
}
|
||||
|
||||
if (geminiClient) {
|
||||
context.ui.setDebugMessage('Clearing terminal and resetting chat.');
|
||||
// If resetChat fails, the exception will propagate and halt the command,
|
||||
@@ -43,16 +51,6 @@ export const clearCommand: SlashCommand = {
|
||||
context.ui.setDebugMessage('Clearing terminal.');
|
||||
}
|
||||
|
||||
// Reset user steering hints
|
||||
config?.userHintService.clear();
|
||||
|
||||
// Start a new conversation recording with a new session ID
|
||||
if (config && chatRecordingService) {
|
||||
const newSessionId = randomUUID();
|
||||
config.setSessionId(newSessionId);
|
||||
chatRecordingService.initialize();
|
||||
}
|
||||
|
||||
// Fire SessionStart hook after clearing
|
||||
let result;
|
||||
if (hookSystem) {
|
||||
@@ -69,7 +67,7 @@ export const clearCommand: SlashCommand = {
|
||||
await flushTelemetry(config);
|
||||
}
|
||||
|
||||
uiTelemetryService.setLastPromptTokenCount(0);
|
||||
uiTelemetryService.clear(newSessionId);
|
||||
context.ui.clear();
|
||||
|
||||
if (result?.systemMessage) {
|
||||
|
||||
Reference in New Issue
Block a user