@devries-cameron20 / t3code Mirror · read-only / commits / cb6670b01d
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, 14:45 UTC

fix(server): a timed-out Git check no longer turns off threads without a project until restart (#36704)

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

Juan committed Nov 14, 2026 at 09:34 UTC cb6670b01d2d1ecbaa6c0fa7e47c20e1ad67af29
2 files changed +55 -8
apps/server/src/project/ManagedProjectFolders.test.ts
+45 -1
@@ -1,7 +1,13 @@
1 import { assert, it } from "@effect/vitest";
2 import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
3 import * as NodeServices from "@effect/platform-node/NodeServices";
4 -import { CommandId, ProjectId, ThreadId, VcsProcessSpawnError } from "@t3tools/contracts";
4 +import {
5 + CommandId,
6 + ProjectId,
7 + ThreadId,
8 + VcsProcessSpawnError,
9 + VcsProcessTimeoutError,
10 +} from "@t3tools/contracts";
11 import * as HostProcess from "@t3tools/shared/HostProcess";
12 import * as Deferred from "effect/Deferred";
13 import * as Effect from "effect/Effect";
@@ -174,6 +180,44 @@ it.effect("offers a Scratch folder when Git is not installed", () =>
180 ),
181 );
182
183 +it.effect("offers the Scratch folder once a Git check that timed out is asked again", () =>
184 + withScratch(
185 + ({ baseDir }) =>
186 + Effect.gen(function* () {
187 + const path = yield* Path.Path;
188 + const scratch = yield* ManagedProjectFolders.ManagedProjectFolders;
189 + assert.isTrue(Option.isNone(yield* scratch.scratchRoot));
190 + assert.equal(yield* requireRoot, path.resolve(baseDir, "scratch"));
191 + }),
192 + {
193 + vcsProcess: Layer.effect(
194 + VcsProcess.VcsProcess,
195 + Effect.map(VcsProcess.make, (real) => {
196 + let timedOut = false;
197 + return VcsProcess.VcsProcess.of({
198 + run: (input) =>
199 + Effect.suspend(() => {
200 + if (timedOut) return real.run(input);
201 + timedOut = true;
202 + return Effect.fail(
203 + new VcsProcessTimeoutError({
204 + operation: input.operation,
205 + command: input.command,
206 + cwd: input.cwd,
207 + timeoutMs: 5_000,
208 + }),
209 + );
210 + }),
211 + });
212 + }),
213 + ).pipe(
214 + Layer.provide(ProcessRunner.layer),
215 + Layer.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)),
216 + ),
217 + },
218 + ),
219 +);
220 +
221 it.effect("creates one Scratch project, even for concurrent first requests", () =>
222 withScratch(() =>
223 Effect.gen(function* () {
apps/server/src/project/ManagedProjectFolders.ts
+10 -7
@@ -268,15 +268,18 @@ const make = Effect.gen(function* () {
268 return Effect.logWarning(unavailable.message).pipe(Effect.as(Result.fail(unavailable)));
269 },
270 ),
271 - Effect.catchCause((cause) =>
272 - Cause.hasInterrupts(cause)
273 - ? Effect.interrupt
274 - : Effect.succeed(Result.fail(new ScratchUnavailableError({ baseDir: config.baseDir }))),
275 - ),
271 ),
277 - Duration.infinity,
272 + // A failed git check (say, a timeout on a busy machine) is not an answer; ask again next time.
273 + Exit.match({ onSuccess: () => Duration.infinity, onFailure: () => Duration.zero }),
274 + );
275 + const scratchProbe = probe.pipe(
276 + Effect.catchCause((cause) =>
277 + Cause.hasInterrupts(cause)
278 + ? Effect.interrupt
279 + : Effect.succeed(Result.fail(new ScratchUnavailableError({ baseDir: config.baseDir }))),
280 + ),
281 + Effect.onInterrupt(() => invalidate),
282 );
279 - const scratchProbe = probe.pipe(Effect.onInterrupt(() => invalidate));
283 // A symlinked scratch folder lets the No project live at either the link or its target.
284 const scratchProjectRoot = (root: string) =>
285 fileSystem.realPath(root).pipe(