diff --git a/browse/src/chrome-launcher.ts b/browse/src/chrome-launcher.ts index b2a0a234..d25d5873 100644 --- a/browse/src/chrome-launcher.ts +++ b/browse/src/chrome-launcher.ts @@ -22,15 +22,12 @@ export interface BrowserBinary { userDataDir: string; // required for --remote-debugging-port } -const HOME = process.env.HOME || '/tmp'; -const APP_SUPPORT = `${HOME}/Library/Application Support`; - export const BROWSER_BINARIES: BrowserBinary[] = [ - { name: 'Comet', binary: '/Applications/Comet.app/Contents/MacOS/Comet', appName: 'Comet', aliases: ['comet', 'perplexity'], userDataDir: `${APP_SUPPORT}/Comet` }, - { name: 'Chrome', binary: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', appName: 'Google Chrome', aliases: ['chrome', 'google-chrome'], userDataDir: `${APP_SUPPORT}/Google/Chrome` }, - { name: 'Arc', binary: '/Applications/Arc.app/Contents/MacOS/Arc', appName: 'Arc', aliases: ['arc'], userDataDir: `${APP_SUPPORT}/Arc/User Data` }, - { name: 'Brave', binary: '/Applications/Brave Browser.app/Contents/MacOS/Brave Browser', appName: 'Brave Browser', aliases: ['brave'], userDataDir: `${APP_SUPPORT}/BraveSoftware/Brave-Browser` }, - { name: 'Edge', binary: '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge', appName: 'Microsoft Edge', aliases: ['edge'], userDataDir: `${APP_SUPPORT}/Microsoft Edge` }, + { name: 'Comet', binary: '/Applications/Comet.app/Contents/MacOS/Comet', appName: 'Comet', aliases: ['comet', 'perplexity'], userDataDir: '' }, + { name: 'Chrome', binary: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', appName: 'Google Chrome', aliases: ['chrome', 'google-chrome'], userDataDir: '' }, + { name: 'Arc', binary: '/Applications/Arc.app/Contents/MacOS/Arc', appName: 'Arc', aliases: ['arc'], userDataDir: '' }, + { name: 'Brave', binary: '/Applications/Brave Browser.app/Contents/MacOS/Brave Browser', appName: 'Brave Browser', aliases: ['brave'], userDataDir: '' }, + { name: 'Edge', binary: '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge', appName: 'Microsoft Edge', aliases: ['edge'], userDataDir: '' }, ]; // ─── CDP Probe ───────────────────────────────────────────────── @@ -204,7 +201,7 @@ export async function launchWithCdp( reason: runtime === 'conductor' ? `Conductor can't restart ${browser.name} due to macOS App Management security. You need to restart it manually.` : `This runtime can't restart ${browser.name}. You need to restart it manually.`, - command: `"${browser.binary}" --remote-debugging-port=${port} --user-data-dir="${browser.userDataDir}" --restore-last-session`, + command: `"${browser.binary}" --remote-debugging-port=${port} --restore-last-session`, }; } @@ -221,7 +218,7 @@ export async function launchWithCdp( browser, port, reason: `Failed to quit ${browser.name} via osascript. You need to restart it manually.`, - command: `"${browser.binary}" --remote-debugging-port=${port} --user-data-dir="${browser.userDataDir}" --restore-last-session`, + command: `"${browser.binary}" --remote-debugging-port=${port} --restore-last-session`, }; } @@ -236,10 +233,9 @@ export async function launchWithCdp( } } - // Launch with CDP flag + explicit user-data-dir (Chrome requires this for remote debugging) + // Launch with CDP flag — Chrome must NOT already be running (same profile can't have two instances) const child = spawn(browser.binary, [ `--remote-debugging-port=${port}`, - `--user-data-dir=${browser.userDataDir}`, '--restore-last-session', ], { detached: true, diff --git a/browse/src/cli.ts b/browse/src/cli.ts index 60ae633e..8b36934b 100644 --- a/browse/src/cli.ts +++ b/browse/src/cli.ts @@ -386,12 +386,16 @@ Refs: After 'snapshot', use @e1, @e2... as selectors: // Handle manual restart needed (Conductor / sandboxed apps) if (isManualRestart(result)) { console.log(`\n${result.reason}\n`); - console.log(`To connect, quit ${result.browser.name} and restart it with CDP enabled:\n`); + console.log(`To connect, FULLY QUIT ${result.browser.name} first (no processes running), then relaunch with CDP:\n`); console.log(` 1. Quit ${result.browser.name} (Cmd+Q)`); - console.log(` 2. Open Terminal and run:`); + console.log(` 2. Wait 3 seconds for all processes to exit`); + console.log(` 3. Verify: pgrep -f "${result.browser.appName}" should return nothing`); + console.log(` 4. Open Terminal and run:`); console.log(` ${result.command}`); - console.log(` 3. Then run: $B connect ${result.browser.name.toLowerCase()}\n`); - console.log(`Or add this to your shell profile to always launch with CDP:`); + console.log(` 5. Then run: $B connect ${result.browser.name.toLowerCase()}\n`); + console.log(`IMPORTANT: Chrome must be fully quit before step 4. If Chrome is already`); + console.log(`running, it ignores --remote-debugging-port and opens in the existing session.\n`); + console.log(`Pro tip — add to your shell profile to always launch with CDP:`); console.log(` alias chrome-cdp='${result.command}'\n`); // Wait and poll — user might restart Chrome while we're printing