Problem#
On macOS, closing T3 Code's last window destroys the renderer while the desktop server remains running. PreviewAutomationHosts lives in that renderer, so MCP preview requests then fail with no available preview automation host until the app is activated again.
Fix#
- Treat an ordinary macOS main-window close as hide, preserving the renderer and its preview automation streams.
- Allow the native close to proceed once DesktopState.quitting is set, preserving Quit, updater, signal, and relaunch shutdown paths.
- Keep non-macOS behavior unchanged.
Proof#
- vp test run apps/desktop/src/window/DesktopWindow.test.ts — 25 passed
- vp run --filter @t3tools/desktop typecheck — passed; two unrelated existing suggestions remain
- vp lint --report-unused-disable-directives apps/desktop/src/window/DesktopWindow.ts apps/desktop/src/window/DesktopWindow.test.ts — passed
- git diff --check — passed
- Mutation checks proved each new regression test fails when its protected branch is broken.
- Independent review found no Critical or Important issues.
Risk and visual changes#
Low lifecycle risk, limited to macOS main-window close handling. The window still disappears immediately, so there is no visual change. A genuine application Quit still destroys the window and completes shutdown.
Known limitation: this is covered by focused desktop lifecycle tests; it does not add a packaged Electron integration test.
Implemented with GPT-5.6-sol through the Codex harness in T3 Code.
Note
Medium Risk
Touches macOS main-window close lifecycle and depends on the quitting flag to still allow real shutdown. Incorrect gating could leave a hidden window or block Quit/updater paths.
Overview
On macOS, closing the main window no longer destroys the renderer. The close handler now hides the window (via preventDefault) unless DesktopState.quitting is set, so preview automation hosts in the renderer keep working while the desktop server is still running.
Genuine Quit / updater / relaunch shutdown still closes normally once quitting is true. Non-macOS close behavior is unchanged.
Adds regression tests for hide-on-close vs allow-close-during-quit, and wires DesktopState into the window layer/tests.
Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 15d4f0fbaff0dd5aa91e55fca851adf29af90fed. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).
Note
Keep preview automation alive by hiding the main window on macOS close instead of quitting#
- On macOS, the
close event handler in DesktopWindow.ts now calls event.preventDefault() and window.hide() instead of destroying the window, unless the app is in a quitting state.
- Reads
DesktopState.quitting via a synchronous Ref check to distinguish a user close from an actual quit.
- Behavioral Change: on macOS, closing the main window no longer terminates the app — it hides it. The window only closes during a full quit.
Macroscope summarized 15d4f0f.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
1e0bbd58-d12b-49c8-95d4-3f99235adc20You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
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