diff --git a/packages/cli/src/gemini.tsx b/packages/cli/src/gemini.tsx index ed0324c2..46d9dfce 100644 --- a/packages/cli/src/gemini.tsx +++ b/packages/cli/src/gemini.tsx @@ -37,7 +37,6 @@ import { logUserPrompt, AuthType, getOauthClient, - shouldAttemptBrowserLaunch, } from '@google/gemini-cli-core'; import { validateAuthMethod } from './config/auth.js'; import { setMaxSizedBoxDebugging } from './ui/components/shared/MaxSizedBox.js'; @@ -188,7 +187,7 @@ export async function main() { if ( settings.merged.selectedAuthType === AuthType.LOGIN_WITH_GOOGLE && - (config.getNoBrowser() || !shouldAttemptBrowserLaunch()) + config.isBrowserLaunchSuppressed() ) { // Do oauth before app renders to make copying the link possible. await getOauthClient(settings.merged.selectedAuthType, config); diff --git a/packages/cli/src/ui/hooks/useAuthCommand.ts b/packages/cli/src/ui/hooks/useAuthCommand.ts index bb1d68a9..e57a11af 100644 --- a/packages/cli/src/ui/hooks/useAuthCommand.ts +++ b/packages/cli/src/ui/hooks/useAuthCommand.ts @@ -11,7 +11,6 @@ import { Config, clearCachedCredentialFile, getErrorMessage, - shouldAttemptBrowserLaunch, } from '@google/gemini-cli-core'; import { runExitCleanup } from '../../utils/cleanup.js'; @@ -60,7 +59,7 @@ export const useAuthCommand = ( settings.setValue(scope, 'selectedAuthType', authType); if ( authType === AuthType.LOGIN_WITH_GOOGLE && - (config.getNoBrowser() || !shouldAttemptBrowserLaunch()) + config.isBrowserLaunchSuppressed() ) { runExitCleanup(); console.log( diff --git a/packages/core/src/code_assist/oauth2.test.ts b/packages/core/src/code_assist/oauth2.test.ts index 8a1af056..ee63c02b 100644 --- a/packages/core/src/code_assist/oauth2.test.ts +++ b/packages/core/src/code_assist/oauth2.test.ts @@ -38,6 +38,7 @@ vi.mock('../utils/browser.js', () => ({ const mockConfig = { getNoBrowser: () => false, getProxy: () => 'http://test.proxy.com:8080', + isBrowserLaunchSuppressed: () => false, } as unknown as Config; // Mock fetch globally @@ -180,6 +181,7 @@ describe('oauth2', () => { const mockConfigWithNoBrowser = { getNoBrowser: () => true, getProxy: () => 'http://test.proxy.com:8080', + isBrowserLaunchSuppressed: () => true, } as unknown as Config; const mockCodeVerifier = { diff --git a/packages/core/src/code_assist/oauth2.ts b/packages/core/src/code_assist/oauth2.ts index 51227086..5958625a 100644 --- a/packages/core/src/code_assist/oauth2.ts +++ b/packages/core/src/code_assist/oauth2.ts @@ -26,7 +26,6 @@ import { clearCachedGoogleAccount, } from '../utils/user_account.js'; import { AuthType } from '../core/contentGenerator.js'; -import { shouldAttemptBrowserLaunch } from '../utils/browser.js'; import readline from 'node:readline'; // OAuth Client ID used to initiate OAuth2Client class. @@ -122,7 +121,7 @@ export async function getOauthClient( } } - if (config.getNoBrowser() || !shouldAttemptBrowserLaunch()) { + if (config.isBrowserLaunchSuppressed()) { let success = false; const maxRetries = 2; for (let i = 0; !success && i < maxRetries; i++) { diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index 6a3a18b6..3f406f85 100644 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -44,6 +44,7 @@ import { DEFAULT_GEMINI_FLASH_MODEL, } from './models.js'; import { ClearcutLogger } from '../telemetry/clearcut-logger/clearcut-logger.js'; +import { shouldAttemptBrowserLaunch } from '../utils/browser.js'; export enum ApprovalMode { DEFAULT = 'default', @@ -542,6 +543,10 @@ export class Config { return this.noBrowser; } + isBrowserLaunchSuppressed(): boolean { + return this.getNoBrowser() || !shouldAttemptBrowserLaunch(); + } + getSummarizeToolOutputConfig(): | Record | undefined {