#14944: fix(browser): prefer openclaw profile in headless/noSandbox environments
size: S
Cluster:
Browser Enhancements and Fixes
## 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
- [x] `pnpm build` - ✅ Success
- [x] `pnpm check` (format + lint + typecheck) - ✅ Success
- [x] `pnpm test` - ✅ 270 tests passed
## AI Disclosure
🤖 AI-assisted (Claude), fully tested locally before submission.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
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.
<h3>Confidence Score: 5/5</h3>
- 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
<sub>Last reviewed commit: df0704d</sub>
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#6193: fix(browser): default to openclaw profile instead of chrome extensi...
by mikezaoldyeck · 2026-02-01
89.7%
#13568: Fix browser (OpenClaw-managed) launch fail by binding remote debugg...
by singlag · 2026-02-10
83.5%
#7157: docs(browser): recommend openclaw managed profile as default
by AkashaBot · 2026-02-02
83.0%
#22952: fix(browser): suggest remote profile when local Chrome is not insta...
by dashed · 2026-02-21
82.9%
#9020: fix(browser): skip port ownership and WS reachability checks for re...
by yepack · 2026-02-04
82.3%
#23363: Browser: fallback to managed profile and improve runtime diagnostics
by isdoho · 2026-02-22
81.7%
#9728: fix(gateway): browser.snapshot ignores profile parameter (#9723)
by divol89 · 2026-02-05
81.1%
#20207: fix(browser): use profile driver instead of hardcoded name
by mahsumaktas · 2026-02-18
81.0%
#10937: fix(browser): correct fallback path for bundled Chrome extension
by dddabtc · 2026-02-07
79.9%
#9398: Fix browser extension install path calculation
by vishaltandale00 · 2026-02-05
79.9%