mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-22 11:04:42 -07:00
feat(sessions): record interactive-only errors and warnings to chat recording JSON files (#13300)
This commit is contained in:
@@ -30,6 +30,7 @@ describe('clearCommand', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
mockResetChat = vi.fn().mockResolvedValue(undefined);
|
||||
const mockGetChatRecordingService = vi.fn();
|
||||
vi.clearAllMocks();
|
||||
|
||||
mockContext = createMockCommandContext({
|
||||
@@ -38,7 +39,11 @@ describe('clearCommand', () => {
|
||||
getGeminiClient: () =>
|
||||
({
|
||||
resetChat: mockResetChat,
|
||||
getChat: () => ({
|
||||
getChatRecordingService: mockGetChatRecordingService,
|
||||
}),
|
||||
}) as unknown as GeminiClient,
|
||||
setSessionId: vi.fn(),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import { uiTelemetryService } from '@google/gemini-cli-core';
|
||||
import type { SlashCommand } from './types.js';
|
||||
import { CommandKind } from './types.js';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
|
||||
export const clearCommand: SlashCommand = {
|
||||
name: 'clear',
|
||||
@@ -14,6 +15,11 @@ export const clearCommand: SlashCommand = {
|
||||
kind: CommandKind.BUILT_IN,
|
||||
action: async (context, _args) => {
|
||||
const geminiClient = context.services.config?.getGeminiClient();
|
||||
const config = context.services.config;
|
||||
const chatRecordingService = context.services.config
|
||||
?.getGeminiClient()
|
||||
?.getChat()
|
||||
.getChatRecordingService();
|
||||
|
||||
if (geminiClient) {
|
||||
context.ui.setDebugMessage('Clearing terminal and resetting chat.');
|
||||
@@ -24,6 +30,13 @@ export const clearCommand: SlashCommand = {
|
||||
context.ui.setDebugMessage('Clearing terminal.');
|
||||
}
|
||||
|
||||
// Start a new conversation recording with a new session ID
|
||||
if (config && chatRecordingService) {
|
||||
const newSessionId = randomUUID();
|
||||
config.setSessionId(newSessionId);
|
||||
chatRecordingService.initialize();
|
||||
}
|
||||
|
||||
uiTelemetryService.setLastPromptTokenCount(0);
|
||||
context.ui.clear();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user