Skip to content

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

Merged
t3dotgg merged 3 commits into
mainfrom
t3code/fix-slow-mac-quit
Aug 19, 2026
Merged

fix(desktop): close the window before quit cleanup#6562
t3dotgg merged 3 commits into
mainfrom
t3code/fix-slow-mac-quit

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Aug 14, 2026

Copy link
Copy Markdown
Member

Quitting T3 Code kept the desktop window visible while the local backend completed about two seconds of graceful cleanup. This made Cmd+Q feel unresponsive on macOS.

The desktop now saves window bounds and destroys all Electron windows before it starts backend cleanup. The Electron process remains alive until cleanup completes, then exits as before. Updater-controlled quits still use the updater path.

Tests:

  • vp test run apps/desktop/src/app/DesktopLifecycle.test.ts apps/desktop/src/electron/ElectronWindow.test.ts
  • vp run --filter @t3tools/desktop typecheck
  • targeted lint and formatting checks

Made by GPT-5.6 using T3 Code through the Codex harness.


Note

Medium Risk
Touches core quit/teardown ordering in the desktop lifecycle; behavior is well-tested but incorrect ordering could affect shutdown or updater paths.

Overview
Quit now hides the UI immediately by flushing main window bounds, destroying all Electron windows, and only then requesting backend shutdown—the process still exits after cleanup finishes.

ElectronWindow.destroyAll attempts every window and surfaces the first destroy error instead of stopping at the first failure; lifecycle logs destroy failures but does not block shutdown. macOS activate is ignored while DesktopState.quitting is set so a window cannot reopen during teardown.

Tests add shared mock layers plus coverage for flush → destroy → shutdown ordering and suppressed activation while quitting.

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

Note

Close all Electron windows before backend shutdown on quit

  • On before-quit, all Electron windows are now destroyed before requesting backend shutdown, ensuring windows close cleanly prior to teardown.
  • destroyAll in ElectronWindow.ts now attempts to destroy every window even if earlier ones fail, reporting only the first failure cause.
  • App activate events are ignored once the quitting flag is set, preventing activation during shutdown.
  • Behavioral Change: requestDesktopShutdownAndWait now accepts an optional afterBoundsFlush effect, changing the quit sequence to: flush bounds → destroy windows → request shutdown → quit.

Macroscope summarized b146aa0.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

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: 43c0a35a-8577-4a6d-ac26-905b72e8f71d

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:

  • 🔍 Trigger review

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.

@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 14, 2026

@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 9a82604. Configure here.

Comment thread apps/desktop/src/app/DesktopLifecycle.ts
@github-actions

github-actions Bot commented Aug 14, 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 0 B (0.0%) 15.1 KiB
Codex Thread snapshot wire 6.3 KiB 6.3 KiB −10 B (−0.2%) 7.3 KiB
Codex Live turn WebSocket wire 6.3 KiB 6.3 KiB +10 B (+0.2%) 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 −5 B (−0.0%) 15.1 KiB
Claude Thread snapshot wire 6.3 KiB 6.3 KiB −1 B (−0.0%) 7.3 KiB
Claude Live turn WebSocket wire 6.3 KiB 6.3 KiB −4 B (−0.1%) 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: 8bbbab5 · PR result: b146aa0 · 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.

@macroscopeapp

macroscopeapp Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at b146aa0

Macroscope's review found this PR approvable — Straightforward bug fix that reorders quit cleanup operations to destroy windows before waiting for backend shutdown. Changes are well-contained to the lifecycle/quit flow with proper test coverage added.

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

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Aug 14, 2026

@CDVolvik CDVolvik 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.

DesktopLifecycle.test.ts: 5/5, including win32.

Quitting while the window is still up runs renderer/cleanup against a dying UI. Destroy the window first, then the rest. The updater before-quit-for-update path still proceeds. MERGEABLE.

@t3dotgg
t3dotgg force-pushed the t3code/fix-slow-mac-quit branch from 65ecd5a to e1564a1 Compare August 19, 2026 08:27
@macroscopeapp
macroscopeapp Bot dismissed their stale review August 19, 2026 08:27

Dismissing prior approval to re-evaluate e1564a1

Comment thread apps/desktop/src/app/DesktopLifecycle.ts
@t3dotgg
t3dotgg force-pushed the t3code/fix-slow-mac-quit branch from e1564a1 to b146aa0 Compare August 19, 2026 08:35
@t3dotgg
t3dotgg merged commit 24c4ba6 into main Aug 19, 2026
18 checks passed
@t3dotgg
t3dotgg deleted the t3code/fix-slow-mac-quit branch August 19, 2026 08:42
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Aug 19, 2026
## What's Changed
* fix(desktop): upgrade Clerk OAuth transport by @t3dotgg in pingdotgg/t3code#7479
* feat(server): run the background service on macOS via launchd by @t3dotgg in pingdotgg/t3code#6286
* fix(web): align sidebar statuses with project names by @RakshithBhat03 in pingdotgg/t3code#7491
* fix(desktop): close the window before quit cleanup by @t3dotgg in pingdotgg/t3code#6562


**Full Changelog**: pingdotgg/t3code@v0.0.34-nightly.20260819.1132...v0.0.34-nightly.20260819.1133

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.34-nightly.20260819.1133
frankdavidcorona pushed a commit to frankdavidcorona/t3code that referenced this pull request Aug 19, 2026
Dvorinka pushed a commit to Dvorinka/t3code-devin that referenced this pull request Aug 19, 2026
sheehanmunim added a commit to munimtechnologies/mtcode that referenced this pull request Aug 19, 2026
* 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)

* feat: choose the app icon, and name the artwork scenes

Artwork options are Night sky, Blueprint, None, and your own uploads; "Match
the build" is gone and Night sky is the default. An explicit pick now outranks
the environment-identification mode and the palette heuristic, which is why
choosing a scene did nothing on a release build.

App icon adds the MT mark, a light variant, a dark variant, or your own image.
It is applied to the running app - Dock tile on macOS, window icon elsewhere -
because rewriting the installed bundle's icon would break the code signature
and take every macOS permission grant with it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Rakshith Bhat <88523594+RakshithBhat03@users.noreply.github.com>
Co-authored-by: GPT-5.6 <noreply@openai.com>
Co-authored-by: Theo Browne <me@t3.gg>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
bcotrim pushed a commit to bcotrim/mognet that referenced this pull request Aug 20, 2026
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.

2 participants