Repository navigation
Description
Area
apps/desktop
Steps to reproduce
- On macOS, launch T3 Code with the local environment enabled (the default) and wait for the main window.
- Close the window with Cmd+W. The app keeps running in the Dock.
- Switch to another app, for example an editor or terminal.
- Make the desktop app's local server child process exit unexpectedly, for example after a crash or OOM, or by sending it
kill -9 <server pid>. - Wait for the automatic restart (about a second of backoff plus startup time).
Expected behavior
The window stays closed. The server restarts in the background, and the window comes back only when I ask for it: Dock click, launching the app again, or a menu action.
Actual behavior
When the restarted server becomes ready, T3 Code creates a new main window, brings it to the front, and calls app.focus({ steal: true }). Whatever app I was using loses focus.
Code path on main @ 16aaf5b:
- Each time the server process exits unexpectedly, the backend instance calls
onShutdown, thenscheduleRestart(apps/desktop/src/backend/DesktopBackendManager.ts:865-876). Each later run that becomes ready resetsrestartAttemptand callsspec.onReadyagain (DesktopBackendManager.ts:903-923). Readiness is therefore reported after every restart, not just at launch. - The primary instance wires
onReadytodesktopWindow.handleBackendReady(apps/desktop/src/backend/DesktopBackendPool.ts:167-176). handleBackendReadysetsbackendReadyRefand runscreateMainIfBackendReady(apps/desktop/src/window/DesktopWindow.ts:1003-1007). That function creates a main window whenever none exists (DesktopWindow.ts:889-895).- On macOS, closing the last window does not quit the app (
apps/desktop/src/app/DesktopLifecycle.ts:244-253). After Cmd+W there is no main window, so a new one is created. - The new window's first-show handler calls
electronWindow.reveal(DesktopWindow.ts:830-838). On darwin, that callsElectron.app.focus({ steal: true })(apps/desktop/src/electron/ElectronWindow.ts:291-293).
This contradicts intent the test suite pins elsewhere. does not reopen a closed main window for a completed capture (apps/desktop/src/window/DesktopWindow.test.ts:1065) guarantees that a background event doesn't bring back a window the user closed.
On Windows and Linux, closing the last window quits the app, so this only affects macOS in practice.
Impact
Minor bug or occasional failure
Version or commit
main @ 16aaf5b
Environment
macOS desktop app. I found this by reading the code, not by watching it happen: I have not reproduced it with a packaged build. A focused unit test in DesktopWindow.test.ts reproduces the window being re-created on main. The test drives backend ready, then a closed window, then backend not-ready, then backend ready again.
Workaround
None in the app. Quitting with Cmd+Q instead of closing the window with Cmd+W avoids it, but it also stops the server.
Activity
juliusmarminge commentedon Nov 22, 2026
I tried to reproduce this on the current build and could not.
Commit f9b19a7 (origin/main). I could not run the app on macOS: no worker has macOS. On Linux, closing the last window quits the app, so the bug cannot show there. I reproduced it with a unit test, 'keeps a closed main window closed when the backend restarts', in apps/desktop/src/window/DesktopWindow.test.ts. The test calls ensureMain, fires ready-to-show, calls handleBackendReady, closes the window, then calls handleBackendNotReady and handleBackendReady again. On main a second main window is created (assert expected 1, received 2). The test then checks that activate (a Dock click) still creates the window. Run with: vp test run src/window/DesktopWindow.test.ts -t closed (from apps/desktop). The reporter has since posted recordings from a real Mac on PR #24102 (macOS 27.2, vp run dev:desktop on main 0bc993a). They closed the window with the red button, sent kill -9 to the managed server, and saw backend ready at 10:01:25.311 and 'main window created' at 10:01:25.327 with no user action.
Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.