import { useMemo } from "react"; import { Briefcase, Robot } from "../ui/icons"; import type { AgentRecord, RunRecord, TaskRecord } from "@shared/types"; interface KanbanProps { tasks: TaskRecord[]; agents: AgentRecord[]; runs: RunRecord[]; onSelectTask: (taskId: string) => void; } const KANBAN_COLUMNS: Array<{ status: TaskRecord["status"]; label: string; tone: string; dotColor: string }> = [ { status: "backlog", label: "Backlog", tone: "text-muted-foreground", dotColor: "bg-[color:var(--muted-foreground)]" }, { status: "todo", label: "Todo", tone: "text-warning", dotColor: "bg-warning" }, { status: "in_progress", label: "In Progress", tone: "text-primary", dotColor: "bg-primary" }, { status: "in_review", label: "In Review", tone: "text-warning", dotColor: "bg-warning" }, { status: "done", label: "Done", tone: "text-success", dotColor: "bg-success" }, { status: "blocked", label: "Blocked", tone: "text-destructive", dotColor: "bg-destructive" }, ]; const priorityColors: Record = { critical: "border-l-[color:var(--destructive)]", high: "border-l-[color:var(--destructive)]", medium: "border-l-[color:var(--primary)]", low: "border-l-[color:var(--muted-foreground)]", }; export function KanbanBoard({ tasks, agents, runs, onSelectTask }: KanbanProps) { const tasksByStatus = useMemo(() => { const grouped: Record = {}; for (const col of KANBAN_COLUMNS) grouped[col.status] = []; for (const task of tasks) { if (task.status === "cancelled") continue; const bucket = grouped[task.status]; if (bucket) bucket.push(task); else grouped.backlog?.push(task); } const priorityOrder = { critical: 0, high: 1, medium: 2, low: 3 }; for (const col of Object.values(grouped)) { col.sort((a, b) => (priorityOrder[a.priority] ?? 9) - (priorityOrder[b.priority] ?? 9)); } return grouped; }, [tasks]); if (tasks.length === 0) { return (
No tasks yet
Tasks created by agents will appear here on the board
); } return (
{KANBAN_COLUMNS.map((col) => { const colTasks = tasksByStatus[col.status] ?? []; return (
{colTasks.map((task) => { const assignee = agents.find((a) => a.id === task.assigneeAgentId); const activeRun = runs.find((r) => r.id === task.activeRunId); const isRunning = activeRun?.status === "running"; return ( ); })}
); })}
); }