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, 04:30 UTC
test(server): AgentSessionScanner blocked-repo test no longer races the git-read timeout (#30554)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 4, 2026 at 11:42 UTC
62db6623cb30ed32968fc9ee0db1ea5355f9b39a
1 file changed
+37
-2
apps/server/src/project/AgentSessionScanner.test.ts
+37
-2
@@ -22,11 +22,13 @@ import * as FileSystem from "effect/FileSystem";
22
import * as Layer from "effect/Layer";
23
import * as Option from "effect/Option";
24
import * as Path from "effect/Path";
25
+import * as Queue from "effect/Queue";
26
import * as Schema from "effect/Schema";
27
import * as Stream from "effect/Stream";
28
import * as TestClock from "effect/testing/TestClock";
29
30
import * as ServerConfig from "../config.ts";
31
+import * as ProcessRunner from "../processRunner.ts";
32
import * as ProjectStore from "../orchestration-v2/ProjectStore.ts";
33
import * as ServerSettings from "../serverSettings.ts";
34
import * as AgentSessionScanner from "./AgentSessionScanner.ts";
@@ -56,10 +58,16 @@ interface ScannerTestInput {
58
readonly importedWorkspaceRoots?: ReadonlyArray<string>;
59
readonly configBaseDir?: string;
60
readonly providerInstances?: ContractServerSettings["providerInstances"];
61
+ readonly processRunner?: Layer.Layer<ProcessRunner.ProcessRunner>;
62
}
63
64
const layerScannerTest = (input: ScannerTestInput) =>
62
- AgentSessionScanner.layer.pipe(
65
+ (input.processRunner === undefined
66
+ ? AgentSessionScanner.layer
67
+ : Layer.effect(AgentSessionScanner.AgentSessionScanner, AgentSessionScanner.make).pipe(
68
+ Layer.provide(input.processRunner),
69
+ )
70
+ ).pipe(
71
Layer.provide(
72
Layer.mergeAll(
73
ServerSettings.layerTest({
@@ -1959,11 +1967,38 @@ describe.skipIf(HostProcess.Platform.defaultValue() === "win32")(
1967
});
1968
}
1969
1970
+ // The deadline fires for every read still in flight, so on a slow runner the
1971
+ // neighbours' `cat` children must have exited before the clock moves.
1972
+ const neighbourConfigs = new Set(
1973
+ [repos[0], repos[2]].map((repo) => path.join(repo, ".git", "config")),
1974
+ );
1975
+ const finishedNeighbourReads = yield* Queue.unbounded<string>();
1976
+ const processRunner = Layer.effect(
1977
+ ProcessRunner.ProcessRunner,
1978
+ Effect.gen(function* () {
1979
+ const runner = yield* ProcessRunner.ProcessRunner;
1980
+ return ProcessRunner.ProcessRunner.of({
1981
+ run: (input) => {
1982
+ const filePath = input.args.at(-1) ?? "";
1983
+ return neighbourConfigs.has(filePath)
1984
+ ? runner
1985
+ .run(input)
1986
+ .pipe(Effect.ensuring(Queue.offer(finishedNeighbourReads, filePath)))
1987
+ : runner.run(input);
1988
+ },
1989
+ });
1990
+ }),
1991
+ ).pipe(Layer.provide(ProcessRunner.layer), Layer.provide(NodeServices.layer));
1992
+
1993
for (let attempt = 1; attempt <= 2; attempt++) {
1963
- const scan = yield* Effect.forkChild(runScan({ claudeHomePath, codexHomePath }));
1994
+ const scan = yield* Effect.forkChild(
1995
+ runScan({ claudeHomePath, codexHomePath, processRunner }),
1996
+ );
1997
const result = yield* Effect.scoped(
1998
Effect.gen(function* () {
1999
yield* awaitGateReader(path.join(repos[1], ".git", "config"));
2000
+ yield* Queue.take(finishedNeighbourReads);
2001
+ yield* Queue.take(finishedNeighbourReads);
2002
yield* TestClock.adjust("2 seconds");
2003
return yield* Fiber.join(scan);
2004
}),