Skip to content

fix(browser-recording): a frame whose tab closes mid-capture is taken of the tab left - #652

Merged
earakely-scale merged 1 commit into
mainfrom
edgararakelyan/browser-frame-tab-closes-mid-capture
Nov 12, 2026
Merged

earakely-scale merged 1 commit into
mainfrom
edgararakelyan/browser-frame-tab-closes-mid-capture

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A follow-up to #650: a frame whose tab closes while its capture is in flight is now taken of the tab that's left, instead of going missing and failing the run.

Testing #650 end to end turned up a third way to lose a frame. When a tab closes while its frame's capture is waiting, Chrome never answers the capture. The frame waited out its whole budget, FRAME_CAPTURE_S (10 s), and went missing, failing the run as an infrastructure failure.

#650's retry doesn't cover this. It handles the browser refusing a capture of a session that's already gone (Session with given id not found). Here the capture is already in flight when the tab goes, so no refusal ever comes back.

What changes

  • BrowserControl._nudged_capture waits for its captures in 0.25 s slices. Between slices it checks that the tab's session is still there. Once it's gone with no capture answered, it stops waiting (_TabGone).
  • BrowserControl.frame then asks again, within the same budget, of the tab the browser has by then: the tab's new session, else the active tab's. This is the same path fix(browser-recording): a recording ends complete when an action is still going, or a tab's session went away #650 added for a refusal, and a frame of a closed tab already went to the active tab.
  • A frame is still missing when the budget runs out before any tab answers, as before.

Test plan

Docs

None beyond #650's: a frame waits up to 10 s, and now also outlasts its tab closing mid-capture.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge.

Summary

The PR recovers recording frames when their tab closes during capture.

  • Browser recordings keep framing the tab left after a tab closes mid-capture.
  • Recording tests check how shutdown logs a command still in flight.

No actionable issues were found. Tests were not run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Capture frame] --> B{Capture answered?}
  B -->|Yes| C[Return image and captured tab]
  B -->|No| D{Session still present?}
  D -->|Yes| B
  D -->|No| E{Budget remains?}
  E -->|No| F[Report missing frame]
  E -->|Yes| G[Cancel pending captures]
  G --> H[Choose replacement session or active tab]
  H --> A
Loading

Reviews (1) · Last reviewed commit: "fix(browser-recording): a frame whose ta..." · Reviewed by Greptile

… of the tab left

A capture asked of a tab that then closes is never answered, so its frame
waited out FRAME_CAPTURE_S (10 s) and went missing, failing the run as an
infrastructure failure. #650's retry catches the browser refusing a capture
of a session already gone; this is the capture already in flight.

While a frame's capture waits, the control now checks that the tab's session
is still there. If it went away, the capture is dropped and asked again,
within the same budget, of the tab the browser has then.

Adds two integration tests, each reproducing one failure against a real
browser computer:
- a recording that ends while an agent's command is in flight, which #650
  fixed: it fails on the main before #650
- a tab that closes while its frame's capture waits: it fails on main and on
  #650, and passes here

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale requested a review from a team as a code owner November 12, 2026 22:24
@earakely-scale
earakely-scale merged commit 3dcc044 into main Nov 12, 2026
35 checks passed
@earakely-scale
earakely-scale deleted the edgararakelyan/browser-frame-tab-closes-mid-capture branch November 12, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant