Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(windows): reduce startup command discovery and Git probe overhead #6124

Closedsimon-curtis(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromrefs/pull/6124/headopened View on GitHub

Windows startup spends seconds searching long PATH/PATHEXT lists and cleaning up already-exited Git probes. This PR reduces both costs, with behavior changes confined to Windows.

  • Command discovery: reuse directory listings across an editor-discovery pass and use indexed filename matching for spawn resolution. Skip missing PATH entries; retain direct probes for directories that cannot be listed. PATH order, case-insensitive matching, and executable-file validation are preserved.
  • Repository discovery: skip missing workspaces and disable post-exit cleanup for git rev-parse --show-toplevel and git remote -v. These commands do not leave child processes behind. A small Effect patch supports the Windows-only override; cancellation, timeout, and default process cleanup remain intact.

Earlier measurements from September 5, compared with nightly v0.0.39-nightly.20260905.1286 (not rerun after this rebase):

Median measurementNightlyThis branch
Launch to backend ready8.87 s6.39 s
Launch to first sidebar snapshot18.20 s8.40 s
Editor discovery2.28 s62 ms

Both versions were built from source and used identical database snapshots, with three interleaved measured launches after a warm-up each. The 54% reduction measures time to the first sidebar snapshot with warm caches. The branch includes newer upstream commits, so this compares releases rather than isolating the patch. Individual runs and benchmark details.

Rebased onto main at 50ff4c371, with the dependency patches updated for Effect 4.0.0-rc.112 and main's repository cache refresh behavior preserved.

Validation after the rebase: 82 focused tests passed, 15 skipped; targeted lint, formatting, and shared typecheck passed. Server typecheck reports two errors in unchanged files, HostPowerMonitor.ts and NativeTelemetryClient.ts. Tests cover resolution fallback, cache lifetime, native process cleanup, and platform-specific behavior.

Model: GPT-6. Harness: Codex in T3 Code.

    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      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: 4eaab204-5559-42cc-a1b9-f24199c759a8

      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

      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. @@ -177,4 +177,4 @@
      177177
      178178 const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, serverSettings);
      179179 const snapshot = yield* makeManagedServerProvider<ProviderSnapshotSettings<ClaudeSettings>>({
      180- maintenanceCapabilities,
      180+ maintenanceCapabilities: maintenanceCapabilities.get,
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High Drivers/ClaudeDriver.ts:180

      maintenanceCapabilities.get() returns the npm updater immediately after ClaudeDriver.create(), even when claude on PATH actually resolves to a native or Homebrew install. Before the deferred maintenanceCapabilities.refresh completes, ProviderRegistry.getProviderMaintenanceCapabilitiesForInstance can therefore return the wrong update action, so an update requested during startup runs npm instead of claude update/Homebrew. makeProviderMaintenanceCapabilitiesSource initializes its current value via resolver.resolve(options) before command-path/realpath discovery, and that synchronous resolve falls back to the npm updater for a bare claude command. Consider initializing current with a non-actionable value (or gating maintenance access) until the deferred resolution completes.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/provider/Drivers/ClaudeDriver.ts around line 180:
      
      `maintenanceCapabilities.get()` returns the npm updater immediately after `ClaudeDriver.create()`, even when `claude` on PATH actually resolves to a native or Homebrew install. Before the deferred `maintenanceCapabilities.refresh` completes, `ProviderRegistry.getProviderMaintenanceCapabilitiesForInstance` can therefore return the wrong update action, so an update requested during startup runs `npm` instead of `claude update`/Homebrew. `makeProviderMaintenanceCapabilitiesSource` initializes its `current` value via `resolver.resolve(options)` before command-path/realpath discovery, and that synchronous resolve falls back to the npm updater for a bare `claude` command. Consider initializing `current` with a non-actionable value (or gating maintenance access) until the deferred resolution completes.
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High

      https://github.com/pingdotgg/t3code/blob/6ed81202581191bbdd9cb1a70da611be813e5a99/scripts/build-desktop-artifact.ts#L996

      Default Windows builds (without --wsl-prebuild) fail during vp install --prod because stageDependencies includes Linux-only @ff-labs/fff-node platform packages from resolveFffNativeDependencies("linux", ...), but createStageWorkspaceConfig no longer lists linux in supportedArchitectures.os when includeWslRuntime is false. pnpm rejects those packages as unsupported-platform dependencies. The Linux fff dependency resolution should be gated on the same wslPrebuild condition that controls includeWslRuntime.

      No longer relevant as of d11e94200cd4e05dfd49c57346696775332ec641

    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR changes Windows command discovery and subprocess cleanup in shared production infrastructure, including a patched process spawner, so its runtime blast radius is broader than a small performance tweak. It also adds a file-level static-analysis suppression in a new test file, while an unresolved High finding describes a startup-time maintenance-action risk.

      Not approved because:

      • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity
      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. 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](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit fef06d741f8c710f0957139af036297f3f3aad90. Configure [here](https://www.cursor.com/dashboard/bugbot).
    6. Read the Windows shell half against today's main. CONFLICTING.

      Desktop: drops the -NoProfile PATH probe entirely and keeps only the profile probe, merging process PATH + profile PATH + knownWindowsCliDirs. That is the ~2s startup win (each PowerShell spawn was ~2s). It also deletes the no-profile source #6356 is trying to make read Machine+User, so a CLI installed after launch still will not show up until the next process start unless the profile sees it.

      Shared: directory listing + case-insensitive name map instead of probing every PATHEXT candidate, with a fallback when readDirectory fails (ACL / unreadable share). That is the right Windows lookup. Returning [command] when the input already has a PATHEXT suffix is also right — the old code generated three casings of the same extension.

      Do not land this and #6356/#4896/#6301 independently; they all rewrite installWindowsEnvironment.

    7. Scope update: I have reframed this PR around reducing first-start/editor-discovery time on Windows.

      After comparing the original branch with current main and the overlapping Windows environment work, the earlier ~2-second startup result was attributable to removing a PowerShell PATH probe. That change affects PATH refresh semantics and conflicts with the other installWindowsEnvironment work, so it no longer belongs in this PR. The installer, packaging, provider-lifecycle, desktop environment, and WSL changes have also been removed.

      What remains is the independently useful shared lookup optimization: list each Windows PATH directory once, match PATHEXT candidates case-insensitively, preserve PATH order, and fall back to the existing direct probes when listing fails. I also restored resolveCommandCandidates exactly to main, so this PR no longer changes candidate casing behavior.

      A targeted five-run benchmark on this machine's 71-entry PATH and 12 PATHEXT values measured provider discovery at 199 ms → 49 ms and first editor discovery at 1,964 ms → 425 ms. This is a resolver benchmark, not an end-to-end startup claim.

    8. Note

      🤖 GPT-6 Astra (preview) responding on behalf of Theo

      This note is part of an automated cleanup pass.

      Preserving these details from items reviewed in the cleanup pass.

      Carryover from #6221 at 59849f94e2: retain the shell.test.ts listing-failure cases. PermissionDenied, Busy, and Unknown must fall back to direct executable probes, while NotFound and BadResource can skip the directory. Keep mixed-case filenames and PATH order intact. The cross-command directory reuse may be useful if Windows measurements still show repeated listings, but the two PRs' benchmarks use different machines and cannot establish which is faster.

      Carry over the slow-discovery evidence from #5050 at 61278bee47. On the reported Windows host with 46 PATH entries and 12 PATHEXT entries, getConfig timed out near 5,000 ms on every call. Concurrent discovery finished in 4,787 ms in that report. Its focused test interrupts one caller during discovery, then requires a later caller to obtain editors. Check cold discovery and caller interruption while retaining bounded expiry and current Linux/WSL file-manager checks. These are reported measurements and a test case to retain, not results rerun here.

      Keep the trace evidence from #4778 at dc7f1727a6 in the Windows resolver review. Its author reported 28,577 shell.isExecutableFile spans from 22 command lookups in 13.7 seconds, plus trace files rotating at 10 MB about every 40 seconds. The distinct code change makes isExecutableFile untraced. Main still traces that helper, although its command cache and VCS limits are now bounded. Check first-scan and miss-heavy trace cost with this PR. Do not copy the older unbounded cache or treat the reported timings as rerun results.

    9. Pushed 6754baee4 and resolved the merge against upstream main. The implementation is now limited to Windows command discovery and Git-probe startup costs; the experimental UI, settlement, and auto-pull changes were removed.

      I compared production source builds against nightly v0.0.39-nightly.20260905.1286 (09aac715), shallow-cloned with --depth 1. Both used identical database snapshots, the same machine/runtime, and isolated state. After discarding one warm-up per build, the measured launches were interleaved:

      Process launch to first sidebar snapshotRun 1Run 2Run 3Median
      Nightly18.345 s16.574 s18.201 s18.201 s
      This branch8.200 s8.885 s8.404 s8.404 s

      That is 9.80 seconds / 54% less time to the first sidebar snapshot in this comparison. Median backend readiness improved from 8.87 s to 6.39 s; editor discovery from 2.28 s to 62 ms. These timings overlap and should not be added together.

      These are warm-cache source-build measurements, not cold boots or a measurement of fully interactive UI readiness. Since the branch includes newer upstream commits, the result compares this branch with that nightly release rather than isolating only this patch.

      Validation: 80 tests passed, 13 skipped, targeted lint and server typecheck passed. Native tests cover completed probes, cancellation, timeout, and preservation of default cleanup; platform tests keep the override Windows-only.

      Model: GPT-6. Harness: Codex in T3 Code.

    10. Closing as part of the open-PR backlog sweep (wave 1).

      Reason: Windows PATH/probe startup work largely landed later Related: #9618

      Reopen if this is still wanted and you’re willing to rebase onto current main.

    11. juliusmarminge closed this

    12. Still have this issue on latest nightly build

    13. Thanks for following up and confirming this is still happening on nightly. I've rebased the Windows startup changes onto current main and updated the patches for the newer Effect version, while keeping main's repository cache refresh behavior.

      The focused checks passed: 82 tests passed and 15 were skipped, with lint, formatting, and shared typecheck passing too. Server typecheck still reports two errors in unchanged files. I've updated the PR description with those details and marked the earlier timing measurements as historical, since I haven't rerun the benchmark after this rebase.

      I'd appreciate another look when you have time. GitHub is rejecting my attempts to reopen the PR, even after restoring its original branch tip. Could a maintainer reopen it, please? The rebased changes are pushed and ready for review.

Sign in to join this conversation.