Skip to content

fix(desktop): throttle hidden preview rendering - #7445

Merged
t3dotgg merged 7 commits into
mainfrom
fix/throttle-hidden-preview-browsers
Aug 19, 2026
Merged

fix(desktop): throttle hidden preview rendering#7445
t3dotgg merged 7 commits into
mainfrom
fix/throttle-hidden-preview-browsers

Conversation

@t3-code

@t3-code t3-code Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

problem

the desktop window disabled electron background throttling for its entire lifetime. electron keeps that window and every hosted preview renderer drawing even when t3 code is hidden or occluded, which can leave preview tabs consuming substantial cpu and energy.

fix

  • restore electron's default background throttling for the desktop window
  • temporarily disable throttling only while preview frame capture is active for recording or picture-in-picture
  • make throttle and session transitions interruption-safe
  • restore throttling after the final frame-capture consumer stops
  • release recording and picture-in-picture captures when the main window closes

runtime probe

on linux with electron 41.5.0, a hidden-window animation ran 240 frames over four seconds with the current global override, versus 0 frames with default throttling restored.

testing

  • vp test run apps/desktop/src/preview apps/desktop/src/window (204 passed)
  • vp run --filter @t3tools/desktop typecheck
  • vp check apps/desktop/src/preview/Manager.ts apps/desktop/src/preview/Manager.test.ts apps/desktop/src/window/DesktopWindow.ts apps/desktop/src/window/DesktopWindow.test.ts

implemented with gpt-5.6-sol through hermes agent.

request provenance


Note

Medium Risk
Changes preview frame-capture and main-window lifecycle timing; incorrect throttling could affect recording quality or background CPU, though behavior is heavily covered by new tests.

Overview
Stops forcing backgroundThrottling: false on the desktop main window at creation so hidden/occluded windows can idle normally again. PreviewManager now calls setBackgroundThrottling(false) when the first frame-capture consumer starts (recording or picture-in-picture) and true when the last one stops, with retries and warnings if restore fails.

Session start/stop and setMainWindow reconciliation are made interruption-safe (uninterruptible paths). Replacing the main window re-applies unthrottled mode if captures are already running; stale closed handlers from old windows are ignored. On close, active recordings and PiP are torn down via stopAllRecordings.

Starting capture after the main window has closed fails with PreviewMainWindowClosedError instead of continuing in a bad state. Tests cover multi-tab refcounting, failed throttle updates, window swap races, and shared capture between recording and PiP.

Reviewed by Cursor Bugbot for commit 7281787. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Throttle main window background rendering only during active frame capture

  • Removes the static backgroundThrottling: false from DesktopWindow creation; throttling is now managed dynamically by PreviewManager based on capture state.
  • Disables background throttling on the main window when the first frame capture session starts, and restores it (with up to 2 retries) when the last session stops.
  • When the main window is replaced via setMainWindow, throttling is disabled on the new window if captures are active; close events from the replaced window are ignored.
  • Adds PreviewMainWindowClosedError so callers get a typed failure when attempting to start capture while the main window is closed.
  • When the main window closes, all picture-in-picture sessions and recordings are stopped concurrently.
  • Behavioral Change: new main windows no longer have backgroundThrottling forced to false at creation time; the setting defaults to undefined and is toggled only during active capture.

Macroscope summarized 7281787.

Co-authored-by: maria <254055478+maria-rcks@users.noreply.github.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Aug 18, 2026
@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 12.6 KiB 12.6 KiB −4 B (−0.0%) 15.1 KiB
Codex Thread snapshot wire 6.3 KiB 6.3 KiB +5 B (+0.1%) 7.3 KiB
Codex Live turn WebSocket wire 6.3 KiB 6.3 KiB −9 B (−0.1%) 7.8 KiB
Codex Live turn WebSocket decoded 51.8 KiB 51.8 KiB 0 B (0.0%) 66.4 KiB
Codex Live turn messages 16 16 0 (0.0%) 21
Claude Total thread wire 12.6 KiB 12.6 KiB +3 B (+0.0%) 15.1 KiB
Claude Thread snapshot wire 6.3 KiB 6.3 KiB 0 B (0.0%) 7.3 KiB
Claude Live turn WebSocket wire 6.3 KiB 6.3 KiB +3 B (+0.0%) 7.8 KiB
Claude Live turn WebSocket decoded 52.7 KiB 52.7 KiB 0 B (0.0%) 66.4 KiB
Claude Live turn messages 16 16 0 (0.0%) 21

Baseline: 3a02c9c · PR result: 7281787 · Source CI: success

Scenario and decoded snapshot size

10 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.

  • Codex decoded thread snapshot: 99.9 KiB
  • Claude decoded thread snapshot: 100.6 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

Comment thread apps/desktop/src/preview/Manager.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR changes runtime behavior by dynamically managing background throttling for preview rendering rather than having it always disabled. The state management added is non-trivial and affects core desktop app functionality, warranting human review.

You can add or adjust custom eligibility rules. Learn more.

Co-authored-by: maria <254055478+maria-rcks@users.noreply.github.com>
Comment thread apps/desktop/src/preview/Manager.ts
Co-authored-by: maria <254055478+maria-rcks@users.noreply.github.com>

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effect service conventions review: one finding on error modeling in apps/desktop/src/preview/Manager.ts. Everything else (namespace subpath imports, Effect.fn/Effect.fnUntraced usage, ref-based state handling, and the tests) matches the conventions.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/desktop/src/preview/Manager.ts Outdated
t3-code Bot and others added 2 commits August 18, 2026 23:27
Co-authored-by: maria <254055478+maria-rcks@users.noreply.github.com>
Co-authored-by: maria <254055478+maria-rcks@users.noreply.github.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

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.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 08bcce8. Configure here.

Comment thread apps/desktop/src/preview/Manager.ts
Co-authored-by: maria <254055478+maria-rcks@users.noreply.github.com>
Comment thread apps/desktop/src/preview/Manager.ts
Co-authored-by: maria <254055478+maria-rcks@users.noreply.github.com>
@t3dotgg
t3dotgg merged commit fe281c5 into main Aug 19, 2026
17 checks passed
@t3dotgg
t3dotgg deleted the fix/throttle-hidden-preview-browsers branch August 19, 2026 00:22
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Aug 19, 2026
## What's Changed
* fix(desktop): throttle hidden preview rendering by @t3-code[bot] in pingdotgg/t3code#7445
* fix(server): stop probing Grok, Cursor, and OpenCode unless turned on by @t3dotgg in pingdotgg/t3code#7459
* fix(desktop): boot the main window unthrottled so cold start paints at full speed by @t3dotgg in pingdotgg/t3code#7460
* fix(threads): a merged PR settles its thread only once by @t3dotgg in pingdotgg/t3code#7454
* feat(cli): npx t3 triage hands broken installs to your own coding agent by @t3dotgg in pingdotgg/t3code#6563


**Full Changelog**: pingdotgg/t3code@v0.0.34-nightly.20260819.1129...v0.0.34-nightly.20260819.1130

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.34-nightly.20260819.1130
sheehanmunim added a commit to munimtechnologies/mtcode that referenced this pull request Aug 19, 2026
pingdotgg#7437, pingdotgg#7459, pingdotgg#7460, pingdotgg#7445, pingdotgg#7122, pingdotgg#7317, pingdotgg#7381, pingdotgg#6563)

Where upstream reworked something the fork had already built, upstream's
version wins and the fork's extras ride on top:

- Browser tab mute (pingdotgg#7252): upstream's rollback-on-refusal setAudioMuted and
  tabMuteMenuItem replace the fork's earlier copies; the fork's guest viewport
  override (setViewport/automationSetViewport) stays.
- Passkey autofill (pingdotgg#7437): upstream's `passkeys` const replaces the fork's
  duplicate manualOnlyPasskeys.
- Settle-once-on-merge (pingdotgg#7454): the sidebar now reports the whole change
  request (state + updatedAt) instead of a bare state, so the new rules can
  tell a fresh merge from inherited branch history. The fork's per-row
  reporting stays; upstream's semantics win.
- Merge action labels (pingdotgg#7381): upstream's confirmation state object, extended
  with the fork's merge-stack action.

Also: Clerk v6 moved `layout` into `options`, so the appearance override moves
with it, and the connect-providers helper joins the web tsconfig include list.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
frankdavidcorona pushed a commit to frankdavidcorona/t3code that referenced this pull request Aug 19, 2026
Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com>
Co-authored-by: maria <254055478+maria-rcks@users.noreply.github.com>
bcotrim pushed a commit to bcotrim/mognet that referenced this pull request Aug 20, 2026
Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com>
Co-authored-by: maria <254055478+maria-rcks@users.noreply.github.com>
(cherry picked from commit fe281c5)
roughcoder added a commit to goodbirdhq/phoenix that referenced this pull request Aug 20, 2026
* test(web): remove duplicate lookup assertion (pingdotgg#7364)

* fix(mobile): show structured input option descriptions (pingdotgg#7321)

* fix(orchestration): do not revive idle tasks from status-free progress (pingdotgg#7172)

* refactor(server): simplify error transformation with Effect.mapError in GitHubPullRequestCli (pingdotgg#7385)

Signed-off-by: aoright <102943475+aoright@users.noreply.github.com>

* fix(preview): open local environment ports on localhost (pingdotgg#7300)

* fix(desktop): prevent quit shortcut spillover (pingdotgg#7397)

* fix(desktop): stop overwriting a custom dock icon on launch (pingdotgg#7125)

* feat(web): show project location in new thread picker (pingdotgg#7392)

Co-authored-by: shivam <91240327+shivamhwp@users.noreply.github.com>

* fix(packaging): install AUR launcher icons where icon themes look (pingdotgg#7421)

* fix(web): label pull request merge actions (pingdotgg#7381)

* fix(server): avoid PRs inherited from default upstreams (pingdotgg#7317)

* fix(desktop): stop the passkey dialog from popping as soon as sign-in opens (pingdotgg#7437)

* feat(desktop): mute a browser tab (pingdotgg#7252)

* fix(web): improve disconnected composer placeholder (pingdotgg#7122)

Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com>
Co-authored-by: maria <254055478+maria-rcks@users.noreply.github.com>

* fix(desktop): throttle hidden preview rendering (pingdotgg#7445)

Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com>
Co-authored-by: maria <254055478+maria-rcks@users.noreply.github.com>

* fix(server): stop probing Grok, Cursor, and OpenCode unless turned on (pingdotgg#7459)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* fix(desktop): boot the main window unthrottled so cold start paints at full speed (pingdotgg#7460)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* fix(threads): a merged PR settles its thread only once (pingdotgg#7454)

* feat(cli): npx t3 triage hands broken installs to your own coding agent (pingdotgg#6563)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* fix(marketing): Safari gets the arm64 Mac download (pingdotgg#7473)

* feat(web): add shortcuts to the surface dropdown (pingdotgg#7318)

* fix(marketing): never serve the Intel build to Apple Silicon Macs (pingdotgg#7477)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* fix(web): animate command palette when closing (pingdotgg#5169)

* fix(desktop): upgrade Clerk OAuth transport (pingdotgg#7479)

* feat(server): run the background service on macOS via launchd (pingdotgg#6286)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* fix(web): align sidebar statuses with project names (pingdotgg#7491)

Co-authored-by: GPT-5.6 <noreply@openai.com>

* fix(desktop): close the window before quit cleanup (pingdotgg#6562)

* fix(desktop): stop automatic passkey prompts (pingdotgg#7522)

* docs(user): document phoenix triage and macOS background service

The 2026-08-19 upstream sync added the triage command with no docs/user
entry, and the docs index still called the background service Linux-only
after launchd support landed. Found by PR #61 code review.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Signed-off-by: aoright <102943475+aoright@users.noreply.github.com>
Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com>
Co-authored-by: Nick Anisimov <n.anisimov.23@gmail.com>
Co-authored-by: Maslin Edwin <maslinje@gmail.com>
Co-authored-by: aoright <102943475+aoright@users.noreply.github.com>
Co-authored-by: Guilherme Barros <gbarros1095@gmail.com>
Co-authored-by: Bilal Bakr <62337003+Bil0000@users.noreply.github.com>
Co-authored-by: Rishet11 <154429365+Rishet11@users.noreply.github.com>
Co-authored-by: Wout Stiens <71498452+StiensWout@users.noreply.github.com>
Co-authored-by: shivam <91240327+shivamhwp@users.noreply.github.com>
Co-authored-by: Augie <augie@luebbers.email>
Co-authored-by: Taras <Taras.Fomin@gmail.com>
Co-authored-by: Gianmarco <gianmarcosimone89@gmail.com>
Co-authored-by: Theo Browne <me@t3.gg>
Co-authored-by: Chris Deeming <chris@xenforo.com>
Co-authored-by: Inaya Yousfi <zied.essaber@gmail.com>
Co-authored-by: maria <254055478+maria-rcks@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Rakshith Bhat <88523594+RakshithBhat03@users.noreply.github.com>
Co-authored-by: GPT-5.6 <noreply@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant