From 06595997952899b9ecbd8c5dca87d32529e31b3e Mon Sep 17 00:00:00 2001 From: robbond Date: Thu, 27 Aug 2026 07:45:15 +0100 Subject: [PATCH] feat(confidence-engine): wire focused contribution finding derivation --- components/scenario-form.jsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/components/scenario-form.jsx b/components/scenario-form.jsx index 3504701..608f74a 100644 --- a/components/scenario-form.jsx +++ b/components/scenario-form.jsx @@ -271,9 +271,20 @@ export default function ScenarioForm() { } function appendFocusedContribution(contribution) { + // Derive a single stored contribution object and use it for BOTH + // contribution storage AND Finding derivation so the same identity + // appears in focusedContributions[] and Finding.contributionId. setFocusedContributions((prev) => { const seq = prev.length + 1; - return [...prev, { ...contribution, sequence: seq, id: `contrib-${String(seq).padStart(4, "0")}` }]; + const storedContribution = { ...contribution, sequence: seq, id: `contrib-${String(seq).padStart(4, "0")}` }; + + // Derive Findings from the exact stored Contribution (not a separate approximation) + setFindings((prevFindings) => { + const newFindings = deriveFindingsFromContributions([storedContribution]).findings; + return normalizeFindings([...prevFindings, ...newFindings]); + }); + + return [...prev, storedContribution]; }); } const textareaRef = useRef(null);