Add branch switch to mobile worktree panel

This commit is contained in:
anonymous
2026-01-12 00:56:36 -08:00
committed by Shirone
parent d1222268c3
commit 74c793b6c6
2 changed files with 34 additions and 6 deletions

View File

@@ -20,6 +20,8 @@ interface BranchSwitchDropdownProps {
branchFilter: string;
isLoadingBranches: boolean;
isSwitching: boolean;
/** When true, renders as a standalone button (not attached to another element) */
standalone?: boolean;
onOpenChange: (open: boolean) => void;
onFilterChange: (value: string) => void;
onSwitchBranch: (worktree: WorktreeInfo, branchName: string) => void;
@@ -33,6 +35,7 @@ export function BranchSwitchDropdown({
branchFilter,
isLoadingBranches,
isSwitching,
standalone = false,
onOpenChange,
onFilterChange,
onSwitchBranch,
@@ -42,16 +45,18 @@ export function BranchSwitchDropdown({
<DropdownMenu onOpenChange={onOpenChange}>
<DropdownMenuTrigger asChild>
<Button
variant={isSelected ? 'default' : 'outline'}
variant={standalone ? 'outline' : isSelected ? 'default' : 'outline'}
size="sm"
className={cn(
'h-7 w-7 p-0 rounded-none border-r-0',
isSelected && 'bg-primary text-primary-foreground',
!isSelected && 'bg-secondary/50 hover:bg-secondary'
'h-7 w-7 p-0',
!standalone && 'rounded-none border-r-0',
standalone && 'h-8 w-8 shrink-0',
!standalone && isSelected && 'bg-primary text-primary-foreground',
!standalone && !isSelected && 'bg-secondary/50 hover:bg-secondary'
)}
title="Switch branch"
>
<GitBranch className="w-3 h-3" />
<GitBranch className={standalone ? 'w-3.5 h-3.5' : 'w-3 h-3'} />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start" className="w-64">

View File

@@ -13,7 +13,12 @@ import {
useWorktreeActions,
useRunningFeatures,
} from './hooks';
import { WorktreeTab, WorktreeMobileDropdown, WorktreeActionsDropdown } from './components';
import {
WorktreeTab,
WorktreeMobileDropdown,
WorktreeActionsDropdown,
BranchSwitchDropdown,
} from './components';
export function WorktreePanel({
projectPath,
@@ -186,6 +191,24 @@ export function WorktreePanel({
onSelectWorktree={handleSelectWorktree}
/>
{/* Branch switch dropdown for the selected worktree */}
{selectedWorktree && (
<BranchSwitchDropdown
worktree={selectedWorktree}
isSelected={true}
standalone={true}
branches={branches}
filteredBranches={filteredBranches}
branchFilter={branchFilter}
isLoadingBranches={isLoadingBranches}
isSwitching={isSwitching}
onOpenChange={handleBranchDropdownOpenChange(selectedWorktree)}
onFilterChange={setBranchFilter}
onSwitchBranch={handleSwitchBranch}
onCreateBranch={onCreateBranch}
/>
)}
{/* Actions menu for the selected worktree */}
{selectedWorktree && (
<WorktreeActionsDropdown