Skip to content

fix(desktop): keep preview automation alive on macOS close - #6317

Closed
proxynico wants to merge 1 commit into
pingdotgg:mainfrom
proxynico:fix/macos-preview-host-lifecycle
Closed

proxynico wants to merge 1 commit into
pingdotgg:mainfrom
proxynico:fix/macos-preview-host-lifecycle

Conversation

@proxynico

@proxynico proxynico commented Aug 12, 2026 •

Copy link
Copy Markdown

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 for commit 15d4f0f. Bugbot is set up for automated code reviews on this repo. Configure here.

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.

@coderabbitai

coderabbitai Bot commented Aug 12, 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: 1e0bbd58-d12b-49c8-95d4-3f99235adc20

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:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Aug 12, 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.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 15d4f0f. Configure here.

if (environment.platform === "darwin" && !runSync(Ref.get(desktopState.quitting))) {
event.preventDefault();
window.hide();
}

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.

Fullscreen close hides to black

Medium Severity

On macOS, ordinary main-window close now calls preventDefault and hide without leaving fullscreen first. Hiding a native fullscreen BrowserWindow is a known Electron/AppKit failure mode that leaves a black screen instead of a clean hide, so closing from fullscreen can break the intended dismiss-and-restore flow.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 15d4f0f. Configure here.

@macroscopeapp

macroscopeapp Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR changes macOS window close behavior from actually closing to hiding the window, which is a significant runtime behavior change affecting user experience. The author is not a frequent contributor to this file, adding a small risk signal.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants