feat(browser): connect CDP to the real user profile - #2195
Merged
Conversation
Chromium drops chrome:// URLs handed to it on the command line and
silently substitutes the New Tab Page, so spawning the browser with
chrome://inspect/#remote-debugging never reached the settings page: the
browser popped open on a blank tab, there was no switch to tick, and the
setup wait always timed out.
macOS now routes the URL through the browser's own AppleScript
`open location` handler, which is not subject to that filter. Other
platforms have no equivalent entry point, so they stop opening a
throwaway tab and hand the URL to the user instead, reported as a
distinct `requires_manual_user_profile_setup` status carrying the URL.
The chrome://inspect page is English-only even under a localized
browser, so the prompts now quote the switch by its real label,
"Allow remote debugging for this browser instance".
Also rewrite the browser control copy that leaked internal vocabulary
("guarded CDP", "real user profile", "empty profile") into plain
language describing what the setting does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Lets browser control attach to the Chrome/Edge the user already has open — existing tabs, existing logins — instead of launching an empty managed profile. The browser owns the consent: a persistent switch on its own settings page, plus a per-connection approval dialog.
Two commits:
feat(browser): connect CDP to real user profiles— discover the browser-level endpoint fromDevToolsActivePortin the browser's normal user-data dir, connect over that WebSocket, and expose an Enable default CDP action in Settings.fix(browser): open the real remote debugging page for default CDP— the setup flow above never actually worked; see below.The bug in commit 1
The setup step spawned the browser with the settings URL on the command line:
Chromium drops
chrome://URLs handed to it on the command line and silently substituteschrome://newtab/. Reproduced on Chrome 151 withchrome://version,chrome://settingsandchrome://inspect— all three land on the New Tab Page. So the browser popped open on a blank tab, there was no switch to tick, and the 60s setup wait always timed out with "the switch was not detected".Fix
open locationhandler, which is not subject to that filter. Verified openingchrome://inspect/#remote-debuggingcorrectly.requires_manual_user_profile_setupstatus that carriessetupUrlso the UI can show it.Also
chrome://inspectis not localized — it stays English even under--lang=zh-CN. The prompts said "勾选『允许远程调试』", which appears nowhere on that page; they now quote the real label, "Allow remote debugging for this browser instance".And the browser-control settings copy leaked internal vocabulary ("guarded CDP", "real user profile", "empty profile"). Rewritten in plain language across
en-US/zh-CN/zh-TW.Verified
On Chrome 151, in throwaway profiles:
devtools.remote_debugging.user-enabled: truein Local State → server on 9222 +DevToolsActivePortwritten to the user-data dir. The detection path in commit 1 is correct./json/version,/json/list) return 404; only the browser WebSocket fromDevToolsActivePortworks — which is what the client uses.#remote-debugging-enabled, "Allow remote debugging for this browser instance".Build/tests:
cargo check -p bitfun-desktop -p bitfun-core -p bitfun-services-integrations,cargo test -p bitfun-services-integrations --features browser-control(9 passed),tsc --noEmit(0 errors). Setup flow confirmed working end to end on macOS by the reporter.