import { Plan } from "@vertesia/common"; import { AlertCircle, CheckCircle, Circle, Clock } from "lucide-react"; import { useUITranslation } from '../../../../i18n/index.js'; interface PlanPanelProps { plan: Plan; workstreamStatus: Map; isVisible: boolean; } // todo: remove this file export default function PlanPanel({ plan, workstreamStatus, isVisible }: PlanPanelProps) { const { t } = useUITranslation(); if (!isVisible) return null; return (
{t('agent.agentPlan')}
{/* Plan Steps */} {plan.plan && plan.plan.length > 0 ? (
{plan.plan.map((task, index) => { // Extract task info const taskId = task.id.toString(); const taskGoal = task.goal; // Determine task status - use task.status if available or lookup from workstream let status: "pending" | "in_progress" | "completed" | "skipped" = task.status || "pending"; if (workstreamStatus.has(taskId)) { status = workstreamStatus.get(taskId)!; } // Determine status icon and style let StatusIcon = Circle; let statusColor = "text-gray-400"; if (status === "in_progress") { StatusIcon = Clock; statusColor = "text-blue-500"; } else if (status === "completed") { StatusIcon = CheckCircle; statusColor = "text-green-500"; } return (
{taskGoal} {taskId}
); })}
) : (
{t('agent.noPlanDetected')}
)} {/* Workstream Status Summary */} {workstreamStatus.size > 1 && (
{t('agent.workstreams')}
{Array.from(workstreamStatus.entries()) // Filter to only show real workstreams (main or those with valid names - not numeric IDs) .filter(([id, _]) => { // Always show 'main' workstream if (id === "main") return true; // Don't show if it's a pure numeric ID (likely a task) if (/^\d+$/.test(id)) return false; // Don't show workstreams that are actually tasks (have matching IDs in plan) if (plan?.plan) { const matchingTask = plan.plan.find((task) => task.id?.toString() === id); return !matchingTask; // Keep if no matching task found } return true; }) .map(([id, status]) => { let StatusIcon = Circle; let statusColor = "text-gray-400"; let statusText = t('agent.pending'); if (status === "in_progress") { StatusIcon = Clock; statusColor = "text-blue-500"; statusText = t('agent.inProgress'); } else if (status === "completed") { StatusIcon = CheckCircle; statusColor = "text-green-500"; statusText = t('agent.completed'); } // Format workstream IDs for better display const displayId = id === "main" ? t('agent.main') : id; return (
{displayId} {statusText}
); })}
)}
); }