The best way to control Claude Code, Codex and more from any computer or phone
fix(server): threads without a project no longer need Git installed (#17959)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Theo Browne committed
Oct 10, 2026 at 17:54 UTC
c73b45480fb79575a90794bfd1d45d538aacb108
2 files changed
+66
-18
apps/server/src/project/ManagedProjectFolders.test.ts
+47
-16
@@ -1,6 +1,12 @@
1
import { assert, it } from "@effect/vitest";
2
import * as NodeServices from "@effect/platform-node/NodeServices";
3
-import { CommandId, GitCommandError, ProjectId, ThreadId } from "@t3tools/contracts";
3
+import {
4
+ CommandId,
5
+ GitCommandError,
6
+ ProjectId,
7
+ ThreadId,
8
+ VcsProcessSpawnError,
9
+} from "@t3tools/contracts";
10
import * as Deferred from "effect/Deferred";
11
import * as Effect from "effect/Effect";
12
import * as Fiber from "effect/Fiber";
@@ -8,9 +14,11 @@ import * as FileSystem from "effect/FileSystem";
14
import * as Layer from "effect/Layer";
15
import * as Option from "effect/Option";
16
import * as Path from "effect/Path";
17
+import * as PlatformError from "effect/PlatformError";
18
import * as Scope from "effect/Scope";
19
20
import * as ServerConfig from "../config.ts";
21
+import * as GitManager from "../git/GitManager.ts";
22
import * as GitWorkflow from "../git/GitWorkflowService.ts";
23
import * as RuntimeLayer from "../orchestration-v2/runtimeLayer.ts";
24
import * as SqlitePersistence from "../persistence/Sqlite.ts";
@@ -25,20 +33,13 @@ import * as ProjectService from "./ProjectService.ts";
33
import * as RepositoryIdentityResolver from "./RepositoryIdentityResolver.ts";
34
import * as ManagedProjectFolders from "./ManagedProjectFolders.ts";
35
28
-// Real repository detection: the service only asks the Git workflow whether
29
-// the data dir is inside a checkout.
30
-const layerGitWorkflow = Layer.unwrap(
31
- Effect.gen(function* () {
32
- const registry = yield* VcsDriverRegistry.VcsDriverRegistry;
33
- return Layer.mock(GitWorkflow.GitWorkflowService)({
34
- isRepository: (cwd) =>
35
- registry.detect({ cwd }).pipe(
36
- Effect.map((handle) => handle?.kind === "git"),
37
- Effect.orDie,
38
- ),
39
- });
40
- }),
41
-).pipe(Layer.provide(VcsDriverRegistry.layer.pipe(Layer.provide(VcsProcess.layer))));
36
+// The real Git workflow over real repository detection, with a mock GitManager
37
+// since the service only asks whether the data dir is inside a checkout.
38
+const layerGitWorkflow = (vcsProcess?: Layer.Layer<VcsProcess.VcsProcess>) =>
39
+ GitWorkflow.layer.pipe(
40
+ Layer.provide(VcsDriverRegistry.layer.pipe(Layer.provide(vcsProcess ?? VcsProcess.layer))),
41
+ Layer.provide(Layer.mock(GitManager.GitManager)({})),
42
+ );
43
44
const layerEnrichment = ProjectEnrichmentService.layer.pipe(
45
Layer.provide(
@@ -56,6 +57,8 @@ const layerEnrichment = ProjectEnrichmentService.layer.pipe(
57
const layerRealGit = GitVcsDriver.layer.pipe(Layer.provide(VcsProcess.layer));
58
59
interface HarnessOptions {
60
+ /** The processes repository detection runs, such as a machine with no Git. */
61
+ readonly vcsProcess?: Layer.Layer<VcsProcess.VcsProcess>;
62
/** A git driver for failures real git cannot produce on demand. */
63
readonly git?: Layer.Layer<GitVcsDriver.GitVcsDriver>;
64
/** Wraps the real ProjectService, for failures it cannot produce on demand. */
@@ -81,7 +84,7 @@ const layer = (baseDir: string, options?: HarnessOptions) =>
84
Layer.provideMerge(RuntimeLayer.layerProjectService),
85
Layer.provideMerge(layerEnrichment),
86
Layer.provideMerge(WorkspacePaths.layer),
84
- Layer.provideMerge(layerGitWorkflow),
87
+ Layer.provideMerge(layerGitWorkflow(options?.vcsProcess)),
88
Layer.provideMerge(options?.git ?? layerRealGit),
89
Layer.provideMerge(SqlitePersistence.layerMemory),
90
Layer.provideMerge(ServerConfig.layerTest(baseDir, baseDir)),
@@ -145,6 +148,34 @@ it.effect("offers nothing when the data dir sits inside a Git checkout", () =>
148
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
149
);
150
151
+it.effect("offers a Scratch folder when Git is not installed", () =>
152
+ withScratch(
153
+ ({ baseDir }) =>
154
+ Effect.gen(function* () {
155
+ const path = yield* Path.Path;
156
+ assert.equal(yield* requireRoot, path.resolve(baseDir, "scratch"));
157
+ }),
158
+ {
159
+ vcsProcess: Layer.succeed(VcsProcess.VcsProcess, {
160
+ run: (input) =>
161
+ Effect.fail(
162
+ new VcsProcessSpawnError({
163
+ operation: input.operation,
164
+ command: input.command,
165
+ cwd: input.cwd,
166
+ cause: PlatformError.systemError({
167
+ _tag: "NotFound",
168
+ module: "ChildProcess",
169
+ method: "spawn",
170
+ syscall: `spawn ${input.command}`,
171
+ }),
172
+ }),
173
+ ),
174
+ }),
175
+ },
176
+ ),
177
+);
178
+
179
it.effect("creates one Scratch project, even for concurrent first requests", () =>
180
withScratch(() =>
181
Effect.gen(function* () {
apps/server/src/project/ManagedProjectFolders.ts
+19
-2
@@ -9,7 +9,13 @@
9
*
10
* @module ManagedProjectFolders
11
*/
12
-import { CommandId, ProjectId, type ThreadId } from "@t3tools/contracts";
12
+import {
13
+ CommandId,
14
+ type GitManagerServiceError,
15
+ ProjectId,
16
+ type ThreadId,
17
+ VcsProcessSpawnError,
18
+} from "@t3tools/contracts";
19
import { newProjectFolderName } from "@t3tools/shared/path";
20
import * as Cause from "effect/Cause";
21
import * as Context from "effect/Context";
@@ -220,6 +226,15 @@ function describeCommitFailure(stderr: string): string {
226
return lines.at(-1) ?? "Git could not make the first commit.";
227
}
228
229
+const isVcsProcessSpawnError = Schema.is(VcsProcessSpawnError);
230
+
231
+// Spawning a `git` that is not on PATH fails with NotFound, on Windows too.
232
+const isGitMissing = (error: GitManagerServiceError) =>
233
+ error._tag === "GitManagerError" &&
234
+ isVcsProcessSpawnError(error.cause) &&
235
+ PlatformError.isPlatformError(error.cause.cause) &&
236
+ error.cause.cause.reason._tag === "NotFound";
237
+
238
const make = Effect.gen(function* () {
239
const config = yield* ServerConfig.ServerConfig;
240
const fileSystem = yield* FileSystem.FileSystem;
@@ -258,11 +273,13 @@ const make = Effect.gen(function* () {
273
274
// Inside a checkout (a dev worktree's .t3, a dotfiles home) the folder would
275
// inherit the repo's git status and checkpoints, so Scratch is offered only
261
- // when the data dir is outside any work tree. Probed once; detection
276
+ // when the data dir is outside any work tree. With no Git installed nothing
277
+ // can see a checkout, so Scratch is offered. Probed once; other detection
278
// failures hide Scratch rather than failing callers. An interrupted probe
279
// invalidates the cache so the next caller probes again.
280
const [probe, invalidate] = yield* Effect.cachedInvalidateWithTTL(
281
gitWorkflow.isRepository(config.baseDir).pipe(
282
+ Effect.catchIf(isGitMissing, () => Effect.succeed(false)),
283
Effect.map((isRepository) =>
284
isRepository ? Option.none<string>() : Option.some(path.resolve(config.baseDir, "scratch")),
285
),