import type { DragEvent } from 'react'; import { FolderOpen, MessageSquare, X } from 'lucide-react'; import type { Pane, PaneKind } from '@/api/types'; import { cn } from '@/lib/utils'; import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, } from '@/components/ui/context-menu'; interface Props { pane: Pane; isActive: boolean; onClick: () => void; onClose: () => void; onSplit: (kind: PaneKind) => void; onCloseOthers: () => void; onCloseToRight: () => void; onCloseAll: () => void; onDragStart: (e: DragEvent) => void; onDragOver: (e: DragEvent) => void; onDrop: (e: DragEvent) => void; } function basename(path: string): string { if (!path) return ''; const parts = path.split('/'); return parts[parts.length - 1] ?? path; } function labelFor(pane: Pane): string { if (pane.kind === 'chat') return 'Chat'; const openFile = pane.state.open_file; if (openFile) return basename(openFile); return 'Files'; } export function PaneTab({ pane, isActive, onClick, onClose, onSplit, onCloseOthers, onCloseToRight, onCloseAll, onDragStart, onDragOver, onDrop, }: Props) { const Icon = pane.kind === 'chat' ? MessageSquare : FolderOpen; const label = labelFor(pane); return (
{label}
Split onSplit('chat')}> Chat onSplit('file_browser')}> File Browser Close Close others Close to the right Close all
); }