Skip to content

Document browser navigation verification loop - #974

Merged
lawrencecchen merged 3 commits into
mainfrom
task-browser-wait-blank-page-hint
Mar 6, 2026
Merged

lawrencecchen merged 3 commits into
mainfrom
task-browser-wait-blank-page-hint

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented Mar 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • update the browser skill’s core loop to verify navigation with get url before waiting or snapshotting
  • align the form/auth templates with the same goto -> get url -> wait -> snapshot pattern so blank/new-tab states are easier to diagnose

Testing

  • git diff --check (pass)

Issues

  • Related: Claude browser-skill issue report from nightly build 2273595350501 (wait --load-state complete silently failed when the page had not actually navigated)

Summary by cubic

Verify navigation with get url before waiting or snapshotting in the browser skill. Prevents silent waits on about:blank and makes blank/new-tab states easier to diagnose.

  • Refactors

    • Updated SKILL.md to standardize the loop: goto → get url → wait → snapshot.
    • Added URL verification to authenticated-session.sh and form-automation.sh templates.
    • Standardized examples to use "cmux --json browser ..." and enforce get url → wait → snapshot ordering.
    • Added a regression test for navigation guidance; removed an invalid docs text inspection test.
  • Bug Fixes

    • Avoids wait --load-state complete succeeding without actual navigation by checking the URL first.
    • Documents that if get url is empty or about:blank, navigate before waiting.

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

Summary by CodeRabbit

  • Documentation

    • Reorganized browser workflow to verify current URL before snapshots and subsequent actions.
    • Updated examples and command guidance to include interim URL checks and waiting steps.
    • Added guidance for handling empty or about:blank navigation states (navigate first, then wait).
  • Tests

    • Added a regression test validating the updated navigation guidance and example ordering.

@vercel

vercel Bot commented Mar 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cmux Ready Ready Preview, Comment Mar 6, 2026 4:55am

@coderabbitai

coderabbitai Bot commented Mar 6, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds an explicit get url verification step into the cmux-browser workflow, reorders examples to perform URL-check -> wait -> snapshot, updates templates to call cmux browser ... get url after navigation, and adds a regression test validating the new guidance and ordering.

Changes

Cohort / File(s) Summary
Documentation
skills/cmux-browser/SKILL.md
Reorders core workflow to verify URL with get url before waiting/snapshotting; documents navigation guard for empty/about:blank URLs; updates examples and command forms to use cmux --json browser open and include get url + wait steps.
Template scripts
skills/cmux-browser/templates/authenticated-session.sh, skills/cmux-browser/templates/form-automation.sh
Each script now invokes cmux browser "$SURFACE" get url immediately after goto navigation to fetch/verify the current URL prior to subsequent wait/snapshot steps.
Tests
tests_v2/test_browser_skill_navigation_docs.py
Adds a regression test that reads the skill doc and templates, asserting presence and ordering of get url -> wait -> snapshot, guidance for blank pages, correct --json usage, and specific sequences in the two templates; includes helper assertion functions and standalone main execution.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped in to check the view,
A tiny get url — quick and true,
I wait, I snap, ensure it's right,
No blank-page fright in morning light,
Hooray — the journey's snug and new! 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: documentation of a browser navigation verification loop, which directly addresses the core refactoring across SKILL.md and shell templates.
Description check ✅ Passed The pull request description includes a clear summary of changes and the rationale, with testing confirmation via git diff, but lacks detailed manual testing information and demo video.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch task-browser-wait-blank-page-hint

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 3 files

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
skills/cmux-browser/templates/authenticated-session.sh (1)

13-15: Consider enforcing URL validity before waiting.

Line 13 retrieves the URL, but Line 14 still runs even if navigation is empty/about:blank. Adding a small guard here would make this template fail fast instead of entering a misleading wait path.

Proposed tweak
 cmux browser "$SURFACE" goto "$DASHBOARD_URL"
-cmux browser "$SURFACE" get url
+CURRENT_URL="$(cmux browser "$SURFACE" get url | tr -d '\r\n')"
+if [ -z "$CURRENT_URL" ] || [ "$CURRENT_URL" = "about:blank" ]; then
+  echo "Navigation not ready (url='$CURRENT_URL'); navigate first before wait." >&2
+  exit 1
+fi
 cmux browser "$SURFACE" wait --load-state complete --timeout-ms 15000
 cmux browser "$SURFACE" snapshot --interactive
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/cmux-browser/templates/authenticated-session.sh` around lines 13 - 15,
After calling cmux browser "$SURFACE" get url, read the resulting URL and
validate it is non-empty and not "about:blank" before running cmux browser
"$SURFACE" wait --load-state complete --timeout-ms 15000; if the URL is empty or
about:blank, emit an error/exit and skip the wait/snapshot steps. Locate the
three commands (cmux browser "$SURFACE" get url, wait --load-state complete
--timeout-ms 15000, snapshot --interactive) and add a guard between the get and
wait that checks the retrieved URL value and fails fast on invalid navigation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@skills/cmux-browser/SKILL.md`:
- Around line 84-86: The example's described flow includes an explicit
"navigate" step but the snippet begins with `cmux browser surface:7 get url`;
add an explicit navigation command (e.g., `cmux browser surface:7 goto <url>` or
`cmux browser surface:7 open <url>`) before the `get url` and `wait` lines so
the sample matches "navigate -> verify -> wait -> snapshot" and is executable as
shown.

---

Nitpick comments:
In `@skills/cmux-browser/templates/authenticated-session.sh`:
- Around line 13-15: After calling cmux browser "$SURFACE" get url, read the
resulting URL and validate it is non-empty and not "about:blank" before running
cmux browser "$SURFACE" wait --load-state complete --timeout-ms 15000; if the
URL is empty or about:blank, emit an error/exit and skip the wait/snapshot
steps. Locate the three commands (cmux browser "$SURFACE" get url, wait
--load-state complete --timeout-ms 15000, snapshot --interactive) and add a
guard between the get and wait that checks the retrieved URL value and fails
fast on invalid navigation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e073585e-36c2-4842-9678-e09254953fe1

📥 Commits

Reviewing files that changed from the base of the PR and between 0fb2b41 and 85e4724.

📒 Files selected for processing (3)
  • skills/cmux-browser/SKILL.md
  • skills/cmux-browser/templates/authenticated-session.sh
  • skills/cmux-browser/templates/form-automation.sh

Comment on lines +84 to 86
# navigate -> verify -> wait -> snapshot -> action -> snapshot
cmux browser surface:7 get url
cmux browser surface:7 wait --load-state complete --timeout-ms 15000

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Stable loop snippet is missing the explicit navigate step.

Line 84 says navigate -> verify -> wait -> snapshot, but the snippet starts at get url on Line 85. Add a goto/open command so the example is executable as written.

Suggested doc fix
 # navigate -> verify -> wait -> snapshot -> action -> snapshot
+cmux browser surface:7 goto https://example.com
 cmux browser surface:7 get url
 cmux browser surface:7 wait --load-state complete --timeout-ms 15000
 cmux browser surface:7 snapshot --interactive
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# navigate -> verify -> wait -> snapshot -> action -> snapshot
cmux browser surface:7 get url
cmux browser surface:7 wait --load-state complete --timeout-ms 15000
# navigate -> verify -> wait -> snapshot -> action -> snapshot
cmux browser surface:7 goto https://example.com
cmux browser surface:7 get url
cmux browser surface:7 wait --load-state complete --timeout-ms 15000
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/cmux-browser/SKILL.md` around lines 84 - 86, The example's described
flow includes an explicit "navigate" step but the snippet begins with `cmux
browser surface:7 get url`; add an explicit navigation command (e.g., `cmux
browser surface:7 goto <url>` or `cmux browser surface:7 open <url>`) before the
`get url` and `wait` lines so the sample matches "navigate -> verify -> wait ->
snapshot" and is executable as shown.

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

Copy link
Copy Markdown

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: 85e4724e3d

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +27 to 28
cmux --json browser surface:7 click e2 --snapshot-after
cmux browser surface:7 snapshot --interactive

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reinstate wait after mutating browser actions

The updated core loop now runs click ... --snapshot-after and immediately snapshots again without any explicit wait, which makes the recommended flow unreliable when the click triggers async DOM updates or navigation. In those cases the immediate snapshot can still capture the pre-update page and produce stale refs for the next step; the prior sequence included a wait to synchronize on page state before re-snapshotting.

Useful? React with 👍 / 👎.

@greptile-apps

greptile-apps Bot commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR documents a goto -> get url -> wait -> snapshot navigation verification pattern for the cmux browser skill, addressing a silent failure case where wait --load-state complete would succeed even when the page had not actually navigated.

Key changes:

  • get url is inserted as step 2 in the core workflow and in all code examples to expose the current URL before waiting on load state
  • --json is consistently repositioned as a global flag (cmux --json browser ...) in most examples
  • A diagnostic tip is added: "If get url is empty or about:blank, navigate first instead of waiting on load state"
  • Both shell templates receive the same get url insertion

Findings:

  • The "Stable Agent Loop" comment references a "navigate" step that doesn't appear in the code snippet itself
  • Both shell templates call get url without capturing or checking its output, meaning they don't actively guard against the silent-failure scenario despite the documented guidance to do so

Confidence Score: 4/5

  • Safe to merge—only documentation and template changes with no impact on runtime code.
  • All changed files are documentation and shell script templates with no production runtime impact. The identified issues (documentation clarity in SKILL.md and template implementation details) are template/example quality concerns rather than shipped-code bugs. The changes align with the PR's stated goal of documenting the navigation verification pattern.
  • The "Stable Agent Loop" comment in SKILL.md (line 84) and both shell templates (authenticated-session.sh and form-automation.sh) should clarify whether get url is diagnostic-only or should be actively checked.

Sequence Diagram

sequenceDiagram
    participant Agent
    participant cmux
    participant Browser

    Agent->>cmux: browser open <url> --json
    cmux->>Browser: navigate to URL
    cmux-->>Agent: surface:N ref

    Agent->>cmux: browser surface:N get url
    cmux->>Browser: query current URL
    Browser-->>cmux: URL string (or about:blank)
    cmux-->>Agent: URL output (stdout only — not checked in templates)

    alt URL is about:blank / empty
        Note over Agent: PR tip says: navigate first
        Agent->>cmux: browser surface:N goto <url>
    else URL looks correct
        Agent->>cmux: browser surface:N wait --load-state complete
        cmux->>Browser: wait for load state
        Browser-->>cmux: ready
        Agent->>cmux: browser surface:N snapshot --interactive
        cmux-->>Agent: element refs
    end
Loading

Last reviewed commit: 85e4724

Comment on lines +84 to +85
# navigate -> verify -> wait -> snapshot -> action -> snapshot
cmux browser surface:7 get url

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The comment header lists "navigate" as the first step in the pattern, but the code snippet starts with get url and contains no goto or open command. This could confuse readers about where navigation happens.

Consider either:

  1. Adding a representative goto command at the top (before get url)
  2. Adjusting the comment to clarify navigation is a prerequisite:
Suggested change
# navigate -> verify -> wait -> snapshot -> action -> snapshot
cmux browser surface:7 get url
# (after goto) verify -> wait -> snapshot -> action -> snapshot
cmux browser surface:7 get url

Comment on lines 12 to 14
cmux browser "$SURFACE" goto "$DASHBOARD_URL"
cmux browser "$SURFACE" get url
cmux browser "$SURFACE" wait --load-state complete --timeout-ms 15000

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

get url is called after goto but its output is not captured or checked—wait --load-state complete runs unconditionally. The SKILL.md guidance (line 92) states: "If get url is empty or about:blank, navigate first instead of waiting on load state." This template should follow that guidance.

This same issue appears in skills/cmux-browser/templates/form-automation.sh (lines 7–9).

For a defensive template that guards against the silent-failure scenario documented in the PR, capture and check the result:

cmux browser "$SURFACE" goto "$DASHBOARD_URL"
CURRENT_URL=$(cmux browser "$SURFACE" get url)
if [ -z "$CURRENT_URL" ] || [ "$CURRENT_URL" = "about:blank" ]; then
  echo "Navigation may have failed (url='$CURRENT_URL'). Aborting." >&2
  exit 1
fi
cmux browser "$SURFACE" wait --load-state complete --timeout-ms 15000
cmux browser "$SURFACE" snapshot --interactive

Alternatively, if the intent is purely diagnostic (print the URL for an agent to observe), add a comment explaining why the result is not checked.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests_v2/test_browser_skill_navigation_docs.py (1)

36-39: Consider loosening exact sentence matching to reduce false test failures.

These assertions are very strict on wording; minor doc phrasing edits could fail the test without changing behavior. Consider matching stable key fragments instead of full sentences.

Optional resilience tweak
-    _must("Verify navigation with `get url` before waiting or snapshotting." in skill, "Expected core workflow to require get url verification")
-    _must("If `get url` is empty or `about:blank`, navigate first instead of waiting on load state." in skill, "Expected blank-page guidance in stable agent loop")
+    _must(
+        "Verify navigation with `get url`" in skill and "before waiting or snapshotting" in skill,
+        "Expected core workflow to require get url verification",
+    )
+    _must(
+        "If `get url` is empty" in skill and "`about:blank`" in skill and "navigate first" in skill,
+        "Expected blank-page guidance in stable agent loop",
+    )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests_v2/test_browser_skill_navigation_docs.py` around lines 36 - 39, The
assertions in tests_v2/test_browser_skill_navigation_docs.py use exact
full-sentence matches via _must which is brittle; update the four _must calls to
check for smaller, stable key fragments instead (e.g., replace "Verify
navigation with `get url` before waiting or snapshotting." with a fragment like
"Verify navigation" or "`get url` before waiting", replace the about:blank check
with "about:blank" or "navigate first" fragment, replace "cmux --json browser
open https://example.com" with "cmux --json browser open" and change the
negative check for "cmux browser open https://example.com --json" to either
assert absence of the fragment "--json" appearing after "cmux browser open" or
assert that "cmux browser open" and "--json" do not appear together in that
order; modify the _must calls (the calls to _must in this diff) to use those
shorter substrings or minimal regex checks so the tests are resilient to minor
phrasing changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests_v2/test_browser_skill_navigation_docs.py`:
- Around line 36-39: The assertions in
tests_v2/test_browser_skill_navigation_docs.py use exact full-sentence matches
via _must which is brittle; update the four _must calls to check for smaller,
stable key fragments instead (e.g., replace "Verify navigation with `get url`
before waiting or snapshotting." with a fragment like "Verify navigation" or
"`get url` before waiting", replace the about:blank check with "about:blank" or
"navigate first" fragment, replace "cmux --json browser open
https://example.com" with "cmux --json browser open" and change the negative
check for "cmux browser open https://example.com --json" to either assert
absence of the fragment "--json" appearing after "cmux browser open" or assert
that "cmux browser open" and "--json" do not appear together in that order;
modify the _must calls (the calls to _must in this diff) to use those shorter
substrings or minimal regex checks so the tests are resilient to minor phrasing
changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 25386423-13fe-4db4-aabe-cd76c859050d

📥 Commits

Reviewing files that changed from the base of the PR and between 85e4724 and 92cef9d.

📒 Files selected for processing (1)
  • tests_v2/test_browser_skill_navigation_docs.py

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

Copy link
Copy Markdown

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: 92cef9d250

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

_must("Verify navigation with `get url` before waiting or snapshotting." in skill, "Expected core workflow to require get url verification")
_must("If `get url` is empty or `about:blank`, navigate first instead of waiting on load state." in skill, "Expected blank-page guidance in stable agent loop")
_must("cmux --json browser open https://example.com" in skill, "Expected safe browser open example with --json before browser")
_must("cmux browser open https://example.com --json" not in skill, "Unexpected trailing --json browser open example")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject all trailing --json browser-open examples

This check only excludes one hard-coded string, so the test still passes while skills/cmux-browser/SKILL.md contains cmux browser open https://example.com --workspace workspace:2 --window window:1 --json (line 38). In CLI/cmux.swift, --json is parsed only as a global option before the command (cmux [global-options] <command>), and browser open joins remaining tokens into the URL, so trailing --json is treated as URL text instead of enabling JSON output. Please validate trailing---json forms generically so this regression is actually caught.

Useful? React with 👍 / 👎.

@lawrencecchen
lawrencecchen merged commit bb05219 into main Mar 6, 2026
12 checks passed

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

Copy link
Copy Markdown

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: e47b884a49

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +8 to 9
cmux browser "$SURFACE" get url
cmux browser "$SURFACE" wait --load-state complete --timeout-ms 15000

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Fail fast when URL verification is blank

This template adds get url but does not use its result before wait --load-state complete; in Sources/TerminalController.swift (v2BrowserWait), load-state waiting is only document.readyState equality, which is already complete on about:blank. If goto fails or has not committed yet, the script still succeeds and snapshots a blank page, so the new verification step does not actually prevent the silent no-op path.

Useful? React with 👍 / 👎.

bn-l pushed a commit to bn-l/cmux that referenced this pull request Apr 3, 2026
* Document browser navigation verification loop

* Add docs regression test for browser navigation guidance

* Remove invalid docs text inspection test

This branch was successfully deployed

1 active deployment
Preview — e47b884a Deployed Mar 6, 2026 by vercel[bot]
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.

1 participant