Skip to content

Commit 1be2536

Browse files
committed
docs: clarify editor discovery and directory cache behavior
1 parent ab872df commit 1be2536

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

‎apps/server/src/process/externalLauncher.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,11 @@ function buildBrowserLaunch(
421421
};
422422
}
423423

424+
/**
425+
* Discover installed editors while sharing PATH listings across command probes.
426+
* Return completed probes after four seconds so the caller can cache partial
427+
* results before server.getConfig's five-second deadline.
428+
*/
424429
const buildAvailableEditors = Effect.fn("externalLauncher.buildAvailableEditors")(function* (
425430
platform: NodeJS.Platform,
426431
env: NodeJS.ProcessEnv,
@@ -431,8 +436,6 @@ const buildAvailableEditors = Effect.fn("externalLauncher.buildAvailableEditors"
431436
> {
432437
const available: EditorId[] = [];
433438

434-
// Return completed probes before server.getConfig's five-second deadline
435-
// would discard the entire list. The existing discovery cache keeps this result.
436439
yield* Effect.gen(function* () {
437440
for (const editor of EDITORS) {
438441
if (editor.commands === null) {

‎packages/shared/src/shell.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,13 @@ const CommandDirectoryCache = Context.Reference<
516516
Map<string, ReadonlySet<string> | null> | undefined
517517
>("@t3tools/shared/shell/CommandDirectoryCache", { defaultValue: () => undefined });
518518

519-
/** Reuse PATH listings for one batch of lookups without retaining stale directory contents. */
519+
/**
520+
* Run a batch of command lookups with a shared PATH directory listing cache.
521+
* Each execution creates a fresh cache so later batches see directory changes.
522+
*
523+
* @param effect - The command lookups that should share directory listings.
524+
* @returns The effect with a fresh directory cache provided for its execution.
525+
*/
520526
export const withCommandDirectoryCache = <A, E, R>(effect: Effect.Effect<A, E, R>) =>
521527
Effect.suspend(() => effect.pipe(Effect.provideService(CommandDirectoryCache, new Map())));
522528

@@ -558,6 +564,11 @@ const isExecutableFile = Effect.fnUntraced(function* (
558564
return canExecuteFile(filePath);
559565
});
560566

567+
/**
568+
* Resolve an executable using the supplied platform and PATH in search order.
569+
* When a directory cache is provided, use its listings to skip absent candidates;
570+
* probe candidates directly when a directory cannot be listed.
571+
*/
561572
const resolveCommandPathForPlatform = Effect.fn("shell.resolveCommandPathForPlatform")(function* (
562573
command: string,
563574
options: CommandAvailabilityOptions & { readonly platform: NodeJS.Platform },

0 commit comments

Comments
 (0)