fix: preserve plain-language current understanding
This commit is contained in:
@@ -179,7 +179,9 @@ function EvidenceLimitCard() {
|
||||
}
|
||||
|
||||
// ── Current understanding card ────────────────────────────────
|
||||
function CurrentUnderstandingCard({ currentSummary }) {
|
||||
function CurrentUnderstandingCard({ currentSummary, plainLanguage }) {
|
||||
if (plainLanguage) return <PlainLanguageCard summary={plainLanguage} />;
|
||||
|
||||
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 (
|
||||
<div className="rounded-lg border border-gray-200 bg-white p-5">
|
||||
<h2 className="mb-3 text-sm font-semibold uppercase tracking-wide text-gray-500">
|
||||
Current understanding
|
||||
</h2>
|
||||
<p className="text-sm leading-relaxed text-gray-700">{summary}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ── 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 (
|
||||
<div className="space-y-6">
|
||||
@@ -502,7 +520,7 @@ export default function ReasoningWorkspace({
|
||||
{status === "success" && !hasSelectedQuestion && graph && !genuineCompletion && <EvidenceLimitCard />}
|
||||
|
||||
{/* ── Supporting sections (same order for active and terminal) ─ */}
|
||||
{hasCurrentSummaryCondition && <CurrentUnderstandingCard currentSummary={graph?.currentSummary || result?.updatedSituationGraph?.currentSummary} />}
|
||||
{hasCurrentSummaryCondition && <CurrentUnderstandingCard currentSummary={graph?.currentSummary || result?.updatedSituationGraph?.currentSummary} plainLanguage={propUnderstanding || null} />}
|
||||
|
||||
<OriginalSituation scenario={scenario} centralStatement={graph?.centralStatement} />
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user