perf(windows): reduce startup command discovery and Git probe overhead #6124
main fromrefs/pull/6124/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/desktop/src/shell/DesktopShellEnvironment.ts line 322OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -374,20 +322 @@374- return {};375- },376-);377-378-const installWindowsEnvironment = Effect.fn("desktop.shellEnvironment.installWindowsEnvironment")(379- function* (380- config: ShellEnvironmentConfig,381- ): Effect.fn.Return<void, never, ChildProcessSpawner.ChildProcessSpawner> {382- // Concurrent, not sequential: these two probes are independent (only their383- // results are combined below) and each spawns its own PowerShell. Run in384- // series they sit at offset 0 of desktop.startup, before anything else, and385- // launch traces measured them at 2718ms then 2066ms — the entire 4.8s386- // startup span, of which desktop.bootstrap is ~30ms.387- const [noProfile, profile] = yield* Effect.all(388- [389- readWindowsEnvironment(["PATH"], { loadProfile: false }),390- readWindowsEnvironment(WINDOWS_PROFILE_ENV_NAMES, { loadProfile: true }),391- ],392- { concurrency: 2 },393- );322+const installWindowsEnvironment = (config: ShellEnvironmentConfig): Effect.Effect<void> =>@@ -177,4 +177,4 @@177177178178 const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, serverSettings);179179 const snapshot = yield* makeManagedServerProvider<ProviderSnapshotSettings<ClaudeSettings>>({180- maintenanceCapabilities,180+ maintenanceCapabilities: maintenanceCapabilities.get,apps/desktop/src/shell/DesktopShellEnvironment.ts lines 322 to 332OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -394,18 +322,11 @@322+const installWindowsEnvironment = (config: ShellEnvironmentConfig): Effect.Effect<void> =>323+ Effect.sync(() => {394324 const mergedPath = mergePaths("win32", [395- trimNonEmpty(profile.PATH),396325 trimNonEmpty(knownWindowsCliDirs(config.env).join(";")),397- trimNonEmpty(noProfile.PATH),398326 readEnvPath(config.env),399327 ]);400328401329 if (Option.isSome(mergedPath)) {402330 config.env.PATH = mergedPath.value;403331 }404- if (!config.env.FNM_DIR && profile.FNM_DIR) {405- config.env.FNM_DIR = profile.FNM_DIR;406- }407- if (!config.env.FNM_MULTISHELL_PATH && profile.FNM_MULTISHELL_PATH) {408- config.env.FNM_MULTISHELL_PATH = profile.FNM_MULTISHELL_PATH;409- }410- },411-);332+ });packages/shared/src/shell.ts lines 571 to 579OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -561,0 +559,21 @@559+ function* (560+ pathEntry: string,561+ commandCandidates: ReadonlyArray<string>,562+ windowsPathExtensions: ReadonlyArray<string>,563+ ): Effect.fn.Return<string | null, never, FileSystem.FileSystem | Path.Path> {564+ const fileSystem = yield* FileSystem.FileSystem;565+ const path = yield* Path.Path;566+ const listing = yield* fileSystem.readDirectory(pathEntry).pipe(567+ Effect.map((directoryEntries) => ({ directoryEntries })),568+ Effect.orElseSucceed(() => null),569+ );570+571+ if (listing !== null) {572+ const names = new Map(listing.directoryEntries.map((entry) => [entry.toUpperCase(), entry]));573+ const candidate = commandCandidates.find((name) => names.has(name.toUpperCase()));574+ if (candidate === undefined) return null;575+ const candidatePath = path.join(pathEntry, names.get(candidate.toUpperCase()) ?? candidate);576+ return (yield* isExecutableFile(candidatePath, "win32", windowsPathExtensions))577+ ? candidatePath578+ : null;579+ }
simon-curtis(GitHub profile, opens in a new tab) changed the title
- apps/server/src/provider/providerMaintenance.ts line 416OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -377,0 +396,21 @@396+) {397+ const fileSystem = yield* FileSystem.FileSystem;398+ const path = yield* Path.Path;399+ const initial = resolver.resolve(options);400+ let current: ProviderMaintenanceCapabilities = { ...initial, update: null };401+ const resolve = yield* Effect.cached(402+ resolveProviderMaintenanceCapabilitiesEffect(resolver, options).pipe(403+ Effect.provideService(FileSystem.FileSystem, fileSystem),404+ Effect.provideService(Path.Path, path),405+ Effect.tap((capabilities) =>406+ Effect.sync(() => {407+ current = capabilities;408+ }),409+ ),410+ ),411+ );412+413+ return {414+ get: () => current,415+ resolve,416+ refresh: resolve.pipe(Effect.asVoid),
- apps/server/src/provider/providerMaintenance.ts line 443OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -377,0 +423,21 @@423+ const fileSystem = yield* FileSystem.FileSystem;424+ const path = yield* Path.Path;425+ const initial = resolver.resolve(options);426+ let current: ProviderMaintenanceCapabilities = { ...initial, update: null };427+ const resolve = yield* cacheEffectSuccess(428+ resolveProviderMaintenanceCapabilitiesEffect(resolver, options).pipe(429+ Effect.provideService(FileSystem.FileSystem, fileSystem),430+ Effect.provideService(Path.Path, path),431+ Effect.tap((capabilities) =>432+ Effect.sync(() => {433+ current = capabilities;434+ }),435+ ),436+ ),437+ );438+439+ return {440+ get: () => current,441+ resolve,442+ refresh: resolve.pipe(Effect.asVoid),443+ } satisfies ProviderMaintenanceCapabilitiesSource;
simon-curtis(GitHub profile, opens in a new tab) changed the title
simon-curtis(GitHub profile, opens in a new tab) changed the title
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
- packages/shared/src/shell.ts lines 621 to 625OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -610,4 +611,15 @@610611 }611612612613 for (const pathEntry of pathEntries) {613- for (const candidate of commandCandidates) {614+ let candidates = commandCandidates;615+ if (platform === "win32") {616+ // Fall back to direct probes when a directory is searchable but not listable.617+ const entries = yield* fileSystem618+ .readDirectory(pathEntry)619+ .pipe(Effect.orElseSucceed(() => null));620+ if (entries !== null) {621+ const names = new Map(entries.map((entry) => [entry.toUpperCase(), entry]));622+ candidates = commandCandidates.flatMap((candidate) => {623+ const match = names.get(candidate.toUpperCase());624+ return match === undefined ? [] : [match];625+ });
simon-curtis(GitHub profile, opens in a new tab) changed the title
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
juliusmarminge closed this
Sign in to join this conversation.


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:
4eaab204-5559-42cc-a1b9-f24199c759a8You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Comment `@coderabbitai help` to get the list of available commands.