fix(ui): handle headless execution in credits and upgrade dialogs (#21850)

This commit is contained in:
Gaurav
2026-03-10 07:54:15 -07:00
committed by GitHub
parent 94ab449e65
commit 47e4f6b13f
7 changed files with 129 additions and 7 deletions

View File

@@ -44,6 +44,7 @@ vi.mock('../telemetry/index.js', () => ({
}));
vi.mock('../utils/secure-browser-launcher.js', () => ({
openBrowserSecurely: vi.fn(),
shouldLaunchBrowser: vi.fn().mockReturnValue(true),
}));
// Mock debugLogger to prevent console pollution and allow spying

View File

@@ -6,7 +6,10 @@
import type { Config } from '../config/config.js';
import { AuthType } from '../core/contentGenerator.js';
import { openBrowserSecurely } from '../utils/secure-browser-launcher.js';
import {
openBrowserSecurely,
shouldLaunchBrowser,
} from '../utils/secure-browser-launcher.js';
import { debugLogger } from '../utils/debugLogger.js';
import { getErrorMessage } from '../utils/errors.js';
import type { FallbackIntent, FallbackRecommendation } from './types.js';
@@ -112,6 +115,12 @@ export async function handleFallback(
}
async function handleUpgrade() {
if (!shouldLaunchBrowser()) {
debugLogger.log(
`Cannot open browser in this environment. Please visit: ${UPGRADE_URL_PAGE}`,
);
return;
}
try {
await openBrowserSecurely(UPGRADE_URL_PAGE);
} catch (error) {