Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

fix(server): detect repositories after initialization (#4848)

Wout Stiensd19039aeef69
diff --git a/apps/server/src/vcs/VcsDriverRegistry.test.ts b/apps/server/src/vcs/VcsDriverRegistry.test.ts
index 7a531a5ad..0ad2450eb 100644
--- a/apps/server/src/vcs/VcsDriverRegistry.test.ts
+++ b/apps/server/src/vcs/VcsDriverRegistry.test.ts
@@ -92,4 +92,49 @@ describe("VcsDriverRegistry", () => {
);
}).pipe(Effect.provide(layer));
});
+
+ it.effect("detects a repository created after a negative lookup", () => {
+ let insideWorkTreeChecks = 0;
+ const layer = Layer.effect(VcsDriverRegistry.VcsDriverRegistry, VcsDriverRegistry.make).pipe(
+ Layer.provide(NodeServices.layer),
+ Layer.provide(
+ Layer.mock(VcsProjectConfig.VcsProjectConfig)({
+ resolveKind: (input) => Effect.succeed(input.requestedKind ?? "auto"),
+ }),
+ ),
+ Layer.provide(
+ Layer.mock(VcsProcess.VcsProcess)({
+ run: (input) =>
+ Effect.sync(() => {
+ const command = normalizeGitArgs(input.args).join(" ");
+ if (command === "rev-parse --is-inside-work-tree") {
+ insideWorkTreeChecks += 1;
+ return insideWorkTreeChecks === 1
+ ? {
+ ...processOutput(""),
+ exitCode: ChildProcessSpawner.ExitCode(128),
+ stderr: "fatal: not a git repository",
+ }
+ : processOutput("true\n");
+ }
+ if (command === "rev-parse --show-toplevel") {
+ return processOutput("/repo\n");
+ }
+ if (command === "rev-parse --git-common-dir") {
+ return processOutput("/repo/.git\n");
+ }
+ return processOutput("");
+ }),
+ }),
+ ),
+ );
+
+ return Effect.gen(function* () {
+ const registry = yield* VcsDriverRegistry.VcsDriverRegistry;
+
+ assert.equal(yield* registry.detect({ cwd: "/repo" }), null);
+ assert.equal((yield* registry.detect({ cwd: "/repo" }))?.repository.rootPath, "/repo");
+ assert.equal(insideWorkTreeChecks, 2);
+ }).pipe(Effect.provide(layer));
+ });
});
diff --git a/apps/server/src/vcs/VcsDriverRegistry.ts b/apps/server/src/vcs/VcsDriverRegistry.ts
index 0bf95c2ff..f40e1dade 100644
--- a/apps/server/src/vcs/VcsDriverRegistry.ts
+++ b/apps/server/src/vcs/VcsDriverRegistry.ts
@@ -115,7 +115,10 @@ export const make = Effect.gen(function* () {
(key) => detectResolvedKind(parseDetectionCacheKey(key)),
{
capacity: DETECTION_CACHE_CAPACITY,
- timeToLive: (exit) => (Exit.isSuccess(exit) ? DETECTION_CACHE_TTL : Duration.zero),
+ timeToLive: Exit.match({
+ onSuccess: (detected) => (detected === null ? Duration.zero : DETECTION_CACHE_TTL),
+ onFailure: () => Duration.zero,
+ }),
},
);