Skip to content

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

address review (claude r2): useMounted for the sweep gate, bounded poll for attach-pending runs

[._.]/ Adam Eivyb29d95f91c68
diff --git a/client/src/components/sprites/WalkWorkflow.jsx b/client/src/components/sprites/WalkWorkflow.jsx
index edbe49334d..877b73e7cf 100644
--- a/client/src/components/sprites/WalkWorkflow.jsx
+++ b/client/src/components/sprites/WalkWorkflow.jsx
@@ -207,12 +207,27 @@ export default function WalkWorkflow({ record, reference, walk, onChanged }) {
// completes (frame extraction + per-pixel un-key can take many seconds on
// slower machines) — the job-completion sweeps alone can both land while a
// run is still 'postprocessing', which would strand the card on
- // "packaging…" forever. Keep refreshing until no run is packaging.
+ // "packaging…" forever. Keep refreshing until no run is packaging. A run
+ // still 'queued' with no live job is an attach waiting behind the record's
+ // write tail (e.g. a long rerun ahead of it) — poll for that too, but give
+ // up after ~60s so a genuinely dead job doesn't poll indefinitely.
+ // Booleans (not the runs array) as deps: refetches produce fresh array
+ // identities every 4s, which would otherwise reset the bounded tick count.
+ const packaging = runs.some((r) => r.status === 'postprocessing');
+ const awaitingAttach = runs.some((r) => r.status === 'queued' && !pendingJobs[r.direction]);
useEffect(() => {
- if (!runs.some((r) => r.status === 'postprocessing')) return undefined;
- const timer = setInterval(onChanged, 4000);
+ if (!packaging && !awaitingAttach) return undefined;
+ let ticks = 0;
+ const timer = setInterval(() => {
+ ticks += 1;
+ if (!packaging && ticks > 15) {
+ clearInterval(timer);
+ return;
+ }
+ onChanged();
+ }, 4000);
return () => clearInterval(timer);
- }, [runs, onChanged]);
+ }, [packaging, awaitingAttach, onChanged]);
const latestRunByDirection = useMemo(() => {
const byDir = {};
diff --git a/client/src/hooks/useSpritePendingRenders.js b/client/src/hooks/useSpritePendingRenders.js
index dc86acbeea..8880f62bd1 100644
--- a/client/src/hooks/useSpritePendingRenders.js
+++ b/client/src/hooks/useSpritePendingRenders.js
@@ -1,6 +1,7 @@
-import { useEffect, useRef, useState } from 'react';
+import { useEffect, useState } from 'react';
import toast from '../components/ui/Toast';
import { getMediaJob, listMediaJobs } from '../services/apiMediaJobs.js';
+import useMounted from './useMounted.js';
/**
* Shared in-flight render tracking for the sprite workflows (#2896 reference
@@ -28,9 +29,10 @@ export function useSpritePendingRenders({
}) {
const [pendingJobs, setPendingJobs] = useState({});
// Unmount guard for the deferred sweeps (repo convention: deferred work
- // respects unmount). Never reset to true — handles dev double-mount.
- const mountedRef = useRef(true);
- useEffect(() => () => { mountedRef.current = false; }, []);
+ // respects unmount). useMounted, NOT a bare ref — a bare ref stays false
+ // after StrictMode's dev mount→cleanup→remount and would suppress every
+ // sweep for the component's whole dev lifetime.
+ const mountedRef = useMounted();
// Rehydrate in-flight renders on mount/record switch — a reload or
// navigate-away-and-back would otherwise lose the map and re-enable