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

fix: keep the retry cache-buster across an async src re-resolution (#2702)

[._.]/ Adam Eivy341c18cd2bd3
diff --git a/PLAN.md b/PLAN.md
index 5552211f0e..f56babe977 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -166,4 +166,6 @@ by `/do:replan --issues`:
### Creative Director preview follow-ups (#2702)
- [ ] **Ship a directive plan's produced media to peers, or stop previewing what can't arrive.** `selectProjectPreview` (`client/src/lib/creativeDirectorPreview.js`) surfaces `plan.steps[].result.jobId` as `/data/images/<jobId>.png` / `/data/videos/<jobId>.mp4`, but `buildProjectAssetManifest()` ships only the starting image and the music bed, and plan steps never file their outputs into the project's linked collection. So a project federated to a peer without full media-library sync arrives as a record whose preview bytes never do — the card sits on MediaImage's "Syncing" placeholder (or ScenePreview's "media missing") forever rather than transiently. Pre-existing gap (the outputs were never federated; #2702 only made it *visible*), and out of scope there because the fix is server-side: either add plan render outputs to the project asset manifest, or `addCollectionItem` each one at `planAdvance.js`'s job-settle so the bytes ride the collection's own manifest. Flagged by codex review on PR #2719.
+- [ ] **A federated video poster never un-sticks from "Syncing".** `peerSyncAssets.js#doPullOneAsset` regenerates a pulled video's thumbnail locally but emits `asset-arrived` only for the `*.mp4` — never for the `.jpg` — so `MediaImage`'s exact-filename listener (now used for the CD card posters in `ProjectPreview.jsx`) never fires, and the card sits on the placeholder until a remount. Worse for a stitched final: the regenerated name is derived from the VIDEO filename (`timeline-<project>-<ts>.jpg`), while every poster URL in the UI is `<jobId>.jpg` — the same id≠filename mismatch #2702 fixed on the client, still live on the federated path. Fix server-side: emit an `asset-arrived` for the regenerated thumbnail, and key its name off the synced history row's `thumbnail` field rather than the mp4 basename. Pre-existing (the bare `<img>` it replaced never recovered either); flagged by codex review on PR #2719.
+
- [ ] **Give the video id→filename resolution a real home.** `useVideoFileSrc` (`client/src/hooks/useVideoFileSrc.js`) fetches the WHOLE `/video-gen/history` list to resolve one id, because a history entry's id is not its filename stem (the timeline renderer mints `timeline-<project>-<ts>.mp4` beside a `randomUUID()` id) and no by-id endpoint exists. Three surfaces now need it (CD cards, CD Overview, `EpisodeVideoStage`). Consider a `GET /api/video-gen/history/:id` (or a `/api/media/video/:id` resolver that 302s to the real file), which would also let `ScenePreview` stop reconstructing paths at all. Deferred from #2702 as an explicit "no new server endpoints" scope-out.
diff --git a/client/src/components/creative-director/ScenePreview.jsx b/client/src/components/creative-director/ScenePreview.jsx
index a82c85f5ff..2d80e8d881 100644
--- a/client/src/components/creative-director/ScenePreview.jsx
+++ b/client/src/components/creative-director/ScenePreview.jsx
@@ -55,14 +55,25 @@ export default function ScenePreview({ jobId, label, aspectClass = 'aspect-video
const [missing, setMissing] = useState(false);
const [attempt, setAttempt] = useState(0);
const videoRef = useRef(null);
- // Reset on `src` too, not just `jobId`: a caller resolving the real filename
- // asynchronously renders once with src=null (the reconstructed guess) and
- // again once it lands. Without this, an error recorded against the guess
- // would pin "media missing" over the correct URL that arrived a tick later.
+ // A new target starts over completely.
useEffect(() => {
setMissing(false);
setAttempt(0);
- }, [jobId, src]);
+ }, [jobId]);
+ // A `src` change for the SAME target clears the error but deliberately keeps
+ // `attempt`. Two reasons this is split from the reset above. (1) A caller
+ // resolving the real filename asynchronously renders once with src=null (the
+ // reconstructed guess) then again once it lands — without clearing `missing`,
+ // an error recorded against the guess would pin "media missing" over the
+ // correct URL that arrived a tick later. (2) But zeroing `attempt` here would
+ // defeat the cache-buster on the exact path it exists for: Retry bumps
+ // `attempt` AND re-arms the caller's lookup, so `src` round-trips
+ // null→resolved on every retry, and a reset would strip `?retry=N` back off
+ // the URL — re-requesting the identical URL whose error response the browser
+ // may still have cached.
+ useEffect(() => {
+ setMissing(false);
+ }, [src]);
// Upgrade the muted autoplay baseline to audible when the browser allows it
// (mirrors MediaLightbox). Re-runs per `attempt` because the Retry button