Skip to content

fix(browser): prefer openclaw profile in headless/noSandbox environments#14944

Merged
steipete merged 4 commits intoopenclaw:mainfrom
BenediktSchackenberg:fix/headless-browser-default-profile
Mar 2, 2026
Merged

fix(browser): prefer openclaw profile in headless/noSandbox environments#14944
steipete merged 4 commits intoopenclaw:mainfrom
BenediktSchackenberg:fix/headless-browser-default-profile

Conversation

@BenediktSchackenberg
Copy link

@BenediktSchackenberg BenediktSchackenberg commented Feb 12, 2026

Summary

Fixes #14895

In headless or noSandbox server environments (like Ubuntu Server), the Chrome extension relay cannot work because there is no GUI browser to attach to.

Previously, the default profile was chrome (extension relay) which caused snapshot/screenshot operations to fail with:

Chrome extension relay is running, but no tab is connected. 
Click the OpenClaw Chrome extension icon on a tab to attach it...

Solution

This fix prefers the openclaw profile (Playwright native mode) when:

  • browser.headless=true, or
  • browser.noSandbox=true

While preserving the chrome default for GUI environments where extension relay works.

Changes

src/browser/config.ts:

  • Added preferOpenClawProfile check based on headless/noSandbox settings
  • Updated defaultProfile resolution to prefer openclaw in server environments

Testing

  • pnpm build - ✅ Success
  • pnpm check (format + lint + typecheck) - ✅ Success
  • pnpm test - ✅ 270 tests passed

AI Disclosure

🤖 AI-assisted (Claude), fully tested locally before submission.

Greptile Overview

Greptile Summary

This change updates browser config resolution so that when running in browser.headless=true or browser.noSandbox=true environments, the default browser profile prefers the built-in openclaw (Playwright/native) profile instead of the chrome (extension relay) profile.

It does this by introducing a preferOpenClawProfile flag and adjusting the defaultProfile fallback selection order, while still honoring any explicit browser.defaultProfile setting from user config. This integrates with the existing profile auto-creation (ensureDefaultProfile / ensureDefaultChromeExtensionProfile) and only affects which profile name is chosen by default.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • The change is small and localized to default-profile selection logic, preserves explicit user configuration, and relies on existing guarantees that the openclaw profile is always present. No behavioral changes occur unless headless/noSandbox is enabled and no explicit default profile is set.
  • src/browser/config.ts

Last reviewed commit: df0704d

(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!

Copilot AI review requested due to automatic review settings February 12, 2026 20:09
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 browser snapshot/screenshot failures in headless or noSandbox server environments (e.g., Ubuntu Server) by automatically preferring the openclaw profile over the chrome extension relay profile when either browser.headless=true or browser.noSandbox=true.

Changes:

  • Modified default profile resolution logic to prefer openclaw in headless/noSandbox environments
  • Preserves chrome as default for GUI environments where extension relay works
  • User-configured defaultProfile still takes precedence over automatic selection

Comment on lines +197 to +204
const preferOpenClawProfile = headless || noSandbox;
const defaultProfile =
defaultProfileFromConfig ??
(profiles[DEFAULT_BROWSER_DEFAULT_PROFILE_NAME]
? DEFAULT_BROWSER_DEFAULT_PROFILE_NAME
: DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME);
(preferOpenClawProfile && profiles[DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME]
? DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME
: profiles[DEFAULT_BROWSER_DEFAULT_PROFILE_NAME]
? DEFAULT_BROWSER_DEFAULT_PROFILE_NAME
: DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME);
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

The new profile preference logic for headless/noSandbox environments lacks test coverage. Consider adding test cases to verify:

  1. When headless=true, defaultProfile should be "openclaw"
  2. When noSandbox=true, defaultProfile should be "openclaw"
  3. When both are false, defaultProfile should remain "chrome" (existing behavior)
  4. When defaultProfile is explicitly set in config, it should override the preference logic

This will ensure the fix for issue #14895 is properly validated and prevent future regressions.

Copilot uses AI. Check for mistakes.
@BenediktSchackenberg BenediktSchackenberg force-pushed the fix/headless-browser-default-profile branch 2 times, most recently from 6d58130 to 90841c3 Compare February 19, 2026 21:04
@dxygit1
Copy link

dxygit1 commented Feb 25, 2026

这个合并进去了么?

Benedikt Schackenberg and others added 4 commits March 2, 2026 06:45
In headless or noSandbox server environments (like Ubuntu Server), the
Chrome extension relay cannot work because there is no GUI browser to
attach to. Previously, the default profile was 'chrome' (extension relay)
which caused snapshot/screenshot operations to fail with:

  'Chrome extension relay is running, but no tab is connected...'

This fix prefers the 'openclaw' profile (Playwright native mode) when
browser.headless=true or browser.noSandbox=true, while preserving the
'chrome' default for GUI environments where extension relay works.

Fixes: openclaw#14895

🤖 AI-assisted (Claude), fully tested: pnpm build && pnpm check && pnpm test
Cover all cases requested in review:
1. headless=true → defaultProfile = 'openclaw'
2. noSandbox=true → defaultProfile = 'openclaw'
3. both false → defaultProfile = 'chrome' (existing behavior)
4. explicit defaultProfile config overrides preference logic
5. custom profiles work in headless mode

Fixes: openclaw#14895
@steipete steipete force-pushed the fix/headless-browser-default-profile branch from 90841c3 to c5b2746 Compare March 2, 2026 06:47
@steipete steipete merged commit cfba64c into openclaw:main Mar 2, 2026
@openclaw-barnacle openclaw-barnacle bot added the agents Agent runtime and tooling label Mar 2, 2026
@steipete
Copy link
Contributor

steipete commented Mar 2, 2026

Landed via temp rebase onto main.

  • Gate: pnpm check && pnpm build && pnpm test
  • Land commits:
    • 3c8ae8798f5fa1c5b07b95e1f1aafdbf287df849 (changelog attribution)
    • c5b2746f7829349d8966be0b3830541b8264f956 (test typing fixups)
  • Merge commit: cfba64c9db848669b92b44d0863578ca84fa28a5

Thanks @BenediktSchackenberg!

@ItsAditya-xyz
Copy link

in which version this went live?

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

Labels

agents Agent runtime and tooling size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Browser snapshot/screenshot fails on Ubuntu Server headless environment

5 participants