fix(desktop): improve Windows host lifecycle - #7489
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the 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. Comment |
| { concurrency: 2 }, | ||
| ); | ||
|
|
||
| if (Option.isNone(cached) && cache !== null) { |
There was a problem hiding this comment.
🟡 Medium shell/DesktopShellEnvironment.ts:446
A failed or timed-out PowerShell probe is cached as a valid snapshot for 24 hours, so subsequent launches skip the probes and permanently miss profile-derived PATH, FNM_DIR, and FNM_MULTISHELL_PATH during that period. runCommandOutput converts failures to "", and readWindowsEnvironment converts that to {}, but line 446 writes those empty or partial results whenever no valid cache was loaded; cache writes must be gated on successful, complete probes rather than only Option.isNone(cached).
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/desktop/src/shell/DesktopShellEnvironment.ts around line 446:
A failed or timed-out PowerShell probe is cached as a valid snapshot for 24 hours, so subsequent launches skip the probes and permanently miss profile-derived `PATH`, `FNM_DIR`, and `FNM_MULTISHELL_PATH` during that period. `runCommandOutput` converts failures to `""`, and `readWindowsEnvironment` converts that to `{}`, but line 446 writes those empty or partial results whenever no valid cache was loaded; cache writes must be gated on successful, complete probes rather than only `Option.isNone(cached)`.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ 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 c5325cb. Configure here.
| Effect.andThen(fileSystem.writeFileString(cache.path, `${encoded.value}\n`)), | ||
| Effect.catchCause(() => Effect.void), | ||
| ); | ||
| } |
There was a problem hiding this comment.
Failed shell probes stay cached
Medium Severity
A cache miss always writes noProfile and profile, including empty objects from timeouts or failed PowerShell probes. The next launches then treat that snapshot as valid for 24 hours while inheritedPath is unchanged, so profile PATH and FNM_* hydration stay skipped after a bad first discovery.
Reviewed by Cursor Bugbot for commit c5325cb. Configure here.
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR introduces a new Windows system tray feature with close-to-background behavior and shell environment caching - significant new runtime capability beyond a simple fix. Additionally, two medium-severity findings about caching failed PowerShell probes remain unresolved. Not approved because:
Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more. |


What Changed
Why
Closing the final T3 Code window on Windows previously exited the entire desktop host. That stopped the backend and disconnected devices using T3 Code remotely.
Windows startup also synchronously repeated expensive PowerShell environment discovery even when the inherited environment had not changed. Local traces showed this adding roughly 3–4 seconds to repeated launches.
This keeps the Windows host available for remote use, provides an explicit way to quit it completely, and avoids repeated environment-discovery work without changing lifecycle behavior on macOS or Linux.
UI Changes
Checklist
Implemented with GPT-5.6-sol through the Codex harness in T3 Code.
Note
Medium Risk
Changes Windows quit/close semantics and process lifetime (backend stays up when the window is hidden), which affects remote connections and shutdown; macOS/Linux behavior is largely unchanged aside from test stubs.
Overview
Windows no longer exits when the main window is closed if the system tray is active: closing hides the window and keeps the backend running for remote pairing, while Quit from the tray (or the normal shutdown path) still tears down the app.
A new Windows-only system tray (Open / Quit) is registered at startup; close-to-background is enabled only after the tray is created successfully so users are not left with a hidden app and no way to reopen it.
before-quitcallsprepareForQuitso updater-driven and explicit quits bypass the hide behavior.Startup on Windows caches the PowerShell-derived shell environment snapshot under the app state directory (
windows-shell-environment.json), reusing it for up to 24 hours or until the inherited PATH changes, avoiding repeated profile probes on warm launches.Tests cover tray lifecycle, window close vs quit, lifecycle
prepareForQuit, and cache reuse; remote-access docs describe the tray behavior.Reviewed by Cursor Bugbot for commit c5325cb. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add Windows system tray support with background mode and shell environment caching
DesktopTray) with Open and Quit menu actions. Closing the main window hides it rather than quitting while the tray is active.DesktopWindowgainssetBackgroundModeEnabledandprepareForQuitmethods;prepareForQuitis called duringbefore-quitso subsequent closes proceed normally instead of hiding.stateDir) and reused for up to 24 hours when the inherited PATH is unchanged, reducing repeated PowerShell profile loads on each launch.📊 Macroscope summarized c5325cb. 7 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted
🗂️ Filtered Issues
No issues evaluated.