Skip to content

Commit 69d9a65

Browse files
fix(git): hide stale merged/closed PRs on the default branch (#1966)
1 parent 9acf46a commit 69d9a65

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

apps/server/src/git/Layers/GitManager.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,36 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
11881188
}),
11891189
);
11901190

1191+
it.effect("status hides merged PRs on the default branch", () =>
1192+
Effect.gen(function* () {
1193+
const repoDir = yield* makeTempDir("t3code-git-manager-");
1194+
yield* initRepo(repoDir);
1195+
1196+
const { manager } = yield* makeManager({
1197+
ghScenario: {
1198+
prListSequence: [
1199+
JSON.stringify([
1200+
{
1201+
number: 23,
1202+
title: "Merged PR",
1203+
url: "https://github.com/pingdotgg/codething-mvp/pull/23",
1204+
baseRefName: "feature/status-default-branch-target",
1205+
headRefName: "main",
1206+
state: "MERGED",
1207+
mergedAt: "2026-01-30T10:00:00Z",
1208+
updatedAt: "2026-01-30T10:00:00Z",
1209+
},
1210+
]),
1211+
],
1212+
},
1213+
});
1214+
1215+
const status = yield* manager.status({ cwd: repoDir });
1216+
expect(status.branch).toBe("main");
1217+
expect(status.pr).toBeNull();
1218+
}),
1219+
);
1220+
11911221
it.effect("status prefers open PR when merged PR has newer updatedAt", () =>
11921222
Effect.gen(function* () {
11931223
const repoDir = yield* makeTempDir("t3code-git-manager-");

apps/server/src/git/Layers/GitManager.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,13 @@ export const makeGitManager = Effect.fn("makeGitManager")(function* () {
688688
branch: details.branch,
689689
upstreamRef: details.upstreamRef,
690690
}).pipe(
691-
Effect.map((latest) => (latest ? toStatusPr(latest) : null)),
691+
Effect.map((latest) => {
692+
if (!latest) return null;
693+
// On the default branch, only surface open PRs.
694+
// Merged/closed matches are usually reverse-merge history, not the thread's PR context.
695+
if (details.isDefaultBranch && latest.state !== "open") return null;
696+
return toStatusPr(latest);
697+
}),
692698
Effect.catch(() => Effect.succeed(null)),
693699
)
694700
: null;

0 commit comments

Comments
 (0)