mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-10 19:37:17 -07:00
feat(browser): default persistent profile to ~/.gemini/cli-browser-profile
This commit is contained in:
@@ -141,7 +141,7 @@ The available modes are:
|
||||
|
||||
| Mode | Description |
|
||||
| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `persistent` | **(Default)** Launches Chrome with a persistent profile stored at `~/.cache/chrome-devtools-mcp/`. Cookies, history, and settings are preserved between sessions. |
|
||||
| `persistent` | **(Default)** Launches Chrome with a persistent profile stored at `~/.gemini/cli-browser-profile/`. Cookies, history, and settings are preserved between sessions. |
|
||||
| `isolated` | Launches Chrome with a temporary profile that is deleted after each session. Use this for clean-state automation. |
|
||||
| `existing` | Attaches to an already-running Chrome instance. You must enable remote debugging first by navigating to `chrome://inspect/#remote-debugging` in Chrome. No new browser process is launched. |
|
||||
|
||||
|
||||
@@ -157,6 +157,10 @@ describe('BrowserManager', () => {
|
||||
?.args as string[];
|
||||
expect(args).not.toContain('--isolated');
|
||||
expect(args).not.toContain('--autoConnect');
|
||||
// Persistent mode should set the default --userDataDir under ~/.gemini
|
||||
expect(args).toContain('--userDataDir');
|
||||
const userDataDirIndex = args.indexOf('--userDataDir');
|
||||
expect(args[userDataDirIndex + 1]).toMatch(/cli-browser-profile$/);
|
||||
});
|
||||
|
||||
it('should pass headless flag when configured', async () => {
|
||||
|
||||
@@ -22,10 +22,15 @@ import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'
|
||||
import type { Tool as McpTool } from '@modelcontextprotocol/sdk/types.js';
|
||||
import { debugLogger } from '../../utils/debugLogger.js';
|
||||
import type { Config } from '../../config/config.js';
|
||||
import { Storage } from '../../config/storage.js';
|
||||
import * as path from 'node:path';
|
||||
|
||||
// Pin chrome-devtools-mcp version for reproducibility.
|
||||
const CHROME_DEVTOOLS_MCP_VERSION = '0.17.1';
|
||||
|
||||
// Default browser profile directory name within ~/.gemini/
|
||||
const BROWSER_PROFILE_DIR = 'cli-browser-profile';
|
||||
|
||||
// Default timeout for MCP operations
|
||||
const MCP_TIMEOUT_MS = 60_000;
|
||||
|
||||
@@ -246,7 +251,7 @@ export class BrowserManager {
|
||||
|
||||
// Session mode determines how the browser is managed:
|
||||
// - "isolated": Temp profile, cleaned up after session (--isolated)
|
||||
// - "persistent": Persistent profile at ~/.cache/chrome-devtools-mcp/ (default)
|
||||
// - "persistent": Persistent profile at ~/.gemini/cli-browser-profile/ (default)
|
||||
// - "existing": Connect to already-running Chrome (--autoConnect, requires
|
||||
// remote debugging enabled at chrome://inspect/#remote-debugging)
|
||||
if (sessionMode === 'isolated') {
|
||||
@@ -261,6 +266,13 @@ export class BrowserManager {
|
||||
}
|
||||
if (browserConfig.customConfig.profilePath) {
|
||||
mcpArgs.push('--userDataDir', browserConfig.customConfig.profilePath);
|
||||
} else if (sessionMode === 'persistent') {
|
||||
// Default persistent profile lives under ~/.gemini/cli-browser-profile
|
||||
const defaultProfilePath = path.join(
|
||||
Storage.getGlobalGeminiDir(),
|
||||
BROWSER_PROFILE_DIR,
|
||||
);
|
||||
mcpArgs.push('--userDataDir', defaultProfilePath);
|
||||
}
|
||||
|
||||
debugLogger.log(
|
||||
|
||||
Reference in New Issue
Block a user