@devries-cameron20 / t3code Mirror · read-only / commits / ce87dc79fb
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, 23:15 UTC

fix(server): opening a folder without Git installed no longer shows a spawn error (#14942)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

tiliakoos committed Oct 20, 2026 at 00:17 UTC ce87dc79fbf3dfc575414d96041135f24d7ff3a9
2 files changed +46 -1
apps/server/src/vcs/GitVcsDriver.test.ts
+41
@@ -1277,6 +1277,47 @@ it.effect("GitVcsDriver forwards execute env to the VCS process", () => {
1277 );
1278 });
1279
1280 +// The real VCS process, spawning `command` wherever the driver runs git.
1281 +const vcsProcessSpawning = (command: string) =>
1282 + Layer.effect(
1283 + VcsProcess.VcsProcess,
1284 + Effect.map(VcsProcess.make, (vcsProcess) =>
1285 + VcsProcess.VcsProcess.of({ run: (input) => vcsProcess.run({ ...input, command }) }),
1286 + ),
1287 + ).pipe(Layer.provide(ProcessRunner.layer), Layer.provideMerge(NodeServices.layer));
1288 +
1289 +it.effect("GitVcsDriver treats a missing git executable as outside any repository", () =>
1290 + Effect.gen(function* () {
1291 + const fileSystem = yield* FileSystem.FileSystem;
1292 + const path = yield* Path.Path;
1293 + const cwd = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-missing-git-" });
1294 + const driver = yield* GitVcsDriver.makeVcsDriverShape().pipe(
1295 + Effect.provide(vcsProcessSpawning(path.join(cwd, "git"))),
1296 + );
1297 +
1298 + assert.strictEqual(yield* driver.isInsideWorkTree(cwd), false);
1299 + assert.strictEqual(yield* driver.detectRepository(cwd), null);
1300 + }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
1301 +);
1302 +
1303 +it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
1304 + "GitVcsDriver still fails detection when git exists but cannot be spawned",
1305 + () =>
1306 + Effect.gen(function* () {
1307 + const fileSystem = yield* FileSystem.FileSystem;
1308 + // A file without the execute bit fails to spawn with a permission error.
1309 + const notExecutable = yield* fileSystem.makeTempFileScoped({ prefix: "t3-git-" });
1310 + const driver = yield* GitVcsDriver.makeVcsDriverShape().pipe(
1311 + Effect.provide(vcsProcessSpawning(notExecutable)),
1312 + );
1313 +
1314 + const error = yield* driver.isInsideWorkTree(process.cwd()).pipe(Effect.flip);
1315 + assert.strictEqual(error._tag, "VcsProcessSpawnError");
1316 + const detectionError = yield* driver.detectRepository(process.cwd()).pipe(Effect.flip);
1317 + assert.strictEqual(detectionError._tag, "VcsProcessSpawnError");
1318 + }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
1319 +);
1320 +
1321 it.effect("GitVcsDriver flushes checkpoint objects and refs to disk before publishing them", () => {
1322 const observedArgs: ReadonlyArray<string>[] = [];
1323
apps/server/src/vcs/GitVcsDriver.ts
+5 -1
@@ -33,6 +33,7 @@ import {
33 type VcsStatusResult,
34 type WorktreeSubmodules,
35 } from "@t3tools/contracts";
36 +import { isMissingExecutable } from "@t3tools/source-control-core/server/discovery";
37 import * as HostProcess from "@t3tools/shared/HostProcess";
38 import {
39 makeGitVcsDriverCore,
@@ -561,7 +562,10 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
562 timeoutMs: 5_000,
563 maxOutputBytes: 4_096,
564 },
564 - ).pipe(Effect.map((result) => result.exitCode === 0 && result.stdout.trim() === "true"));
565 + ).pipe(
566 + Effect.map((result) => result.exitCode === 0 && result.stdout.trim() === "true"),
567 + Effect.catchIf(isMissingExecutable, () => Effect.succeed(false)),
568 + );
569
570 const execute: VcsDriver.VcsDriver["Service"]["execute"] = (input) =>
571 gitCommand(vcsProcess, input.operation, input.cwd, input.args, {