diff --git a/frontend/components/chat/action-preview-card.tsx b/frontend/components/chat/action-preview-card.tsx index e3c8658..ec9e203 100644 --- a/frontend/components/chat/action-preview-card.tsx +++ b/frontend/components/chat/action-preview-card.tsx @@ -214,9 +214,23 @@ export function RecordSummary({ // The human approval gate for an agent-proposed add. The agent drafts the record // (dry run, nothing written); the clinician reviews it here, may edit it, and // must approve before it is committed via the matching RBAC-gated create endpoint. -export function ActionPreviewCard({ data }: { data: ActionPreviewData }) { +export function ActionPreviewCard({ + data, + onResolved, +}: { + data: ActionPreviewData; + // Called once committed/discarded so the parent can persist the resolution + // (prevents re-adding after re-render or conversation reload). + onResolved?: (resolution: "added" | "discarded") => void; +}) { const { t } = useTranslation(); - const [status, setStatus] = useState("pending"); + const [status, setStatus] = useState( + data.resolved === "added" + ? "done" + : data.resolved === "discarded" + ? "rejected" + : "pending", + ); // Editable working copy of the proposed record (edits commit, not the draft). const [record, setRecord] = useState>( data.record as Record, @@ -230,6 +244,7 @@ export function ActionPreviewCard({ data }: { data: ActionPreviewData }) { try { await commitAction({ ...data, record }); setStatus("done"); + onResolved?.("added"); notify.success( t("chat.actionCard.addedTitle"), t(`chat.actionCard.kind.${data.kind}`), @@ -300,7 +315,10 @@ export function ActionPreviewCard({ data }: { data: ActionPreviewData }) {