From dcf19fbd45db0697043fa85377ab93cf57faee6e Mon Sep 17 00:00:00 2001 From: Cody Seibert Date: Fri, 19 Dec 2025 23:45:54 -0500 Subject: [PATCH] refactor: clean up and improve readability in WorktreePanel component - Simplified the formatting of dropdown open change handlers for better readability. - Updated the label from "Branch:" to "Worktrees:" for clarity. - Enhanced conditional checks for removed worktrees to improve code structure. --- .../worktree-panel/worktree-panel.tsx | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/apps/ui/src/components/views/board-view/worktree-panel/worktree-panel.tsx b/apps/ui/src/components/views/board-view/worktree-panel/worktree-panel.tsx index a941f696..e50f1e59 100644 --- a/apps/ui/src/components/views/board-view/worktree-panel/worktree-panel.tsx +++ b/apps/ui/src/components/views/board-view/worktree-panel/worktree-panel.tsx @@ -1,4 +1,3 @@ - import { Button } from "@/components/ui/button"; import { GitBranch, Plus, RefreshCw } from "lucide-react"; import { cn, pathsEqual } from "@/lib/utils"; @@ -88,18 +87,20 @@ export function WorktreePanel({ : pathsEqual(worktree.path, currentWorktreePath); }; - const handleBranchDropdownOpenChange = (worktree: WorktreeInfo) => (open: boolean) => { - if (open) { - fetchBranches(worktree.path); - resetBranchFilter(); - } - }; + const handleBranchDropdownOpenChange = + (worktree: WorktreeInfo) => (open: boolean) => { + if (open) { + fetchBranches(worktree.path); + resetBranchFilter(); + } + }; - const handleActionsDropdownOpenChange = (worktree: WorktreeInfo) => (open: boolean) => { - if (open) { - fetchBranches(worktree.path); - } - }; + const handleActionsDropdownOpenChange = + (worktree: WorktreeInfo) => (open: boolean) => { + if (open) { + fetchBranches(worktree.path); + } + }; if (!useWorktreesEnabled) { return null; @@ -108,7 +109,7 @@ export function WorktreePanel({ return (
- Branch: + Worktrees:
{worktrees.map((worktree) => { @@ -137,8 +138,12 @@ export function WorktreePanel({ aheadCount={aheadCount} behindCount={behindCount} onSelectWorktree={handleSelectWorktree} - onBranchDropdownOpenChange={handleBranchDropdownOpenChange(worktree)} - onActionsDropdownOpenChange={handleActionsDropdownOpenChange(worktree)} + onBranchDropdownOpenChange={handleBranchDropdownOpenChange( + worktree + )} + onActionsDropdownOpenChange={handleActionsDropdownOpenChange( + worktree + )} onBranchFilterChange={setBranchFilter} onSwitchBranch={handleSwitchBranch} onCreateBranch={onCreateBranch} @@ -172,7 +177,11 @@ export function WorktreePanel({ className="h-7 w-7 p-0 text-muted-foreground hover:text-foreground" onClick={async () => { const removedWorktrees = await fetchWorktrees(); - if (removedWorktrees && removedWorktrees.length > 0 && onRemovedWorktrees) { + if ( + removedWorktrees && + removedWorktrees.length > 0 && + onRemovedWorktrees + ) { onRemovedWorktrees(removedWorktrees); } }}