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

View File

@@ -13,7 +13,12 @@ import {
useWorktreeActions, useWorktreeActions,
useRunningFeatures, useRunningFeatures,
} from './hooks'; } from './hooks';
import { WorktreeTab, WorktreeMobileDropdown, WorktreeActionsDropdown } from './components'; import {
WorktreeTab,
WorktreeMobileDropdown,
WorktreeActionsDropdown,
BranchSwitchDropdown,
} from './components';
export function WorktreePanel({ export function WorktreePanel({
projectPath, projectPath,
@@ -186,6 +191,24 @@ export function WorktreePanel({
onSelectWorktree={handleSelectWorktree} 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 */} {/* Actions menu for the selected worktree */}
{selectedWorktree && ( {selectedWorktree && (
<WorktreeActionsDropdown <WorktreeActionsDropdown