From 8f757f561eeb397aaea70d7c10d41445cc5e50b5 Mon Sep 17 00:00:00 2001 From: soryu Date: Sat, 7 Feb 2026 16:58:38 +0000 Subject: Show directive init on frontend --- .../src/components/directives/DirectiveDetail.tsx | 180 ++++++++++++++++++--- 1 file changed, 156 insertions(+), 24 deletions(-) (limited to 'makima/frontend/src/components/directives/DirectiveDetail.tsx') diff --git a/makima/frontend/src/components/directives/DirectiveDetail.tsx b/makima/frontend/src/components/directives/DirectiveDetail.tsx index e519b92..094cdf2 100644 --- a/makima/frontend/src/components/directives/DirectiveDetail.tsx +++ b/makima/frontend/src/components/directives/DirectiveDetail.tsx @@ -1,14 +1,19 @@ +import { useEffect, useRef } from "react"; +import { useNavigate } from "react-router"; import type { DirectiveWithChains, DirectiveStatus, - DirectiveChain, + ChainWithSteps, + ChainStep, } from "../../lib/api"; +import { getDirective } from "../../lib/api"; interface DirectiveDetailProps { directive: DirectiveWithChains; onBack: () => void; onDelete?: (id: string) => void; onStart?: (id: string) => void; + onRefresh?: (updated: DirectiveWithChains) => void; } const statusColors: Record = { @@ -21,31 +26,93 @@ const statusColors: Record = { failed: "text-red-400", }; -function ChainCard({ chain }: { chain: DirectiveChain }) { +const stepStatusColors: Record = { + pending: "text-[#888]", + running: "text-yellow-400", + passed: "text-green-400", + failed: "text-red-400", +}; + +const stepStatusIcons: Record = { + pending: "\u25CB", // ○ + running: "\u25D4", // ◔ + passed: "\u25CF", // ● + failed: "\u2715", // ✕ +}; + +function StepRow({ step }: { step: ChainStep }) { + const navigate = useNavigate(); + const color = stepStatusColors[step.status] || "text-[#888]"; + const icon = stepStatusIcons[step.status] || "\u25CB"; + return ( -
-
- {chain.name} - - gen {chain.generation} · {chain.status} - +
+ {icon} +
+
+ + {step.name} + + + {step.status} + +
+ {step.description && ( +

+ {step.description} +

+ )}
- {chain.description && ( -

- {chain.description} -

+ {step.contractId && ( + )} -
- - {chain.completedSteps}/{chain.totalSteps} steps - - {chain.failedSteps > 0 && ( - {chain.failedSteps} failed - )} - {chain.currentConfidence != null && ( - confidence: {(chain.currentConfidence * 100).toFixed(0)}% +
+ ); +} + +function ChainCard({ chainWithSteps }: { chainWithSteps: ChainWithSteps }) { + const chain = chainWithSteps; + const steps = chainWithSteps.steps || []; + + return ( +
+
+
+ {chain.name} + + gen {chain.generation} · {chain.status} + +
+ {chain.description && ( +

+ {chain.description} +

)} +
+ + {chain.completedSteps}/{chain.totalSteps} steps + + {chain.failedSteps > 0 && ( + {chain.failedSteps} failed + )} + {chain.currentConfidence != null && ( + confidence: {(chain.currentConfidence * 100).toFixed(0)}% + )} +
+ {steps.length > 0 && ( +
+ {steps.map((step) => ( + + ))} +
+ )}
); } @@ -81,7 +148,43 @@ export function DirectiveDetail({ onBack, onDelete, onStart, + onRefresh, }: DirectiveDetailProps) { + const navigate = useNavigate(); + + // Auto-poll when directive is in an active state + const isLive = + directive.status === "planning" || directive.status === "active"; + const intervalRef = useRef | null>(null); + + useEffect(() => { + if (!isLive) { + if (intervalRef.current) { + clearInterval(intervalRef.current); + intervalRef.current = null; + } + return; + } + + intervalRef.current = setInterval(async () => { + try { + const updated = await getDirective(directive.id); + if (updated && onRefresh) { + onRefresh(updated); + } + } catch { + // Ignore poll errors + } + }, 5000); + + return () => { + if (intervalRef.current) { + clearInterval(intervalRef.current); + intervalRef.current = null; + } + }; + }, [isLive, directive.id, onRefresh]); + return (
{/* Header */} @@ -100,6 +203,11 @@ export function DirectiveDetail({ > {directive.status} + {isLive && ( + + polling + + )} v{directive.version} @@ -129,6 +237,28 @@ export function DirectiveDetail({ {/* Content */}
+ {/* Orchestrator contract link */} + {directive.orchestratorContractId && ( +
+ + Planning Contract + + + {directive.status === "planning" && ( + + planning in progress + + )} +
+ )} + {/* Goal */}

@@ -196,12 +326,14 @@ export function DirectiveDetail({

{directive.chains.length === 0 ? (

- No chains yet. Chains are created during planning. + {directive.status === "planning" + ? "Planning in progress... chains will appear when the planner completes." + : "No chains yet. Chains are created during planning."}

) : (
- {directive.chains.map((chain) => ( - + {directive.chains.map((cws) => ( + ))}
)} -- cgit v1.2.3