import { useState } from "react"; import type { DirectiveWithSteps, DirectiveStatus } from "../../lib/api"; import { DirectiveDAG } from "./DirectiveDAG"; const STATUS_BADGE: Record = { draft: { color: "text-[#7788aa] border-[#2a3a5a]", label: "DRAFT" }, active: { color: "text-green-400 border-green-800", label: "ACTIVE" }, idle: { color: "text-yellow-400 border-yellow-800", label: "IDLE" }, paused: { color: "text-orange-400 border-orange-800", label: "PAUSED" }, archived: { color: "text-[#556677] border-[#2a3a5a]", label: "ARCHIVED" }, }; interface DirectiveDetailProps { directive: DirectiveWithSteps; onStart: () => void; onPause: () => void; onAdvance: () => void; onCompleteStep: (stepId: string) => void; onFailStep: (stepId: string) => void; onSkipStep: (stepId: string) => void; onUpdateGoal: (goal: string) => void; onDelete: () => void; onRefresh: () => void; } export function DirectiveDetail({ directive, onStart, onPause, onAdvance, onCompleteStep, onFailStep, onSkipStep, onUpdateGoal, onDelete, onRefresh, }: DirectiveDetailProps) { const [editingGoal, setEditingGoal] = useState(false); const [goalText, setGoalText] = useState(directive.goal); const badge = STATUS_BADGE[directive.status] || STATUS_BADGE.draft; const completedSteps = directive.steps.filter((s) => s.status === "completed").length; const totalSteps = directive.steps.length; const progress = totalSteps > 0 ? Math.round((completedSteps / totalSteps) * 100) : 0; const handleGoalSave = () => { if (goalText.trim() && goalText !== directive.goal) { onUpdateGoal(goalText.trim()); } setEditingGoal(false); }; return (
{/* Header */}

{directive.title}

{badge.label}
{/* Progress bar */} {totalSteps > 0 && (
{completedSteps}/{totalSteps} steps
)} {/* Repo info */} {(directive.repositoryUrl || directive.localPath) && (
{directive.repositoryUrl || directive.localPath} {directive.baseBranch && ` @ ${directive.baseBranch}`}
)} {/* Orchestrator planning indicator */} {directive.orchestratorTaskId && (
Planning in progress... View task
)} {/* Controls */}
{(directive.status === "draft" || directive.status === "paused") && ( )} {directive.status === "active" && ( <> )} {directive.status === "idle" && (
All steps done. Update goal to add new work.
)}
{/* Goal */}
Goal {!editingGoal && ( )}
{editingGoal ? (