Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review: snapshot prior annotation from ref, not closure mutation
[._.]/ Adam Eivya236972a2878
diff --git a/client/src/hooks/useMediaAnnotations.js b/client/src/hooks/useMediaAnnotations.jsindex 6f0e167159..594565effc 100644--- a/client/src/hooks/useMediaAnnotations.js+++ b/client/src/hooks/useMediaAnnotations.js@@ -68,22 +68,26 @@ export function useMediaAnnotations() {}, []);const updateAnnotation = useCallback(async (key, patch) => {- let prior;+ // Snapshot prior state synchronously from the ref — state updaters in+ // React 18 concurrent mode can be deferred or retried, so mutating an+ // outer `let prior` from inside `setAnnotations((prev) => { ... })` is+ // unsafe and would leave the revert path with the wrong (or undefined)+ // snapshot. The ref always reflects the latest committed state.+ const prior = annotationsRef.current[key];+ const priorOwn = prior?.own ?? null;+ const mergedOwn = {+ authorName: priorOwn?.authorName ?? '',+ starred: 'starred' in patch ? patch.starred : (priorOwn?.starred ?? false),+ note: 'note' in patch ? patch.note : (priorOwn?.note ?? ''),+ updatedAt: new Date().toISOString(),+ };+ const others = prior?.others ?? [];+ const ownEmpty = !mergedOwn.starred && !mergedOwn.note;+ const nextEntry = enrich({+ own: ownEmpty ? null : mergedOwn,+ others,+ });setAnnotations((prev) => {- prior = prev[key];- const priorOwn = prior?.own ?? null;- const mergedOwn = {- authorName: priorOwn?.authorName ?? '',- starred: 'starred' in patch ? patch.starred : (priorOwn?.starred ?? false),- note: 'note' in patch ? patch.note : (priorOwn?.note ?? ''),- updatedAt: new Date().toISOString(),- };- const others = prior?.others ?? [];- const ownEmpty = !mergedOwn.starred && !mergedOwn.note;- const nextEntry = enrich({- own: ownEmpty ? null : mergedOwn,- others,- });const next = { ...prev };if (!nextEntry || (!nextEntry.own && nextEntry.others.length === 0)) delete next[key];else next[key] = nextEntry;