feat(sessions): record interactive-only errors and warnings to chat recording JSON files (#13300)

This commit is contained in:
bl-ue
2025-11-19 09:32:13 -07:00
committed by GitHub
parent 282654e7b8
commit e1c711f5ba
14 changed files with 167 additions and 26 deletions
@@ -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();
},