Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(cua-driver): point the macOS CDP-port error at browser_prepare, not launch_app flags (#2931)

webdevf0447fad70e1
diff --git a/docs/content/docs/cua-driver/guides/browsers.mdx b/docs/content/docs/cua-driver/guides/browsers.mdx
index 0ce8baf703..f464d11fd9 100644
--- a/docs/content/docs/cua-driver/guides/browsers.mdx
+++ b/docs/content/docs/cua-driver/guides/browsers.mdx
@@ -100,6 +100,13 @@ session, on a trusted machine. CDP exposes that profile's pages, cookies, and
storage, and loopback is not authentication: other processes running as the
same user can reach an open endpoint.
+Relaunching the browser yourself with `--remote-debugging-port` does not reach
+that profile. Chrome and Edge ignore the flag on their default user-data
+directory: no listener opens and no `DevToolsActivePort` file is written. The
+flag works only with a different `--user-data-dir`, which is a different,
+signed-out profile. The browser's own remote-debugging switch, which
+`browser_prepare` drives below, is the route into the real profile.
+
<Callout type="warn">
Attachment is an explicit boundary. It needs `--grant existing-profile` at launch (standard),
a manifest entry `kind: existing_profile` (bounded), an embedding host's authorization callback,
diff --git a/libs/cua-driver/rust/crates/platform-macos/src/tools/page.rs b/libs/cua-driver/rust/crates/platform-macos/src/tools/page.rs
index 7d773be08a..050ac124c3 100644
--- a/libs/cua-driver/rust/crates/platform-macos/src/tools/page.rs
+++ b/libs/cua-driver/rust/crates/platform-macos/src/tools/page.rs
@@ -252,10 +252,14 @@ async fn resolve_cdp_port(pid: i32, cdp_port: Option<u16>, action: &str) -> anyh
the browser to have been launched with a CDP port on a NON-default profile — \
Chrome refuses to open --remote-debugging-port on its default data directory \
(even if you pass --user-data-dir explicitly pointing at that same default \
- path). Relaunch via launch_app with cdp_debugging_port AND \
- additional_arguments: [\"--user-data-dir=<some other path>\"], e.g. a \
- dedicated automation profile — this will not have the user's existing \
- logins/session. Alternatively, if you already enabled Chrome's own \
+ path). Call browser_prepare instead: profile.mode isolated_new with \
+ allow_launch true starts a driver-owned automation profile (no existing \
+ logins/session), and \
+ strategy.kind existing_profile with this browser's pid and window_id drives \
+ the browser's own remote-debugging toggle under explicit approval when the \
+ authenticated profile is required. Do not relaunch \
+ with remote-debugging flags through launch_app — it refuses them, so that \
+ route cannot succeed. Alternatively, if you already enabled Chrome's own \
remote-debugging toggle for this profile (chrome://inspect/#remote-debugging), \
pass that port explicitly via cdp_port — auto-discovery can't confirm it."
)