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.
Skip local-branch PR checks and dedupe sidebar git status
Julius Marmingedcdb9ac92320
diff --git a/apps/server/src/gitManager.test.ts b/apps/server/src/gitManager.test.tsindex 961f74fb9..67aaaf978 100644--- a/apps/server/src/gitManager.test.ts+++ b/apps/server/src/gitManager.test.ts@@ -242,6 +242,28 @@ describe("GitManager", () => {expect(ghCalls.some((call) => call.includes("--state merged"))).toBe(true);});+ it("status skips open PR lookup 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);+ });+it("status is resilient to gh lookup failures and returns openPr/mergedPr null", async () => {const repoDir = makeTempDir("t3code-git-manager-");await initRepo(repoDir);diff --git a/apps/server/src/gitManager.ts b/apps/server/src/gitManager.tsindex d163b8ee9..c8668d1cb 100644--- a/apps/server/src/gitManager.ts+++ b/apps/server/src/gitManager.ts@@ -195,10 +195,13 @@ export class GitManager {let mergedPr: ReturnType<typeof toStatusOpenPr> | null = null;if (details.branch) {try {- const existing = await this.findOpenPr(input.cwd, details.branch);- if (existing) {- openPr = toStatusOpenPr(existing);- } else {+ if (details.hasUpstream) {+ const existing = await this.findOpenPr(input.cwd, details.branch);+ if (existing) {+ openPr = toStatusOpenPr(existing);+ }+ }+ if (!openPr) {const merged = await this.findMergedPr(input.cwd, details.branch);if (merged) {mergedPr = toStatusOpenPr(merged);diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsxindex a0bd90740..5f18ccb42 100644--- a/apps/web/src/components/Sidebar.tsx+++ b/apps/web/src/components/Sidebar.tsx@@ -1,7 +1,7 @@import { MonitorIcon, MoonIcon, SunIcon, TerminalIcon } from "lucide-react";import { useCallback, useEffect, useMemo, useState } from "react";import { useMutation, useQueries, useQueryClient } from "@tanstack/react-query";-import type { GitStatusResult } from "@t3tools/contracts";+import { gitStatusResultSchema, type GitStatusResult } from "@t3tools/contracts";import { isElectron } from "../env";import { useTheme } from "../hooks/useTheme";import { DEFAULT_MODEL } from "../model-logic";@@ -153,29 +153,49 @@ export default function Sidebar() {})),[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: threadGitTargets.map((target) => {- const base = gitStatusQueryOptions(api, target.cwd);+ queries: threadGitStatusCwds.map((cwd) => {+ const base = gitStatusQueryOptions(api, cwd);return {...base,- enabled: Boolean(base.enabled && target.branch !== null),+ enabled: Boolean(base.enabled),staleTime: 30_000,refetchInterval: 60_000,};}),});const mergedPrByThreadId = 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>();- for (let index = 0; index < threadGitTargets.length; index += 1) {- const target = threadGitTargets[index];- if (!target) continue;- const status = threadGitStatusQueries[index]?.data as GitStatusResult | undefined;+ 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);}return map;- }, [threadGitStatusQueries, threadGitTargets]);+ }, [threadGitStatusCwds, threadGitStatusQueries, threadGitTargets]);const handleNewThread = useCallback((projectId: string) => {