fix(rto): persist focused contributions immediately after deconstruct success
The successful focused deconstruct calls onFocusedContribution which updates parent state, but never persisted the new collection to sessionStorage. This meant an immediate reload would lose the contribution. Fix: add a useEffect in ReasoningWorkspace that watches the focusedContributions prop for changes and saves via the existing saveSession mechanism. A ref guard prevents double-save alongside the existing updateStatus-success effect.
This commit is contained in:
@@ -972,6 +972,23 @@ export default function ReasoningWorkspace({
|
||||
const [focusedInvestigations, setFocusedInvestigations] = useState({});
|
||||
const [focusedAnswer, setFocusedAnswer] = useState("");
|
||||
|
||||
// ── Persist focused contributions immediately after deconstruct success ────
|
||||
const lastPersistedContribCount = useRef(0);
|
||||
|
||||
useEffect(() => {
|
||||
if (!graph) return;
|
||||
if (focusedContributions.length === lastPersistedContribCount.current) return;
|
||||
lastPersistedContribCount.current = focusedContributions.length;
|
||||
saveSession({
|
||||
scenario,
|
||||
situationGraph: graph,
|
||||
selectedQuestion: result?.selectedQuestion,
|
||||
summary: result?.summary || propUnderstanding,
|
||||
updatedAt: new Date().toISOString(),
|
||||
focusedContributions,
|
||||
});
|
||||
}, [focusedContributions]);
|
||||
|
||||
function getFocusedInvestigation() {
|
||||
if (!focusedPresentationItemId) return null;
|
||||
return focusedInvestigations[focusedPresentationItemId] || null;
|
||||
|
||||
Reference in New Issue
Block a user