feat: instrument analysis

This commit is contained in:
OpenSquared
2026-06-29 00:06:14 +02:00
parent 3bcecdab09
commit 5e65424500
3 changed files with 28 additions and 5 deletions

View File

@@ -60,6 +60,8 @@ interface CausalAnalysis {
activation_score: number | null
analyzed_at: string
prediction_json: Record<string, number>
actual_json: Record<string, number>
graph_json?: { nodes: GraphNode[]; edges: GraphEdge[] }
}
interface TemplateRef {
@@ -410,9 +412,18 @@ function EventDetail({
if (r.ok) {
const data: CausalAnalysis[] = await r.json()
setAnalyses(data)
// Pre-select the most recent analysis's template so the form isn't blank on re-open
if (data.length > 0 && data[0].template_id) {
setSelTmpl(data[0].template_id)
if (data.length > 0) {
const latest = data[0]
if (latest.template_id) setSelTmpl(latest.template_id)
// Reconstruct graph state from stored analysis so it's always visible on reopen
setAnResult({
score: latest.activation_score,
preds: latest.prediction_json || {},
actuals: latest.actual_json || {},
})
if (latest.graph_json?.nodes?.length) {
setGraphData(latest.graph_json as GraphData)
}
}
}
}, [event.id])