fix(confidence-engine): keep focused investigation in current presentation

This commit is contained in:
2026-08-26 11:30:59 +01:00
parent 81dda77392
commit 6288ef1031
2 changed files with 150 additions and 4 deletions
+22 -4
View File
@@ -1329,7 +1329,11 @@ export default function ReasoningWorkspace({
// ── RTO.29D — manage initial reflection lifecycle ────────────
useEffect(() => {
const entering = status === "success" && hasGraph && propUnderstanding && !hasSelectedQuestion;
// Entry is now based on successful initial reconstruction state ONLY.
// selectedQuestion is internal reasoning data — it must NOT gate the
// post-Analyse presentation path. Both null and populated
// selectedQuestion enter Run A identically.
const entering = status === "success" && hasGraph && propUnderstanding;
if (entering) {
setPostAnalyseStatus("success");
setInitialReflectionActive(true);
@@ -1340,14 +1344,28 @@ export default function ReasoningWorkspace({
}
}, [status, result, hasGraph]);
// Deactivate initial reflection when user does anything meaningful
// Deactivate initial reflection when user submits a turn (leaves post-analyse).
// DO NOT deactivate on formulationStep or processingStep transitions — those
// are part of the focused workflow and must not break Run A's lifecycle.
useEffect(() => {
if (!initialReflectionActive) return;
if (selectedPresentationItemId || focusedPresentationItemId || investigationHistory.length > 0 || formulationStep !== "idle" || processingStep !== "idle") {
// If we've already transitioned out of post-analyse mode, bail early.
// This prevents the effect from re-triggering on every state change after
// an explicit deactivation and avoids spurious double-fires when multiple
// dependencies change in the same commit.
if (postAnalyseStatus !== "success") return;
// Genuine exit: a turn has been submitted → history grows past zero.
// No other lifecycle state (formulation, processing, focused IDs, etc.)
// deactivates Run A during a focused investigation cycle.
if (investigationHistory.length > 0) {
setInitialReflectionActive(false);
setPostAnalyseStatus(null);
}
}, [selectedPresentationItemId, focusedPresentationItemId, investigationHistory, formulationStep, processingStep]);
// All other lifecycle events within the focused workflow are intentionally
// ignored here — Run A stays active until an explicit turn is submitted.
}, [initialReflectionActive, investigationHistory, postAnalyseStatus]);
return (
<div className="space-y-6" data-testid="reasoning-workspace">