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
fix(media): broadcast annotation updates so notes/stars sync across views
Ilya Eivyb3b4be6ca0c1
diff --git a/client/src/hooks/useMediaAnnotations.js b/client/src/hooks/useMediaAnnotations.jsindex e9e0b5d494..3444b3144d 100644--- a/client/src/hooks/useMediaAnnotations.js+++ b/client/src/hooks/useMediaAnnotations.js@@ -1,5 +1,6 @@import { useCallback, useEffect, useState } from 'react';import { listMediaAnnotations, setMediaAnnotation } from '../services/api';+import socket from '../services/socket';import toast from '../components/ui/Toast';// Loads the full media-annotation map once and exposes optimistic-update@@ -23,6 +24,23 @@ export function useMediaAnnotations() {return () => { cancelled = true; };}, []);+ // Mirror server broadcasts so a note/star toggle in one view (or browser tab)+ // shows up in every other open consumer. Originator also receives this; the+ // server entry is authoritative and overrides the optimistic merge.+ useEffect(() => {+ const onUpdate = ({ key, entry }) => {+ if (!key) return;+ setAnnotations((prev) => {+ const next = { ...prev };+ if (entry) next[key] = entry;+ else delete next[key];+ return next;+ });+ };+ socket.on('media:annotation:updated', onUpdate);+ return () => socket.off('media:annotation:updated', onUpdate);+ }, []);+const updateAnnotation = useCallback(async (key, patch) => {// Snapshot prior state for revert; build optimistic next state.let prior;diff --git a/server/routes/mediaAnnotations.js b/server/routes/mediaAnnotations.jsindex 9bf22dc98c..f1b530ef69 100644--- a/server/routes/mediaAnnotations.js+++ b/server/routes/mediaAnnotations.js@@ -40,6 +40,10 @@ router.patch('/:key', asyncHandler(async (req, res) => {// Express decodes the path param, but the key still has to round-trip through// svc validation so a hand-rolled curl can't sneak past.const updated = await svc.setAnnotation(req.params.key, body).catch((err) => { throw mapServiceError(err); });+ // Broadcast so every other open view (History, Collections, Pipeline, other+ // browser tabs) reflects the change without a manual refresh. `entry` is null+ // when the annotation was pruned (both starred=false and note='').+ req.app.get('io')?.emit('media:annotation:updated', { key: req.params.key, entry: updated });res.json({ key: req.params.key, entry: updated });}));