Reorder branch switcher dropdown: view changes and add branch at top, scrollable branch list below

This commit is contained in:
Chris Scott committed 2025-12-27 18:19:57 -05:00
1 parent f22bd67128
commit ee99bb65fc
1 file changed
+28 -26
+28 -26
View File
@@ -83,7 +83,7 @@ export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl, rep
{!iconOnly && <span className="truncate">{activeBranch}</span>}
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent sideOffset={0} align="end" className="bg-card border-border min-w-[200px] max-w-[95vw] sm:max-w-none max-h-[70vh] overflow-y-auto">
<DropdownMenuContent sideOffset={0} align="end" className="bg-card border-border min-w-[200px] max-w-[95vw] sm:max-w-none">
{isWorktree ? (
<>
<DropdownMenuItem disabled className="text-muted-foreground">
@@ -110,31 +110,6 @@ export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl, rep
</>
) : (
<>
{branchesLoading && !branches ? (
<DropdownMenuItem disabled className="text-muted-foreground">
Loading branches...
</DropdownMenuItem>
) : branches?.all && branches.all.length > 0 ? (
branches.all.map((branch: string) => (
<DropdownMenuItem
key={branch}
onClick={() => switchBranchMutation.mutate(branch)}
disabled={switchBranchMutation.isPending}
className="text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer"
>
<div className="flex items-center gap-2 w-full">
<GitBranch className="w-3 h-3" />
<span className="flex-1">{branch}</span>
{branch === activeBranch && <Check className="w-3 h-3 text-green-500" />}
</div>
</DropdownMenuItem>
))
) : (
<DropdownMenuItem disabled className="text-muted-foreground">
No branches available
</DropdownMenuItem>
)}
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={() => setGitChangesOpen(true)}
className="text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer"
@@ -163,6 +138,33 @@ export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl, rep
</DropdownMenuItem>
</>
)}
<DropdownMenuSeparator />
<div className="max-h-[60vh] overflow-y-auto w-full">
{branchesLoading && !branches ? (
<DropdownMenuItem disabled className="text-muted-foreground">
Loading branches...
</DropdownMenuItem>
) : branches?.all && branches.all.length > 0 ? (
branches.all.map((branch: string) => (
<DropdownMenuItem
key={branch}
onClick={() => switchBranchMutation.mutate(branch)}
disabled={switchBranchMutation.isPending}
className="text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer"
>
<div className="flex items-center gap-2 w-full">
<GitBranch className="w-3 h-3" />
<span className="flex-1">{branch}</span>
{branch === activeBranch && <Check className="w-3 h-3 text-green-500" />}
</div>
</DropdownMenuItem>
))
) : (
<DropdownMenuItem disabled className="text-muted-foreground">
No branches available
</DropdownMenuItem>
)}
</div>
</>
)}
</DropdownMenuContent>