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(git): hide stale merged/closed PRs on the default branch (#1966)

Guilherme Vieira69d9a659a36e
diff --git a/apps/server/src/git/Layers/GitManager.test.ts b/apps/server/src/git/Layers/GitManager.test.ts
index fd991273d..b8eeb5418 100644
--- a/apps/server/src/git/Layers/GitManager.test.ts
+++ b/apps/server/src/git/Layers/GitManager.test.ts
@@ -1188,6 +1188,36 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
}),
);
+ it.effect("status hides merged PRs on the default branch", () =>
+ Effect.gen(function* () {
+ const repoDir = yield* makeTempDir("t3code-git-manager-");
+ yield* initRepo(repoDir);
+
+ const { manager } = yield* makeManager({
+ ghScenario: {
+ prListSequence: [
+ JSON.stringify([
+ {
+ number: 23,
+ title: "Merged PR",
+ url: "https://github.com/pingdotgg/codething-mvp/pull/23",
+ baseRefName: "feature/status-default-branch-target",
+ headRefName: "main",
+ state: "MERGED",
+ mergedAt: "2026-01-30T10:00:00Z",
+ updatedAt: "2026-01-30T10:00:00Z",
+ },
+ ]),
+ ],
+ },
+ });
+
+ const status = yield* manager.status({ cwd: repoDir });
+ expect(status.branch).toBe("main");
+ expect(status.pr).toBeNull();
+ }),
+ );
+
it.effect("status prefers open PR when merged PR has newer updatedAt", () =>
Effect.gen(function* () {
const repoDir = yield* makeTempDir("t3code-git-manager-");
diff --git a/apps/server/src/git/Layers/GitManager.ts b/apps/server/src/git/Layers/GitManager.ts
index dadf2f7e7..21f3411d1 100644
--- a/apps/server/src/git/Layers/GitManager.ts
+++ b/apps/server/src/git/Layers/GitManager.ts
@@ -688,7 +688,13 @@ export const makeGitManager = Effect.fn("makeGitManager")(function* () {
branch: details.branch,
upstreamRef: details.upstreamRef,
}).pipe(
- Effect.map((latest) => (latest ? toStatusPr(latest) : null)),
+ Effect.map((latest) => {
+ if (!latest) return null;
+ // On the default branch, only surface open PRs.
+ // Merged/closed matches are usually reverse-merge history, not the thread's PR context.
+ if (details.isDefaultBranch && latest.state !== "open") return null;
+ return toStatusPr(latest);
+ }),
Effect.catch(() => Effect.succeed(null)),
)
: null;