[STG-1752] fix(cli): default browse env local to isolated#1945
Merged
Conversation
🦋 Changeset detectedLatest commit: a132cb1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
There was a problem hiding this comment.
No issues found across 8 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant User
participant CLI as CLI (Commander)
participant FS as Local Config Store
participant Resolver as NEW: Local Strategy Resolver
participant Discovery as CDP Discovery
participant Browser as Local Chrome / Stagehand
Note over User,Browser: Environment Configuration Phase
User->>CLI: browse env local [target] [--auto-connect]
CLI->>CLI: CHANGED: Validate conflicting flags<br/>(auto-connect vs target vs isolated)
alt Valid configuration
CLI->>FS: NEW: Save LocalConfig (strategy + cdpTarget)
CLI->>FS: Trigger Daemon Restart
else Invalid configuration
CLI-->>User: Error: Conflicting options
end
Note over User,Browser: Runtime Strategy Resolution (Daemon Start)
CLI->>FS: Read LocalConfig
FS-->>CLI: strategy (isolated | auto | cdp)
CLI->>Resolver: NEW: resolveLocalStrategy(config)
alt strategy == "isolated" (NEW DEFAULT)
Resolver-->>CLI: Return LaunchOptions (Clean Browser)
else strategy == "cdp" (Explicit Target)
Resolver->>Resolver: Resolve WS URL from port/URL
Resolver-->>CLI: Return LaunchOptions (Attach to Target)
else strategy == "auto" (--auto-connect)
Resolver->>Discovery: discoverLocalCdp()
alt Found existing Chrome
Discovery-->>Resolver: wsUrl
Resolver-->>CLI: Return LaunchOptions (Attach to Existing)
else No Chrome found
Discovery-->>Resolver: null
Resolver-->>CLI: CHANGED: Fallback to LaunchOptions (Isolated)
end
end
CLI->>Browser: Start/Connect via Stagehand
Browser-->>CLI: Session Started
CLI->>FS: NEW: Save LocalInfo (localSource, resolvedCdpUrl)
CLI-->>User: Output JSON Status (mode, localStrategy, localSource)
pirate
approved these changes
Apr 1, 2026
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.
Summary
browse env localdefault back to an isolated local browserbrowse env local --auto-connectas the explicit opt-in path for auto-discovering a debuggable local Chromebrowse env local <port|url>and add tests to lock in the strategy behaviorWhy
browse env localwas auto-attaching to an existing local Chrome by default. That can trigger Chrome's remote debugging approval dialog unexpectedly and makes isolated local usage less predictable.Impact
Users now get a clean local browser by default, while still having two explicit ways to reuse an existing browser when they want to:
browse env local --auto-connectbrowse env local <port|url>Test Plan
pnpm --filter @browserbasehq/browse-cli buildpnpm --filter @browserbasehq/browse-cli testpnpm exec prettier --check packages/cli && cd packages/cli && pnpm run eslint && pnpm run typecheck127.0.0.1:9229using a temporaryHOME/ user-data-dir so the checks do not touch a real browsing profilebrowse env localreturnslocalStrategy: "isolated"browse statusin isolated mode reportslocalSource: "isolated"browse env localandbrowse statusboth print the hint to usebrowse env local --auto-connectto reuse local credentials/cookiesbrowse env local --auto-connectreturnslocalStrategy: "auto"browse env local --auto-connectprints the hint that plainbrowse env localswitches back to an isolated Chromium browseropen https://example.comsucceeds after--auto-connectbrowse statusafter--auto-connectreportslocalSource: "attached-existing"with the resolved CDP URL and the isolated-browser hintbrowse env local 9229returnslocalStrategy: "cdp"browse statusafterbrowse env local 9229reportslocalSource: "attached-explicit"Linear: STG-1752
Summary by cubic
Defaulted
browse env localto a clean, isolated browser. Added--auto-connectto opt into reusing a debuggable Chrome, kept explicit CDP attach viabrowse env local <port|url>, and added mode hints to guide users. Addresses Linear STG-1752 to make local usage predictable and avoid surprise debugging prompts.New Features
--auto-connect.browse env/browse statussuggest when to use--auto-connector switch back to isolated.browse env local <port|url>remains for explicit CDP targets.src/local-strategy.tswith unit tests.browse envusage and validation; rejects mixing--auto-connect,--isolated, or a target.--isolatedis deprecated (accepted; hidden from help).Migration
browse env local --auto-connect.browse env local <port|url>.Written for commit a132cb1. Summary will update on new commits. Review in cubic