Skip to content

fix(browser): recover stale panel after stream disconnects - #141576

Merged
obviyus merged 2 commits into
openclaw:mainfrom
safzanpirani:fix/browser-stream-recovery
Sep 8, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
safzanpirani:fix/browser-stream-recovery

Conversation

@safzanpirani

@safzanpirani safzanpirani commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Closes #141564

What Problem This Solves

Fixes an issue where the Browser panel would keep displaying a stale image after an established screencast connection failed. The Gateway client could remain available while the panel requested neither a screenshot nor a replacement stream.

Why This Change Was Made

The stream owner now requests screenshot fallback and retries streaming through its existing ten-second backoff. Recovery cancels when ownership changes. The screenshot controller preserves captured annotation and inspection images.

Review follow-up in 68e57c98:

  • A retry reconnects the stream directly and requests a new screenshot only when no screenshot is still in flight. A failed reconnect no longer discards a pending fallback screenshot.
  • A large width change during annotation or inspection no longer closes the stream. The restart waits until interaction mode resumes.

User Impact

The panel recovers without a refresh, resize, or navigation action. Users can finish annotating or inspecting their captured image and return to interaction mode to resume streaming, including after resizing the panel.

Evidence

  • All 202 tests pass across the 14 browser panel test files. The 36 stream tests include three new regressions for the review findings; all three failed on d05d51d6 before the fix.
  • Formatting, lint, UI typecheck, and git diff --check pass. check:madge-import-cycles reports zero cycles.
  • An independent reviewer checked the follow-up commit. It found no defect in either fix and confirmed that the three regressions fail on the previous head for the traced reasons. Its one remaining note concerns the open-socket case below.

The Chromium fixture loads the production Browser panel and terminates a real disposable WebSocket connection. Gateway request responses are synthetic; this does not test a real Gateway backend.

Observation Baseline 63126736 PR head 68e57c98
Screenshot after disconnect None within 12 seconds Requested after 4 ms
Replacement stream None within 12 seconds Connected after 10.004 seconds
Display Original image remains Fallback screenshot, then a new streamed frame
Gateway client Available throughout Available throughout

The timing values describe one fixture run. No manual refresh occurs.

A socket that stays open without sending its first frame remains outside this fix. The independent review of the follow-up commit flagged the same case; it behaves as it did on the previous head and on main.

The checks-ui-e2e (7/13) failure on d05d51d6 was chat-flow.image-handoff.e2e.test.ts, which this change does not touch.

AI-assisted implementation and review.

@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: M labels Sep 7, 2026
@safzanpirani
safzanpirani force-pushed the fix/browser-stream-recovery branch from 5a2746c to d51af6f Compare September 7, 2026 21:24
@safzanpirani
safzanpirani marked this pull request as ready for review September 7, 2026 21:26
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 7:00 PM ET / 23:00 UTC.

ClawSweeper review

What this changes

The Browser panel automatically refreshes screenshots and reconnects failed streams while preserving annotation and inspection images and deferring resize restarts.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still lacks automatic recovery after an established stream disconnects. Both earlier findings are addressed, the supplied Chromium evidence demonstrates recovery, and no blocking defect was found.

Priority: P2
Reviewed head: 68e57c98497b5973b421843c3743582319106724

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with relevant real-transport observations, meaningful regression coverage, and both earlier findings resolved.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured Chromium observations exercise the production Browser panel and real WebSocket disconnect: head 68e57c9 requests fallback after 4 ms and reconnects after 10.004 seconds, displaying a new frame without intervention. Synthetic Gateway RPC responses limit backend coverage but adequately isolate the changed transport-recovery boundary.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured Chromium observations exercise the production Browser panel and real WebSocket disconnect: head 68e57c9 requests fallback after 4 ms and reconnects after 10.004 seconds, displaying a new frame without intervention. Synthetic Gateway RPC responses limit backend coverage but adequately isolate the changed transport-recovery boundary.
Evidence reviewed 8 items Current main still needs recovery: The ordinary socket-close handler records a failure and releases stream ownership without scheduling a screenshot or replacement connection. The existing first-frame timeout also remains unchanged; a socket that stays open without frames is outside this repair.
Recovery preserves pending captures: Recovery reconnects directly through ensure(), then requests a screenshot only when no capture is pending. The timer checks the selected tab, live operation scope, and interaction mode before resuming.
Earlier findings addressed: The two findings at #141576 (comment) are addressed by the pending-capture guard and deferred resize teardown. Regression cases cover reconnecting during a pending screenshot, preserving that screenshot after reconnect failure, and resuming resize restarts after both capture modes. The contributor reports that the three new regressions failed on the preceding head; this review did not execute them.
Findings None None.
Security None None.

How this fits together

The Control UI Browser panel displays streamed frames or fallback screenshots from the selected browser tab. Its stream and snapshot controllers coordinate reconnects, image ownership, and capture modes.

flowchart TD
  A[Selected browser tab] --> B[Browser stream]
  B --> C{Connection lost}
  C --> D{Interaction mode}
  D -->|Yes| E[Screenshot fallback and delayed reconnect]
  D -->|No| F[Preserve captured image]
  F -->|Exit capture mode| E
  E --> G[Updated Browser panel]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +70, Tests +201, Docs +4. Total +275 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 91 21 +70
Tests 1 225 24 +201
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 320 45 +275

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +70 lines; tests net +201 lines Production growth implements lifecycle-owned recovery and deferred restarts; tests protect timing, image retention, and teardown behavior.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #141564
Summary: This PR is the explicit candidate repair for the same author's open Browser panel disconnect report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep recovery in the stream lifecycle owner, with bounded retries, preserved in-flight screenshots, and capture-mode-aware restarts.

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

Yes: terminate an established screencast while the Gateway client remains available and observe the absence of automatic recovery on current main. Source inspection supports the supplied Chromium baseline; this review did not execute it.

Is this the best way to solve the issue?

Yes: the patch repairs the existing stream owner and reuses screenshot fallback and backoff, while addressing both previously reported lifecycle races.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 80dc985ed386.

Labels

Label justifications:

  • P2: Repairs a stale Browser panel after stream disconnects without evidence of broader runtime or message-delivery impact.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured Chromium observations exercise the production Browser panel and real WebSocket disconnect: head 68e57c9 requests fallback after 4 ms and reconnects after 10.004 seconds, displaying a new frame without intervention. Synthetic Gateway RPC responses limit backend coverage but adequately isolate the changed transport-recovery boundary.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured Chromium observations exercise the production Browser panel and real WebSocket disconnect: head 68e57c9 requests fallback after 4 ms and reconnects after 10.004 seconds, displaying a new frame without intervention. Synthetic Gateway RPC responses limit backend coverage but adequately isolate the changed transport-recovery boundary.

Evidence

What I checked:

  • Current main still needs recovery: The ordinary socket-close handler records a failure and releases stream ownership without scheduling a screenshot or replacement connection. The existing first-frame timeout also remains unchanged; a socket that stays open without frames is outside this repair. (ui/src/components/browser/browser-panel-stream.ts:174, 80dc985ed386)
  • Recovery preserves pending captures: Recovery reconnects directly through ensure(), then requests a screenshot only when no capture is pending. The timer checks the selected tab, live operation scope, and interaction mode before resuming. (ui/src/components/browser/browser-panel-stream.ts:221, 68e57c98497b)
  • Earlier findings addressed: The two findings at fix(browser): recover stale panel after stream disconnects #141576 (comment) are addressed by the pending-capture guard and deferred resize teardown. Regression cases cover reconnecting during a pending screenshot, preserving that screenshot after reconnect failure, and resuming resize restarts after both capture modes. The contributor reports that the three new regressions failed on the preceding head; this review did not execute them. (ui/src/components/browser/browser-panel-stream.test.ts:147, 68e57c98497b)
  • After-fix Chromium observations: The complete captured PR body, sourceRevision 23dff6da60c3075f3c486281195068c996a8c3cd1a19ecafbc080159f8a868aa, reports the production Browser panel running in Chromium against a real disposable WebSocket. At head 68e57c9, terminating the established connection requested a screenshot after 4 ms and connected a replacement stream after 10.004 seconds, displaying fallback then new streamed pixels without manual refresh. Gateway RPC responses were synthetic. The linked issue supplies the corresponding baseline environment and failure trace. (68e57c98497b)
  • Existing lifecycle and request boundaries retained: Browser requests remain bound to the current panel client and route. Recovery reuses those checks, cancels on ownership teardown, and preserves the special blocked-navigation and closed-target handling. No credentials, dependencies, persistent schemas, or plugin APIs change. (ui/src/components/browser/browser-client.ts:75, 68e57c98497b)
  • Feature history and routing: Current-main history identifies Peter Steinberger's stream implementation and subsequent native-browser controller work. Blame maps the live-attempt predicate to a7175b2; raw commit inspection records parent 9c960ad, whose tree has no stream file. (ui/src/components/browser/browser-panel-stream.ts:87, a7175b2af3aa)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

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-09-07T21:34:30.435Z sha d51af6f3af7a1ab81dcd8e67e23c986af0863ccf :: needs maintainer review before merge. :: none
  • reviewed 2026-09-07T21:51:14.475Z sha d05d51d :: needs maintainer review before merge. :: none

@safzanpirani
safzanpirani force-pushed the fix/browser-stream-recovery branch from d51af6f to d05d51d Compare September 7, 2026 21:41
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Reviewed d05d51d6c892. Recovery belongs in the stream owner, but two P2 issues remain:

  1. P2 — Reconnects invalidate valid fallback screenshots. Code. refreshView() calls beginCapture() before stream.ensure(), superseding an in-flight screenshot. With fast captures, e.g. 15-second media downloads, and repeated fast transient stream failures, the 10-second retries prevent any screenshot from being displayed. Preserve the pending fallback while reconnecting independently.

  2. P2 — Resizing during capture mode loses the restart. Code. A >30% width change closes the stream, then the new mode guard skips restarting it. If Annotate/Inspect remains active until resize refreshes finish, exiting has neither an attempt nor a recovery to resume. Retain the pending restart or defer teardown.

Please add regression tests for both sequences. These are statically traced findings, not independently executed reproductions.

Inspected CI, attempt 1: 33 stream tests passed; a separate chat-image E2E test failed. A causal relationship with this PR has not been established.

…ecovery

A recovery retry reconnects the stream directly and requests a new
screenshot only when none is in flight, so a failed reconnect no longer
discards a pending fallback screenshot. A large width change during
annotation or inspection keeps the stream open; the restart waits until
interaction mode resumes.
@safzanpirani

Copy link
Copy Markdown
Contributor Author

Both findings are fixed in 68e57c9.

  1. The recovery retry now reconnects the stream directly and requests a screenshot only when the reconnect fails and no screenshot is in flight. A pending fallback screenshot survives a failed retry and is displayed when it arrives.
  2. A large width change during annotate or inspect no longer closes the stream. The restart is re-evaluated when interaction mode resumes.

Three regression tests cover both sequences. All three failed on d05d51d before the fix. Locally, 202 browser panel tests, lint, the UI typecheck, and the import-cycle check pass. The Chromium proof passed again on the new head; the PR body carries the updated trace.

The checks-ui-e2e (7/13) failure was chat-flow.image-handoff.e2e.test.ts, which this PR does not touch.

@obviyus
obviyus merged commit 06bef28 into openclaw:main Sep 8, 2026
168 of 170 checks passed
@obviyus

obviyus commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Thanks @safzanpirani!

Proof: The production Control UI Browser panel was exercised in Chromium with a real disposable WebSocket and synthetic Gateway responses. The complete browser outcome was checked without a manual refresh.

  • Bug: Disconnecting an established screencast left the last image visible without requesting fallback or reconnecting.
  • Fix: The stream owner schedules screenshot fallback and retries, preserves pending screenshots, and defers recovery while an annotation or inspection image is pinned.
Before After
The panel remains stale after an established stream disconnects. The panel displays a fallback screenshot and resumes streamed frames automatically.
No automatic recovery after the stream is lost. Annotation remains pinned until interaction resumes; a late screenshot does not overwrite recovered streamed pixels.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
…141576)

Recover the Browser panel after an established screencast disconnects by requesting a fallback screenshot and retrying the stream through the existing backoff.

Keep pending screenshots valid during failed reconnects. Preserve annotation and inspection images, then resume deferred recovery and resize restarts when interaction mode returns.

Fixes openclaw#141564.

Co-authored-by: Ayaan Zaidi <[email protected]>
vincentkoc added a commit to LiuwqGit/openclaw that referenced this pull request Sep 8, 2026
…1-prep

* commit 'da37d47920d102044a4cb33f8cd688b4abc3c2a6': (460 commits)
  refactor(memory): simplify built-in runtime delegation (openclaw#141847)
  refactor(comfy): remove unused cloud fixture input (openclaw#141844)
  fix(agents): keep canonical target casing for session-bound replies (openclaw#140418)
  fix(ci): hydrate release source ancestry through branch (openclaw#141840)
  fix(telemetry): include mixed-case configured providers (openclaw#141134)
  fix(qa): retain Slack presentation history (openclaw#127300)
  test(cli): compact argv case matrices (openclaw#141832)
  test(agents): compact code mode case matrices (openclaw#141831)
  test(gateway): compact control ui routing cases (openclaw#141834)
  test(reasoning): compact reasoning tag cases (openclaw#141833)
  fix(cli): keep progress spinners within terminal width (openclaw#141401)
  fix(release): provision native live harness dependencies (openclaw#141829)
  fix(cron): preserve prepared runtime and error ownership (openclaw#140941)
  fix(npm): recognize companion-owned runtime imports (openclaw#141647)
  fix(browser): reject unsupported buttons in click commands (openclaw#140976)
  refactor(gateway): keep cached turn replay with dedupe (openclaw#141824)
  fix(release): preserve frozen gateway package resolution (openclaw#141827)
  refactor: keep live image probe matching private (openclaw#141823)
  fix(browser): recover stale panel after stream disconnects (openclaw#141576)
  feat(cron): explain slow automation list requests (openclaw#141805)
  ...
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 docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

[Bug]: Browser panel stays stale after screencast socket disconnects

3 participants