GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): open stable Zed when a prerelease Zed is first on PATH by only21mil · Pull Request #24656 · pingdotgg/t3code

fix(server): open stable Zed when a prerelease Zed is first on PATH #24656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
juliusmarminge merged 9 commits into pingdotgg:main from only21mil:fix/i1978-windows-open-in-zed-opens-zed-nightly-in
Nov 14, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

fix(server): open stable Zed when a prerelease Zed is first on PATH #24656

Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit Hold shift + click to select a range
659d97e
fix(server): open stable Zed when a prerelease Zed is first on PATH
only21mil Oct 24, 2026
076fc4f
fix(shared): only the Zed install folder decides its Windows channel
only21mil Oct 24, 2026
a6620f2
merge: bring main into Windows Zed fix
maria-rcks Oct 26, 2026
03a458d
test(server): cover stable-first Windows Zed resolution
maria-rcks Oct 26, 2026
87cdaa2
merge: bring main into the Windows Zed fix
only21mil Nov 10, 2026
64fe428
merge: bring main into the Windows Zed fix
only21mil Nov 11, 2026
9b0be02
fix(shared): stop the Windows Zed PATH scan at the first stable install
only21mil Nov 11, 2026
e11c6fb
Merge remote-tracking branch 'origin/main' into fix/i1978-windows-ope…
juliusmarminge Nov 14, 2026
99a3c0e
test(shared): drop the PATH probe test the launcher case already covers
juliusmarminge Nov 14, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

51 changes: 51 additions & 0 deletions 51 apps/server/src/process/externalLauncher.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,57 @@ it.effect(
},
);

it.effect.each(["Zed Nightly", "Zed Preview"])(
"launches stable Zed on Windows when %s comes first on PATH",
(channel) =>
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const root = yield* fs.makeTempDirectoryScoped({ prefix: "t3-zed-channels-" });
// A user folder naming Zed and a channel does not mark either install.
const programs = path.join(root, "Users", "zedpreview", "Programs");
const prereleaseBin = path.join(programs, channel, "bin");
const stableBin = path.join(programs, "Zed", "bin");
for (const dir of [prereleaseBin, stableBin]) {
yield* fs.makeDirectory(dir, { recursive: true });
yield* fs.writeFileString(path.join(dir, "zed.EXE"), "");
}
const env = { PATH: `${prereleaseBin};${stableBin}`, PATHEXT: ".COM;.EXE;.BAT;.CMD" };

const launchZed = Effect.gen(function* () {
let spawned: ChildProcess.StandardCommand | undefined;
yield* Effect.gen(function* () {
const launcher = yield* ExternalLauncher.ExternalLauncher;
yield* launcher.launchEditor({ editor: "zed", cwd: "C:\\workspace" });
}).pipe(
Effect.provide(
layerTest({
platform: "win32",
env,
onSpawn: (command) => {
spawned = command;
},
}),
),
);
assert.ok(spawned);
return spawned;
});

const stable = yield* launchZed;
assert.equal(stable.command, path.join(stableBin, "zed.EXE"));
assert.deepEqual(stable.args, ["C:\\workspace"]);

env.PATH = `${stableBin};${prereleaseBin}`;
assert.equal((yield* launchZed).command, "zed");

env.PATH = `${prereleaseBin};${stableBin}`;
// With only the prerelease install left, it still opens by name.
yield* fs.remove(path.join(stableBin, "zed.EXE"));
assert.equal((yield* launchZed).command, "zed");
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
);

const launchWindowsShimEditor = (cwd: string) =>
Effect.gen(function* () {
const fileSystem = yield* FileSystem.FileSystem;
Expand Down
28 changes: 26 additions & 2 deletions 28 packages/shared/src/editor.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@ import * as Stream from "effect/Stream";
import { ChildProcess, ChildProcessSpawner } from "effect/process";

import * as HostProcess from "./HostProcess.ts";
import { isCommandAvailable, resolveCommandPath } from "./shell.ts";
import { isCommandAvailable, resolveCommandPath, resolveCommandPaths } from "./shell.ts";

type Editor = (typeof EDITORS)[number];

// The nearest Zed folder identifies the channel, even below a user named zedpreview.
const isPrereleaseZedPath = (filePath: string) => {
const install = filePath
.split(/[\\/]/)
.slice(0, -1)
.findLast((folder) => folder.toLowerCase().includes("zed"))
?.toLowerCase();
return install !== undefined && (install.includes("nightly") || install.includes("preview"));
};

const installNames: Partial<Record<Editor["id"], ReadonlyArray<string>>> = {
vscode: ["Visual Studio Code"],
"vscode-insiders": ["Visual Studio Code - Insiders"],
Expand Down Expand Up @@ -59,7 +69,21 @@ export const resolveEditorCommand = Effect.fn("editor.resolveEditorCommand")(fun
// Prefer Zed's macOS bundle because OpenZFS also installs a zed executable.
const preferBundle = platform === "darwin" && editor.id === "zed";
const preferZeditor = platform === "linux" && editor.id === "zed";
if (!preferBundle && !preferZeditor) {
if (platform === "win32" && editor.id === "zed") {
const isStable = (resolved: string) => !isPrereleaseZedPath(resolved);
let firstCommand: string | undefined;
for (const command of editor.commands) {
const matches = yield* resolveCommandPaths(command, { env, until: isStable });
const stable = matches.find(isStable);
// Bypass PATH only when stable is behind a prerelease install.
if (stable !== undefined) {
const isFirst = firstCommand === undefined && stable === matches[0];
return Option.some({ command: isFirst ? command : stable, baseArgs });
}
if (firstCommand === undefined && matches.length > 0) firstCommand = command;
}
if (firstCommand !== undefined) return Option.some({ command: firstCommand, baseArgs });
} else if (!preferBundle && !preferZeditor) {
for (const command of editor.commands) {
if (yield* isCommandAvailable(command, { env })) return Option.some({ command, baseArgs });
}
Expand Down
29 changes: 29 additions & 0 deletions 29 packages/shared/src/shell.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
readEnvironmentFromLoginShell,
readEnvironmentFromWindowsShell,
resolveCommandPath,
resolveCommandPaths,
resolveSpawnCommand,
resolveWindowsEnvironment,
runsGitWithoutConsole,
Expand Down Expand Up @@ -595,6 +596,34 @@ effectIt.layer(NodeServices.layer)("resolveCommandPath", (it) => {
Effect.provideService(CommandResolutionCache, new Map()),
),
);

it.effect("stops listing PATH matches at the first one the caller accepts", () =>
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const first = yield* fs.makeTempDirectoryScoped();
const second = yield* fs.makeTempDirectoryScoped();
const third = yield* fs.makeTempDirectoryScoped();
for (const dir of [first, second, third]) {
yield* fs.writeFileString(path.join(dir, "zed.EXE"), "");
}
const probed: Array<string> = [];
const matches = yield* resolveCommandPaths("zed", {
env: { PATH: `${first};${second};${third}`, PATHEXT: ".EXE" },
until: (match) => path.dirname(match) === second,
}).pipe(
Effect.provideService(FileSystem.FileSystem, {
...fs,
stat: (file) => {
probed.push(file);
return fs.stat(file);
},
}),
);
expect(matches).toEqual([path.join(first, "zed.EXE"), path.join(second, "zed.EXE")]);
expect(probed.filter((file) => file.startsWith(third))).toEqual([]);
}).pipe(Effect.provideService(HostProcess.Platform, "win32")),
);
});

describe("runsGitWithoutConsole", () => {
Expand Down
97 changes: 68 additions & 29 deletions 97 packages/shared/src/shell.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,47 @@ const isExecutableFile = Effect.fnUntraced(function* (
return canExecuteFile(filePath);
});

// Called within the traced command resolvers.
const findOnPath = Effect.fnUntraced(function* (
pathValue: string,
commandCandidates: ReadonlyArray<string>,
platform: NodeJS.Platform,
windowsPathExtensions: ReadonlyArray<string>,
isLast: (match: string) => boolean,
): Effect.fn.Return<ReadonlyArray<string>, never, FileSystem.FileSystem | Path.Path> {
const path = yield* Path.Path;
// Keep case variants: Windows can make PATH directories case-sensitive.
const pathEntries: string[] = [];
const seenPathEntries = new Set<string>();
for (const entry of pathValue.split(pathDelimiterForPlatform(platform))) {
const pathEntry = stripWrappingQuotes(entry.trim());
if (pathEntry.length === 0 || seenPathEntries.has(pathEntry)) continue;

seenPathEntries.add(pathEntry);
pathEntries.push(pathEntry);
}

const listings = yield* PathDirectoryListings;
const matches: string[] = [];
for (const pathEntry of pathEntries) {
let listing = listings && (yield* Cache.get(listings, pathEntry));
if (listings && listing?.names && listing.modified !== (yield* directoryMtime(pathEntry))) {
yield* Cache.invalidate(listings, pathEntry);
listing = yield* Cache.get(listings, pathEntry);
}
for (const candidate of commandCandidates) {
if (listing?.names && !listing.names.has(candidate.toLowerCase())) continue;
const candidatePath = path.join(pathEntry, candidate);
if (yield* isExecutableFile(candidatePath, platform, windowsPathExtensions)) {
matches.push(candidatePath);
if (isLast(candidatePath)) return matches;
break;
}
}
}
return matches;
});

const resolveCommandPathForPlatform = Effect.fn("shell.resolveCommandPathForPlatform")(function* (
command: string,
options: CommandAvailabilityOptions & { readonly platform: NodeJS.Platform },
Expand Down Expand Up @@ -653,35 +694,15 @@ const resolveCommandPathForPlatform = Effect.fn("shell.resolveCommandPathForPlat
return cached.resolvedPath;
}

// Keep case variants: Windows can make PATH directories case-sensitive.
const pathEntries: string[] = [];
const seenPathEntries = new Set<string>();
for (const entry of pathValue.split(pathDelimiterForPlatform(platform))) {
const pathEntry = stripWrappingQuotes(entry.trim());
if (pathEntry.length === 0 || seenPathEntries.has(pathEntry)) continue;

seenPathEntries.add(pathEntry);
pathEntries.push(pathEntry);
}

const listings = yield* PathDirectoryListings;
for (const pathEntry of pathEntries) {
let listing = listings && (yield* Cache.get(listings, pathEntry));
if (listings && listing?.names && listing.modified !== (yield* directoryMtime(pathEntry))) {
yield* Cache.invalidate(listings, pathEntry);
listing = yield* Cache.get(listings, pathEntry);
}
for (const candidate of commandCandidates) {
if (listing?.names && !listing.names.has(candidate.toLowerCase())) continue;
const candidatePath = path.join(pathEntry, candidate);
if (yield* isExecutableFile(candidatePath, platform, windowsPathExtensions)) {
cacheCommandResolution(cache, cacheKey, candidatePath, nowNanos);
return candidatePath;
}
}
}
cacheCommandResolution(cache, cacheKey, null, nowNanos);
return null;
const [resolvedPath = null] = yield* findOnPath(
pathValue,
commandCandidates,
platform,
windowsPathExtensions,
() => true,
);
cacheCommandResolution(cache, cacheKey, resolvedPath, nowNanos);
return resolvedPath;
});

export const resolveCommandPath = Effect.fn("shell.resolveCommandPath")(function* (
Expand All @@ -694,6 +715,24 @@ export const resolveCommandPath = Effect.fn("shell.resolveCommandPath")(function
});
});

// Matches for a bare command in PATH order, up to the first one `until` accepts; not cached.
export const resolveCommandPaths = Effect.fn("shell.resolveCommandPaths")(function* (
command: string,
options: CommandAvailabilityOptions & { readonly until: (match: string) => boolean },
) {
const path = yield* Path.Path;
const platform = yield* HostProcess.Platform;
const env = options.env ?? (yield* HostProcess.Environment);
const windowsPathExtensions = platform === "win32" ? resolveWindowsPathExtensions(env) : [];
return yield* findOnPath(
resolvePathEnvironmentVariable(env),
resolveCommandCandidates(command, platform, windowsPathExtensions, path.extname),
platform,
windowsPathExtensions,
options.until,
);
});

// Git 2.56 x64 uses ucrt64; ARM64 uses clangarm64; older x64/32-bit builds use mingw64/mingw32.
const GIT_FOR_WINDOWS_BUILDS = ["ucrt64", "clangarm64", "mingw64", "mingw32"] as const;

Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.