@devries-cameron20 / t3code Mirror · read-only / commits / 6bc105f04e
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 16:00 UTC

fix(editors): find JetBrains IDEs whose Toolbox script is named idea1 (#23743)

Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: only21mil <only21mil@users.noreply.github.com>

Victor committed Nov 13, 2026 at 22:28 UTC 6bc105f04e8643643f274d7aa26a8571b75ac32c
2 files changed +85 -7
apps/server/src/process/externalLauncher.test.ts
+56
@@ -860,6 +860,62 @@ it.effect("keeps the macOS VS Code Insiders bundle out of stable VS Code", () =>
860 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
861 );
862
863 +it.effect.each([
864 + {
865 + platform: "darwin",
866 + scripts: "Library/Application Support/JetBrains/Toolbox/scripts",
867 + suffix: "",
868 + },
869 + { platform: "linux", scripts: ".local/share/JetBrains/Toolbox/scripts", suffix: "" },
870 + { platform: "win32", scripts: "JetBrains/Toolbox/scripts", suffix: ".cmd" },
871 + {
872 + platform: "win32",
873 + scripts: "JetBrains/Toolbox/scripts",
874 + suffix: ".cmd",
875 + install: "Programs/IntelliJ IDEA/bin/idea64.exe",
876 + },
877 +] as const)(
878 + "discovers a numbered JetBrains Toolbox script on $platform",
879 + ({ platform, scripts, suffix, ...row }) =>
880 + Effect.gen(function* () {
881 + const fs = yield* FileSystem.FileSystem;
882 + const path = yield* Path.Path;
883 + const home = yield* fs.makeTempDirectoryScoped({ prefix: "t3-toolbox-numbered-" });
884 + const dir = path.join(home, scripts);
885 + yield* fs.makeDirectory(dir, { recursive: true });
886 + for (const name of ["idea10", "idea2"]) {
887 + yield* fs.writeFileString(path.join(dir, `${name}${suffix}`), "#!/bin/sh\n");
888 + yield* fs.chmod(path.join(dir, `${name}${suffix}`), 0o755);
889 + }
890 + const install = "install" in row ? path.join(home, row.install) : undefined;
891 + if (install) {
892 + yield* fs.makeDirectory(path.dirname(install), { recursive: true });
893 + yield* fs.writeFileString(install, "");
894 + }
895 +
896 + const editor = EDITORS.find((editor) => editor.id === "idea")!;
897 + const resolved = yield* resolveEditorCommand(editor, {
898 + HOME: home,
899 + LOCALAPPDATA: home,
900 + PATH: path.join(home, "empty"),
901 + PATHEXT: ".COM;.EXE;.BAT;.CMD",
902 + }).pipe(
903 + Effect.provideService(HostProcess.Platform, platform),
904 + // Keep IDEs installed on the host out of system locations such as /Applications.
905 + Effect.provideService(FileSystem.FileSystem, {
906 + ...fs,
907 + stat: (file) =>
908 + fs.stat(file.startsWith(`${home}${path.sep}`) ? file : path.join(home, "missing")),
909 + }),
910 + );
911 +
912 + assert.deepEqual(
913 + resolved,
914 + Option.some({ command: install ?? path.join(dir, `idea2${suffix}`), baseArgs: [] }),
915 + );
916 + }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
917 +);
918 +
919 for (const { platform, installPath, onPath } of [
920 { platform: "darwin", installPath: ".local/bin/agy", onPath: true },
921 { platform: "linux", installPath: ".local/bin/agy", onPath: false },
packages/shared/src/editor.ts
+29 -7
@@ -72,6 +72,7 @@ export const resolveEditorCommand = Effect.fn("editor.resolveEditorCommand")(fun
72 const command = editor.commands[0];
73 const jetbrains = editor.launchStyle === "line-column";
74 const candidates: string[] = [];
75 + let toolbox: { dir: string; suffix: string } | undefined;
76
77 if (platform === "darwin") {
78 const roots = [...(home ? [path.join(home, "Applications")] : []), "/Applications"];
@@ -97,9 +98,11 @@ export const resolveEditorCommand = Effect.fn("editor.resolveEditorCommand")(fun
98 }
99 }
100 if (home && jetbrains) {
100 - candidates.push(
101 - path.join(home, "Library/Application Support/JetBrains/Toolbox/scripts", command),
102 - );
101 + toolbox = {
102 + dir: path.join(home, "Library/Application Support/JetBrains/Toolbox/scripts"),
103 + suffix: "",
104 + };
105 + candidates.push(path.join(toolbox.dir, command));
106 }
107 } else if (platform === "win32") {
108 const roots = [
@@ -110,7 +113,8 @@ export const resolveEditorCommand = Effect.fn("editor.resolveEditorCommand")(fun
113 ];
114 if (jetbrains) {
115 if (env.LOCALAPPDATA) {
113 - candidates.push(path.join(env.LOCALAPPDATA, "JetBrains/Toolbox/scripts", `${command}.cmd`));
116 + toolbox = { dir: path.join(env.LOCALAPPDATA, "JetBrains/Toolbox/scripts"), suffix: ".cmd" };
117 + candidates.push(path.join(toolbox.dir, `${command}.cmd`));
118 }
119 for (const directory of roots.flatMap((root) => [root, path.join(root, "JetBrains")])) {
120 const entries = yield* fs.readDirectory(directory).pipe(Effect.orElseSucceed(() => []));
@@ -150,9 +154,10 @@ export const resolveEditorCommand = Effect.fn("editor.resolveEditorCommand")(fun
154 "/usr/bin",
155 "/snap/bin",
156 ];
153 - if (jetbrains) {
154 - const dataHome = env.XDG_DATA_HOME || (home ? path.join(home, ".local/share") : undefined);
155 - if (dataHome) dirs.push(path.join(dataHome, "JetBrains/Toolbox/scripts"));
157 + const dataHome = env.XDG_DATA_HOME || (home ? path.join(home, ".local/share") : undefined);
158 + if (jetbrains && dataHome) {
159 + toolbox = { dir: path.join(dataHome, "JetBrains/Toolbox/scripts"), suffix: "" };
160 + dirs.push(toolbox.dir);
161 }
162 if (preferZeditor) {
163 // Linux packages use zeditor because OpenZFS owns the zed command.
@@ -167,6 +172,23 @@ export const resolveEditorCommand = Effect.fn("editor.resolveEditorCommand")(fun
172 }
173
174 if (preferBundle) candidates.push(...editor.commands);
175 + if (toolbox) {
176 + // Toolbox names a launch script `idea1`, `idea2`, ... while `idea` is taken, and keeps that
177 + // name after the other install is removed. Try these only after every canonical candidate.
178 + const { dir, suffix } = toolbox;
179 + const entries = yield* fs.readDirectory(dir).pipe(Effect.orElseSucceed(() => []));
180 + candidates.push(
181 + ...entries
182 + .filter(
183 + (entry) =>
184 + entry.startsWith(command) &&
185 + entry.endsWith(suffix) &&
186 + /^\d+$/.test(entry.slice(command.length, entry.length - suffix.length)),
187 + )
188 + .sort((a, b) => a.length - b.length || a.localeCompare(b))
189 + .map((entry) => path.join(dir, entry)),
190 + );
191 + }
192 const rejected = new Set<string>();
193 for (const candidate of candidates) {
194 const resolved = yield* resolveCommandPath(candidate, { env });