The best way to control Claude Code, Codex and more from any computer or phone
fix(server): a branch tracking another local branch no longer shows that branch's PR (#30563)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
MarcoDotIO committed
Nov 5, 2026 at 23:31 UTC
9bf7dcd92d930f923061f9beebc0d525b1333268
2 files changed
+72
-7
apps/server/src/git/GitManager.test.ts
+56
@@ -2574,6 +2574,62 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
2574
}),
2575
);
2576
2577
+ it.effect("branch PR lookup ignores the PR of a local branch the branch tracks", () =>
2578
+ Effect.gen(function* () {
2579
+ const repoDir = yield* makeTempDir("t3code-git-manager-");
2580
+ yield* initRepo(repoDir);
2581
+ const remoteDir = yield* createBareRemote();
2582
+ yield* runGit(repoDir, ["remote", "add", "origin", remoteDir]);
2583
+ yield* runGit(repoDir, ["push", "-u", "origin", "main"]);
2584
+ yield* runGit(repoDir, ["remote", "set-head", "origin", "main"]);
2585
+ yield* runGit(repoDir, ["checkout", "-b", "develop"]);
2586
+ yield* runGit(repoDir, ["push", "-u", "origin", "develop"]);
2587
+ // `--track` from a local branch, or `branch.autoSetupMerge=always`, records remote ".".
2588
+ yield* runGit(repoDir, ["checkout", "-b", "feature/local-base", "--track", "develop"]);
2589
+
2590
+ const { manager, providerCalls } = yield* makeManager({
2591
+ providerScenario: {
2592
+ prListByHeadSelector: {
2593
+ develop: [
2594
+ {
2595
+ number: 61,
2596
+ title: "Release develop",
2597
+ url: "https://github.com/pingdotgg/codething-mvp/pull/61",
2598
+ baseRefName: "main",
2599
+ headRefName: "develop",
2600
+ state: "open",
2601
+ updatedAt: "2026-05-01T10:00:00Z",
2602
+ },
2603
+ ],
2604
+ // Someone else's branch of the same name; this one was never pushed.
2605
+ "feature/local-base": [
2606
+ {
2607
+ number: 62,
2608
+ title: "Another local base",
2609
+ url: "https://github.com/pingdotgg/codething-mvp/pull/62",
2610
+ baseRefName: "main",
2611
+ headRefName: "feature/local-base",
2612
+ state: "open",
2613
+ updatedAt: "2026-05-01T10:00:00Z",
2614
+ },
2615
+ ],
2616
+ },
2617
+ },
2618
+ });
2619
+
2620
+ const status = yield* manager.status({ cwd: repoDir });
2621
+ expect(status.refName).toBe("feature/local-base");
2622
+ expect(status.pr).toBeNull();
2623
+ expect(listedSelectors(providerCalls).includes("develop")).toBe(false);
2624
+
2625
+ const branchPullRequest = yield* manager.branchPullRequest({
2626
+ cwd: repoDir,
2627
+ branch: "feature/local-base",
2628
+ });
2629
+ expect(branchPullRequest).toBeNull();
2630
+ }),
2631
+ );
2632
+
2633
it.effect("status finds a PR pushed under the branch's own name despite a default upstream", () =>
2634
Effect.gen(function* () {
2635
const repoDir = yield* makeTempDir("t3code-git-manager-");
apps/server/src/git/GitManager.ts
+16
-7
@@ -558,6 +558,11 @@ function parseCustomCommitMessage(raw: string): { subject: string; body: string
558
};
559
}
560
561
+// A branch remote of "." tracks another local branch, which no change request can have as its head.
562
+function publishedRemoteName(branchRemote: string | null): string | null {
563
+ return branchRemote === "." ? null : branchRemote;
564
+}
565
+
566
function headBranchProbe(
567
provider: SourceControlProvider.SourceControlProvider["Service"],
568
headSelectors: ReadonlyArray<string>,
@@ -1238,7 +1243,7 @@ export const make = Effect.gen(function* () {
1243
}
1244
if (
1245
details.localBranchExists &&
1241
- details.upstreamRef === null &&
1246
+ (details.upstreamRef === null || headContext.remoteName === null) &&
1247
(yield* isUnpublishedBranch(cwd, headContext))
1248
) {
1249
return { latest: null, headContext };
@@ -1557,12 +1562,14 @@ export const make = Effect.gen(function* () {
1562
cwd: string,
1563
details: { branch: string; upstreamRef: string | null; remoteName?: string },
1564
) {
1560
- const remoteName =
1565
+ const branchRemote =
1566
details.remoteName ??
1567
(yield* readConfigValueNullable(cwd, `branch.${details.branch}.remote`));
1563
- const headBranchFromUpstream = details.upstreamRef
1564
- ? extractBranchNameFromRemoteRef(details.upstreamRef, { remoteName })
1565
- : "";
1568
+ const remoteName = publishedRemoteName(branchRemote);
1569
+ const headBranchFromUpstream =
1570
+ details.upstreamRef && branchRemote !== "."
1571
+ ? extractBranchNameFromRemoteRef(details.upstreamRef, { remoteName })
1572
+ : "";
1573
const headBranch = headBranchFromUpstream.length > 0 ? headBranchFromUpstream : details.branch;
1574
const shouldProbeLocalBranchSelector =
1575
headBranchFromUpstream.length === 0 || headBranch === details.branch;
@@ -1843,7 +1850,7 @@ export const make = Effect.gen(function* () {
1850
],
1851
{ concurrency: "unbounded" },
1852
);
1846
- if (configuredRemote !== null && configuredMerge !== null) {
1853
+ if (configuredRemote !== null && configuredRemote !== "." && configuredMerge !== null) {
1854
return false;
1855
}
1856
@@ -2494,7 +2501,9 @@ export const make = Effect.gen(function* () {
2501
remoteUrl ? sourceControlDefinitions.repositoryKeyFromRemote(remoteUrl) : null,
2502
),
2503
);
2497
- const remoteName = remoteNameOverride ?? (yield* readConfig(`branch.${branch}.remote`));
2504
+ const remoteName = publishedRemoteName(
2505
+ remoteNameOverride ?? (yield* readConfig(`branch.${branch}.remote`)),
2506
+ );
2507
const [headRemoteUrlKey, targetRemoteUrlKey] =
2508
remoteName === "origin"
2509
? yield* readRemoteUrlKey("origin").pipe(Effect.map((key) => [key, key] as const))