import { useState } from "react"; import type { PlanDisplayEntry } from "../../src/lib/types"; import type { PlanEntry, PlanEntryPriority, PlanEntryStatus } from "../../src/acp/types"; import { cn } from "../../src/lib/utils"; import { CheckCircle2, Loader2, Circle } from "lucide-react"; // ============================================================================= // Plan 展示组件 — 执行计划可视化 // ============================================================================= interface PlanDisplayProps { entry: PlanDisplayEntry; } export function PlanDisplay({ entry }: PlanDisplayProps) { const [collapsed, setCollapsed] = useState(false); const { entries } = entry; if (entries.length === 0) return null; const completed = entries.filter((e) => e.status === "completed").length; const total = entries.length; const percentage = total > 0 ? Math.round((completed / total) * 100) : 0; return (
{/* Header */} {/* Entry list */} {!collapsed && (
5 && "max-h-64 overflow-y-auto", )}> {entries.map((planEntry, i) => ( ))}
)}
); } // ============================================================================= // 单条 Plan 条目 // ============================================================================= function PlanEntryRow({ entry }: { entry: PlanEntry }) { return (
{entry.content}
); } // ============================================================================= // 状态图标 // ============================================================================= function StatusIcon({ status }: { status: PlanEntryStatus }) { switch (status) { case "completed": return ; case "in_progress": return ; case "pending": return ; } } // ============================================================================= // 优先级标签 // ============================================================================= function PriorityBadge({ priority }: { priority: PlanEntryPriority }) { const styles: Record = { high: "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300", medium: "bg-brand/10 text-brand dark:bg-brand/20", low: "bg-surface-1 text-text-muted", }; const labels: Record = { high: "高", medium: "中", low: "低", }; return ( {labels[priority]} ); }