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: mirror the server's basename contract and close the Overview resolution window (#2702)

[._.]/ Adam Eivy38a53848c2b8
diff --git a/PLAN.md b/PLAN.md
index 6a68aa1d17..5552211f0e 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -162,3 +162,8 @@ by `/do:replan --issues`:
### Vision model pickers — `useProviderModels` auto-select ignores a late-arriving capability list
- [ ] **Make `VisionProviderPicker` union the server's authoritative vision-model list into its filter (the `gemma4` gap), which requires `useProviderModels` to re-pick its initial model when `modelFilter` changes.** The Creative Director / AI Assignments vision pickers were fixed to union `useVisionModelIds()` (the server's `/api/local-llm/vision-models`, which reads Ollama `/api/show` capabilities + LM Studio's `vlm` tag) into `visionLocalModelFilter`, because the client id regex in `client/src/utils/providers.js#isVisionModel` knows `gemma-3` but not `gemma4`/`glm-4.6v` and so hides installed VLMs. `client/src/components/universe/VisionProviderPicker.jsx:27` has the identical defect but was **deliberately left unfixed**: it gets its models from `useProviderModels({ modelFilter })`, and passing a `modelFilter` whose identity changes when the fetch resolves (null → Set) breaks two ways. (1) `pickInitialModel` (`client/src/hooks/useProviderModels.js:44-49`) closes over `modelFilter`, and `load` (`:52-68`) depends on `pickInitialModel`, so the `useEffect(() => { load(); }, [load])` at `:70` re-fires a redundant `api.getProviders()`. (2) Worse, `load` guards initial selection behind `hasSetInitialRef` (`:62`), so the model auto-picked during the FIRST load (regex-only, returns `''` when the only VLM is `gemma4`) is never re-picked once the authoritative set lands — leaving `selectedModel === ''` while `availableModels` now contains `gemma4`, which renders the "no vision model" blocker (`VisionProviderPicker.jsx:41` `noVisionModel = hasProviders && !selectedModel`) *next to a populated dropdown*. That half-fixed state is more confusing than the current consistent-but-wrong behavior, so the change was reverted. Doing it properly means teaching `useProviderModels` to re-run its initial pick when `modelFilter`'s identity changes (e.g. re-pick when the current `selectedModel` is no longer in / absent from `availableModels`, without clobbering a deliberate user clear) — that hook is shared by many callers and `VisionProviderPicker` has no test file, so it needs its own PR + tests. Deferred from the Creative-Director vision-picker fix, which is scoped to the `assignment*` helpers and ships fully tested.
+
+### 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.
+- [ ] **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/OverviewTab.jsx b/client/src/components/creative-director/OverviewTab.jsx
index 71b268088d..b5b06dc1e1 100644
--- a/client/src/components/creative-director/OverviewTab.jsx
+++ b/client/src/components/creative-director/OverviewTab.jsx
@@ -178,10 +178,14 @@ export default function OverviewTab({ project, onProjectUpdate, onAsyncWorkQueue
// that carries a `jobId`, so that's the discriminator (pinned by a test).
const inlineImage = !project.finalVideoId && preview.kind === 'image' && preview.jobId ? preview : null;
// The id→file mismatch: a stitched final is `timeline-*.mp4` behind a UUID.
- // The idle player is `preload="none"`, so a late resolve can't be raced here.
- const { src: finalVideoSrc, retry: retryFinalVideo } = useVideoFileSrc(project.finalVideoId, {
- enabled: Boolean(project.finalVideoId),
- });
+ // `preload="none"` stops the browser fetching during the lookup, but it does
+ // NOT stop the USER: mounting early would expose the unresolved guess to both
+ // the play control and ScenePreview's open-in-new-tab link, so a click inside
+ // the window 404s. Hold the frame until it settles, as the card does.
+ const { src: finalVideoSrc, resolving: finalVideoResolving, retry: retryFinalVideo } = useVideoFileSrc(
+ project.finalVideoId,
+ { enabled: Boolean(project.finalVideoId) },
+ );
return (
<div className="space-y-4 max-w-3xl">
@@ -192,7 +196,9 @@ export default function OverviewTab({ project, onProjectUpdate, onAsyncWorkQueue
</h2>
<div className={`${aspectClass} ${maxWidthClass} w-full mx-auto rounded overflow-hidden bg-port-bg`}>
{project.finalVideoId
- ? <ScenePreview jobId={project.finalVideoId} src={finalVideoSrc} onRetry={retryFinalVideo} label="Final video" aspectClass={aspectClass} />
+ ? (finalVideoResolving
+ ? <div className="w-full h-full flex items-center justify-center text-port-text-muted text-xs">loading…</div>
+ : <ScenePreview jobId={project.finalVideoId} src={finalVideoSrc} onRetry={retryFinalVideo} label="Final video" aspectClass={aspectClass} />)
: (
<MediaImage
src={inlineImage.src}
diff --git a/client/src/components/creative-director/ProjectPreview.jsx b/client/src/components/creative-director/ProjectPreview.jsx
index 4d5b9dd9f6..da94400ccb 100644
--- a/client/src/components/creative-director/ProjectPreview.jsx
+++ b/client/src/components/creative-director/ProjectPreview.jsx
@@ -25,19 +25,16 @@ import { useVideoFileSrc } from '../../hooks/useVideoFileSrc.js';
*/
export default function ProjectPreview({ project, to }) {
const [playing, setPlaying] = useState(false);
- const [posterMissing, setPosterMissing] = useState(false);
const preview = selectProjectPreview(project);
const aspectClass = previewAspectClass(project?.aspectRatio);
// The card keeps its identity across list updates (the grid keys on project
// id, and start/pause patch a project in place), so this instance outlives a
// change of preview target — e.g. a scene render lands, or the stitch
- // promotes a finalVideoId. Reset the per-asset state when the target moves,
- // or a 404 recorded against the OLD poster would pin the placeholder on the
- // new one, and a card left playing would keep showing the previous render.
- // Mirrors ScenePreview's own `jobId` reset effect.
+ // promotes a finalVideoId. Drop back to the poster when the target moves, or
+ // a card left playing would keep showing the previous render. (MediaImage and
+ // ScenePreview each own the reset of their own load state.)
useEffect(() => {
- setPosterMissing(false);
setPlaying(false);
}, [preview.jobId, preview.src]);
@@ -81,25 +78,28 @@ export default function ProjectPreview({ project, to }) {
className="w-full h-full object-cover"
/>
)}
- {preview.kind === 'video' && !posterMissing && (
- <img
+ {preview.kind === 'video' && (
+ // Every render path writes a `<jobId>.jpg` thumbnail (clips via
+ // videoGen, stitched finals via the timeline renderer), so a failure
+ // here means the poster isn't loadable right now — a pruned history
+ // entry, or a federated project whose bytes haven't been pulled yet.
+ // MediaImage is the right tool for exactly that: it degrades to a
+ // placeholder instead of a broken-image icon AND auto-recovers on
+ // `peerSync:asset-arrived`, which a bare <img onError> can't do (it
+ // would strand the card on the placeholder until a remount). The play
+ // affordance stays regardless — the mp4 can be fine when its poster
+ // isn't.
+ <MediaImage
src={preview.poster}
alt={`${preview.label} — ${project?.name || 'project'}`}
loading="lazy"
- // Every render path DOES write a `<jobId>.jpg` thumbnail — clips via
- // videoGen, stitched finals via the timeline renderer — so a 404 here
- // means the poster was deleted out from under us (history prune), not
- // that this project type lacks one. Degrade to the placeholder rather
- // than a broken-image icon; the play affordance stays either way,
- // since the mp4 can be fine even when its poster isn't.
- onError={() => setPosterMissing(true)}
className="w-full h-full object-cover"
/>
)}
- {(preview.kind === 'none' || (preview.kind === 'video' && posterMissing)) && (
+ {preview.kind === 'none' && (
<div className="w-full h-full flex flex-col items-center justify-center gap-1 text-port-text-muted text-xs">
<Film className="w-4 h-4 opacity-50" aria-hidden="true" />
- <span>{preview.kind === 'none' ? 'no render yet' : preview.label}</span>
+ <span>no render yet</span>
</div>
)}
</Link>
diff --git a/client/src/components/pipeline/stages/EpisodeVideoStage.jsx b/client/src/components/pipeline/stages/EpisodeVideoStage.jsx
index 4451fdb2ea..62f3a2edc6 100644
--- a/client/src/components/pipeline/stages/EpisodeVideoStage.jsx
+++ b/client/src/components/pipeline/stages/EpisodeVideoStage.jsx
@@ -10,6 +10,7 @@ import ScenePreview from '../../creative-director/ScenePreview';
import ModelSelect from '../../ModelSelect';
import { useAsyncAction } from '../../../hooks/useAsyncAction';
import { useAutoRefetch } from '../../../hooks/useAutoRefetch';
+import { useVideoFileSrc } from '../../../hooks/useVideoFileSrc';
import { sceneShotWarnings } from '../../../lib/shotContinuity';
// Monotonic snapshot: a poll is logically equivalent when the project's id,
@@ -221,6 +222,14 @@ export default function EpisodeVideoStage({ issue, onStageUpdate }) {
const accepted = sortedScenes.filter((s) => s.status === 'accepted').length;
const total = sortedScenes.length;
const finalVideoId = cdProject?.finalVideoId || null;
+ // A CD final is a video-history id, NOT a filename stem — the timeline
+ // renderer that stitches it mints `timeline-<project>-<ts>.mp4` beside a
+ // randomUUID() id, so ScenePreview's `<jobId>.mp4` reconstruction 404s here
+ // (under a poster that loads fine, since thumbnails ARE `<jobId>.jpg`).
+ // Resolve through the stored filename like the CD surfaces do (#2702).
+ const { src: finalVideoSrc, retry: retryFinalVideo } = useVideoFileSrc(finalVideoId, {
+ enabled: Boolean(finalVideoId),
+ });
const isComplete = cdProject?.status === 'complete' && finalVideoId;
const isFailed = cdProject?.status === 'failed';
const polling = cdProject && !isTerminalProjectStatus(cdProject.status);
@@ -376,7 +385,7 @@ export default function EpisodeVideoStage({ issue, onStageUpdate }) {
{isComplete && finalVideoId && (
<div className="space-y-2 pt-1">
- <ScenePreview jobId={finalVideoId} label="Final episode video" />
+ <ScenePreview jobId={finalVideoId} src={finalVideoSrc} onRetry={retryFinalVideo} label="Final episode video" />
<div className="text-xs text-gray-500">
<span className="font-mono">final {finalVideoId.slice(0, 8)}</span>
</div>
diff --git a/client/src/lib/creativeDirectorPreview.js b/client/src/lib/creativeDirectorPreview.js
index 7f8ccbf9a3..4bc0a4c46c 100644
--- a/client/src/lib/creativeDirectorPreview.js
+++ b/client/src/lib/creativeDirectorPreview.js
@@ -135,7 +135,10 @@ export function startingImageSrc(startingImageFile) {
if (raw.startsWith(IMAGES_PREFIX)) name = raw.slice(IMAGES_PREFIX.length);
else if (raw.startsWith('/')) return null; // some other absolute path → not a gallery image
else name = raw;
- const base = nonEmptyString(name.split('/').pop());
+ // Strip the query/hash BEFORE taking the basename — exactly as the server's
+ // `assetBasename` does. Reversing the order resolves the wrong asset when a
+ // suffix itself contains a slash (`photo.png?source=/other.png` → `other.png`).
+ const base = nonEmptyString(name.split(/[?#]/)[0].split('/').pop());
if (!base || base === '.' || base === '..') return null;
return `${IMAGES_PREFIX}${base}`;
}
diff --git a/client/src/lib/creativeDirectorPreview.test.js b/client/src/lib/creativeDirectorPreview.test.js
index 936ebec4fb..592dbb88f2 100644
--- a/client/src/lib/creativeDirectorPreview.test.js
+++ b/client/src/lib/creativeDirectorPreview.test.js
@@ -74,6 +74,16 @@ describe('startingImageSrc', () => {
expect(startingImageSrc('/data/images/../../secret.png')).toBe('/data/images/secret.png');
});
+ it('strips a query/hash suffix BEFORE taking the basename, like the server helper', () => {
+ // Order matters: basename-first would resolve a slash-bearing suffix as the
+ // filename (`photo.png?source=/other.png` → `other.png`), pointing the
+ // preview at a different asset than `localImageFilename()` ships.
+ expect(startingImageSrc('/data/images/photo.png?source=/other.png')).toBe('/data/images/photo.png');
+ expect(startingImageSrc('photo.png?v=2')).toBe('/data/images/photo.png');
+ expect(startingImageSrc('/data/images/photo.png#frag')).toBe('/data/images/photo.png');
+ expect(startingImageSrc('/data/images/photo.png?a=1#b')).toBe('/data/images/photo.png');
+ });
+
it('returns null for empty/blank/non-string input', () => {
expect(startingImageSrc('')).toBeNull();
expect(startingImageSrc(' ')).toBeNull();