Skip to content

fix: address reviewer comments from PR #315 (snap detection + README)#315

Open
Ayush-Mahadik wants to merge 2 commits intobrowser-use:mainfrom
Ayush-Mahadik:readme-prereq-snap-doctor
Open

fix: address reviewer comments from PR #315 (snap detection + README)#315
Ayush-Mahadik wants to merge 2 commits intobrowser-use:mainfrom
Ayush-Mahadik:readme-prereq-snap-doctor

Conversation

@Ayush-Mahadik
Copy link
Copy Markdown

@Ayush-Mahadik Ayush-Mahadik commented May 6, 2026

Summary

Two fixes bundled into one PR:

1. README: Add Chrome Remote Debugging Prerequisite (fixes #123)

New Prerequisites section before the Setup prompt with:

  • macOS: open -a 'Google Chrome' --args --remote-debugging-port=9222
  • Linux: google-chrome --remote-debugging-port=9222
  • Note about Snap Chromium CDP limitations

2. admin.py: Add Snap Confinement Detection (fixes #191)

New _snap_browser_detected() helper that checks:

  • SNAP env var is set (running inside a snap)
  • /snap/chromium/ or /snap/google-chrome/ in process cmdlines via /proc/

Surfaced as a FAIL row in run_doctor() with:

snap Chromium cannot bind CDP port — install Chrome from google.com/chrome instead

Files Changed

  • README.md — added Prerequisites section
  • src/browser_harness/admin.py — _snap_browser_detected() + doctor row

Tests

63/64 unit tests pass. The single failure (test_cloud_bootstrap_on_headless_server) is pre-existing and unrelated to these changes.


Summary by cubic

Adds a clear Chrome remote‑debugging Prerequisites section (two ways to connect) and updates the doctor to detect and fail on Snap‑confined Chromium, reducing Linux setup issues.

  • New Features
    • README: Adds Prerequisites with two options: (Way 1) enable “Allow remote debugging for this browser instance” in chrome://inspect/#remote-debugging (handles Chrome 144+ allow prompt), or (Way 2) launch with --remote-debugging-port=9222 and a non‑default --user-data-dir (e.g. /tmp/chrome-harness); recommend setting BU_CDP_URL=http://127.0.0.1:9222.
    • Doctor: Adds _snap_browser_detected() (Linux) that scans /proc/*/cmdline for /snap/chromium/ or /snap/google-chrome/ (no SNAP env var reliance), scans only when Chrome is running, and tolerates non‑UTF‑8 cmdlines; adds a “snap confinement” row and includes it in the exit status with guidance: “snap Chromium cannot bind CDP port — install Chrome from google.com/chrome instead”.

Written for commit a7a7b52. Summary will update on new commits.

- README: add Prerequisites section with macOS/Linux Chrome launch commands
  and a note about Snap Chromium CDP limitations (fixes browser-use#123)
- admin.py: add _snap_browser_detected() checking SNAP env var and /snap/
  paths in /proc/cmdline; surface in run_doctor() as a FAIL row when snap
  Chromium is detected (fixes browser-use#191)
Copilot AI review requested due to automatic review settings May 6, 2026 11:15
Copy link
Copy Markdown

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 improves first-time setup and diagnostics for local Chrome connections by documenting the CDP remote-debugging prerequisite and adding a --doctor check for Snap-confined Chromium environments on Linux.

Changes:

  • Add a new Prerequisites section to the README describing how to start Chrome with remote debugging and a note about Snap Chromium limitations.
  • Introduce _snap_browser_detected() and surface its result as a new run_doctor() row (“snap confinement”).
  • Extend --doctor output to recommend installing non-snap Chrome when Snap confinement is detected.

Reviewed changes

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

File Description
README.md Documents CDP remote-debugging startup and Snap Chromium caveats before the setup prompt.
src/browser_harness/admin.py Adds Snap Chromium detection and reports it in browser-harness --doctor.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/browser_harness/admin.py Outdated
Comment on lines +674 to +686
if os.environ.get("SNAP"):
return True
try:
# Walk /proc looking for chromium/chrome processes with a snap mount
for pid_dir in Path("/proc").iterdir():
if not pid_dir.name.isdigit():
continue
try:
cmdline = Path(pid_dir / "cmdline").read_text()
except (FileNotFoundError, PermissionError, OSError):
continue
if "/snap/chromium/" in cmdline or "/snap/google-chrome/" in cmdline:
return True
Comment on lines +676 to +688
try:
# Walk /proc looking for chromium/chrome processes with a snap mount
for pid_dir in Path("/proc").iterdir():
if not pid_dir.name.isdigit():
continue
try:
cmdline = Path(pid_dir / "cmdline").read_text()
except (FileNotFoundError, PermissionError, OSError):
continue
if "/snap/chromium/" in cmdline or "/snap/google-chrome/" in cmdline:
return True
except Exception:
pass
Comment thread src/browser_harness/admin.py Outdated
cur = _version()
mode = _install_mode()
chrome = _chrome_running()
snap = _snap_browser_detected()
Comment thread README.md
Comment on lines +23 to +33
Before running browser-harness, Chrome must be running with remote debugging enabled. The harness connects to Chrome via CDP — it will not launch Chrome itself.

**macOS**
```bash
open -a 'Google Chrome' --args --remote-debugging-port=9222
```

**Linux**
```bash
google-chrome --remote-debugging-port=9222
```
Comment thread README.md Outdated
Comment on lines +35 to +36
Then open `chrome://inspect/#remote-debugging` and enable **Discover network targets** in the Devices tab.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

3 issues found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/browser_harness/admin.py">

<violation number="1" location="src/browser_harness/admin.py:674">
P2: This early `SNAP` check misidentifies the harness process as a snap browser and can produce a false FAIL in doctor output.</violation>

<violation number="2" location="src/browser_harness/admin.py:683">
P2: `Path.read_text()` on `/proc/<pid>/cmdline` can raise `UnicodeDecodeError` (a `ValueError`, not `OSError`) if a process has non-UTF-8 bytes in its command line. Since only `FileNotFoundError | PermissionError | OSError` are caught per-PID, the error propagates to the outer `try/except Exception` which aborts the entire scan and returns `False`. Read as bytes instead (`read_bytes()`) or add `ValueError` to the inner except clause.</violation>

<violation number="3" location="src/browser_harness/admin.py:722">
P2: Snap confinement is reported as FAIL but is not included in the doctor exit status, so `--doctor` can exit 0 while signaling an unhealthy browser setup.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread src/browser_harness/admin.py Outdated
Comment thread src/browser_harness/admin.py
Comment thread src/browser_harness/admin.py Outdated
- Fix false positive SNAP env var check in _snap_browser_detected()
  (SNAP env var identifies the harness process, not the browser)
- Add ValueError to exception handling for UnicodeDecodeError on /proc cmdline
- Short-circuit snap detection: only scan /proc when chrome is running
- Include snap confinement in doctor exit status
- Rewrite Prerequisites section: align with install.md (Way 1/Way 2)
- Fix Chrome UI toggle: 'Discover network targets' -> 'Allow remote debugging
  for this browser instance' (matches repo's own docs)
- Move snap note to doctor output, update README to point to install.md
@Ayush-Mahadik Ayush-Mahadik changed the title docs+doctor: add Chrome remote-debugging prerequisite and snap detection fix: address reviewer comments from PR #315 (snap detection + README) May 7, 2026
@Ayush-Mahadik
Copy link
Copy Markdown
Author

Hi @Alezander9 👋

Just pushed the fixes addressing all reviewer comments from Copilot and cubic-dev-ai. Here's what was changed:

  • admin.py: removed false-positive SNAP env var check, added ValueError to exception handling, short-circuited /proc walk to only run when chrome is detected, and included snap confinement in doctor exit status
  • README.md: rewrote Prerequisites section to align with install.md (Way 1/Way 2), fixed the Chrome UI toggle reference to match the repo's own docs and screenshots

Could you please take another look when you get a chance? Happy to make any further adjustments. Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setup challenges: Snap confinement and environment-specific blockers README Quick Start: add Chrome remote debugging prerequisite

2 participants