fix: preserve plain-language current understanding
This commit is contained in:
@@ -179,7 +179,9 @@ function EvidenceLimitCard() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ── Current understanding card ────────────────────────────────
|
// ── Current understanding card ────────────────────────────────
|
||||||
function CurrentUnderstandingCard({ currentSummary }) {
|
function CurrentUnderstandingCard({ currentSummary, plainLanguage }) {
|
||||||
|
if (plainLanguage) return <PlainLanguageCard summary={plainLanguage} />;
|
||||||
|
|
||||||
const summary = resolveCurrentSummary(currentSummary);
|
const summary = resolveCurrentSummary(currentSummary);
|
||||||
|
|
||||||
if (!summary) return null;
|
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) ──────
|
// ── Investigation history card (readable notebook style) ──────
|
||||||
function InvestigationHistoryCard({ turn }) {
|
function InvestigationHistoryCard({ turn }) {
|
||||||
const isCollapsed = turn._collapsed;
|
const isCollapsed = turn._collapsed;
|
||||||
@@ -356,6 +372,7 @@ export default function ReasoningWorkspace({
|
|||||||
scenario,
|
scenario,
|
||||||
status,
|
status,
|
||||||
updateStatus,
|
updateStatus,
|
||||||
|
currentUnderstanding: propUnderstanding,
|
||||||
result,
|
result,
|
||||||
answer,
|
answer,
|
||||||
setAnswer,
|
setAnswer,
|
||||||
@@ -425,10 +442,11 @@ export default function ReasoningWorkspace({
|
|||||||
const genuineCompletion = hasGenuineCompletion(graph);
|
const genuineCompletion = hasGenuineCompletion(graph);
|
||||||
|
|
||||||
// Determine whether the Current Understanding card should render:
|
// 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.
|
// — when the investigation has reached a terminal state with no active question.
|
||||||
const hasCurrentSummaryCondition =
|
const hasCurrentSummaryCondition =
|
||||||
Boolean(graph?.currentSummary || result?.updatedSituationGraph?.currentSummary) || !hasSelectedQuestion;
|
Boolean(propUnderstanding || graph?.currentSummary || result?.updatedSituationGraph?.currentSummary) || !hasSelectedQuestion;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
@@ -502,7 +520,7 @@ export default function ReasoningWorkspace({
|
|||||||
{status === "success" && !hasSelectedQuestion && graph && !genuineCompletion && <EvidenceLimitCard />}
|
{status === "success" && !hasSelectedQuestion && graph && !genuineCompletion && <EvidenceLimitCard />}
|
||||||
|
|
||||||
{/* ── Supporting sections (same order for active and terminal) ─ */}
|
{/* ── 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} />
|
<OriginalSituation scenario={scenario} centralStatement={graph?.centralStatement} />
|
||||||
|
|
||||||
|
|||||||
@@ -195,6 +195,7 @@ export default function ScenarioForm() {
|
|||||||
const [updateError, setUpdateError] = useState(null);
|
const [updateError, setUpdateError] = useState(null);
|
||||||
const [updateResult, setUpdateResult] = useState(null);
|
const [updateResult, setUpdateResult] = useState(null);
|
||||||
const [lastSubmittedAnswer, setLastSubmittedAnswer] = useState("");
|
const [lastSubmittedAnswer, setLastSubmittedAnswer] = useState("");
|
||||||
|
const [currentUnderstanding, setCurrentUnderstanding] = useState(null);
|
||||||
const textareaRef = useRef(null);
|
const textareaRef = useRef(null);
|
||||||
|
|
||||||
/* Inject mock globals so the interceptor can read them at runtime */
|
/* Inject mock globals so the interceptor can read them at runtime */
|
||||||
@@ -219,8 +220,7 @@ export default function ScenarioForm() {
|
|||||||
setUpdateResult(null);
|
setUpdateResult(null);
|
||||||
setLastSubmittedAnswer("");
|
setLastSubmittedAnswer("");
|
||||||
setUpdateError(null);
|
setUpdateError(null);
|
||||||
setResult(null);
|
setCurrentUnderstanding(null);
|
||||||
setUpdateResult(null);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await submitScenarioForStartCase(MOCK_ENABLED ? mockFetch : fetch, scenario);
|
const res = await submitScenarioForStartCase(MOCK_ENABLED ? mockFetch : fetch, scenario);
|
||||||
@@ -229,9 +229,11 @@ export default function ScenarioForm() {
|
|||||||
|
|
||||||
if (res.ok && data.success) {
|
if (res.ok && data.success) {
|
||||||
setStatus("success");
|
setStatus("success");
|
||||||
|
setCurrentUnderstanding(data.summary ?? null);
|
||||||
setResult(normaliseStartResult(data));
|
setResult(normaliseStartResult(data));
|
||||||
} else {
|
} else {
|
||||||
setStatus("error");
|
setStatus("error");
|
||||||
|
setCurrentUnderstanding(data.summary ?? null);
|
||||||
setResult(normaliseStartResult(data));
|
setResult(normaliseStartResult(data));
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -271,6 +273,9 @@ export default function ScenarioForm() {
|
|||||||
|
|
||||||
if (submission.ok && outcome.success) {
|
if (submission.ok && outcome.success) {
|
||||||
setUpdateStatus("success");
|
setUpdateStatus("success");
|
||||||
|
setCurrentUnderstanding(
|
||||||
|
outcome.summary ? outcome.summary : currentUnderstanding,
|
||||||
|
);
|
||||||
setUpdateResult({
|
setUpdateResult({
|
||||||
...outcome,
|
...outcome,
|
||||||
previousSituationGraph: result?.situationGraph ?? null,
|
previousSituationGraph: result?.situationGraph ?? null,
|
||||||
@@ -340,6 +345,7 @@ export default function ScenarioForm() {
|
|||||||
scenario={scenario}
|
scenario={scenario}
|
||||||
status={status}
|
status={status}
|
||||||
updateStatus={updateStatus}
|
updateStatus={updateStatus}
|
||||||
|
currentUnderstanding={currentUnderstanding}
|
||||||
result={{
|
result={{
|
||||||
...(result || {}),
|
...(result || {}),
|
||||||
situationGraph: updateResult?.updatedSituationGraph ?? result?.situationGraph,
|
situationGraph: updateResult?.updatedSituationGraph ?? result?.situationGraph,
|
||||||
@@ -367,6 +373,7 @@ export default function ScenarioForm() {
|
|||||||
setUpdateStatus("idle");
|
setUpdateStatus("idle");
|
||||||
setUpdateResult(null);
|
setUpdateResult(null);
|
||||||
setLastSubmittedAnswer("");
|
setLastSubmittedAnswer("");
|
||||||
|
setCurrentUnderstanding(null);
|
||||||
setUpdateError(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"
|
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