Repository navigation
fix(desktop): preview screenshots work while the window is not painted - #152
Conversation
After first reveal the main window renderer is background-throttled. While Chromeria is minimized, hidden or covered, it never composites a guest that automation moved into the viewport, so capturePage on the guest stalls or fails with UnknownVizError. Hold the main window unthrottled for each guest capture, as recording and picture-in-picture already do, and restore it once no capture or frame-capture session needs it. Closes #151 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Independent review: APPROVEReviewed exact head
Proof was limited to the focused test, source review, and the provided standalone repro. I did not run the installed-app recipe or broader lint/typecheck checks. |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
What: Agent browser screenshots (
preview_snapshot, preview screenshots) work again while the Chromeria window is minimized, hidden or covered.Why: After first reveal the main window renderer is background-throttled. While the window is not painted it never composites a guest that automation moved into the viewport, so
capturePageon the guest stalls (1 s timeouts) or fails withUnknownVizError.So what: The maintainer reviews and merges. After install, the live check below confirms it on the installed build.
Closes #151
Root cause and evidence
Live trace (
~/.t3/userdata/logs/desktop.trace.ndjson*, read-only): everyPreviewManager.capturePageWithRetryfrom 2026-10-02 10:06:49 to 10:57:07 CEST failed on WebContents 2, 3, 4 and 5. That includes guests created fresh at 10:07:40 and 10:22:23, and the app and GPU processes were the same throughout (up since 02:14), so the failure was global, not one wedged guest.desktop.lifecycle.activatefired at 12:36:57; a background-thread snapshot at 12:45:44 then succeeded in 4 ms.Standalone Electron 44.4.2 repro (
/tmp/pc-repro/app/main.js): a<webview>guest moved into the viewport from-100000px(whathostedBrowserWebviewStyle.tsdoes for background automation), thencapturePageon the guest.Change
capturePageWithRetryholds a page capture lease for the whole retried capture. The first lease unthrottles the main window unless a recording or picture-in-picture session already has it unthrottled. When the last lease ends and no session remains, the window is throttled again. A failed toggle logs a warning and never fails the capture.frameCaptureSessionsRef, so it is serialized with session start and stop.stopFrameCapture, the failed-start rollback andsetMainWindowrespect in-flight captures.apps/desktop/src/preview/Manager.ts,Manager.test.ts. They are listed inscripts/fork-upstream-edits.txtanddocs/fork-features.md(preview-capture-unthrottle). The change is self-contained and can be offered upstream as is.Proof
pnpm exec vp test run apps/desktop/src/preview/Manager.test.ts: 93 passed. The new test "keeps the main window unthrottled while a guest page capture runs" fails on the unfixedManager.ts(expected [ 'capture' ] to deeply equal [ 'throttle:false', 'capture', …(1) ]), and also fails if thestopFrameCaptureguard is dropped.pnpm exec vp linton both Manager files: exit 0. The one warning (no-extraneous-classatManager.test.ts:211) is pre-existing.tsc --noEmitinapps/desktop): exit 0.vp fmt --check: clean.bash scripts/fork-check.sh: OK.preview_openwithurl: "https://example.com"and thenpreview_snapshot. Before:Desktop preview operation failed: automationSnapshot.capturePage ... TimeoutError. After: a screenshot is returned.Review
Independent review: APPROVE, no blocking findings, on exact head
d0cdd010bce1d5536a9e22d4dce1e610ac93d1a6. Reviewer: Prism reviewer threadsub.sub.46b03420-8643-4703-8756-8602f14b39fb.dispatcher-0f3d8c3717b2.reviewer-9dfffb3b6221(codex / gpt-6-luna). Findings;review/independent= success.Reversible assumptions
requestAnimationFrame. The capture's existing 3 x 1 s retries cover the first paint after unthrottling.Out of scope
preview_openwithurl: "about:blank"fails with the generic "Preview automation open failed on client ..." error. That is a separate input-handling issue.No versioning by design: this fork has no version policy, and builds are identified by commit SHA.
Elon record
preview_open/preview_snapshotfrom a background thread; Electron 44.4.2 repro across all window states; reran the focused test on the commit.Written by Claude Opus 5.5 (planner) and a Claude Opus 5.5 writer thread, in Claude Code inside Chromeria.
🤖 Generated with Claude Code