@devries-cameron20 / t3code Mirror · read-only / commits / b6fbd181ca
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 22, 12:00 UTC

fix(desktop): installing the t3 command no longer reports its own launcher as another t3 (#22375)

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>

Gourav Kumar Dhiman committed Oct 29, 2026 at 23:54 UTC b6fbd181cae49d38927360913851121cc35ec4ff
2 files changed +60 -6
apps/desktop/src/app/DesktopCliCommand.test.ts
+36
@@ -136,6 +136,14 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
136 yield* command.uninstall;
137 expect(yield* fs.readFileString(theirs)).toBe("npm's t3\n");
138 expect(yield* fs.readLink(path.join(home, "bin", "t3"))).toBe(path.join(home, "gone"));
139 +
140 + const launcher = path.join(home, ".t3", "bin", "t3");
141 + yield* fs.writeFileString(launcher, "npm's t3\n");
142 + process.env.PATH = path.dirname(launcher);
143 + expect(yield* command.state).toMatchObject({ onPath: false, shadowedBy: launcher });
144 + expect((yield* Effect.flip(command.install)).message).toContain("Could not set up");
145 + yield* command.uninstall;
146 + expect(yield* fs.readFileString(launcher)).toBe("npm's t3\n");
147 }).pipe(Effect.scoped),
148 );
149
@@ -217,6 +225,34 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
225 }).pipe(Effect.scoped),
226 );
227
228 + it.effect("does not treat its own launcher as another t3 when its folder is first on PATH", () =>
229 + Effect.gen(function* () {
230 + const fs = yield* FileSystem.FileSystem;
231 + const path = yield* Path.Path;
232 + const home = yield* fs.makeTempDirectoryScoped();
233 + const launcher = path.join(home, ".t3", "bin", "t3");
234 + process.env.PATH = [path.dirname(launcher), path.join(home, ".local", "bin")].join(":");
235 +
236 + const command = yield* commandIn({ home });
237 + const installed = yield* command.install;
238 +
239 + expect(yield* fs.exists(launcher)).toBe(true);
240 + expect(installed).toMatchObject({
241 + onPath: true,
242 + installedPath: path.join(home, ".local", "bin", "t3"),
243 + });
244 + expect(installed.shadowedBy).toBeUndefined();
245 + expect(yield* command.state).toEqual(installed);
246 +
247 + const removed = yield* command.uninstall;
248 + expect(removed.installedPath).toBeNull();
249 + expect(removed.onPath).toBe(true);
250 + expect(yield* command.state).toEqual(removed);
251 + expect(yield* fs.exists(installed.installedPath!)).toBe(false);
252 + expect(yield* fs.exists(launcher)).toBe(true);
253 + }).pipe(Effect.scoped),
254 + );
255 +
256 it.effect("leaves the Windows PATH alone when it cannot be read", () =>
257 Effect.gen(function* () {
258 const fs = yield* FileSystem.FileSystem;
apps/desktop/src/app/DesktopCliCommand.ts
+24 -6
@@ -92,6 +92,19 @@ export const make = Effect.gen(function* () {
92 Effect.orElseSucceed(() => false),
93 );
94
95 + // PATH can reach the regular launcher directly; removal still requires isOurLink.
96 + const runsOurLauncher = Effect.fn("DesktopCliCommand.runsOurLauncher")(
97 + function* (candidate: string) {
98 + if (yield* isOurLink(candidate)) return true;
99 + const [resolved, ours] = yield* Effect.all([fs.realPath(candidate), fs.realPath(launcher)]);
100 + if (resolved !== ours) return false;
101 + const info = yield* fs.stat(candidate);
102 + if (info.type !== "File" || Number(info.size) > 16_384) return false;
103 + return (yield* fs.readFileString(candidate)).includes(DesktopCliShim.MARKER);
104 + },
105 + Effect.orElseSucceed(() => false),
106 + );
107 +
108 const powershell = (env: Record<string, string>) =>
109 Effect.scoped(
110 Effect.gen(function* () {
@@ -141,7 +154,7 @@ export const make = Effect.gen(function* () {
154 const foreignFirstOnPath = Effect.gen(function* () {
155 if (windows) return Option.none<string>();
156 const first = yield* firstOnPath;
144 - if (Option.isNone(first) || (yield* isOurLink(first.value))) return Option.none<string>();
157 + if (Option.isNone(first) || (yield* runsOurLauncher(first.value))) return Option.none<string>();
158 return first;
159 });
160
@@ -168,12 +181,17 @@ export const make = Effect.gen(function* () {
181 const installed = yield* installedAt;
182 const shadowedBy = yield* foreignFirstOnPath;
183 const shadow = Option.isSome(shadowedBy) ? { shadowedBy: shadowedBy.value } : {};
171 - if (Option.isNone(installed)) {
172 - return { supported: true, installedPath: null, onPath: false, launcherPath, ...shadow };
173 - }
184 const first = yield* firstOnPath;
175 - const onPath = windows || (Option.isSome(first) && (yield* isOurLink(first.value)));
176 - return { supported: true, installedPath: installed.value, onPath, launcherPath, ...shadow };
185 + const onPath = windows
186 + ? Option.isSome(installed)
187 + : Option.isSome(first) && (yield* runsOurLauncher(first.value));
188 + return {
189 + supported: true,
190 + installedPath: Option.getOrNull(installed),
191 + onPath,
192 + launcherPath,
193 + ...shadow,
194 + };
195 }).pipe(
196 Effect.orElseSucceed(() => ({
197 supported: false,