diff --git a/components/reasoning-workspace.jsx b/components/reasoning-workspace.jsx index c7f2495..20706ca 100644 --- a/components/reasoning-workspace.jsx +++ b/components/reasoning-workspace.jsx @@ -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 ( -