import { useMemo, useState } from "react"; import { ChevronDown, FolderGit2, FolderRoot } from "lucide-react"; import type { WorkspaceInfo } from "../hooks/useWorkspaces"; import "./WorkspaceSelector.css"; interface WorkspaceSelectorProps { currentWorkspace: string; projectName: string; workspaces: WorkspaceInfo[]; onSelect: (workspace: string) => void; } function truncateTitle(title?: string, maxLength = 44): string | undefined { if (!title) return undefined; if (title.length <= maxLength) return title; return `${title.slice(0, maxLength - 1)}…`; } export function WorkspaceSelector({ currentWorkspace, projectName, workspaces, onSelect, }: WorkspaceSelectorProps) { const [open, setOpen] = useState(false); const currentLabel = useMemo(() => { if (currentWorkspace === "project") { return projectName || "Project Root"; } const match = workspaces.find((workspace) => workspace.id === currentWorkspace); return match?.label ?? currentWorkspace; }, [currentWorkspace, projectName, workspaces]); return (
{open && (
{workspaces.length > 0 && (
Task Worktrees
{workspaces.map((workspace) => ( ))}
)}
)}
); }