refactor: emphasise investigation conclusions over system status
This commit is contained in:
@@ -267,62 +267,35 @@ function OriginalSituation({ scenario, centralStatement }) {
|
||||
);
|
||||
}
|
||||
|
||||
// ── Update acknowledgement ────────────────────────────────────
|
||||
// ── Transient acknowledgement (auto-dismisses after 3s) ─────────
|
||||
|
||||
function useAutoDismiss(duration = 3000) {
|
||||
const [visible, setVisible] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
if (!visible) return;
|
||||
const timer = setTimeout(() => setVisible(false), duration);
|
||||
return () => clearTimeout(timer);
|
||||
}, [visible, duration]);
|
||||
|
||||
return visible;
|
||||
}
|
||||
|
||||
function UpdateAcknowledgement({ updateResult }) {
|
||||
if (!updateResult) return null;
|
||||
const visible = useAutoDismiss(3000);
|
||||
|
||||
if (!updateResult || !visible) return null;
|
||||
|
||||
const summary = updateResult.summary;
|
||||
const hasResolvedNodes = updateResult.resolvedUnknownNodeIds?.length > 0;
|
||||
const hasAffectedNodes = updateResult.affectedNodeIds?.length > 0;
|
||||
const graph = updateResult.updatedSituationGraph;
|
||||
|
||||
function getNodeText(nodeId) {
|
||||
if (!graph?.nodes) return String(nodeId);
|
||||
const node = graph.nodes.find((n) => n.id === nodeId);
|
||||
if (node) {
|
||||
const parts = [node.label];
|
||||
if (node.status !== "resolved") {
|
||||
parts.push(node.status);
|
||||
}
|
||||
return parts.join(" ");
|
||||
}
|
||||
return String(nodeId);
|
||||
}
|
||||
|
||||
let changedText;
|
||||
if (hasResolvedNodes) {
|
||||
const items = [];
|
||||
for (const id of updateResult.resolvedUnknownNodeIds.slice(0, 3)) {
|
||||
items.push(getNodeText(id));
|
||||
}
|
||||
if (updateResult.resolvedUnknownNodeIds.length > 3) {
|
||||
items.push(`and ${updateResult.resolvedUnknownNodeIds.length - 3} more resolved`);
|
||||
}
|
||||
changedText = items.join(". ") + ".";
|
||||
} else if (hasAffectedNodes) {
|
||||
const items = [];
|
||||
for (const id of updateResult.affectedNodeIds.slice(0, 3)) {
|
||||
items.push(getNodeText(id));
|
||||
}
|
||||
if (updateResult.affectedNodeIds.length > 3) {
|
||||
items.push(`and ${updateResult.affectedNodeIds.length - 3} more affected`);
|
||||
}
|
||||
changedText = items.join(". ") + ".";
|
||||
} else if (updateResult.changesApplied) {
|
||||
const ca = updateResult.changesApplied;
|
||||
const parts = [];
|
||||
if (ca.addedNodeCount) parts.push(`${ca.addedNodeCount} node(s) added`);
|
||||
if (ca.updatedNodeCount) parts.push(`${ca.updatedNodeCount} node(s) updated`);
|
||||
if (ca.addedEdgeCount) parts.push(`${ca.addedEdgeCount} edge(s) added`);
|
||||
if (ca.removedEdgeCount) parts.push(`${ca.removedEdgeCount} edge(s) removed`);
|
||||
changedText = parts.length > 0 ? parts.join(", ") : null;
|
||||
}
|
||||
|
||||
const displayMessage = summary || changedText || "Your answer has been added to the investigation.";
|
||||
|
||||
return (
|
||||
<div className="rounded-lg border border-blue-100 bg-blue-50/80 px-5 py-3 text-sm text-blue-900">
|
||||
{displayMessage}
|
||||
<div
|
||||
className="transition-all duration-1500 ease-in"
|
||||
style={{ opacity: visible ? 0.7 : 0, maxHeight: visible ? "4rem" : "0", marginBottom: visible ? "1rem" : "0" }}
|
||||
>
|
||||
<div className="rounded-lg border border-blue-200 bg-blue-50/60 px-4 py-2 text-xs text-blue-800">
|
||||
{summary}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -451,6 +424,12 @@ export default function ReasoningWorkspace({
|
||||
const newlySurfacedNodeIds = result?.newlySurfacedNodeIds || [];
|
||||
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 the investigation has reached a terminal state with no active question.
|
||||
const hasCurrentSummaryCondition =
|
||||
Boolean(graph?.currentSummary || result?.updatedSituationGraph?.currentSummary) || !hasSelectedQuestion;
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* ── Loading overlays ─────────────────────────────── */}
|
||||
@@ -523,7 +502,7 @@ export default function ReasoningWorkspace({
|
||||
{status === "success" && !hasSelectedQuestion && graph && !genuineCompletion && <EvidenceLimitCard />}
|
||||
|
||||
{/* ── Supporting sections (same order for active and terminal) ─ */}
|
||||
{(graph?.currentSummary || (status === "success" && !canAnswer)) && <CurrentUnderstandingCard currentSummary={graph.currentSummary} />}
|
||||
{hasCurrentSummaryCondition && <CurrentUnderstandingCard currentSummary={graph?.currentSummary || result?.updatedSituationGraph?.currentSummary} />}
|
||||
|
||||
<OriginalSituation scenario={scenario} centralStatement={graph?.centralStatement} />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user