fix(browser): honor OPENCLI_CDP_ENDPOINT for website CLIs (remote-Chrome mode) - #2286
Open
luckydududu wants to merge 1 commit into
Open
fix(browser): honor OPENCLI_CDP_ENDPOINT for website CLIs (remote-Chrome mode)#2286luckydududu wants to merge 1 commit into
luckydududu wants to merge 1 commit into
Conversation
…ome mode) docs/advanced/remote-chrome.md promises that setting OPENCLI_CDP_ENDPOINT lets OpenCLI drive a remote Chrome (headless servers, CI), but execution only honored the variable for Electron apps -- website CLIs always went through the Browser Bridge extension, which cannot be installed in many remote/headless setups. - runtime: getBrowserFactory routes any site over CDPBridge when OPENCLI_CDP_ENDPOINT is set (Electron behavior unchanged) - execution: pass the manual endpoint for non-Electron sites; no localhost port probe since the endpoint may be on another machine -- CDPBridge validates it when fetching /json - cdp: website sessions open a dedicated tab via /json/new (PUT with GET fallback for pre-111 Chrome) instead of attaching to whichever existing tab ranks first, and close it on close(); ws:// endpoints and the attach path keep their previous behavior - tests: dedicated-tab lifecycle (create/close, PUT->GET fallback, legacy attach unchanged) against a real local HTTP server; factory routing unit tests - docs: describe website-CLI support and dedicated-tab semantics Verified end-to-end against a real remote Chrome over the network: twitter whoami and timeline --type for-you return correct data with no extension installed, and no tabs leak into the shared browser.
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.
Problem
docs/advanced/remote-chrome.mdpromises that settingOPENCLI_CDP_ENDPOINTlets OpenCLI drive a remote Chrome (headless servers, CI — the doc even ships a CI recipe withxvfb+--remote-debugging-port). In practice the variable is only honored for Electron app CLIs: website CLIs always route through the Browser Bridge extension (getBrowserFactory→BrowserBridge), which cannot be installed in many remote/headless setups. Soopencli twitter timelineetc. fail withBrowser Bridge extension not connectedeven when a perfectly good remote Chrome is reachable.Fix
getBrowserFactoryreturnsCDPBridgefor any site whenOPENCLI_CDP_ENDPOINTis set (explicit opt-in; default behavior unchanged, Electron unchanged).CDPBridgealready validates it when fetching/json./json/new(PUT, with GET fallback for pre-111 Chrome) instead of attaching to whichever existing tab ranks first — a shared remote browser may have the user's real tabs open, and hijacking one to navigate to the site would be destructive. The tab is closed onclose()(best-effort).ws://endpoints and the existing attach path (Electron / nodedicatedTarget) keep their previous behavior, includingOPENCLI_CDP_TARGETranking.Tests
PUT→GETfallback on 405, and legacy attach path unchanged (GET /jsononly).BrowserBridge; set →CDPBridge).npx tsc --noEmitclean; fullnpm test— the only failures are 2 pre-existing ones insrc/download/index.test.ts(cross-domain redirect cookies), reproducible on a cleanmaincheckout in the same environment.Verified end-to-end
Against a real Chrome on another machine over the network (no extension installed in that Chrome):
Tab hygiene confirmed: repeated runs leave no extra tabs in the shared browser.
Docs
remote-chrome.mdupdated to state that website CLIs work in this mode, describe the dedicated-tab semantics, and clarifyws://endpoint behavior.