feat(confidence-engine): clarify understanding during Done refresh

This commit is contained in:
2026-09-02 07:53:45 +01:00
parent b647236d44
commit 043ba5f264
5 changed files with 207 additions and 13 deletions
+21 -8
View File
@@ -281,6 +281,7 @@ export default function ScenarioForm() {
const [updateResult, setUpdateResult] = useState(null);
const [lastSubmittedAnswer, setLastSubmittedAnswer] = useState("");
const [currentUnderstanding, setCurrentUnderstanding] = useState(null);
const [cuSynthesisLoading, setCuSynthesisLoading] = useState(false);
const [mockScenario, setMockScenario] = useState("");
const [hideFacilitatorOnLanding, setHideFacilitatorOnLanding] = useState(false);
@@ -357,16 +358,29 @@ export default function ScenarioForm() {
* Authoritative graph reconsideration triggered by "Done for now"
* activity boundary. Delegates to the exported executeEpisodeDone pipeline.
*/
async function handleDoneForNowPromotion(targetNodeId) {
async function handleDoneForNowPromotion(targetNodeId, onImmediateGraphUpdate) {
if (!targetNodeId || !findings?.length) return;
// In-flight guard: exactly-once enforcement
if (doneInProgressRef.current) return;
doneInProgressRef.current = true;
/* ── Immediate client transition — before awaiting async work ── */
const preDoneGraph = result?.situationGraph;
if (preDoneGraph && onImmediateGraphUpdate) {
const immediateResolvedIds = new Set(preDoneGraph.resolvedNodeIds || []);
immediateResolvedIds.add(targetNodeId);
const immediateGraph = {
...preDoneGraph,
resolvedNodeIds: Array.from(immediateResolvedIds),
};
onImmediateGraphUpdate(immediateGraph);
}
setCuSynthesisLoading(true);
try {
const doneResult = await executeEpisodeDone({
resultSituationGraph: result?.situationGraph,
resultSituationGraph: preDoneGraph,
targetNodeId,
focusedContributions: focusedContributions ?? [],
findings,
@@ -388,6 +402,7 @@ export default function ScenarioForm() {
} finally {
doneInProgressRef.current = false;
setCuSynthesisLoading(false);
}
}
@@ -422,14 +437,9 @@ export default function ScenarioForm() {
const currentGraph = result?.situationGraph;
if (!currentGraph) return;
const completeNextFindings = normalizeFindings([
...(findings ?? []),
...newFindingsDelta,
]);
void synthesizeFromFindings(fetch, {
situationGraph: currentGraph,
findings: completeNextFindings,
findings: normalizeFindings([...(findings ?? []), ...newFindingsDelta]),
}).then((res) => {
if (res.ok && res.data?.currentUnderstanding) {
setCurrentUnderstanding(res.data.currentUnderstanding);
@@ -794,6 +804,7 @@ export default function ScenarioForm() {
scenario={scenario}
status={status}
updateStatus={updateStatus}
cuSynthesisLoading={cuSynthesisLoading}
currentUnderstanding={currentUnderstanding}
result={{
...(result || {}),
@@ -814,6 +825,8 @@ export default function ScenarioForm() {
onUpdateFindingProposition={updateFindingProposition}
/* v0.49 done-for-now promotion seam */
onSummaryUpdate={handleDoneForNowPromotion}
/* immediate graph transition (Done acknowledged before async) */
onImmediateGraphChange={(nextGraph) => setResult((prev) => ({ ...(prev ?? {}), situationGraph: nextGraph }))}
/* canonical graph-replacement seam (future Re-open) */
onSituationGraphChange={(nextGraph) => setResult((prev) => ({ ...(prev ?? {}), situationGraph: nextGraph }))}
onRestart={() => {