"use client"; import { Fragment, memo, useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { IconArrowBigRightLines, IconCheck, IconChevronDown, IconLogicBuffer, } from "@tabler/icons-react"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@kandev/ui/tooltip"; import { Popover, PopoverContent, PopoverTrigger } from "@kandev/ui/popover"; import { Button } from "@kandev/ui/button"; import { Drawer, DrawerContent, DrawerDescription, DrawerHeader, DrawerTitle, DrawerTrigger, } from "@kandev/ui/drawer"; import { useTouchDrawer } from "@/hooks/use-compact-task-chrome"; import type { WorkflowSnapshotData } from "@/lib/state/slices/kanban/types"; import type { AgentProfileOption } from "@/lib/state/slices"; import { AgentLogo } from "@/components/agent-logo"; import type { TaskCreateLaunchPreview } from "@/components/task-create-dialog-launch-preview"; type StepItem = { id: string; title: string; color: string; position: number; agent_profile_id?: string; is_start_step?: boolean; }; function InlineSteps({ steps, agentProfiles, }: { steps: StepItem[]; agentProfiles: AgentProfileOption[]; }) { const { t } = useTranslation(); if (steps.length === 0) return null; return (
{steps.map((s, i) => { const stepProfile = s.agent_profile_id ? agentProfiles.find((p) => p.id === s.agent_profile_id) : null; return ( {i > 0 && {"\u2192"}} {s.title} {s.is_start_step && ( * {t("workflows:startStep")} )} {stepProfile && ( {stepProfile.label} )} ); })}
); } type WorkflowSelectorRowProps = { workflows: Array<{ id: string; name: string; description?: string | null; agent_profile_id?: string; }>; snapshots: Record; selectedWorkflowId: string | null; onWorkflowChange: (workflowId: string) => void; agentProfiles: AgentProfileOption[]; launchPreview?: TaskCreateLaunchPreview | null; clearLabel?: string; placeholder?: string; }; function WorkflowSelectorTrigger({ selectedWorkflow, placeholder, }: { selectedWorkflow: WorkflowSelectorRowProps["workflows"][number] | undefined; placeholder?: string; }) { const { t } = useTranslation(); return ( ); } function LaunchDestinationInfo() { const { t } = useTranslation(); const usesTouchDrawer = useTouchDrawer(); const [drawerOpen, setDrawerOpen] = useState(false); const label = t("task:launchDestinationHelpLabel"); const description = t("task:launchDestinationHelp"); const trigger = ( ); if (usesTouchDrawer) { return ( {trigger} {label} {description} ); } return ( {trigger} {description} ); } function LaunchDestinationLabel({ stepName }: { stepName: string }) { return ( {stepName} ); } export const WorkflowSelectorRow = memo(function WorkflowSelectorRow({ workflows, snapshots, selectedWorkflowId, onWorkflowChange, agentProfiles, launchPreview, clearLabel, placeholder, }: WorkflowSelectorRowProps) { const { t } = useTranslation(); const [open, setOpen] = useState(false); const selectedWorkflow = useMemo( () => workflows.find((w) => w.id === selectedWorkflowId), [workflows, selectedWorkflowId], ); return (
{launchPreview && ( <> )}
{t("workflows:workflow")}
{clearLabel ? ( ) : null} {workflows.map((wf) => { const isSelected = wf.id === selectedWorkflowId; const snapshot = snapshots[wf.id]; const steps = snapshot ? [...snapshot.steps].sort((a, b) => a.position - b.position) : []; return ( ); })}
); });