"use client"; import { useState } from "react"; import { GitBranchListResponse, BranchType } from "@/types/git"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Skeleton } from "@/components/ui/skeleton"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, DialogTrigger, } from "@/components/ui/dialog"; import { GitBranch, Check, Cloud, Plus, RefreshCw } from "lucide-react"; import { HelpTip } from "@/components/ui/help-tip"; interface GitBranchPanelProps { branches: GitBranchListResponse | undefined; isLoading: boolean; onCheckout: (branch: string) => void; onCreateBranch: (branchType: BranchType, taskId: string) => void; isCheckingOut: boolean; isCreating: boolean; } export function GitBranchPanel({ branches, isLoading, onCheckout, onCreateBranch, isCheckingOut, isCreating, }: GitBranchPanelProps) { const [showCreateDialog, setShowCreateDialog] = useState(false); const [newBranchType, setNewBranchType] = useState("feature"); const [taskId, setTaskId] = useState(""); const handleCreateBranch = () => { if (taskId.trim()) { onCreateBranch(newBranchType, taskId.trim()); setShowCreateDialog(false); setTaskId(""); } }; if (isLoading) { return ( {Array.from({ length: 5 }).map((_, i) => ( ))} ); } if (!branches) { return (

No branches available

); } const localBranches = branches.branches.filter((b) => !b.is_remote); const remoteBranches = branches.branches.filter((b) => b.is_remote); return ( Branches Create Task Branch
setTaskId(e.target.value)} />
{/* Local Branches */}

Local ({localBranches.length})

{localBranches.map((branch) => ( ))}
{/* Remote Branches */} {remoteBranches.length > 0 && (

Remote ({remoteBranches.length})

{remoteBranches.map((branch) => ( ))}
)}
); }