Skip to content

fix: browser screenshots fail on routed Control UI pages - #126290

Merged
steipete merged 5 commits into
mainfrom
steipete/browser-failure-6c618e
Aug 19, 2026
Merged

steipete merged 5 commits into
mainfrom
steipete/browser-failure-6c618e

Conversation

@steipete

@steipete steipete commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users opening the Browser panel from a routed Control UI URL could see Screenshot fetch failed (404) even though the managed browser loaded the page and captured the screenshot successfully.

The same route/resource confusion could also send chat media, icons, avatars, and other Gateway-owned HTTP resources to a router namespace that did not own them. Separately, a browser node could return a successful file-bearing result without transferring every referenced file back to the Gateway.

Why This Change Was Made

The Control UI now carries two explicit paths: the router base remains responsible for application navigation, while a server-declared resource base owns Gateway HTTP resources. This preserves routed pages without prefixing assistant media or other resource requests with the router namespace.

Browser node files now use one fail-closed validate, persist, and rewrite operation. Missing, duplicate, or unreferenced file payloads fail before any files are written, and both Gateway RPC and agent-tool proxy consumers use the same owner.

This PR is AI-assisted. I reviewed the architecture, diff, tests, and live behavior directly.

User Impact

The Browser panel renders captured pages normally from routed Control UI URLs instead of showing a misleading 404. New-session routing continues to work, and local chat media plus other Gateway-served UI resources resolve from the correct mount. Operators do not need a config change or migration.

Evidence

Before

Browser panel returning Screenshot fetch failed 404

After

Browser panel rendering Example Domain

browser-focus-after.webm

Isolated Hetzner post-fix proof

Browser panel rendering Example Domain on the Hetzner host

browser-focus-hetzner-after.webm

Live diagnosis on openclaw-team established the original boundary: Chromium and the Gateway were on the same Hetzner host, browser.request succeeded, the screenshot existed, the canonical /__openclaw__/assistant-media route returned the complete image, and the inferred /focus/__openclaw__/assistant-media route returned 404.

An isolated real-Gateway/real-Chromium before-and-after run then proved both sides of the repair:

  • A routed New Session page remains navigable while declaring an empty root resource mount.
  • The routed chat surface opens a browser tab and renders the real Example Domain screenshot.
  • The final result had a visible Browser panel and screenshot, no alert, and no browser console errors.
  • The same scenario passed in an isolated checkout on the actual Hetzner host; the production Gateway stayed healthy with HTTP 200 throughout.

Landing integration note: PR #126143 reserved root /focus/* URLs for the new focused-presentation contract before this PR merged. The final integrated regression uses the default /__openclaw__ route namespace for the route/resource split. The original /focus/new live evidence remains the reproduction that exposed the conflation; team-owned legacy /focus/<app-route> links now need a separate route migration rather than weakening the canonical Focus grammar.

Exact merged-head Hetzner proof

Merge commit 1fa82e9795762a87937fd25f847c6ff75e0534f2 was built and run in an isolated checkout on the Hetzner host after the Focus-route integration. /__openclaw__/new remained the New Session route, /__openclaw__/chat/main rendered Example Domain in the Browser panel, the resource mount was the empty root, and production health remained HTTP 200.

Exact merged head rendering Example Domain

browser-route-resource-merged-after.webm

Focused validation:

  • node scripts/run-vitest.mjs src/gateway/control-ui.http.test.ts — 144 passed
  • node scripts/run-vitest.mjs extensions/browser/src/browser/proxy-files.test.ts extensions/browser/src/browser-node-proxy.test.ts extensions/browser/src/gateway/browser-request.profile-from-body.test.ts — 65 passed
  • node scripts/run-vitest.mjs ui/src/app/browser.test.ts ui/src/app/bootstrap.test.ts ui/src/components/browser/browser-client.test.ts ui/src/pages/chat/components/chat-message.test.ts ui/src/pages/plugins/icon-loader.test.ts — 241 passed across two shards
  • node scripts/run-vitest.mjs src/gateway/control-ui.auto-root.http.test.ts ui/src/pages/plugins/plugins-page.test.ts — 29 passed across two shards
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/login-gate.e2e.test.ts — 12 passed
  • node scripts/check-changed.mjs — passed
  • pnpm build — passed
  • structured Codex autoreview — clean, no accepted/actionable findings
  • final exact-head CI run 32247459967 — passed

Final merged production/tooling LOC: +288/-229 (net +59). Tests/support: +375/-165.

@clawsweeper

clawsweeper Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime extensions: browser size: L maintainer Maintainer-authored PR labels Aug 19, 2026
@steipete
steipete marked this pull request as ready for review August 19, 2026 10:06
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 19, 2026
@clawsweeper

clawsweeper Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 19, 2026, 6:59 AM ET / 10:59 UTC.

ClawSweeper review

What this changes

Separates Control UI navigation paths from Gateway resource paths and validates browser-node file envelopes before persisting and rewriting their returned paths.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open for maintainer review: the source-backed repair is coherent and no blocking defect was found, but the protected maintainer label and compatibility decision still require explicit owner acceptance.

Priority: P2
Reviewed head: c7e08cb97f27c8950f49254c75eaaa85832463a8
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong real-flow evidence and focused owner-boundary coverage support a clean patch, pending the compatibility decision.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (recording): The PR body provides before/after visual evidence and an isolated real-Gateway/real-Chromium post-fix run for the changed routed UI flow.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (recording): The PR body provides before/after visual evidence and an isolated real-Gateway/real-Chromium post-fix run for the changed routed UI flow.
Evidence reviewed 6 items Current-main failure path: Current main omits the declared base-path attribute for an empty mount, then the UI falls back to pathname inference; screenshot fetching prepends that inferred path to the assistant-media endpoint.
Owner-boundary repair: The branch retains inferred routing while treating an explicitly emitted empty resource mount as authoritative, then threads that fact through the resource consumers.
Sibling coverage: Focused tests cover root-mounted and configured resource mounts, bootstrap route resolution, browser screenshots, chat media, icons, and invalid browser-node file envelopes.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

pnpm openclaw --help
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-126290-ws7rJe/target$ pnpm openclaw --help
$ node scripts/run-node.mjs --help
pnpm openclaw --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 400.66 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 109.90 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

[tsdown-build] invocation 2/2 finished in 13.8s
[plugin-control-plane-loads] verified 36 built modules with native require and checked doctor closures
runtime-postbuild: 10 phases completed in 4379ms (slowest: built plugin control-plane loads 3619ms)

OpenClaw 2026.8.1 (c7e08cb) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console
… output truncated …

Assertions:

  • PASS expect_output: Usage:

How this fits together

The Control UI derives a navigation base for browser routing and a Gateway resource base for media, icons, avatars, and bootstrap requests. Browser-node proxy results cross from a remote browser host into the Gateway media store before the UI consumes them.

flowchart LR
  A[Deep Control UI URL] --> B[Route-base resolution]
  B --> C[Control UI navigation]
  B --> D[Gateway resource mount]
  D --> E[Media, icons, and avatars]
  F[Browser node result] --> G[Validate and persist files]
  G --> E
Loading

Decision needed

Question Recommendation
Should routed root-mounted Control UI deployments formally use the server-declared empty resource mount while preserving the inferred route base for navigation? Accept the explicit resource mount: Confirm that Gateway HTTP resources are root-mounted for these deployments and retain the split route/resource model.

Why: This is an intentional compatibility contract across all same-origin resource consumers, not a mechanical correctness repair that automation should choose alone.

Before merge

  • Resolve merge risk (P1) - Merging changes same-origin resource URLs for root-mounted deep links; maintainers should explicitly accept the server-declared resource mount as the deployment contract for routed Control UI URLs.
  • Resolve merge risk (P1) - This bug-fix branch has a net +83 production/tooling LOC delta; the broader propagation is justified only if route and resource bases remain distinct owner facts rather than parallel conventions.
  • Complete next step (P2) - The remaining action is maintainer acceptance of the routed deployment compatibility model, not an automated repair.
Agent review details

Security

None.

PR surface

Source +89, Tests +203. Total +292 across 75 files.

View PR surface stats
Area Files Added Removed Net
Source 54 264 175 +89
Tests 21 350 147 +203
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 75 614 322 +292

Review metrics

Metric Value Why it matters
Production versus test delta production/tooling +260/-177 (net +83); tests/support +348/-142 The positive production delta propagates one resource-owner fact across UI consumers and adds atomic browser-node file validation.

Stored data model

Persistent data-model change detected: persistent cache schema: ui/src/pages/chat/components/chat-message-attachment-availability.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Accept the explicit resource mount (recommended)
    Confirm the root-mounted resource contract for routed Control UI URLs, then merge once the exact head has completed its normal checks.
  2. Pause for a proxy-contract revision
    Hold the branch if supported deployments require resource requests to remain under an inferred route namespace.

Technical review

Best possible solution:

Adopt the server-declared resource mount as the sole source for Gateway HTTP resources while preserving inferred routing for navigation, then merge after owner confirmation.

Do we have a high-confidence way to reproduce the issue?

Yes: current-main source shows an empty server mount becomes a pathname-inferred resource base, causing routed pages to request assistant media beneath that route namespace; the PR also supplies real after-fix evidence.

Is this the best way to solve the issue?

Yes: carrying separate navigation and resource facts from the Gateway bootstrap is the narrowest canonical repair, and is preferable to per-consumer route exceptions.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4af09d4961c9.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: The branch intentionally changes which same-origin base existing routed deployments use for Gateway media and resource endpoints.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: The PR repairs a user-visible Control UI resource-routing failure with limited scope.
  • merge-risk: 🚨 compatibility: The branch intentionally changes which same-origin base existing routed deployments use for Gateway media and resource endpoints.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (recording): The PR body provides before/after visual evidence and an isolated real-Gateway/real-Chromium post-fix run for the changed routed UI flow.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides before/after visual evidence and an isolated real-Gateway/real-Chromium post-fix run for the changed routed UI flow.
  • proof: 🎥 video: Contributor real behavior proof includes video or recording evidence. The PR body provides before/after visual evidence and an isolated real-Gateway/real-Chromium post-fix run for the changed routed UI flow.

Evidence

What I checked:

  • Current-main failure path: Current main omits the declared base-path attribute for an empty mount, then the UI falls back to pathname inference; screenshot fetching prepends that inferred path to the assistant-media endpoint. (src/gateway/control-ui.ts:674, 4af09d4961c9)
  • Owner-boundary repair: The branch retains inferred routing while treating an explicitly emitted empty resource mount as authoritative, then threads that fact through the resource consumers. (ui/src/app/browser.ts:38, c7e08cb97f27)
  • Sibling coverage: Focused tests cover root-mounted and configured resource mounts, bootstrap route resolution, browser screenshots, chat media, icons, and invalid browser-node file envelopes. (src/gateway/control-ui.http.test.ts:1567, c7e08cb97f27)
  • Feature history: The original configured-base startup behavior appears to date to the Control UI/base-path commit, while current-main history identifies later Control UI and screenshot-flow contributors. (ui/src/app/browser.ts:10, 9d1554403856)
  • Real behavior evidence: The PR body supplies before/after media plus an isolated real-Gateway and Chromium run showing routed navigation and the repaired screenshot; attachment retrieval was unavailable in this reviewer environment, which does not reduce the supplied evidence. (c7e08cb97f27)
  • Main and release status: The reviewed head is not contained by local main or a release tag, so this remains an unmerged fix rather than an implemented-on-main outcome. (c7e08cb97f27)

Likely related people:

  • Shakker: Authored the current base-path startup behavior that this repair refines. (role: introduced configured Control UI base-path behavior; confidence: high; commits: 9d1554403856; files: ui/src/app/browser.ts, ui/src/app/bootstrap.ts, src/gateway/control-ui.ts)
  • Ayaan Zaidi: Current-main blame attributes the screenshot media-fetch path to this contributor. (role: current screenshot-flow contributor; confidence: medium; commits: 97e3136b9e6f; files: ui/src/components/browser/browser-client.ts)
  • steipete: Current-main history identifies this contributor on the latest Control UI surface, independently of this PR branch. (role: recent Control UI contributor; confidence: medium; commits: 4af09d4961c9; files: src/gateway/control-ui.ts, ui/src/app/browser.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-19T10:14:13.159Z sha f7a3ff7dd2c59e9729ca2f1af3ac7aac282fa191 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-19T10:39:13.358Z sha 02cfca2e7433c73319b2c2b01a8bddb4173f9201 :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready verification is complete on exact head 02cfca2e7433c73319b2c2b01a8bddb4173f9201.

Maintainer decision: accept the explicit route-base/resource-base compatibility model. Navigation and Gateway HTTP resources are distinct facts in deployments such as /focus; keeping one inferred value caused the reported 404, while removing inference broke /focus/new. The +83 production-line delta is justified by carrying that ownership fact through the existing resource consumers and by making browser-node file transfer fail closed. No persisted cache, config, database, or protocol schema changed, so no migration is required.

Local proof:

  • node scripts/run-vitest.mjs src/gateway/control-ui.http.test.ts — 144 passed
  • node scripts/run-vitest.mjs extensions/browser/src/browser/proxy-files.test.ts extensions/browser/src/browser-node-proxy.test.ts extensions/browser/src/gateway/browser-request.profile-from-body.test.ts — 65 passed
  • node scripts/run-vitest.mjs ui/src/app/browser.test.ts ui/src/app/bootstrap.test.ts ui/src/components/browser/browser-client.test.ts ui/src/pages/chat/components/chat-message.test.ts ui/src/pages/plugins/icon-loader.test.ts — 241 passed across two shards
  • node scripts/run-vitest.mjs src/gateway/control-ui.auto-root.http.test.ts ui/src/pages/plugins/plugins-page.test.ts — 29 passed across two shards
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/login-gate.e2e.test.ts — 12 passed
  • node scripts/check-changed.mjs — passed
  • pnpm build — passed
  • structured Codex autoreview — clean, no accepted/actionable findings

Real behavior proof:

  • The original live Hetzner diagnosis showed browser.request succeeding and the screenshot file existing; the canonical assistant-media route returned 200 while the inferred /focus resource route returned 404.
  • A post-fix isolated checkout on the same Hetzner host preserved /focus/new, rendered Example Domain in the Browser panel from /focus/chat/main, returned no alert or console error, and left the production Gateway healthy with HTTP 200. Screenshot and recording are in the PR body.

The first CI run exposed three stale test fixtures in the changed contract; those were repaired and their exact files rerun locally. Exact-head CI run 32243011921 is fully green. No known proof gaps remain.

@steipete
steipete force-pushed the steipete/browser-failure-6c618e branch from 02cfca2 to c7e08cb Compare August 19, 2026 10:52
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 19, 2026
@steipete
steipete merged commit 1fa82e9 into main Aug 19, 2026
236 checks passed
@steipete
steipete deleted the steipete/browser-failure-6c618e branch August 19, 2026 11:36
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 20, 2026
…6290)

* fix(browser): validate proxied file ownership

* fix(ui): separate route and resource base paths

* test(ui): align resource base fixtures

* test(ui): align route-base fixtures with focus routes

* perf(ui): keep profile avatar URLs out of startup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui extensions: browser gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant