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.
Enrich branches with worktree paths, fix toolbar display, and improve HMR config
Julius Marminge8324949b54c9
diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.tsindex de9e839fd..eada6aae7 100644--- a/apps/desktop/src/main.ts+++ b/apps/desktop/src/main.ts@@ -186,6 +186,7 @@ function createWindow(): BrowserWindow {if (isDevelopment) {void window.loadURL(process.env.VITE_DEV_SERVER_URL as string);+ window.webContents.openDevTools({ mode: "detach" });} else {if (!fs.existsSync(WEB_ENTRY)) {throw new Error(`Web bundle missing at ${WEB_ENTRY}`);diff --git a/apps/server/src/git.ts b/apps/server/src/git.tsindex 59fb1b694..718cf7e47 100644--- a/apps/server/src/git.ts+++ b/apps/server/src/git.ts@@ -123,19 +123,41 @@ export async function listGitBranches(input: GitListBranchesInput): Promise<GitL}// Resolve the real default branch from the remote- const defaultRef = await runGit(["symbolic-ref", "refs/remotes/origin/HEAD"], input.cwd, 5_000);+ const [defaultRef, worktreeList] = await Promise.all([+ runGit(["symbolic-ref", "refs/remotes/origin/HEAD"], input.cwd, 5_000),+ runGit(["worktree", "list", "--porcelain"], input.cwd, 5_000),+ ]);const defaultBranch =defaultRef.code === 0 ? defaultRef.stdout.trim().replace(/^refs\/remotes\/origin\//, "") : null;+ // Build branch-name → worktree-path map from porcelain output.+ const worktreeMap = new Map<string, string>();+ if (worktreeList.code === 0) {+ let currentPath: string | null = null;+ for (const line of worktreeList.stdout.split("\n")) {+ if (line.startsWith("worktree ")) {+ currentPath = line.slice("worktree ".length);+ } else if (line.startsWith("branch refs/heads/") && currentPath) {+ worktreeMap.set(line.slice("branch refs/heads/".length), currentPath);+ } else if (line === "") {+ currentPath = null;+ }+ }+ }+const branches = result.stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0)- .map((line) => ({- name: line.replace(/^[*+]\s+/, ""),- current: line.startsWith("* "),- isDefault: line.replace(/^[*+]\s+/, "") === defaultBranch,- }))+ .map((line) => {+ const name = line.replace(/^[*+]\s+/, "");+ return {+ name,+ current: line.startsWith("* "),+ isDefault: name === defaultBranch,+ worktreePath: worktreeMap.get(name) ?? null,+ };+ }).toSorted((a, b) => {if (a.current !== b.current) return a.current ? -1 : 1;if (a.isDefault !== b.isDefault) return a.isDefault ? -1 : 1;diff --git a/apps/web/src/components/BranchToolbar.tsx b/apps/web/src/components/BranchToolbar.tsxindex aed876f20..f28aacac6 100644--- a/apps/web/src/components/BranchToolbar.tsx+++ b/apps/web/src/components/BranchToolbar.tsx@@ -122,6 +122,17 @@ export default function BranchToolbar({ envMode, onEnvModeChange, envLocked }: Breturn;}+ // If the branch already lives in a secondary worktree, point the thread+ // there instead of trying to checkout (which git would reject).+ // Ignore the main worktree (project cwd) — that's just a normal local checkout.+ const isSecondaryWorktree = branch.worktreePath && branch.worktreePath !== activeProject?.cwd;+ if (isSecondaryWorktree) {+ setThreadError(null);+ setThreadBranch(branch.name, branch.worktreePath);+ setIsBranchMenuOpen(false);+ return;+ }+checkoutMutation.mutate(branch.name, {onSuccess: () => {setThreadError(null);@@ -150,9 +161,9 @@ export default function BranchToolbar({ envMode, onEnvModeChange, envLocked }: Breturn (<div className="mx-auto flex w-full max-w-3xl items-center justify-between px-5 pb-3 pt-1"><div className="flex items-center gap-2">- {envLocked ? (+ {envLocked || activeWorktreePath ? (<span className="inline-flex items-center gap-1.5 px-1 text-[12px] text-muted-foreground/55">- {activeThread.worktreePath ? "Worktree" : "Local"}+ {activeWorktreePath ? "Worktree" : "Local"}</span>) : (<button@@ -188,7 +199,7 @@ export default function BranchToolbar({ envMode, onEnvModeChange, envLocked }: B><span className="max-w-[240px] truncate font-mono">{activeThread.branch- ? envMode === "worktree" && !envLocked+ ? envMode === "worktree" && !activeWorktreePath? `From ${activeThread.branch}`: activeThread.branch: "Select branch"}@@ -218,6 +229,8 @@ export default function BranchToolbar({ envMode, onEnvModeChange, envLocked }: B<div className="max-h-64 overflow-y-auto">{branches.map((branch) => {const isSelected = branch.name === activeThread.branch;+ const hasSecondaryWorktree =+ branch.worktreePath && branch.worktreePath !== activeProject.cwd;return (<buttonkey={branch.name}@@ -230,9 +243,9 @@ export default function BranchToolbar({ envMode, onEnvModeChange, envLocked }: BonClick={() => selectBranch(branch)}><span className="truncate">{branch.name}</span>- {(branch.current || branch.isDefault) && (+ {(branch.current || branch.isDefault || hasSecondaryWorktree) && (<span className="shrink-0 text-[10px] text-muted-foreground/45">- {branch.current ? "current" : "default"}+ {branch.current ? "current" : hasSecondaryWorktree ? "worktree" : "default"}</span>)}</button>diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.tsindex f65e60321..34f6a3f63 100644--- a/apps/web/vite.config.ts+++ b/apps/web/vite.config.ts@@ -2,6 +2,8 @@ import tailwindcss from "@tailwindcss/vite";import react from "@vitejs/plugin-react";import { defineConfig } from "vite";+const port = Number(process.env.PORT ?? 5173);+export default defineConfig({plugins: [react({@@ -16,8 +18,15 @@ export default defineConfig({"import.meta.env.VITE_WS_URL": JSON.stringify(process.env.VITE_WS_URL ?? ""),},server: {- port: Number(process.env.PORT ?? 5173),+ port,strictPort: true,+ hmr: {+ // Explicit config so Vite's HMR WebSocket connects reliably+ // inside Electron's BrowserWindow. Vite 8 uses console.debug for+ // connection logs — enable "Verbose" in DevTools to see them.+ protocol: "ws",+ host: "localhost",+ },},build: {outDir: "dist",diff --git a/packages/contracts/src/git.ts b/packages/contracts/src/git.tsindex be5d568c2..e53a600c5 100644--- a/packages/contracts/src/git.ts+++ b/packages/contracts/src/git.ts@@ -40,6 +40,7 @@ export const gitBranchSchema = z.object({name: z.string().min(1),current: z.boolean(),isDefault: z.boolean(),+ worktreePath: z.string().min(1).nullable(),});export const gitWorktreeSchema = z.object({