diff --git a/components/reasoning-workspace.jsx b/components/reasoning-workspace.jsx index 20706ca..6b9145f 100644 --- a/components/reasoning-workspace.jsx +++ b/components/reasoning-workspace.jsx @@ -179,7 +179,9 @@ function EvidenceLimitCard() { } // ── Current understanding card ──────────────────────────────── -function CurrentUnderstandingCard({ currentSummary }) { +function CurrentUnderstandingCard({ currentSummary, plainLanguage }) { + if (plainLanguage) return ; + const summary = resolveCurrentSummary(currentSummary); if (!summary) return null; @@ -194,6 +196,20 @@ function CurrentUnderstandingCard({ currentSummary }) { ); } +// ── Plain-language understanding card (from pipeline summary) ── +function PlainLanguageCard({ summary }) { + if (!summary) return null; + + return ( +
+

+ Current understanding +

+

{summary}

+
+ ); +} + // ── Investigation history card (readable notebook style) ────── function InvestigationHistoryCard({ turn }) { const isCollapsed = turn._collapsed; @@ -356,6 +372,7 @@ export default function ReasoningWorkspace({ scenario, status, updateStatus, + currentUnderstanding: propUnderstanding, result, answer, setAnswer, @@ -425,10 +442,11 @@ export default function ReasoningWorkspace({ const genuineCompletion = hasGenuineCompletion(graph); // Determine whether the Current Understanding card should render: - // — shows while there is an actual summary from any graph snapshot, or + // — when there is a durable plain-language understanding, or + // — when there is an actual summary from any graph snapshot, or // — when the investigation has reached a terminal state with no active question. const hasCurrentSummaryCondition = - Boolean(graph?.currentSummary || result?.updatedSituationGraph?.currentSummary) || !hasSelectedQuestion; + Boolean(propUnderstanding || graph?.currentSummary || result?.updatedSituationGraph?.currentSummary) || !hasSelectedQuestion; return (
@@ -502,7 +520,7 @@ export default function ReasoningWorkspace({ {status === "success" && !hasSelectedQuestion && graph && !genuineCompletion && } {/* ── Supporting sections (same order for active and terminal) ─ */} - {hasCurrentSummaryCondition && } + {hasCurrentSummaryCondition && } diff --git a/components/scenario-form.jsx b/components/scenario-form.jsx index 1c9993b..e677f6f 100644 --- a/components/scenario-form.jsx +++ b/components/scenario-form.jsx @@ -195,6 +195,7 @@ export default function ScenarioForm() { const [updateError, setUpdateError] = useState(null); const [updateResult, setUpdateResult] = useState(null); const [lastSubmittedAnswer, setLastSubmittedAnswer] = useState(""); + const [currentUnderstanding, setCurrentUnderstanding] = useState(null); const textareaRef = useRef(null); /* Inject mock globals so the interceptor can read them at runtime */ @@ -219,8 +220,7 @@ export default function ScenarioForm() { setUpdateResult(null); setLastSubmittedAnswer(""); setUpdateError(null); - setResult(null); - setUpdateResult(null); + setCurrentUnderstanding(null); try { const res = await submitScenarioForStartCase(MOCK_ENABLED ? mockFetch : fetch, scenario); @@ -229,9 +229,11 @@ export default function ScenarioForm() { if (res.ok && data.success) { setStatus("success"); + setCurrentUnderstanding(data.summary ?? null); setResult(normaliseStartResult(data)); } else { setStatus("error"); + setCurrentUnderstanding(data.summary ?? null); setResult(normaliseStartResult(data)); } } catch (err) { @@ -271,6 +273,9 @@ export default function ScenarioForm() { if (submission.ok && outcome.success) { setUpdateStatus("success"); + setCurrentUnderstanding( + outcome.summary ? outcome.summary : currentUnderstanding, + ); setUpdateResult({ ...outcome, previousSituationGraph: result?.situationGraph ?? null, @@ -340,6 +345,7 @@ export default function ScenarioForm() { scenario={scenario} status={status} updateStatus={updateStatus} + currentUnderstanding={currentUnderstanding} result={{ ...(result || {}), situationGraph: updateResult?.updatedSituationGraph ?? result?.situationGraph, @@ -367,6 +373,7 @@ export default function ScenarioForm() { setUpdateStatus("idle"); setUpdateResult(null); setLastSubmittedAnswer(""); + setCurrentUnderstanding(null); setUpdateError(null); }} className="rounded-lg border border-gray-300 px-4 py-2 text-sm font-medium text-gray-600 transition hover:bg-gray-50"