The best way to control Claude Code, Codex and more from any computer or phone
fix(desktop): resolve executable commands when checking CLI shadowing (#22046)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Victor Vogel committed
Oct 29, 2026 at 12:49 UTC
e692729e22a2fa1445b7417f7039f20e0700b0a6
2 files changed
+47
-1
apps/desktop/src/app/DesktopCliCommand.test.ts
+34
@@ -1,5 +1,6 @@
1
import * as NodeServices from "@effect/platform-node/NodeServices";
2
import { afterEach, beforeEach, expect, it } from "@effect/vitest";
3
+import * as HostProcess from "@t3tools/shared/HostProcess";
4
import * as Effect from "effect/Effect";
5
import * as FileSystem from "effect/FileSystem";
6
import * as Option from "effect/Option";
@@ -183,6 +184,39 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
184
}).pipe(Effect.scoped),
185
);
186
187
+ it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
188
+ "skips a t3 directory or a file this user cannot execute",
189
+ () =>
190
+ Effect.gen(function* () {
191
+ const fs = yield* FileSystem.FileSystem;
192
+ const path = yield* Path.Path;
193
+ const home = yield* fs.makeTempDirectoryScoped();
194
+ const folder = path.join(home, "folder");
195
+ const plain = path.join(home, "plain");
196
+ const shadow = path.join(home, "shadow");
197
+ yield* fs.makeDirectory(path.join(folder, "t3"), { recursive: true });
198
+ yield* fs.makeDirectory(plain);
199
+ yield* fs.writeFileString(path.join(plain, "t3"), "notes\n");
200
+ // Root can execute mode 0o601; other users must honor the owner permissions.
201
+ yield* fs.chmod(path.join(plain, "t3"), process.getuid?.() === 0 ? 0o600 : 0o601);
202
+ yield* fs.makeDirectory(shadow);
203
+ yield* fs.writeFileString(path.join(shadow, "t3"), "#!/bin/sh\n", { mode: 0o755 });
204
+ process.env.PATH = [folder, plain, shadow, path.join(home, ".local", "bin")].join(":");
205
+
206
+ const command = yield* commandIn({ home });
207
+ expect((yield* command.state).shadowedBy).toBe(path.join(shadow, "t3"));
208
+
209
+ const error = yield* Effect.flip(command.install);
210
+ expect(error.message).toContain(path.join(shadow, "t3"));
211
+
212
+ yield* fs.remove(shadow, { recursive: true });
213
+ expect(yield* command.install).toMatchObject({
214
+ onPath: true,
215
+ installedPath: path.join(home, ".local", "bin", "t3"),
216
+ });
217
+ }).pipe(Effect.scoped),
218
+ );
219
+
220
it.effect("leaves the Windows PATH alone when it cannot be read", () =>
221
Effect.gen(function* () {
222
const fs = yield* FileSystem.FileSystem;
apps/desktop/src/app/DesktopCliCommand.ts
+13
-1
@@ -1,3 +1,6 @@
1
+// @effect-diagnostics-next-line nodeBuiltinImport:off -- FileSystem.access has no execute check.
2
+import * as NodeFSP from "node:fs/promises";
3
+
4
import type { DesktopCliCommandState } from "@t3tools/contracts";
5
import * as Context from "effect/Context";
6
import * as Effect from "effect/Effect";
@@ -118,10 +121,19 @@ export const make = Effect.gen(function* () {
121
Effect.mapError(() => fail("Could not update your PATH.")),
122
);
123
124
+ const isExecutableFile = Effect.fn("DesktopCliCommand.isExecutableFile")(
125
+ function* (target: string) {
126
+ if ((yield* fs.stat(target)).type !== "File") return false;
127
+ yield* Effect.tryPromise(() => NodeFSP.access(target, NodeFSP.constants.X_OK));
128
+ return true;
129
+ },
130
+ Effect.orElseSucceed(() => false),
131
+ );
132
+
133
const firstOnPath = Effect.gen(function* () {
134
for (const directory of pathEntries(process.env.PATH, ":")) {
135
const candidate = path.join(directory, "t3");
124
- if (yield* exists(candidate)) return Option.some(candidate);
136
+ if (yield* isExecutableFile(candidate)) return Option.some(candidate);
137
}
138
return Option.none<string>();
139
});