import {useEffect, useState} from 'react'; import {getJSON} from './api.ts'; import type {NPRun, NPRuns} from './contract.ts'; import {generationError} from './generation-logic.ts'; import {VerifyTable} from './VerifyRows.tsx'; import {evidenceURL} from './verify.ts'; import type {VerifyReport} from './verify.ts'; export function Verification({run}: {run: string | null}) { const [runs, setRuns] = useState([]), [listError, setListError] = useState(''), [listed, setListed] = useState(false); const [report, setReport] = useState(null), [error, setError] = useState(''), [expanded, setExpanded] = useState(null), [revision, setRevision] = useState(0); const id = run || runs[0]?.id || ''; useEffect(() => { const controller = new AbortController(); getJSON('/api/v1/np/runs', controller.signal).then(value => {if (!controller.signal.aborted) {setRuns(value.runs); setListed(true);}}).catch(e => {if (!controller.signal.aborted) {setListError(generationError(e)); setListed(true);}}); return () => controller.abort(); }, [revision]); useEffect(() => { setReport(null); setError(''); setExpanded(null); if (!id) return; const controller = new AbortController(); getJSON('/api/v1/np/runs/' + encodeURIComponent(id) + '/verify', controller.signal).then(value => {if (!controller.signal.aborted) setReport(value);}).catch(e => {if (!controller.signal.aborted) setError(generationError(e));}); return () => controller.abort(); }, [id, revision]); return

脚本验证

读取试跑已有记录。计划 PASS、导入核验、观测产物存在分别展示;不代表画面验收。

{listError &&

{listError}

}
{error ?

{error}

: report ? <>

{report.run_id} {report.segments.length} 段 · {report.status}

生成器版本:{report.generator_commit || '未登记'}

批次错误与通用原因
{JSON.stringify({errors: report.errors, generic_reasons: report.generic_reasons}, null, 2)}
{report.evidence.map(path =>

{path} ↗

)}
:

{id || !listed ? '读取试跑记录…' : listError ? '试跑列表不可用。' : '还没有试跑。'}

}
; }