mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-13 02:14:32 +00:00
fix(browser): address platform and port review
This commit is contained in:
1 parent
06f6f5485f
commit
8a17410f96
7 files changed
+87
-18
No files matched your search
@@ -1,14 +1,9 @@
|
||||
import { getBrowserStatus, type BrowserStatusPayload } from '../utils/browser';
|
||||
import { getNodePlatformKey } from '../utils/browser/platform';
|
||||
import { color, dim, header, initUI, subheader } from '../utils/ui';
|
||||
|
||||
type HelpWriter = (line: string) => void;
|
||||
|
||||
function currentPlatform(): 'darwin' | 'linux' | 'win32' {
|
||||
if (process.platform === 'darwin') return 'darwin';
|
||||
if (process.platform === 'win32') return 'win32';
|
||||
return 'linux';
|
||||
}
|
||||
|
||||
function summarizeBrowserHealth(status: BrowserStatusPayload): {
|
||||
label: 'ready' | 'partial' | 'action required';
|
||||
exitCode: 0 | 1;
|
||||
@@ -63,9 +58,8 @@ function writeClaudeStatus(
|
||||
writeLine(` Detail: ${status.detail}`);
|
||||
writeLine(` Next step: ${status.nextStep}`);
|
||||
if (includeLaunchGuidance && status.enabled && status.state !== 'ready') {
|
||||
writeLine(
|
||||
` Launch command (${currentPlatform()}): ${status.launchCommands[currentPlatform()]}`
|
||||
);
|
||||
const platform = getNodePlatformKey();
|
||||
writeLine(` Launch command (${platform}): ${status.launchCommands[platform]}`);
|
||||
}
|
||||
writeLine('');
|
||||
}
|
||||
|
||||
@@ -74,6 +74,9 @@ export function getEffectiveClaudeBrowserAttachConfig(
|
||||
overrideActive: false,
|
||||
userDataDir: configUserDataDir,
|
||||
devtoolsPort: configPort,
|
||||
// Config-backed browser attach always keeps an explicit port so launches
|
||||
// stay aligned with Settings > Browser, even when the effective value is
|
||||
// the default 9222.
|
||||
hasExplicitDevtoolsPort: true,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { getBrowserConfig } from '../../config/unified-config-loader';
|
||||
import { getCodexBinaryInfo } from '../../targets/codex-detector';
|
||||
import { type BrowserRuntimeEnv, resolveBrowserRuntimeEnv } from './chrome-reuse';
|
||||
import { getBrowserMcpServerName, getBrowserMcpServerPath } from './mcp-installer';
|
||||
import { getNodePlatformKey } from './platform';
|
||||
import {
|
||||
getEffectiveClaudeBrowserAttachConfig,
|
||||
getRecommendedBrowserUserDataDir,
|
||||
@@ -107,7 +108,7 @@ async function buildClaudeBrowserStatus(
|
||||
state: 'path_missing',
|
||||
title: 'Claude Browser Attach path is missing.',
|
||||
detail: message,
|
||||
nextStep: `Create or choose a Chrome user-data directory, then launch Chrome with attach mode enabled. Example: ${launchCommands[platformKey()]}`,
|
||||
nextStep: `Create or choose a Chrome user-data directory, then launch Chrome with attach mode enabled. Example: ${launchCommands[getNodePlatformKey()]}`,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -117,7 +118,7 @@ async function buildClaudeBrowserStatus(
|
||||
state: 'browser_not_running',
|
||||
title: 'Claude Browser Attach could not find a running browser session.',
|
||||
detail: message,
|
||||
nextStep: `Start Chrome with remote debugging and the configured user-data dir. Example: ${launchCommands[platformKey()]}`,
|
||||
nextStep: `Start Chrome with remote debugging and the configured user-data dir. Example: ${launchCommands[getNodePlatformKey()]}`,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -126,7 +127,7 @@ async function buildClaudeBrowserStatus(
|
||||
state: 'endpoint_unreachable',
|
||||
title: 'Claude Browser Attach could not reach the DevTools endpoint.',
|
||||
detail: message,
|
||||
nextStep: `Restart the attach browser session or confirm the configured port. Example: ${launchCommands[platformKey()]}`,
|
||||
nextStep: `Restart the attach browser session or confirm the configured port. Example: ${launchCommands[getNodePlatformKey()]}`,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -185,9 +186,3 @@ function buildLaunchCommands(userDataDir: string, devtoolsPort: number): Browser
|
||||
win32: `chrome.exe --remote-debugging-port=${devtoolsPort} --user-data-dir=${quotedPath}`,
|
||||
};
|
||||
}
|
||||
|
||||
function platformKey(): keyof BrowserLaunchCommands {
|
||||
if (process.platform === 'darwin') return 'darwin';
|
||||
if (process.platform === 'win32') return 'win32';
|
||||
return 'linux';
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
export type BrowserPlatformKey = 'darwin' | 'linux' | 'win32';
|
||||
|
||||
export function getNodePlatformKey(
|
||||
platform: NodeJS.Platform = process.platform
|
||||
): BrowserPlatformKey {
|
||||
if (platform === 'darwin') return 'darwin';
|
||||
if (platform === 'win32') return 'win32';
|
||||
return 'linux';
|
||||
}
|
||||
Reference in new issue
Block a user