feat(core): implement persistent browser session management (#21306)

Co-authored-by: Gaurav <39389231+gsquared94@users.noreply.github.com>
Co-authored-by: cynthialong0-0 <82900738+cynthialong0-0@users.noreply.github.com>
This commit is contained in:
Aditya Bijalwan
2026-03-27 03:03:37 +05:30
committed by GitHub
parent d25ce0e143
commit 73dd7328df
9 changed files with 332 additions and 61 deletions

View File

@@ -9,6 +9,7 @@ import {
SessionEndReason,
SessionStartSource,
flushTelemetry,
resetBrowserSession,
} from '@google/gemini-cli-core';
import { CommandKind, type SlashCommand } from './types.js';
import { MessageType } from '../types.js';
@@ -43,6 +44,10 @@ export const clearCommand: SlashCommand = {
if (geminiClient) {
context.ui.setDebugMessage('Clearing terminal and resetting chat.');
// Close persistent browser sessions before resetting chat
await resetBrowserSession();
// 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();

View File

@@ -11,6 +11,7 @@ import {
shutdownTelemetry,
isTelemetrySdkInitialized,
ExitCodes,
resetBrowserSession,
} from '@google/gemini-cli-core';
import type { Config } from '@google/gemini-cli-core';
@@ -72,6 +73,13 @@ export async function runExitCleanup() {
}
cleanupFunctions.length = 0; // Clear the array
// Close persistent browser sessions before disposing config
try {
await resetBrowserSession();
} catch (_) {
// Ignore errors during browser cleanup
}
if (configForTelemetry) {
try {
await configForTelemetry.dispose();