diff --git a/artifacts/tx-os/src/components/notes/incoming-note-popup.tsx b/artifacts/tx-os/src/components/notes/incoming-note-popup.tsx index eab7be3c..9e09bf99 100644 --- a/artifacts/tx-os/src/components/notes/incoming-note-popup.tsx +++ b/artifacts/tx-os/src/components/notes/incoming-note-popup.tsx @@ -172,17 +172,20 @@ function PopupChecklistPreview({ onChange={(e) => { const next = e.target.checked; setOverrides((o) => ({ ...o, [it.id]: next })); + const drop = () => + // Always clear the override once the mutation + // settles so the next render reflects authoritative + // state (either the optimistic cache write that + // already landed, or — for a concurrent collaborator + // toggle that arrived during our roundtrip — the + // socket-pushed value that supersedes ours). + setOverrides((o) => { + const { [it.id]: _drop, ...rest } = o; + return rest; + }); toggle.mutate( { id: noteId, itemId: it.id, done: next }, - { - onError: () => - // Roll back the local override on failure so the - // checkbox reflects authoritative state. - setOverrides((o) => { - const { [it.id]: _drop, ...rest } = o; - return rest; - }), - }, + { onSuccess: drop, onError: drop }, ); }} className="mt-0.5 h-4 w-4 rounded border-black/30 accent-amber-500"