GeezerVison is showing github.com — Make preview automation bounded and recoverable by Quicksaver · Pull Request #4577 · pingdotgg/t3code
Conversation
Quicksaver
commented
Jul 26, 2026
•
edited by macroscopeapp
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
Preview automation had no single deadline across renderer readiness, MCP routing, IPC, and Electron CDP. A request could time out at one layer while work continued in another, leaving a debugger session stuck, losing a recording during retry, or returning a generic error. Capturing an unselected tab added a nastier failure mode. Staging the native guest could cover the T3 interface, and a screenshot failure threw away semantic page data that was still valid.
This branch carries one remaining budget and one epoch-scoped runtime target through the full request. Electron sessions start lazily and are replaced safely after stalls, recording finalization can be retried without duplicate artifacts, and background snapshots use a short-lived presentation lease without selecting or focusing the tab. If raster capture fails, the snapshot still returns page state, interactive elements, accessibility data, diagnostics, and the action timeline with screenshot: null.
That keeps preview tools inside the caller's time limit and usable after Chromium or renderer stalls. Agents can retry without corrupting session state or losing captured work, and automation no longer disrupts the user's visible preview.
What changed
- Carried the remaining request budget through preview open and readiness work, input, viewport and appearance changes, snapshots, recording, MCP, IPC, and desktop control. Deadline failures now use typed errors, reserve bounded response grace, and identify the failed operation or screenshot-capture stage.
- Made Electron control sessions lazy and recoverable. Timeout cleanup detaches only the acquired debugger session, queued work retries against the replacement instead of using a retired session, and final controller-state notification cannot let a stalled listener withhold the timeout response.
- Captured active tabs from the compositor and added a bounded
webContents.capturePage fallback. PNG validation and nullable screenshot contracts preserve semantic snapshot data when both raster paths fail.
- Added a reference-counted presentation lease for one-shot background snapshots. It stages the exact runtime guest without selecting or focusing it, restores its placement, and stays active until an in-flight capture settles.
- Made recording start, stop, and artifact persistence deadline-bounded and retry-safe. Captured chunks and recording state survive timeout, in-flight saves are shared, and a validated idempotency key prevents duplicate files.
- Serialized appearance and viewport mutations, rechecked deadlines after readiness and queue waits, and retried appearance changes against replacement guests without persisting stale state.
- Made preview-open decisions use one settings and session snapshot. New tabs acknowledge creation before cold renderer readiness, while reused tabs keep the waits required by their current state. Visibility retries preserve a right panel that already owns the tab instead of reopening the inline mini-player and stealing its surface lease.
- Scoped browser-surface subscriptions, geometry, and host accessibility exposure to the relevant runtime guest so background staging does not rerender or expose unrelated tabs.
- Serialized pairing tokens delivered through later URL-fragment changes, standardized development listener and proxy routing on loopback, and gave explicit worktree desktop runs their own Electron user-data directory.
- Updated the shared contracts, preload and IPC bridge, MCP tools, and focused regression coverage for the new timeout, recovery, capture, recording, pairing, and development-host behavior.
Validation
- The branch-focused suite passed 334 tests across 22 files. It covers deadline propagation, control-session replacement, bounded controller finalization, retryable recording cleanup, background staging, panel lease preservation, foreground geometry, appearance serialization, native mute reconciliation, viewport polling, runtime replacement, accessibility, and listener/proxy routing.
- Browser-default, provider-access, pull-request budget, tooltip, update-copy, and settings coverage passed 552 tests across 26 files. A separate focused open-policy and open-session run passed 18 tests.
- Desktop, server, contracts, and mobile typechecks passed. Web typecheck reports 16 documented baseline errors in
BranchToolbarBranchSelector.tsx, ModelPickerContent.tsx, PreviewAutomationHosts.tsx, FontFamilyPicker.tsx, use-atom-command.ts, and use-atom-query-runner.ts.
- An isolated web client on ports
5744 and 13784 paired and loaded through Playwright with no browser-console errors. It verified the browser defaults and agent-access setting, including disabling and restoring agent browser access. The non-Electron client correctly disabled desktop-only viewport, zoom, and appearance controls.
- An isolated
dev:desktop instance paired successfully and remained usable through repeated renderer and CDP inspection and raster capture. An archive-worktree client also loaded without the earlier incompatible IndexedDB VersionError.
git diff --check upstream/main...HEAD passed.
🤖 Generated by GPT-5 in Codex via T3 Code
Note Medium Risk
Touches core Electron CDP control, recording persistence, and MCP snapshot contracts, but changes are deadline-bounded with explicit recovery paths and broad regression coverage rather than altering auth or data models.
Overview
Makes preview automation bounded and recoverable across the web host, MCP server, and Electron CDP layer instead of letting work continue after a timeout at another layer.
Deadlines and errors: Caller timeoutMs (and remaining host budget) now flow through MCP, IPC, preload, and PreviewManager control sessions, with reserved response grace and PreviewAutomationTimeoutError that names the stalled operation (including screenshot stages). Controller reset commits before the IPC response even if state listeners stall; queued work on a retired session retries against the replacement without a queued timeout detaching an active debugger.
Snapshots: Active tabs prefer CDP Page.captureScreenshot; background/offscreen targets use a short-lived hidden bridge plus bounded capturePage fallback (stayHidden). Contracts and MCP treat screenshot as nullable—structured page state still returns when raster capture fails. The renderer adds a reference-counted background presentation lease that stages the epoch-scoped runtime guest without selecting or calling Page.bringToFront.
Recording and appearance: Recording start/stop/save accept deadlines; saveRecording takes an idempotencyKey so retries after timeout do not duplicate artifacts. Color-scheme changes serialize per tab, honor deadlines, and do not persist after timeout.
Supporting changes: Open/readiness and browser-surface rendering scope to the relevant runtime tab; dev routing standardizes on shared loopback helpers; T3CODE_DESKTOP_USER_DATA_DIR isolates worktree Electron profiles; pairing can consume tokens from later URL fragments. Large focused test additions cover the new behavior.
Reviewed by Cursor Bugbot for commit b3b92fa. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add bounded execution budgets and recoverable recording to preview automation
- Introduces a host-level execution budget for preview automation via
previewAutomationExecutionBudget and previewAutomationRemainingBudget in previewAutomationRequestConsumer.ts. Operations that exceed the budget reject with PreviewAutomationHostDeadlineExceededError.
- Makes recording stop and save recoverable.
stopBrowserRecording retains captured chunks on stop-deadline errors, and saveRecording requires an idempotencyKey to share in-flight saves across retries in browserRecording.ts.
- Adds background capture for automation snapshots using a hidden
BrowserWindow and CDP Page.captureScreenshot in Manager.ts. The webview renders offscreen via resolveBrowserSurfaceBackgroundCaptureRect in browserSurfaceStore.ts when inactive.
- Risk:
saveRecording in Manager.ts now requires an idempotencyKey argument, and PreviewAutomationSnapshot.screenshot in previewAutomation.ts is now nullable. Existing callers must adapt.
Macroscope summarized b3b92fa.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Report background presentation deadlines as typed timeouts.
Bound background leases and preserve short request timeouts.
Isolate queued CDP timeouts and handle hidden empty tabs.
Preserve control deadlines and screenshot recovery.
Default legacy snapshot IPC and scope loopback host overrides.
- Release background capture leases when staged operations time out
- Keep desktop wait operations inside caller timeout budgets
coderabbitai
Bot
commented
Jul 26, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Important
Review skipped
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 48ea6f9e-d3c8-416f-8be3-b0dc8fed93a3
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Approvability
Verdict: Skipped
Macroscope did not run approvability analysis for this PR. Diff is too large for automated approval analysis, so this PR cannot be approved automatically.
You can add or adjust custom eligibility rules. Learn more.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
- Clamp background capture staging to current renderer bounds
- Share host deadlines and pass snapshot budgets through desktop IPC
- Retain presentation leases until timed-out captures settle
- Add focused regression coverage for all review findings
|
Follow-up to Macroscope’s approvability summary: all five inline findings were addressed in 27d0818, each thread now has a concrete resolution reply, and all review threads are resolved. The feature-focused suite passes with 11 files and 119 tests; targeted lint and affected-package typechecks also pass.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Use selected panel state for background capture
- Bound compositor frames and release stalled staging leases
- Cover panel-switch and paused-frame regressions
|
Follow-up to Macroscope's approvability summary: the two later inline findings were addressed in bfe907c and both threads are resolved. Background capture now follows selected panel state, paused compositor-frame waits release staging before desktop capture begins, and the feature-focused suite passes with 11 files and 121 tests.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
- Preserve upstream attribution for single-origin browser dev
- Document optional preferred ports and collision handling
…ion-reliability
# Conflicts:
# apps/desktop/src/preview/Manager.test.ts
# apps/desktop/src/preview/Manager.ts
# apps/server/src/mcp/toolkits/preview/tools.ts
# apps/web/src/browser/HostedBrowserWebview.tsx
# apps/web/src/browser/browserSurfaceStore.ts
# apps/web/src/browser/hostedBrowserWebviewStyle.test.ts
# apps/web/src/browser/hostedBrowserWebviewStyle.ts
# apps/web/src/components/preview/PreviewAutomationHosts.tsx
# apps/web/src/components/preview/previewAutomationOpenReadiness.test.ts
# apps/web/src/components/preview/previewAutomationOpenReadiness.ts
- Preserve namespaced active surface identifiers across inline previews
- Keep timeout diagnostics consistent for hidden and competing surfaces
- Restore complete behavior-level branch documentation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One finding on the new background-capture presentation path in HostedBrowserWebview.tsx. Everything else in the changed web UI (staging style ownership in hostedBrowserWebviewStyle.ts, the reference-counted lease and render-state selector in browserSurfaceStore.ts, and the pairing surface primitives) looks consistent; the previously flagged aria-hidden regression is resolved by resolveHostedBrowserWebviewAriaHidden.
Posted via Macroscope — UI Consistency
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- share listener and guest loopback hosts across dev layers
- cover proxy-to-preview environment-port compatibility
🤖 Co-authored by GPT-5.6-Sol in Codex via T3 Code
- inject POSIX path semantics into simulated desktop environments
- keep merged identity coverage portable across test hosts
🤖 Co-authored by GPT-5.6-Sol in Codex via T3 Code
- document upstream loopback and dock-icon ownership
- record shared proxy composition and green Windows coverage
🤖 Co-authored by GPT-5.6-Sol in Codex via T3 Code
- assert the listener and browser loopback constants explicitly
- keep the proxy-to-navigation regression independent of shared values
🤖 Co-authored by GPT-5 in Codex via Codex
…ion-reliability
# Conflicts:
# apps/desktop/src/preload.ts
# apps/desktop/src/preview/Manager.test.ts
# apps/desktop/src/preview/Manager.ts
# packages/contracts/src/ipc.ts
- add mute and audibility methods to reliability fixtures
- preserve deadline and control-session regression coverage
🤖 Co-authored by GPT-5 in Codex via T3 Code
- centralize branch reliability guests on typed safe defaults
- preserve native mute and lazy CDP appearance reconciliation
- distinguish sustained frame capture from one-shot snapshots
🤖 Co-authored by GPT-5 in Codex via T3 Code
- document sustained capture and audio ownership boundaries
- describe native mute reconciliation beside lazy CDP recovery
- refresh focused regression coverage
🤖 Co-authored by GPT-5 in Codex via T3 Code
- bound recording cleanup observation to response grace
- serialize per-tab appearance mutations across callers
- preserve foreground geometry during capture leases
- add focused timing and presentation regressions
🤖 Co-authored by GPT-5 in Codex via T3 Code
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One finding on the background-capture staging gate in apps/web/src/browser/hostedBrowserWebviewStyle.ts. The rest of the changed web UI (aria-hidden restoration, foreground rect retention during a capture lease, pairing surface, presentation helpers) looks consistent with the shared surface/primitive contracts.
Posted via Macroscope — UI Consistency
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- keep recording stop responses bounded during stalled cleanup
- preserve concrete dev proxy hosts and wildcard loopback routing
- stage never-presented guests with deterministic geometry
- propagate remaining evaluate budgets through desktop control
🤖 Co-authored by GPT-5 in Codex via T3 Code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ac3a962. Configure here.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- pass evaluate timeout into the targeted broker request
- cover the routed timeout in the MCP integration test
- document end-to-end evaluate deadline propagation
🤖 Co-authored by GPT-5 in Codex via T3 Code
|
Final follow-up to Macroscope's approvability status: the eight inline findings added after the previous general status were resolved across fbd8bb946, ac3a96202, and 326a8725d. All 44 review threads are resolved. The branch-focused suite passes all 332 tests; targeted formatting, lint, and affected-package typechecks pass. The integrated web flow also loaded authenticated and clean after pairing, with no steady-state page or console errors.
🤖 Generated by GPT-5 in Codex via T3 Code
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
🤖 Co-authored by GPT-5 in Codex via T3 Code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One finding: the new open-visibility wait can repeatedly force the inline mini-player open for a tab the right panel already owns, which steals the BrowserSurfaceSlot lease and can leave the panel showing an empty guest area. Details inline.
Posted via Macroscope — UI Consistency
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
🤖 Co-authored by GPT-5 in Codex via T3 Code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One finding: the desktop PreviewAutomationTimeoutError is reused for several new, semantically distinct timeouts without carrying the operation/stage context, so its caller-visible message no longer describes the failure. Details inline.
Posted via Macroscope — Effect Service Conventions
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
🤖 Co-authored by GPT-5 in Codex via T3 Code
Uh oh!
There was an error while loading. Please reload this page.
🤖 Co-authored by GPT-5 in Codex via T3 Code
Note 🤖 GPT-5.6 Sol responding on behalf of Theo
Closing this PR after an automated pass over open pull requests. Broad preview automation rewrite overlaps the smaller trusted change in #4685.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
size:XXL
1,000+ changed lines (additions + deletions).
vouch:unvouched
Author is not yet trusted in the VOUCHED list.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|