feat: add macOS-only native no-activate launch option#724
Open
2c67cc18 wants to merge 3 commits intovercel-labs:mainfrom
Open
feat: add macOS-only native no-activate launch option#7242c67cc18 wants to merge 3 commits intovercel-labs:mainfrom
2c67cc18 wants to merge 3 commits intovercel-labs:mainfrom
Conversation
Contributor
|
@2c67cc18 is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
2b47ba7 to
128193c
Compare
Co-authored-by: OpenAI Codex <codex@openai.com>
128193c to
c252d71
Compare
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.
Add a macOS-only
--no-activate/AGENT_BROWSER_NO_ACTIVATEoption for native headed Chrome launches.On macOS native Chrome launches,
--no-activatenow usesopen -gto start the browser without intentionally foregrounding it, captures the DevTools websocket URL from redirected stderr, and keeps a PID-based fallback soclosecan still terminate the browser ifBrowser.closedoes not complete.This is scoped intentionally:
Several alternatives were considered and not chosen:
Fixed
--remote-debugging-port=<port>for PID lookup.This worked, but it introduces a real port-allocation race: the port must be released before Chrome can bind it, so another process can theoretically claim it in between.
Using
--user-data-diras the process identity.This is not reliably unique when persistent profiles are reused, so PID lookup can become ambiguous.
Dropping PID ownership and relying only on
Browser.close.This would reduce code, but it weakens lifecycle control compared with the normal native path, which already prefers owning the browser process and having a fallback kill path.
A macOS-native launcher via AppKit /
NSWorkspace(for example through Rust Objective-C bindings).That may be a cleaner long-term macOS integration path, but it would require introducing new platform-specific code and dependencies. This change stays within the existing dependency/tooling model and keeps the implementation narrower.
Extending Playwright / non-native behavior.
That was intentionally left out of scope. This change is only for the native Chrome path.
Given those tradeoffs, the final implementation uses:
open -gfor macOS no-activate launchValidation:
cargo checkcargo test no_activatecargo test e2e_no_activate_launch_and_interact -- --ignored --test-threads=1cargo test e2e_no_activate_close_kills_stopped_pid -- --ignored --test-threads=1cargo run -- --native --headed --no-activate open example.comOne test tradeoff remains open:
e2e_no_activate_close_kills_stopped_pidcurrently takes about 30 seconds because it intentionally stops the browser process and therefore waits through the existingCdpClient::send_commandtimeout before the PID fallback executes. That proves the real production path, but it is slow. It is still unclear whether the better tradeoff is to keep that full-path e2e as-is or add a narrower test-specific close helper with a shorter timeout.