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.

Merge origin/main and resolve PR status/sidebar conflicts

Julius Marmingefe86836b43db
diff --cc apps/server/src/gitManager.test.ts
index 67aaaf978,f2d399c8b..e1c089df8
--- a/apps/server/src/gitManager.test.ts
+++ b/apps/server/src/gitManager.test.ts
@@@ -190,81 -190,16 +190,81 @@@ describe("GitManager", () =>
const status = await manager.status({ cwd: repoDir });
expect(status.branch).toBe("feature/status-open-pr");
-- expect(status.openPr).toEqual({
++ expect(status.pr).toEqual({
number: 13,
title: "Existing PR",
url: "https://github.com/pingdotgg/codething-mvp/pull/13",
baseBranch: "main",
headBranch: "feature/status-open-pr",
++ state: "open",
+ });
- expect(status.mergedPr).toBeNull();
- expect(ghCalls.some((call) => call.includes("--state merged"))).toBe(false);
++ expect(ghCalls.some((call) => call.includes("--state all"))).toBe(true);
+ });
+
+ it("status includes merged PR metadata when there is no open PR", async () => {
+ const repoDir = makeTempDir("t3code-git-manager-");
+ await initRepo(repoDir);
+ await runGit(repoDir, ["checkout", "-b", "feature/status-merged-pr"]);
+ const remoteDir = await createBareRemote();
+ await runGit(repoDir, ["remote", "add", "origin", remoteDir]);
+ await runGit(repoDir, ["push", "-u", "origin", "feature/status-merged-pr"]);
+
+ const { runner, ghCalls } = createRunnerWithFakeGh({
+ prListSequence: [
- "[]",
+ JSON.stringify([
+ {
+ number: 26,
+ title: "Merged PR",
+ url: "https://github.com/pingdotgg/codething-mvp/pull/26",
+ baseRefName: "main",
+ headRefName: "feature/status-merged-pr",
++ state: "CLOSED",
++ mergedAt: "2026-02-14T10:00:00Z",
++ updatedAt: "2026-02-14T10:00:00Z",
+ },
+ ]),
+ ],
+ });
+
+ const manager = new GitManager({
+ runProcess: runner,
+ textGenerator: createTextGenerator(),
+ });
+
+ const status = await manager.status({ cwd: repoDir });
+ expect(status.branch).toBe("feature/status-merged-pr");
- expect(status.openPr).toBeNull();
- expect(status.mergedPr).toEqual({
++ expect(status.pr).toEqual({
+ number: 26,
+ title: "Merged PR",
+ url: "https://github.com/pingdotgg/codething-mvp/pull/26",
+ baseBranch: "main",
+ headBranch: "feature/status-merged-pr",
++ state: "merged",
});
- expect(ghCalls.some((call) => call.includes("--state merged"))).toBe(true);
++ expect(ghCalls.some((call) => call.includes("--state all"))).toBe(true);
+ });
+
- it("status skips open PR lookup for branches without upstream", async () => {
++ it("status checks all PR states for branches without upstream", async () => {
+ const repoDir = makeTempDir("t3code-git-manager-");
+ await initRepo(repoDir);
+ await runGit(repoDir, ["checkout", "-b", "feature/local-only"]);
+
+ const { runner, ghCalls } = createRunnerWithFakeGh({
+ prListSequence: ["[]"],
+ });
+
+ const manager = new GitManager({
+ runProcess: runner,
+ textGenerator: createTextGenerator(),
+ });
+
+ const status = await manager.status({ cwd: repoDir });
+ expect(status.branch).toBe("feature/local-only");
- expect(status.openPr).toBeNull();
- expect(status.mergedPr).toBeNull();
- expect(ghCalls.some((call) => call.includes("--state open"))).toBe(false);
- expect(ghCalls.some((call) => call.includes("--state merged"))).toBe(true);
++ expect(status.pr).toBeNull();
++ expect(ghCalls.some((call) => call.includes("--state all"))).toBe(true);
});
- it("status is resilient to gh lookup failures and returns openPr/mergedPr null", async () => {
- it("status is resilient to gh lookup failures and returns openPr null", async () => {
++ it("status is resilient to gh lookup failures and returns pr null", async () => {
const repoDir = makeTempDir("t3code-git-manager-");
await initRepo(repoDir);
await runGit(repoDir, ["checkout", "-b", "feature/status-no-gh"]);
@@@ -282,8 -217,7 +282,7 @@@
const status = await manager.status({ cwd: repoDir });
expect(status.branch).toBe("feature/status-no-gh");
-- expect(status.openPr).toBeNull();
- expect(status.mergedPr).toBeNull();
++ expect(status.pr).toBeNull();
});
it("creates a commit when working tree is dirty", async () => {
diff --cc apps/server/src/gitManager.ts
index d1ca7b0b5,a9d768951..8aaf52911
--- a/apps/server/src/gitManager.ts
+++ b/apps/server/src/gitManager.ts
@@@ -72,21 -65,6 +71,21 @@@ function parsePullRequestList(raw: unkn
) {
continue;
}
+
+ let normalizedState: GitStatusPrState;
+ if ((typeof mergedAt === "string" && mergedAt.trim().length > 0) || state === "MERGED") {
+ normalizedState = "merged";
- } else if (state === "OPEN") {
++ } else if (state === "OPEN" || state === undefined || state === null) {
+ normalizedState = "open";
+ } else if (state === "CLOSED") {
+ normalizedState = "closed";
+ } else {
+ continue;
+ }
+
+ const normalizedUpdatedAt =
+ typeof updatedAt === "string" && updatedAt.trim().length > 0 ? updatedAt : null;
+
parsed.push({
number,
title,
diff --cc apps/web/src/components/GitActionsControl.logic.test.ts
index feac3a689,b764fac27..ba8cbdad4
--- a/apps/web/src/components/GitActionsControl.logic.test.ts
+++ b/apps/web/src/components/GitActionsControl.logic.test.ts
@@@ -20,8 -20,7 +20,7 @@@ function status(overrides: Partial<GitS
hasUpstream: true,
aheadCount: 0,
behindCount: 0,
-- openPr: null,
- mergedPr: null,
++ pr: null,
...overrides,
};
}
@@@ -30,12 -29,12 +29,13 @@@ describe("when: branch is clean and ha
it("resolveQuickAction opens the existing PR", () => {
const quick = resolveQuickAction(
status({
-- openPr: {
++ pr: {
number: 10,
title: "Open PR",
url: "https://example.com/pr/10",
baseBranch: "main",
headBranch: "feature/test",
++ state: "open",
},
}),
false,
@@@ -46,12 -45,12 +46,13 @@@
it("buildMenuItems disables commit/push and enables open PR", () => {
const items = buildMenuItems(
status({
-- openPr: {
++ pr: {
number: 11,
title: "Existing PR",
url: "https://example.com/pr/11",
baseBranch: "main",
headBranch: "feature/test",
++ state: "open",
},
}),
false,
@@@ -148,12 -147,12 +149,13 @@@ describe("when: branch is clean, ahead
const quick = resolveQuickAction(
status({
aheadCount: 3,
-- openPr: {
++ pr: {
number: 13,
title: "Open PR",
url: "https://example.com/pr/13",
baseBranch: "main",
headBranch: "feature/test",
++ state: "open",
},
}),
false,
@@@ -165,12 -164,12 +167,13 @@@
const items = buildMenuItems(
status({
aheadCount: 2,
-- openPr: {
++ pr: {
number: 12,
title: "Existing PR",
url: "https://example.com/pr/12",
baseBranch: "main",
headBranch: "feature/test",
++ state: "open",
},
}),
false,
@@@ -205,7 -204,7 +208,7 @@@
describe("when: branch is clean, ahead, and has no open PR", () => {
it("resolveQuickAction pushes and creates a PR", () => {
-- const quick = resolveQuickAction(status({ aheadCount: 2, openPr: null }), false);
++ const quick = resolveQuickAction(status({ aheadCount: 2, pr: null }), false);
assert.deepInclude(quick, {
kind: "run_action",
action: "commit_push_pr",
@@@ -214,7 -213,7 +217,7 @@@
});
it("buildMenuItems enables push and create PR, with commit disabled", () => {
-- const items = buildMenuItems(status({ aheadCount: 2, openPr: null }), false);
++ const items = buildMenuItems(status({ aheadCount: 2, pr: null }), false);
assert.deepEqual(items, [
{
id: "commit",
@@@ -247,14 -246,14 +250,14 @@@
describe("when: branch is clean, up to date, and has no open PR", () => {
it("resolveQuickAction returns disabled no-action state", () => {
const quick = resolveQuickAction(
-- status({ aheadCount: 0, behindCount: 0, hasWorkingTreeChanges: false, openPr: null }),
++ status({ aheadCount: 0, behindCount: 0, hasWorkingTreeChanges: false, pr: null }),
false,
);
assert.deepInclude(quick, { kind: "show_hint", label: "Commit", disabled: true });
});
it("buildMenuItems disables commit, push, and create PR", () => {
-- const items = buildMenuItems(status({ aheadCount: 0, behindCount: 0, openPr: null }), false);
++ const items = buildMenuItems(status({ aheadCount: 0, behindCount: 0, pr: null }), false);
assert.deepEqual(items, [
{
id: "commit",
@@@ -291,7 -290,7 +294,7 @@@ describe("when: branch is behind upstre
});
it("buildMenuItems disables push and create PR", () => {
-- const items = buildMenuItems(status({ behindCount: 1, openPr: null }), false);
++ const items = buildMenuItems(status({ behindCount: 1, pr: null }), false);
assert.deepEqual(items, [
{
id: "commit",
@@@ -347,12 -346,12 +350,13 @@@ describe("when: working tree has local
const quick = resolveQuickAction(
status({
hasWorkingTreeChanges: true,
-- openPr: {
++ pr: {
number: 16,
title: "Existing PR",
url: "https://example.com/pr/16",
baseBranch: "main",
headBranch: "feature/test",
++ state: "open",
},
}),
false,
@@@ -412,7 -411,7 +416,7 @@@ describe("when: on default branch witho
it("resolveQuickAction returns push when branch is ahead", () => {
const quick = resolveQuickAction(
-- status({ branch: "main", aheadCount: 2, openPr: null }),
++ status({ branch: "main", aheadCount: 2, pr: null }),
false,
true,
);
@@@ -512,7 -511,7 +516,7 @@@ describe("when: HEAD is detached and th
describe("when: branch has no upstream configured", () => {
it("resolveQuickAction returns disabled commit state when clean and no commits are ahead", () => {
const quick = resolveQuickAction(
-- status({ hasUpstream: false, openPr: null, aheadCount: 0 }),
++ status({ hasUpstream: false, pr: null, aheadCount: 0 }),
false,
);
assert.deepInclude(quick, {
@@@ -527,12 -526,12 +531,13 @@@
status({
hasUpstream: false,
aheadCount: 0,
-- openPr: {
++ pr: {
number: 14,
title: "Existing PR",
url: "https://example.com/pr/14",
baseBranch: "main",
headBranch: "feature/test",
++ state: "open",
},
}),
false,
@@@ -549,12 -548,12 +554,13 @@@
status({
hasUpstream: false,
aheadCount: 1,
-- openPr: {
++ pr: {
number: 15,
title: "Existing PR",
url: "https://example.com/pr/15",
baseBranch: "main",
headBranch: "feature/test",
++ state: "open",
},
}),
false,
@@@ -569,7 -568,7 +575,7 @@@
it("buildMenuItems disables push and create PR when no commits are ahead", () => {
const items = buildMenuItems(
-- status({ hasUpstream: false, openPr: null, aheadCount: 0 }),
++ status({ hasUpstream: false, pr: null, aheadCount: 0 }),
false,
);
assert.deepEqual(items, [
diff --cc apps/web/src/components/GitActionsControl.logic.ts
index 50de7b6c5,50de7b6c5..44497f48f
--- a/apps/web/src/components/GitActionsControl.logic.ts
+++ b/apps/web/src/components/GitActionsControl.logic.ts
@@@ -108,7 -108,7 +108,7 @@@ export function buildMenuItems
const hasBranch = gitStatus.branch !== null;
const hasChanges = gitStatus.hasWorkingTreeChanges;
-- const hasOpenPr = gitStatus.openPr !== null;
++ const hasOpenPr = gitStatus.pr?.state === "open";
const isBehind = gitStatus.behindCount > 0;
const canCommit = !isBusy && hasChanges;
const canPush = !isBusy && hasBranch && !hasChanges && !isBehind && gitStatus.aheadCount > 0;
@@@ -178,7 -178,7 +178,7 @@@ export function resolveQuickAction
const hasBranch = gitStatus.branch !== null;
const hasChanges = gitStatus.hasWorkingTreeChanges;
-- const hasOpenPr = gitStatus.openPr !== null;
++ const hasOpenPr = gitStatus.pr?.state === "open";
const isAhead = gitStatus.aheadCount > 0;
const isBehind = gitStatus.behindCount > 0;
const isDiverged = isAhead && isBehind;
diff --cc apps/web/src/components/GitActionsControl.tsx
index 83c74e5f5,e30ff30df..438c0ac63
--- a/apps/web/src/components/GitActionsControl.tsx
+++ b/apps/web/src/components/GitActionsControl.tsx
@@@ -57,7 -57,7 +57,7 @@@ function getMenuActionDisabledReason
const hasBranch = gitStatus.branch !== null;
const hasChanges = gitStatus.hasWorkingTreeChanges;
-- const hasOpenPr = gitStatus.openPr !== null;
++ const hasOpenPr = gitStatus.pr?.state === "open";
const isAhead = gitStatus.aheadCount > 0;
const isBehind = gitStatus.behindCount > 0;
@@@ -217,7 -217,7 +217,7 @@@ export default function GitActionsContr
});
return;
}
-- const prUrl = gitStatusForActions?.openPr?.url ?? null;
++ const prUrl = gitStatusForActions?.pr?.state === "open" ? gitStatusForActions.pr.url : null;
if (!prUrl) {
toastManager.add({
type: "error",
@@@ -237,7 -237,7 +237,7 @@@
}),
});
void promise.catch(() => undefined);
-- }, [api, gitStatusForActions?.openPr?.url, threadToastData]);
++ }, [api, gitStatusForActions?.pr, threadToastData]);
const runGitActionWithToast = useCallback(
async ({
@@@ -297,7 -297,7 +297,9 @@@
stopProgressUpdates();
const resultToast = summarizeGitResult(result);
-- const prUrl = result.pr.url ?? gitStatusForActions?.openPr?.url;
++ const existingOpenPrUrl =
++ gitStatusForActions?.pr?.state === "open" ? gitStatusForActions.pr.url : undefined;
++ const prUrl = result.pr.url ?? existingOpenPrUrl;
const shouldOfferPushCta = action === "commit" && result.commit.status === "created";
const shouldOfferOpenPrCta =
(action === "commit_push" || action === "commit_push_pr") && !!prUrl && !isDefaultBranch;
@@@ -362,7 -365,7 +367,7 @@@
api,
gitStatusForActions?.branch,
gitStatusForActions?.hasWorkingTreeChanges,
-- gitStatusForActions?.openPr?.url,
++ gitStatusForActions?.pr,
isDefaultBranch,
maybeConfirmPushToDefaultBranch,
runImmediateGitActionMutation,
diff --cc apps/web/src/components/Sidebar.tsx
index 5f18ccb42,2c29a6da4..01bbcbafa
--- a/apps/web/src/components/Sidebar.tsx
+++ b/apps/web/src/components/Sidebar.tsx
@@@ -1,7 -1,7 +1,14 @@@
--import { MonitorIcon, MoonIcon, SunIcon, TerminalIcon } from "lucide-react";
++import {
++ GitPullRequestIcon,
++ MonitorIcon,
++ MoonIcon,
++ SunIcon,
++ TerminalIcon,
++} from "lucide-react";
import { useCallback, useEffect, useMemo, useState } from "react";
- import { useMutation, useQueries, useQueryClient } from "@tanstack/react-query";
+ import type { ResolvedKeybindingsConfig } from "@t3tools/contracts";
-import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
++import { useMutation, useQueries, useQuery, useQueryClient } from "@tanstack/react-query";
+import { gitStatusResultSchema, type GitStatusResult } from "@t3tools/contracts";
import { isElectron } from "../env";
import { useTheme } from "../hooks/useTheme";
import { DEFAULT_MODEL } from "../model-logic";
@@@ -14,7 -15,9 +22,9 @@@ import
type Thread,
} from "../types";
import { useNativeApi } from "../hooks/useNativeApi";
-import { gitRemoveWorktreeMutationOptions } from "../lib/gitReactQuery";
+import { gitRemoveWorktreeMutationOptions, gitStatusQueryOptions } from "../lib/gitReactQuery";
+ import { serverConfigQueryOptions } from "../lib/serverReactQuery";
+ import { toastManager } from "./ui/toast";
import { formatWorktreePathForDisplay, getOrphanedWorktreePathForThread } from "../worktreeCleanup";
const THEME_CYCLE = { system: "light", light: "dark", dark: "system" } as const;
@@@ -48,6 -53,6 +60,13 @@@ interface TerminalStatusIndicator
pulse: boolean;
}
++interface PrStatusIndicator {
++ label: "PR open" | "PR closed" | "PR merged";
++ colorClass: string;
++}
++
++type ThreadPrState = NonNullable<GitStatusResult["pr"]>["state"] | null;
++
function hasUnseenCompletion(thread: Thread): boolean {
if (!thread.latestTurnCompletedAt) return false;
const completedAt = Date.parse(thread.latestTurnCompletedAt);
@@@ -59,11 -64,7 +78,10 @@@
return completedAt > lastVisitedAt;
}
-function threadStatusPill(thread: Thread, hasPendingApprovals: boolean): ThreadStatusPill | null {
+function threadStatusPill(
+ thread: Thread,
+ hasPendingApprovals: boolean,
- hasMergedPr: boolean,
+): ThreadStatusPill | null {
if (hasPendingApprovals) {
return {
label: "Awaiting response",
@@@ -112,6 -104,6 +121,28 @@@
return null;
}
++function prStatusIndicator(prState: ThreadPrState): PrStatusIndicator | null {
++ if (prState === "open") {
++ return {
++ label: "PR open",
++ colorClass: "text-emerald-600 dark:text-emerald-300/90",
++ };
++ }
++ if (prState === "closed") {
++ return {
++ label: "PR closed",
++ colorClass: "text-zinc-500 dark:text-zinc-400/80",
++ };
++ }
++ if (prState === "merged") {
++ return {
++ label: "PR merged",
++ colorClass: "text-violet-600 dark:text-violet-300/90",
++ };
++ }
++ return null;
++}
++
function terminalStatusIndicator(thread: Thread): TerminalStatusIndicator | null {
if (thread.runningTerminalIds.length === 0) {
return null;
@@@ -140,65 -138,15 +177,71 @@@ export default function Sidebar()
}
return map;
}, [state.threads]);
+ const projectCwdById = useMemo(
+ () => new Map(state.projects.map((project) => [project.id, project.cwd] as const)),
+ [state.projects],
+ );
+ const threadGitTargets = useMemo(
+ () =>
+ state.threads.map((thread) => ({
+ threadId: thread.id,
+ branch: thread.branch,
+ cwd: thread.worktreePath ?? projectCwdById.get(thread.projectId) ?? null,
+ })),
+ [projectCwdById, state.threads],
+ );
+ const threadGitStatusCwds = useMemo(
+ () =>
+ [
+ ...new Set(
+ threadGitTargets
+ .filter((target) => target.branch !== null)
+ .map((target) => target.cwd)
+ .filter((cwd): cwd is string => cwd !== null),
+ ),
+ ],
+ [threadGitTargets],
+ );
+ const threadGitStatusQueries = useQueries({
+ queries: threadGitStatusCwds.map((cwd) => {
+ const base = gitStatusQueryOptions(api, cwd);
+ return {
+ ...base,
+ enabled: Boolean(base.enabled),
+ staleTime: 30_000,
+ refetchInterval: 60_000,
+ };
+ }),
+ });
- const mergedPrByThreadId = useMemo(() => {
++ const prStateByThreadId = useMemo(() => {
+ const statusByCwd = new Map<string, GitStatusResult>();
+ for (let index = 0; index < threadGitStatusCwds.length; index += 1) {
+ const cwd = threadGitStatusCwds[index];
+ if (!cwd) continue;
+ const parsed = gitStatusResultSchema.safeParse(threadGitStatusQueries[index]?.data);
+ if (parsed.success) {
+ statusByCwd.set(cwd, parsed.data);
+ }
+ }
+
- const map = new Map<string, boolean>();
++ const map = new Map<string, ThreadPrState>();
+ for (const target of threadGitTargets) {
+ const status = target.cwd ? statusByCwd.get(target.cwd) : undefined;
+ const branchMatches =
+ target.branch !== null && status?.branch !== null && status?.branch === target.branch;
- map.set(target.threadId, branchMatches && status?.openPr === null && status?.mergedPr !== null);
++ map.set(target.threadId, branchMatches ? status?.pr?.state ?? null : null);
+ }
+ return map;
+ }, [threadGitStatusCwds, threadGitStatusQueries, threadGitTargets]);
const handleNewThread = useCallback(
- (projectId: string) => {
+ (
+ projectId: string,
+ options?: {
+ branch?: string | null;
+ worktreePath?: string | null;
+ },
+ ) => {
dispatch({
type: "ADD_THREAD",
thread: {
@@@ -496,9 -499,8 +594,9 @@@
const threadStatus = threadStatusPill(
thread,
pendingApprovalByThreadId.get(thread.id) === true,
- mergedPrByThreadId.get(thread.id) === true,
);
const terminalStatus = terminalStatusIndicator(thread);
++ const prStatus = prStatusIndicator(prStateByThreadId.get(thread.id) ?? null);
return (
<button
key={thread.id}
@@@ -538,6 -540,6 +636,16 @@@
<span className="min-w-0 flex-1 truncate text-xs">{thread.title}</span>
</div>
<div className="ml-2 flex shrink-0 items-center gap-1.5">
++ {prStatus && (
++ <span
++ role="img"
++ aria-label={prStatus.label}
++ title={prStatus.label}
++ className={`inline-flex items-center justify-center ${prStatus.colorClass}`}
++ >
++ <GitPullRequestIcon className="size-3" />
++ </span>
++ )}
{terminalStatus && (
<span
role="img"