Compare commits

...

9 Commits

Author SHA1 Message Date
Andrei Edell 6ad5430dca rename button labels to launch browser 2025-05-12 20:02:27 -07:00
Andrei Edell 3445b8fa57 probably dont need the whole warning and relaunch flow now 2025-05-12 19:54:24 -07:00
Andrei Edell cefe9e2c53 apparently quotes are bad 2025-05-12 19:50:25 -07:00
Andrei Edell e4a5b696ab import os, quote path arg 2025-05-12 19:00:07 -07:00
Andrei Edell 2d93f92033 Revert "Update src/services/browser/BrowserSession.ts"
This reverts commit 5dbd82aea2.
2025-05-12 18:28:52 -07:00
Andrei Eternal 5dbd82aea2 Update src/services/browser/BrowserSession.ts
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-05-12 18:23:51 -07:00
kevinneung ce4877d945 fix: Add required --user-data-dir flag when launching Chrome with remote debugging port 2025-05-12 17:08:07 -07:00
kevinneung 307d5bfaef Add changeset for Chrome remote debugging fix 2025-05-12 17:06:48 -07:00
kevinneung 09be283a75 fix: Add required --user-data-dir flag when launching Chrome with remote debugging port
When Chrome is launched with the --remote-debugging-port flag, it requires a non-default user data directory to be specified using the --user-data-dir flag. Without this flag, Chrome shows the error 'DevTools remote debugging requires a non-default data directory' and the debug port is not opened.

This fix adds the --user-data-dir flag when launching Chrome with the remote debugging port, which resolves the 'Chrome was launched but debug port is not responding' error.
2025-05-12 16:20:51 -07:00
3 changed files with 14 additions and 33 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"claude-dev": patch
---
This fix adds the --user-data-dir flag when launching Chrome with the remote debugging port, which resolves the 'Chrome was launched but debug port is not responding' error.
+8 -32
View File
@@ -16,6 +16,7 @@ import { discoverChromeInstances, testBrowserConnection, isPortOpen } from "./Br
import * as chromeLauncher from "chrome-launcher"
import { Controller } from "@core/controller"
import { telemetryService } from "@/services/posthog/telemetry/TelemetryService"
import os from "os"
interface PCRStats {
puppeteer: { launch: typeof launch }
@@ -123,45 +124,20 @@ export class BrowserSession {
}
async relaunchChromeDebugMode(controller: Controller) {
const result = await vscode.window.showWarningMessage(
"This will close your existing Chrome tabs and relaunch Chrome in debug mode. Are you sure?",
{ modal: true },
"Yes",
)
if (result !== "Yes") {
controller?.postMessageToWebview({
type: "browserRelaunchResult",
success: false,
text: "Operation cancelled by user",
})
return
}
try {
// Chrome-launcher's killAll only kills instances it launched
// We need to handle system Chrome processes separately
await this.killAllChromeBrowsers()
// Wait a moment for Chrome to fully shut down
await new Promise((resolve) => setTimeout(resolve, 500))
// Instead of using any default flags, use a minimal set to ensure session persistence
// This closely mimics running "google-chrome-stable --remote-debugging-port=9222" from the CLI
const chromeFlags = [
"--remote-debugging-port=" + DEBUG_PORT,
"--disable-notifications",
// Do not add any flags that might interfere with profile data
]
const userDataDir = path.join(os.tmpdir(), "chrome-debug-profile")
const installation = chromeLauncher.Launcher.getFirstInstallation()
if (!installation) {
throw new Error("Could not find Chrome installation on this system")
}
console.info("chrome installation", installation)
// Prepare the command arguments
const args = [`--remote-debugging-port=${DEBUG_PORT}`, "--disable-notifications", "chrome://newtab"]
const args = [
`--remote-debugging-port=${DEBUG_PORT}`,
`--user-data-dir=${userDataDir}`,
"--disable-notifications",
"chrome://newtab",
]
// Spawn Chrome as a detached process
const chromeProcess = spawn(installation, args, {
@@ -462,7 +462,7 @@ export const BrowserSettingsSection: React.FC = () => {
{shouldShowRelaunchButton && (
<div style={{ display: "flex", gap: "10px", marginBottom: 8, justifyContent: "center" }}>
<VSCodeButton style={{ flex: 1 }} disabled={debugMode} onClick={relaunchChromeDebugMode}>
{debugMode ? "Relaunching Browser..." : "Relaunch Browser with Debug Mode"}
{debugMode ? "Launching Browser..." : "Launch Browser with Debug Mode"}
</VSCodeButton>
</div>
)}