import { useSimulationState } from '../../store/simulationStore'; function MetricRow({ label, value, valueClass = 'text-zinc-200' }) { return (
{label} {value}
); } function Panel({ accent, title, children, badge }) { return (
{title}
{children}
); } export default function BeforeAfterSplit() { const { scenarioContext, chosenRun, rejectedRun, rcaDocument, lastValidatorResult, telemetry, counterfactual, scenarioComplete, isRunning, spent, } = useSimulationState(); const runtime = telemetry.validator_runtime || scenarioContext?.validator_runtime || {}; const validator = lastValidatorResult || chosenRun || {}; const gpuMetricsApplicable = validator.gpu_metrics_applicable ?? runtime.gpu_metrics_applicable ?? false; const checksApplied = Array.isArray(validator.checks_applied) ? validator.checks_applied : []; // Phase 3: if we have a passing fix (chosenRun), the incident IS resolved — // don't wait for the counterfactual payload to arrive. const isResolved = scenarioComplete || Boolean(chosenRun); const closureOutcome = counterfactual?.actual?.outcome || (isResolved ? 'RESOLVED' : 'IN_PROGRESS'); const isIncomplete = closureOutcome === 'INCOMPLETE'; const outcomeClass = isIncomplete ? 'text-red-400 font-bold' : isResolved ? 'text-emerald-400 font-bold' : 'text-zinc-400 font-bold'; const closureNote = isResolved ? 'Success: The incident closed with validator-backed evidence, cost tracking, and replayable execution logs.' : 'Pending: Awaiting the final closure note and counterfactual summary.'; return (
{/* ── Phase 1: Incident Trigger ── */}

{scenarioContext?.incident_summary || 'Waiting for the incident brief from the backend...'}

{/* ── Phase 2: Validation Proof ── */}
{gpuMetricsApplicable ? ( ) : ( )}
{validator.validator_detail || telemetry.validator_detail || runtime.detail || 'Validator proof details will appear here after execution.'}
{/* ── Phase 3: Incident Outcome ── */}
0 ? 'SAFE' : 'BREACHED')} valueClass={telemetry.sla_remaining_seconds > 0 || counterfactual?.actual?.sla === 'SAFE' ? 'text-emerald-400' : 'text-red-400'} />
{closureNote}
); }