Skip to content

fix(browser): default to openclaw profile and simplify default selection logic#31972

Closed
velamints2 wants to merge 3 commits intoopenclaw:mainfrom
velamints2:fix/browser-default-openclaw-31907
Closed

fix(browser): default to openclaw profile and simplify default selection logic#31972
velamints2 wants to merge 3 commits intoopenclaw:mainfrom
velamints2:fix/browser-default-openclaw-31907

Conversation

@velamints2
Copy link
Contributor

Summary

  • Problem: Default browser profile resolution always picked the chrome extension-relay profile on GUI desktop environments, causing 10-minute relay timeouts on fresh installs where no relay extension is attached.
  • Root cause (Layer 1): DEFAULT_BROWSER_DEFAULT_PROFILE_NAME = "chrome" combined with ensureDefaultChromeExtensionProfile() always creating a "chrome" profile made the default-resolution ternary always resolve to relay.
  • Regression vector (Layer 2): The partial fix in fix(browser): prefer openclaw profile in headless/noSandbox environments #14944 added a preferOpenClawProfile branch for headless/noSandbox environments, leaving GUI desktop untouched. While the driver layer (server-context.availability.ts) currently routes correctly based on profile.driver, removing this branching logic ensures that the constant is the single source of truth for default profile selection, preventing future regressions.
  • Documentation bug: docs/tools/browser.md still stated "Default profile is chrome", which will mislead users and cause the regression to be reintroduced next refactor.

What changed:

  1. src/browser/constants.tsDEFAULT_BROWSER_DEFAULT_PROFILE_NAME: "chrome""openclaw"
  2. src/browser/config.ts — remove preferOpenClawProfile branch; simplify to defaultProfileFromConfig ?? DEFAULT_BROWSER_DEFAULT_PROFILE_NAME (applied the simplification suggested by greptile-bot on fix(browser): default to openclaw profile when unspecified #31913, which identified the redundant ternary after the constant change)
  3. src/browser/config.test.ts — update default-profile assertions; rename suite
  4. docs/tools/browser.md — fix outdated "Default profile is chrome" statement
  5. CHANGELOG.md — add entry

What did NOT change:

  • Explicit browser.defaultProfile overrides still respected
  • chrome relay profile still auto-created and available for explicit opt-in
  • Extension relay behavior unchanged

Linked Issue/PR

Design Rationale

ensureDefaultProfile() always creates the "openclaw" entry before default-resolution runs, so the profile-existence check was guaranteed to pass. Collapsing the ternary to a single constant lookup makes DEFAULT_BROWSER_DEFAULT_PROFILE_NAME the single source of truth for default profile selection, enforcing the invariant that the default never depends on auto-created relay state.

…ion logic

DEFAULT_BROWSER_DEFAULT_PROFILE_NAME was 'chrome', causing all
no-profile browser tool calls to route through the extension relay on
GUI desktop environments regardless of relay availability.

Changes:
- Set DEFAULT_BROWSER_DEFAULT_PROFILE_NAME to 'openclaw' (constants.ts)
- Remove preferOpenClawProfile branch; collapse to a single constant
  lookup, enforcing the invariant that default profile selection never
  depends on auto-created relay state (config.ts)
- Update config.test.ts assertions and test suite name
- Fix docs/tools/browser.md: default is now openclaw, not chrome
- CHANGELOG entry

Closes openclaw#31907
Copilot AI review requested due to automatic review settings March 2, 2026 17:31
@openclaw-barnacle openclaw-barnacle bot added docs Improvements or additions to documentation size: XS labels Mar 2, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a longstanding bug where the default browser profile for the OpenClaw browser tool resolved to "chrome" (extension relay), causing 10-minute timeouts on fresh installs without the relay extension. It changes the default to "openclaw" (standalone CDP mode) for all environments, simplifies the default-resolution logic to a single constant lookup, and updates one note in the browser documentation.

Changes:

  • DEFAULT_BROWSER_DEFAULT_PROFILE_NAME constant changed from "chrome" to "openclaw", making openclaw the default browser profile in all environments.
  • preferOpenClawProfile branch removed from resolveBrowserConfig, replaced with a single defaultProfileFromConfig ?? DEFAULT_BROWSER_DEFAULT_PROFILE_NAME expression.
  • Browser config tests and CHANGELOG updated to reflect the new default behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/browser/constants.ts Changes the DEFAULT_BROWSER_DEFAULT_PROFILE_NAME constant value from "chrome" to "openclaw"
src/browser/config.ts Removes the preferOpenClawProfile branch and simplifies default profile resolution to a single constant lookup
src/browser/config.test.ts Updates default-profile test assertions to expect "openclaw", verifies chrome profile is still available, and renames the test suite and test cases
docs/tools/browser.md Updates one note in the Notes section to reflect that openclaw is now the default and chrome requires explicit opt-in
CHANGELOG.md Adds a changelog entry describing the behavioral change

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

This PR successfully fixes the browser profile default resolution issue that caused 10-minute relay timeouts on fresh GUI installations. The fix changes the default from chrome (extension relay) to openclaw (managed browser), eliminating the relay dependency for default configurations.

Key changes:

  • Changed DEFAULT_BROWSER_DEFAULT_PROFILE_NAME constant from "chrome" to "openclaw"
  • Simplified default profile resolution logic by removing the preferOpenClawProfile conditional and making the constant the single source of truth
  • Updated all tests to reflect the new default behavior
  • Added comprehensive CHANGELOG entry

Strengths:

  • Clean, minimal code change that directly addresses the root cause
  • Excellent test coverage with updated assertions
  • The chrome relay profile remains available for explicit opt-in
  • Logic simplification improves maintainability

Issues found:

  • Two places in browser.md (lines 21-22 and 52) still suggest chrome is the default or that users need to switch to openclaw, which is now inaccurate

The core implementation is solid and the fix is appropriate for the problem.

Confidence Score: 4/5

  • This PR is safe to merge with minor documentation improvements recommended
  • The code changes are well-tested and directly fix the stated problem. The logic simplification is sound and the constant change is correct. The only issues are two outdated documentation statements that should be updated for consistency, but these don't affect functionality. Score is 4 (not 5) due to the documentation gaps.
  • Pay attention to docs/tools/browser.md - two sections still suggest chrome is the default and should be updated for consistency with the code changes.

Last reviewed commit: 8dd83e9

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 2, 2026

Additional Comments (2)

docs/tools/browser.md
This still suggests chrome is the default and users need to "switch to openclaw", but after this PR openclaw is now the default. Consider updating to something like:

- The `openclaw` profile (default) uses an isolated, OpenClaw-managed browser.
- The `chrome` profile uses the **system default Chromium browser** via the extension relay; use `defaultProfile: "chrome"` to opt into relay mode.
Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/tools/browser.md
Line: 21-22

Comment:
This still suggests `chrome` is the default and users need to "switch to `openclaw`", but after this PR `openclaw` is now the default. Consider updating to something like:

```suggestion
- The `openclaw` profile (default) uses an isolated, OpenClaw-managed browser.
- The `chrome` profile uses the **system default Chromium browser** via the extension relay; use `defaultProfile: "chrome"` to opt into relay mode.
```

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


docs/tools/browser.md
This is now outdated - openclaw IS the default after this PR. Consider:

The `openclaw` profile is used by default. Set `browser.defaultProfile: "chrome"` if you want extension relay mode instead.
Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/tools/browser.md
Line: 52

Comment:
This is now outdated - `openclaw` IS the default after this PR. Consider:

```suggestion
The `openclaw` profile is used by default. Set `browser.defaultProfile: "chrome"` if you want extension relay mode instead.
```

How can I resolve this? If you propose a fix, please make it concise.

@velamints2
Copy link
Contributor Author

"All checks passed and documentation synced. This PR provides a more robust fix for #31907 compared to #31913 by:

Simplifying logic: Removing redundant ternary operators and dead preferOpenClawProfile code (as suggested by the Greptile bot).

Complete Docs: Fully updating browser.md to reflect the new default behavior (fixing the outdated 'chrome is default' notes).

Clean tests: Refactoring the test suite to align with the new constant-driven architecture."

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a5ccfd40f6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

: DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME);
// ensureDefaultProfile() guarantees the openclaw profile always exists.
// Use the constant directly as the single source of truth (#31907).
const defaultProfile = defaultProfileFromConfig ?? DEFAULT_BROWSER_DEFAULT_PROFILE_NAME;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve fallback when default openclaw profile is incomplete

This line makes openclaw the unconditional default when browser.defaultProfile is unset, but ensureDefaultProfile() only adds openclaw when the key is missing and does not backfill an existing profiles.openclaw entry. If a user has profiles.openclaw with only metadata (for example color/driver but no cdpPort/cdpUrl), resolveProfile() will now throw Profile "openclaw" must define cdpPort or cdpUrl for any call that omits profile; before this commit, desktop configs still defaulted to chrome and avoided that failure path.

Useful? React with 👍 / 👎.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the flag. ensureDefaultProfile() gates on !result["openclaw"], so a completely absent key always gets a valid entry with cdpPort. The only way to hit this path is if a user manually writes an incomplete profiles.openclaw (with color/driver but missing cdpPort/cdpUrl) — but that is a config-validation error that would also throw under the pre-existing headless path (preferOpenClawProfile = true → selects "openclaw" unconditionally), so this PR does not introduce a new failure mode.

The correct fix for incomplete user profiles would be input validation inside ensureDefaultProfile() (backfilling missing fields on an existing entry), which is orthogonal to default-selection logic and could be a follow-up if desired.

@velamints2
Copy link
Contributor Author

"Regarding the failed bun test in CI: I've investigated the logs and confirmed it's a pre-existing flaky test in src/cron/isolated-agent.uses-last-non-empty-agent-text-as.test.ts.

The failure (expected 'anthropic' to be 'openai') is unrelated to the browser profile changes in this PR. All relevant tests in src/browser/ passed successfully. Ready for merge."

@steipete
Copy link
Contributor

steipete commented Mar 2, 2026

Thanks for the work here.

Closing as superseded by #32031 (merged), which landed the same browser.defaultProfile default fix (openclaw by default) and now includes the corresponding docs update (docs/tools/browser.md) in the merged result.

Why #32031 was landed:

  • Same behavior fix with a tighter final landed diff.
  • Targeted browser config/profile tests passed on the rebased branch.
  • Final merged state includes docs + changelog alignment.

Merged replacement:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Default browser profile should prefer "openclaw" (standalone CDP) over "chrome" (extension relay) on desktop GUI environments

3 participants