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: queue-internal canon lock-all + stale-state-free job progress
[._.]/ Adam Eivy48938e4868b7
diff --git a/client/src/hooks/useMediaJobProgress.js b/client/src/hooks/useMediaJobProgress.jsindex ee48a5102b..2bdff31de5 100644--- a/client/src/hooks/useMediaJobProgress.js+++ b/client/src/hooks/useMediaJobProgress.js@@ -32,6 +32,20 @@ const INITIAL_STATE = Object.freeze({export default function useMediaJobProgress(jobId, { kind = 'image' } = {}) {const [state, setState] = useState(INITIAL_STATE);+ // SYNCHRONOUS reset when `jobId` changes — React's "adjusting state on+ // prop change" pattern. Doing this in a `useEffect` (as we used to)+ // means the FIRST render after `jobId` flips still returns the previous+ // job's `status` / `filename`. Consumers that fire `onJobCompleted` on+ // status='completed' would mis-attribute the prior job's filename to the+ // NEW jobId and prematurely clear the rest of a queued batch. With this+ // pattern React discards the in-progress render and re-runs the+ // component immediately, so the new jobId is never observed against+ // stale state.+ const prevJobIdRef = useRef(jobId);+ if (prevJobIdRef.current !== jobId) {+ prevJobIdRef.current = jobId;+ setState(INITIAL_STATE);+ }// Track mount so the initial fetch's setState doesn't fire after unmount// (the panel could be removed while the GET is in flight).//@@ -48,10 +62,6 @@ export default function useMediaJobProgress(jobId, { kind = 'image' } = {}) {}, []);useEffect(() => {- // Reset state on every jobId change so the previous job's filename /- // currentImage doesn't briefly leak into the new job's render window- // (between the listener attach and the new fetch resolving).- setState(INITIAL_STATE);if (!jobId) return undefined;// Hydrate from the server. The job may already be completed (the userdiff --git a/server/services/universeCanon.js b/server/services/universeCanon.jsindex a28b68d773..0525afbf8f 100644--- a/server/services/universeCanon.js+++ b/server/services/universeCanon.js@@ -299,18 +299,27 @@ export async function setCanonKindLockAll(universeId, kind, locked) {{ status: 400, code: 'UNIVERSE_CANON_INVALID_KIND' },);}- const universe = await getUniverse(universeId);const field = BIBLE_FIELD[kind];- const list = Array.isArray(universe[field]) ? universe[field] : [];let changed = 0;- const nextList = list.map((e) => {- if ((e.locked === true) === (locked === true)) return e;- changed += 1;- return { ...e, locked };+ let total = 0;+ // Run inside `updateUniverse`'s file-write queue (mutator form) so the+ // patch is built from the freshest persisted state. A read-modify-write+ // split (getUniverse → updateUniverse(patchObject)) would clobber a+ // concurrent render-completion `imageRefs[]` append or an inline canon+ // edit landing between the two calls — the patch's full-array shape+ // replaces wholesale via PATCHABLE_SCALARS. Mirrors `setVariationsLockAll`.+ const updated = await updateUniverse(universeId, (cur) => {+ const list = Array.isArray(cur[field]) ? cur[field] : [];+ total = list.length;+ const nextList = list.map((e) => {+ if ((e.locked === true) === (locked === true)) return e;+ changed += 1;+ return { ...e, locked };+ });+ if (changed === 0) return null; // no-op short-circuit+ return { [field]: nextList };});- if (changed === 0) return { universe, kind, locked, changed: 0, total: list.length };- const updated = await updateUniverse(universeId, { [field]: nextList });- return { universe: updated, kind, locked, changed, total: list.length };+ return { universe: updated, kind, locked, changed, total };}/**