import { useState } from "react"; import { Button } from "./Button"; interface PlanStep { id: string; title: string; description: string; files: string[]; estimatedTokens?: string; riskLevel?: "low" | "medium" | "high"; } interface PlanViewProps { steps: PlanStep[]; onApprove: () => void; onReject: () => void; onEditStep?: (stepId: string, description: string) => void; } export function PlanView({ steps, onApprove, onReject, onEditStep, }: PlanViewProps) { const [expandedStep, setExpandedStep] = useState( steps[0]?.id ?? null, ); const [editingStep, setEditingStep] = useState(null); const [editText, setEditText] = useState(""); const totalFiles = new Set(steps.flatMap((s) => s.files)).size; const highRiskCount = steps.filter((s) => s.riskLevel === "high").length; const handleEditStart = (step: PlanStep) => { setEditingStep(step.id); setEditText(step.description); }; const handleEditSave = (stepId: string) => { onEditStep?.(stepId, editText); setEditingStep(null); }; return (
{/* Plan header */}

Plan

{steps.length} step{steps.length > 1 ? "s" : ""} · {totalFiles}{" "} file{totalFiles > 1 ? "s" : ""} {highRiskCount > 0 && ` · ${highRiskCount} high-risk`}

{/* Stats row */}
0 ? "⚠ High" : "✓ Low"} />
{/* Steps */}
{steps.map((step, idx) => (
{/* Step header */} {/* Expanded content */} {expandedStep === step.id && (
{editingStep === step.id ? (