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, 07:00 UTC
fix(server): treat a repository's only non-origin remote as its primary remote (#22119)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: GPT-6.1 Sol <noreply@openai.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Victor Vogel committed
Nov 1, 2026 at 15:56 UTC
93d110abd111f46431db3b34bd8c94dbd5e673f1
2 files changed
+28
-21
apps/server/src/vcs/GitVcsDriverCore.test.ts
+15
-13
@@ -314,22 +314,24 @@ it.effect.each(["root", "nested", "worktree"] as const)(
314
}).pipe(Effect.provide(layerTest)),
315
);
316
317
-it.effect("invalidates origin remote cache when a driver mutation adds origin", () =>
318
- Effect.gen(function* () {
319
- const driver = yield* GitVcsDriver.GitVcsDriver;
320
- const cwd = yield* makeTmpDir();
321
- const remote = yield* makeTmpDir("git-vcs-driver-remote-");
322
- yield* initRepoWithCommit(cwd);
323
- yield* git(remote, ["init", "--bare"]);
317
+it.effect.each(["origin", "github"] as const)(
318
+ "recognizes %s as the primary remote after a driver mutation",
319
+ (remoteName) =>
320
+ Effect.gen(function* () {
321
+ const driver = yield* GitVcsDriver.GitVcsDriver;
322
+ const cwd = yield* makeTmpDir();
323
+ const remote = yield* makeTmpDir("git-vcs-driver-remote-");
324
+ yield* initRepoWithCommit(cwd);
325
+ yield* git(remote, ["init", "--bare"]);
326
325
- const before = yield* driver.statusDetailsLocal(cwd);
326
- assert.equal(before.hasOriginRemote, false);
327
+ assert.equal((yield* driver.statusDetailsLocal(cwd)).hasOriginRemote, false);
328
+ assert.equal((yield* driver.listRefs({ cwd })).hasPrimaryRemote, false);
329
328
- yield* driver.ensureRemote({ cwd, preferredName: "origin", url: remote });
330
+ yield* driver.ensureRemote({ cwd, preferredName: remoteName, url: remote });
331
330
- const after = yield* driver.statusDetailsLocal(cwd);
331
- assert.equal(after.hasOriginRemote, true);
332
- }).pipe(Effect.provide(layerTest)),
332
+ assert.equal((yield* driver.statusDetailsLocal(cwd)).hasOriginRemote, true);
333
+ assert.equal((yield* driver.listRefs({ cwd })).hasPrimaryRemote, true);
334
+ }).pipe(Effect.provide(layerTest)),
335
);
336
337
it.effect.each([
apps/server/src/vcs/GitVcsDriverCore.ts
+13
-8
@@ -1551,18 +1551,18 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
1551
}),
1552
},
1553
);
1554
- const originExistsCache = yield* Cache.makeWith(
1554
+ const primaryRemoteExistsCache = yield* Cache.makeWith(
1555
(gitCommonDir: string) =>
1556
Effect.gen(function* () {
1557
const path = yield* Path.Path;
1558
const fetchCwd =
1559
path.basename(gitCommonDir) === ".git" ? path.dirname(gitCommonDir) : gitCommonDir;
1560
return yield* executeGit(
1561
- "GitVcsDriver.statusDetails.originExists",
1561
+ "GitVcsDriver.statusDetails.primaryRemoteExists",
1562
fetchCwd,
1563
- ["--git-dir", gitCommonDir, "remote", "get-url", "origin"],
1563
+ ["--git-dir", gitCommonDir, "remote"],
1564
{ allowNonZeroExit: true },
1565
- ).pipe(Effect.map((result) => result.exitCode === 0));
1565
+ ).pipe(Effect.map((result) => result.exitCode === 0 && result.stdout.trim().length > 0));
1566
}),
1567
{
1568
capacity: 2_048,
@@ -1582,7 +1582,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
1582
: gitCommonDir;
1583
const cacheKey = commonDir ?? normalizeRepositoryPathsCacheKey(cwd);
1584
yield* Cache.invalidate(defaultBranchCache, cacheKey);
1585
- yield* Cache.invalidate(originExistsCache, cacheKey);
1585
+ yield* Cache.invalidate(primaryRemoteExistsCache, cacheKey);
1586
},
1587
);
1588
@@ -2196,8 +2196,13 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
2196
? Cache.get(defaultBranchCache, statusCacheKey).pipe(Effect.orElseSucceed(() => null))
2197
: resolveDefaultBranchName(cwd, "origin").pipe(Effect.orElseSucceed(() => null)),
2198
statusCacheKey
2199
- ? Cache.get(originExistsCache, statusCacheKey).pipe(Effect.orElseSucceed(() => false))
2200
- : originRemoteExists(cwd).pipe(Effect.orElseSucceed(() => false)),
2199
+ ? Cache.get(primaryRemoteExistsCache, statusCacheKey).pipe(
2200
+ Effect.orElseSucceed(() => false),
2201
+ )
2202
+ : listRemoteNames(cwd).pipe(
2203
+ Effect.map((remoteNames) => remoteNames.length > 0),
2204
+ Effect.orElseSucceed(() => false),
2205
+ ),
2206
],
2207
{ concurrency: "unbounded" },
2208
);
@@ -3939,7 +3944,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
3944
return {
3945
localBranches: localBranches.toSorted(byRecencyThenName).map(({ ref }) => ref),
3946
remoteBranches: remoteBranches.toSorted(byRecencyThenName).map(({ ref }) => ref),
3942
- hasPrimaryRemote: remoteNames.includes("origin"),
3947
+ hasPrimaryRemote: remoteNames.length > 0,
3948
} satisfies GitRefsSnapshot;
3949
});
3950