refactor(confidence-engine): remove legacy workspace persistence
This commit is contained in:
@@ -117,37 +117,6 @@ function ContinueLaterBanner({ onRestart }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Session persistence hook (Phase 3) ────────────────────────
|
|
||||||
|
|
||||||
function useSessionPersistence() {
|
|
||||||
const [sessionReady, setSessionReady] = useState(false);
|
|
||||||
const sessionKey = "confidence-engine-session";
|
|
||||||
|
|
||||||
function saveSession(state) {
|
|
||||||
if (typeof sessionStorage === "undefined") return;
|
|
||||||
try {
|
|
||||||
sessionStorage.setItem(sessionKey, JSON.stringify(state));
|
|
||||||
} catch (_) { /* quota or disabled — ignore silently */ }
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadSession() {
|
|
||||||
if (typeof sessionStorage === "undefined") return null;
|
|
||||||
try {
|
|
||||||
const raw = sessionStorage.getItem(sessionKey);
|
|
||||||
return raw ? JSON.parse(raw) : null;
|
|
||||||
} catch (_) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearSession() {
|
|
||||||
if (typeof sessionStorage === "undefined") return;
|
|
||||||
try { sessionStorage.removeItem(sessionKey); } catch (_) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
return { saveSession, loadSession, clearSession, sessionReady: true };
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Shared focused-question body (extracted from OpenQuestionsPanel) ──
|
// ── Shared focused-question body (extracted from OpenQuestionsPanel) ──
|
||||||
|
|
||||||
function FocusedQuestionBody({
|
function FocusedQuestionBody({
|
||||||
@@ -1289,22 +1258,6 @@ export default function ReasoningWorkspace({
|
|||||||
const [initialReflectionActive, setInitialReflectionActive] = useState(false);
|
const [initialReflectionActive, setInitialReflectionActive] = useState(false);
|
||||||
const [postAnalyseStatus, setPostAnalyseStatus] = useState(null);
|
const [postAnalyseStatus, setPostAnalyseStatus] = useState(null);
|
||||||
|
|
||||||
const { saveSession, loadSession } = useSessionPersistence();
|
|
||||||
|
|
||||||
// Persist workspace state on every successful update (Phase 3)
|
|
||||||
useEffect(() => {
|
|
||||||
if (updateStatus === "success" && result?.situationGraph) {
|
|
||||||
saveSession({
|
|
||||||
scenario,
|
|
||||||
situationGraph: result.situationGraph,
|
|
||||||
selectedQuestion: result.selectedQuestion,
|
|
||||||
summary: result.summary || propUnderstanding,
|
|
||||||
updatedAt: new Date().toISOString(),
|
|
||||||
focusedContributions,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, [updateStatus, result, focusedContributions]);
|
|
||||||
|
|
||||||
// Capture the current selected question at submit time (not from a stale ref)
|
// Capture the current selected question at submit time (not from a stale ref)
|
||||||
const capturePendingTurn = (selectedQuestion, answerText) => {
|
const capturePendingTurn = (selectedQuestion, answerText) => {
|
||||||
if (!selectedQuestion || !answerText?.trim()) return null;
|
if (!selectedQuestion || !answerText?.trim()) return null;
|
||||||
@@ -1402,23 +1355,6 @@ export default function ReasoningWorkspace({
|
|||||||
const [focusedInvestigations, setFocusedInvestigations] = useState({});
|
const [focusedInvestigations, setFocusedInvestigations] = useState({});
|
||||||
const [focusedAnswer, setFocusedAnswer] = 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() {
|
function getFocusedInvestigation() {
|
||||||
if (!focusedPresentationItemId) return null;
|
if (!focusedPresentationItemId) return null;
|
||||||
return focusedInvestigations[focusedPresentationItemId] || null;
|
return focusedInvestigations[focusedPresentationItemId] || null;
|
||||||
|
|||||||
Reference in New Issue
Block a user