import React from 'react'; import { motion } from 'framer-motion'; import { API_BASE } from '../api'; interface Props { designName: string; result: any; jobStatus: string; events: any[]; jobId?: string; onReset: () => void; } function StatCell({ label, value, warn }: { label: string; value: any; warn?: boolean }) { return (
{value ?? '—'} {label}
); } function CheckRow({ label, passed, detail }: { label: string; passed: boolean | null; detail?: string }) { const status = passed === true ? 'pass' : passed === false ? 'fail' : 'skip'; return (
{status === 'pass' ? '✓' : status === 'fail' ? '✕' : '–'}
{label} {detail && {detail}}
); } export const ChipSummary: React.FC = ({ designName, result, jobStatus, events, jobId, onReset }) => { const success = jobStatus === 'done'; const metrics = result?.metrics || {}; const convergence = result?.convergence_history || []; const spec = result?.spec || ''; const rtlSnippet = result?.rtl_snippet || ''; const strategy = result?.strategy || ''; const buildTimeSec = result?.build_time_s || 0; const buildTimeMin = Math.round(buildTimeSec / 60); const coverage = result?.coverage || {}; const formalResult = result?.formal_result || ''; const signoffResult = result?.signoff_result || ''; const selfHeal = result?.self_heal || { stage_exception_count: events.filter(e => /stage .* exception/i.test(e?.message || '')).length, formal_regen_count: events.filter(e => /regenerating sva/i.test(e?.message || '')).length, coverage_best_restore_count: events.filter(e => /restoring best testbench/i.test(e?.message || '')).length, coverage_regression_reject_count: events.filter(e => /regressed coverage/i.test(e?.message || '')).length, deterministic_tb_fallback_count: events.filter(e => /deterministic tb fallback/i.test(e?.message || '')).length, }; const checkpointCount = events.filter(e => e.type === 'transition' || e.type === 'checkpoint').length; const syntaxPassed = events.some(e => /syntax.*pass|lint.*clean/i.test(e?.message || '')); const simPassed = events.some(e => /test passed|simulation.*pass/i.test(e?.message || '')); const formalPassed = formalResult ? /pass|success/i.test(formalResult) : events.some(e => /formal.*pass/i.test(e?.message || '')); const coveragePassed = events.some(e => /coverage passed/i.test(e?.message || '')); const signoffPassed = signoffResult ? /pass|success/i.test(signoffResult) : null; const lineCov = coverage?.line || coverage?.line_pct; const branchCov = coverage?.branch || coverage?.branch_pct; const totalHealActions = (selfHeal.stage_exception_count || 0) + (selfHeal.formal_regen_count || 0) + (selfHeal.coverage_best_restore_count || 0) + (selfHeal.coverage_regression_reject_count || 0) + (selfHeal.deterministic_tb_fallback_count || 0); const hasMetrics = metrics.wns !== undefined || metrics.area || metrics.power || metrics.gate_count; const failureExplanation = result?.failure_explanation; const failureSuggestion = result?.failure_suggestion; return (
{/* ── Banner ─────────────────────────────── */}

{success ? `${designName} is ready` : 'Build stopped'}

{success ? [ buildTimeMin > 0 ? `${buildTimeMin} min` : null, checkpointCount > 0 ? `${checkpointCount} checkpoints passed` : null, strategy || null, ].filter(Boolean).join(' · ') : `${designName} · Review the log below for details` }

{/* ── Silicon Metrics ─────────────────────── */} {success && hasMetrics && (

Silicon Metrics

)} {/* ── Verification ────────────────────────── */}

Verification

{/* ── Self-Healing ────────────────────────── */} {totalHealActions > 0 && (

Self-Healing Activity

{selfHeal.stage_exception_count > 0 && (
Stage exception guards {selfHeal.stage_exception_count}×
)} {selfHeal.formal_regen_count > 0 && (
Formal SVA regeneration {selfHeal.formal_regen_count}×
)} {selfHeal.coverage_regression_reject_count > 0 && (
Testbench regression rejections {selfHeal.coverage_regression_reject_count}×
)} {selfHeal.coverage_best_restore_count > 0 && (
Best testbench restores {selfHeal.coverage_best_restore_count}×
)} {selfHeal.deterministic_tb_fallback_count > 0 && (
Deterministic testbench fallbacks {selfHeal.deterministic_tb_fallback_count}×
)}
)} {/* ── Architecture Spec ───────────────────── */} {spec && (

Architecture Specification

                            {spec.substring(0, 1200)}{spec.length > 1200 ? '\n…' : ''}
                        
)} {/* ── RTL Preview ─────────────────────────── */} {rtlSnippet && (

RTL Preview

                            {rtlSnippet.substring(0, 1200)}{rtlSnippet.length > 1200 ? '\n// …' : ''}
                        
)} {/* ── Convergence History ─────────────────── */} {convergence.length > 0 && (

Convergence History

{convergence.slice(-5).map((s: any, i: number) => ( ))}
IterWNS (ns)TNS (ns) Congestion %Area (µm²)Power (W)
{s.iteration} = 0 ? 'true' : 'false'}>{s.wns?.toFixed(3)} {s.tns?.toFixed(3)} {s.congestion?.toFixed(2)} {s.area_um2?.toFixed(0)} {s.power_w?.toExponential(2)}
)} {/* ── Failure Detail ──────────────────────── */} {!success && (failureExplanation || result?.error) && (

What went wrong

{failureExplanation && (

{failureExplanation}

)} {failureSuggestion && (

Try: {failureSuggestion}

)} {result?.error && !failureExplanation && (
                                {String(result.error).substring(0, 500)}
                            
)}
)} {/* ── Actions ─────────────────────────────── */}
{/* Full build report downloads */} {jobId && (
Download Build Report: ↓ PDF Report ↓ DOCX Report
)} Build another chip
); };