From dc8aeaa26c5467e90bf9398125a1b4d54bd3f021 Mon Sep 17 00:00:00 2001 From: Chris Scott Date: Sun, 14 Dec 2025 19:26:26 -0500 Subject: [PATCH] Show branch switcher for worktrees with view changes option --- .../src/components/repo/BranchSwitcher.tsx | 112 +++++++++++------- frontend/src/components/repo/RepoCard.tsx | 22 ++-- 2 files changed, 78 insertions(+), 56 deletions(-) diff --git a/frontend/src/components/repo/BranchSwitcher.tsx b/frontend/src/components/repo/BranchSwitcher.tsx index d5d52ca7..4a756c9b 100644 --- a/frontend/src/components/repo/BranchSwitcher.tsx +++ b/frontend/src/components/repo/BranchSwitcher.tsx @@ -60,10 +60,6 @@ export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl, rep }, }); - if (isWorktree) { - return null; - } - const isCurrentBranchInList = branches?.all?.includes(currentBranch) ?? false; const showLoading = switchBranchMutation.isPending || (branchesLoading && !isCurrentBranchInList); @@ -86,58 +82,86 @@ export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl, rep - {branchesLoading ? ( - - Loading branches... - - ) : branches?.all && branches.all.length > 0 ? ( - branches.all.map((branch: string) => ( - switchBranchMutation.mutate(branch)} - disabled={switchBranchMutation.isPending} - className="text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer" - > + {isWorktree ? ( + <> +
- {branch} - {branch === currentBranch && } + Worktree: {currentBranch}
- )) - ) : ( - - No branches available - - )} - - setGitChangesOpen(true)} - className="text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer" - > -
- - View Changes - {gitStatus?.hasChanges && ( - - {gitStatus.files.length} - - )} -
-
- {!isWorktree && repoUrl && ( - <> setAddBranchOpen(true)} + onClick={() => setGitChangesOpen(true)} className="text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer" >
- - Add Branch + + View Changes + {gitStatus?.hasChanges && ( + + {gitStatus.files.length} + + )}
+ ) : ( + <> + {branchesLoading ? ( + + Loading branches... + + ) : branches?.all && branches.all.length > 0 ? ( + branches.all.map((branch: string) => ( + switchBranchMutation.mutate(branch)} + disabled={switchBranchMutation.isPending} + className="text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer" + > +
+ + {branch} + {branch === currentBranch && } +
+
+ )) + ) : ( + + No branches available + + )} + + setGitChangesOpen(true)} + className="text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer" + > +
+ + View Changes + {gitStatus?.hasChanges && ( + + {gitStatus.files.length} + + )} +
+
+ {repoUrl && ( + <> + + setAddBranchOpen(true)} + className="text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer" + > +
+ + Add Branch +
+
+ + )} + )}
diff --git a/frontend/src/components/repo/RepoCard.tsx b/frontend/src/components/repo/RepoCard.tsx index 650d46f4..c52d033a 100644 --- a/frontend/src/components/repo/RepoCard.tsx +++ b/frontend/src/components/repo/RepoCard.tsx @@ -83,7 +83,7 @@ export function RepoCard({ - worktree + {branchToDisplay || "main"} )} {repo.cloneStatus === "cloning" && ( @@ -120,17 +120,15 @@ export function RepoCard({ Open - {!repo.isWorktree && ( - - )} +