diff --git a/frontend/src/pages/InstrumentDashboard.tsx b/frontend/src/pages/InstrumentDashboard.tsx index 7c00560..1b45e73 100644 --- a/frontend/src/pages/InstrumentDashboard.tsx +++ b/frontend/src/pages/InstrumentDashboard.tsx @@ -760,6 +760,20 @@ function CausalFrise({ const [activeChip, setActiveChip] = useState<{ tmpl: CausalTemplate; ev: SnapshotEvent; chipX: number; chipY: number } | null>(null) + const [popupScore, setPopupScore] = useState('loading') + + // Fetch activation_score live when popup opens for a specific event + useEffect(() => { + const evId = activeChip?.ev.id + if (!evId) { setPopupScore(null); return } + setPopupScore('loading') + api.get(`/causal-lab/analyses?market_event_id=${evId}&limit=1`) + .then(r => { + const score = r.data?.[0]?.activation_score + setPopupScore(score != null ? Math.round(score * 100) : null) + }) + .catch(() => setPopupScore(null)) + }, [activeChip?.ev.id]) useEffect(() => { const el = containerRef.current; if (!el) return @@ -969,25 +983,24 @@ function CausalFrise({ )} - {/* Précision — causalScores (API fraîche) avec fallback sur activation_score du snapshot */} - {(() => { - const snapScore = ev.activation_score != null ? Math.round(ev.activation_score * 100) : null - const s = ev.id != null ? (causalScores[ev.id] ?? snapScore) : snapScore - if (s == null) return null - const barCls = s >= 70 ? 'bg-emerald-500' : s >= 40 ? 'bg-amber-500' : 'bg-red-500' - const txtCls = s >= 70 ? 'text-emerald-400' : s >= 40 ? 'text-amber-400' : 'text-red-400' + {/* Précision — fetch live depuis causal_event_analyses au moment du clic */} + {popupScore === 'loading' ? ( +
Chargement score…
+ ) : popupScore != null ? (() => { + const barCls = popupScore >= 70 ? 'bg-emerald-500' : popupScore >= 40 ? 'bg-amber-500' : 'bg-red-500' + const txtCls = popupScore >= 70 ? 'text-emerald-400' : popupScore >= 40 ? 'text-amber-400' : 'text-red-400' return (
Précision prédiction - {s}% + {popupScore}%
-
+
) - })()} + })() : null}