feat(confidence-engine): persist canonical investigation state
This commit is contained in:
@@ -313,6 +313,33 @@ export default function ScenarioForm() {
|
||||
}
|
||||
}, []);
|
||||
|
||||
/* ── Canonical autosave — persist whenever state changes (Phase 2) ── */
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window === "undefined") return;
|
||||
// Guard: no valid investigation yet → skip autosave during idle/start flows.
|
||||
// Also prevents overwriting an existing saved investigation with the initial
|
||||
// empty state of a fresh ScenarioForm instance (hydration race guard).
|
||||
if (!result?.situationGraph) return;
|
||||
|
||||
void saveInvestigation({
|
||||
scenario,
|
||||
situationGraph: result.situationGraph,
|
||||
selectedQuestion: result.selectedQuestion,
|
||||
summary: currentUnderstanding,
|
||||
updatedAt: new Date().toISOString(),
|
||||
focusedContributions,
|
||||
findings,
|
||||
});
|
||||
}, [
|
||||
scenario,
|
||||
result?.situationGraph,
|
||||
result?.selectedQuestion,
|
||||
currentUnderstanding,
|
||||
focusedContributions,
|
||||
findings,
|
||||
]);
|
||||
|
||||
/* Restore facilitator dismiss preference (Experiment 05) ─── */
|
||||
useEffect(() => {
|
||||
if (typeof window === "undefined") return;
|
||||
|
||||
Reference in New Issue
Block a user