You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(desktop): agent screenshots of an unwatched preview wait for its animations - #41233
When the T3 window was minimized or covered, an agent's first screenshot of a background preview tab could show an animation half done, even long after it should have finished. Chromium defers a guest's animations while it is not drawn, so they only started once the capture made the tab draw. Now a screenshot of a guest that was not already drawn first lets the page settle: it waits two frames, then waits for its running finite animations to finish, capped at 1 second. Screenshots of an already-drawn guest are unchanged.
Being captured: before and after in the real app. This section is filled in before the pull request can merge.
Tests
vp test run src/preview/DesktopBrowserHost.test.ts (apps/desktop): 44 passed, including the extended 'sends a screenshot once the client draws the guest at full detail, or soon after' case
vp run check:changed: format, lint, knip, typecheck (2 packages) and the test file all passed
Real Electron probe under headless-desktop running the settle expression: 150 ms fade returned in 183 ms with opacity 1; infinite animation and no animation each returned in about 50 ms
Not in this change
A visible guest whose client never reports it drawn at full detail already waits the full 1 s CAPTURE_DRAW_WAIT before every screenshot.
document.getAnimations() only covers the top document, so animations inside iframes are not waited for.
Who did the work
Written by Claude Opus 5.5, in Claude Code
Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5
No actionable comments were generated in the recent review.
Walkthrough
Undrawn guest captures now wait for page animations to settle after the draw wait. The wait has a one-second limit. Already-drawn guests still proceed to capture immediately.
Changes: Guest capture timing
Layer / File(s)
Summary
Animation settling and capture ordering apps/desktop/src/preview/DesktopBrowserHost.ts, apps/desktop/src/preview/DesktopBrowserHost.test.ts
The host waits for two animation frames and finite running animations, with a one-second fallback, before capturing an undrawn guest. Tests verify the evaluation-before-screenshot order and that capture proceeds when the evaluation remains unanswered.
Screenshots of undrawn preview guests now wait briefly for finite animations to settle, capped at one second. Already-drawn guests are unchanged. No merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the change (agent screenshots of an unwatched preview wait for animations) and the scope (desktop). It matches the main change in DesktopBrowserHost.ts and its test: undrawn guests now…
Description check
The description follows the template sections: Problem, Change, Scope, Verification, and the agent attribution line. The Problem and Change sections are clear and explain the root cause (Chromium defe…
Linked Issues check
Issue #34707 requires that a screenshot of an undrawn preview guest show animations in their settled state. The diff to apps/desktop/src/preview/DesktopBrowserHost.ts adds settleAnimations, which runs…
Out of Scope Changes check
The code diff touches only DesktopBrowserHost.ts (new constants, settleAnimations helper, and its use in paintUntilAnswered) and its test file. Every hunk serves the settle-before-capture objective fr…
Full details: Title check
Explanation
The title names the change (agent screenshots of an unwatched preview wait for animations) and the scope (desktop). It matches the main change in DesktopBrowserHost.ts and its test: undrawn guests now wait for a page-side animation settle before capture. It is specific and follows the conventional commit style of the template.
Full details: Description check
Explanation
The description follows the template sections: Problem, Change, Scope, Verification, and the agent attribution line. The Problem and Change sections are clear and explain the root cause (Chromium defers animations while a guest is not drawn) and the fix (settle step with a 1 s cap). Scope links issue #34707. Verification lists focused tests and a real Electron probe, with observed results. The Evidence section is a placeholder that says it will be filled in before merge, so a before/after screenshot or recording is still missing. The template requires visual evidence for UI-timing changes, so this is a gap to close before merge. The description also says the reproduction on main did not hit the covered-window timeout, which is useful context. Overall the description is mostly complete.
Full details: Linked Issues check
Explanation
Issue #34707 requires that a screenshot of an undrawn preview guest show animations in their settled state. The diff to apps/desktop/src/preview/DesktopBrowserHost.ts adds settleAnimations, which runs before send() in paintUntilAnswered only when the guest is not in drawnTabs. The page-side SETTLE_ANIMATIONS script waits two requestAnimationFrame frames, then waits for running animations whose effect endTime is finite (Number.isFinite), then waits one more frame. Infinite animations are excluded, as the issue asks. Already-drawn guests still send at once, as the issue expects. The host also resolves after 1 second on its own timer, so an unresponsive page only delays the capture. The test file change extends the screenshot timing test to check that Runtime.evaluate runs before the capture, and that capture proceeds after 1 second when the settle command never answers. Deviation noted: the issue proposed a cap of at most 500 ms, and the PR uses 1 second (CAPTURE_SETTLE_WAIT). The issue presents its fix as a possible direction, and the expected behavior (fade finished at snapshot time) is met by the implementation. The PR also reports a main reproduction that did not hit the covered-window timeout. That finding does not change the code requirement. The author's test and probe results were not re-run in this review; the assessment relies on the diff.
Full details: Out of Scope Changes check
Explanation
The code diff touches only DesktopBrowserHost.ts (new constants, settleAnimations helper, and its use in paintUntilAnswered) and its test file. Every hunk serves the settle-before-capture objective from #34707. The PR description's non-code sections (evidence placeholder, reproduction notes, authorship) are not code changes. The stated exclusions (CAPTURE_DRAW_WAIT behavior for never-drawn visible guests, iframe animations) are documented limits, not out-of-scope edits.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:M30-99 changed lines (additions + deletions).vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the T3 window was minimized or covered, an agent's first screenshot of a background preview tab could show an animation half done, even long after it should have finished. Chromium defers a guest's animations while it is not drawn, so they only started once the capture made the tab draw. Now a screenshot of a guest that was not already drawn first lets the page settle: it waits two frames, then waits for its running finite animations to finish, capped at 1 second. Screenshots of an already-drawn guest are unchanged.
Fixes #34707
Reproduction on main
Commit: origin/main 9d3054a. Machine: pooled Mac, macOS 26.6.2 arm64,
T3CODE_DEV_SEED=0 vp run dev:desktop(fresh worktree database, onboarding completed with a click). A local page at http://127.0.0.1:8765/ exposes window.go(n), which replaces a full-viewport red div and runs el.animate([{opacity:0},{opacity:1}],{duration:150}). Project added witht3 project add; each pass was a Claude Haiku thread started witht3 thread start <proj> <prompt> --provider claudeAgent --model haiku --wait, prompting: preview_open url=http://127.0.0.1:8765/ open=false (Browser panel never shows it), then 8 times: preview_evaluate(async()=>{const r=window.go(N);await new Promise(r2=>setTimeout(r2,600));return r})()followed by preview_snapshot save=true. The centre pixel of each saved screenshot was sampled (pure rgb(255,0,0) = fade finished). Results: window in front 0/8 mid-fade; window minimized (AXMinimized) 1/8 mid-fade (run 1 = rgb(255,122,122)); minimized again 1/8 (run 1 = rgb(255,125,125)); window fully covered by a full-screen Finder window 1/8 (run 1 = rgb(255,115,115)). In each hidden pass the first snapshot is caught at about half opacity, 600 ms after a 150 ms fade began; the later ones are finished. Unlike the report, on this macOS 26.6.2 Mac the covered and minimized snapshots on main did not time out (#23139 was not hit). Evidence (left: minimized run 1 mid-fade, right: run 2 finished): https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/5ec50978cfe11a11/compare.pngEvidence
Being captured: before and after in the real app. This section is filled in before the pull request can merge.
Tests
vp test run src/preview/DesktopBrowserHost.test.ts(apps/desktop): 44 passed, including the extended 'sends a screenshot once the client draws the guest at full detail, or soon after' casevp run check:changed: format, lint, knip, typecheck (2 packages) and the test file all passedheadless-desktoprunning the settle expression: 150 ms fade returned in 183 ms with opacity 1; infinite animation and no animation each returned in about 50 msNot in this change
Who did the work
Run by the t3code factory in T3 Code.