import { useNavigate } from "react-router"; import type { DirectiveWithChains, StepContractSummary, ContractPhase, } from "../../lib/api"; import { PhaseProgressBarCompact } from "../contracts/PhaseProgressBar"; interface DirectiveContractsTabProps { directive: DirectiveWithChains; } const statusColors: Record = { active: "text-green-400", completed: "text-blue-400", archived: "text-[#555]", }; function ContractCard({ summary, label, }: { summary: StepContractSummary; label: string; }) { const navigate = useNavigate(); const progressPct = summary.taskCount > 0 ? Math.round((summary.tasksDone / summary.taskCount) * 100) : 0; return (
navigate(`/contracts/${summary.id}`)} >
{summary.name} {summary.contractType}
{summary.status}
{label}
{/* Task progress bar */}
{summary.tasksDone}/{summary.taskCount} tasks
); } export function DirectiveContractsTab({ directive, }: DirectiveContractsTabProps) { // Collect all contract summaries const contracts: { summary: StepContractSummary; label: string }[] = []; if (directive.orchestratorContractSummary) { contracts.push({ summary: directive.orchestratorContractSummary, label: "Planning", }); } for (const chain of directive.chains) { for (const step of chain.steps) { if (step.contractSummary) { contracts.push({ summary: step.contractSummary, label: step.name, }); } // Show monitoring/evaluation contracts if (step.monitoringContractId) { contracts.push({ summary: { id: step.monitoringContractId, name: `${step.name} - Evaluation`, contractType: "monitoring", status: step.status === "evaluating" ? "active" : "completed", phase: "plan", taskCount: 1, tasksDone: step.status === "evaluating" ? 0 : 1, tasksRunning: step.status === "evaluating" ? 1 : 0, tasksFailed: 0, }, label: `${step.name} eval`, }); } } } if (contracts.length === 0) { return (

{directive.status === "draft" ? "No contracts yet. Start the directive to begin planning." : directive.status === "planning" ? "Planning in progress... contracts will appear when steps are created." : "No contracts associated with this directive."}

); } return (
{contracts.map((c) => ( ))}
); }