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

Keep the soundtrack panel usable when a saved render is gone; label only a rendered take

Claude11e3dfe5a0b0
diff --git a/client/src/components/codeAnimation/CodeAnimationSoundtrack.jsx b/client/src/components/codeAnimation/CodeAnimationSoundtrack.jsx
index add23f5f68..7816933cb8 100644
--- a/client/src/components/codeAnimation/CodeAnimationSoundtrack.jsx
+++ b/client/src/components/codeAnimation/CodeAnimationSoundtrack.jsx
@@ -38,7 +38,7 @@ function engineNote(engine, filmSec) {
* the score, and render a track at the film's length. The animation is not
* re-run; the track becomes its audio for the preview and the MP4 export.
*/
-export default function CodeAnimationSoundtrack({ jobId, soundtrack, audioUrl, durationSeconds, onReady }) {
+export default function CodeAnimationSoundtrack({ jobId, soundtrack, audioUrl, audioTrackId, durationSeconds, onReady }) {
const filmSec = Math.ceil(Number(durationSeconds) || 0);
const engineList = useListResource(fetchEngines);
const engines = engineList.state === 'ready' ? engineList.items : null;
@@ -46,6 +46,9 @@ export default function CodeAnimationSoundtrack({ jobId, soundtrack, audioUrl, d
const [prompt, setPrompt] = useState(soundtrack?.prompt || '');
const [starting, setStarting] = useState(false);
const [mediaJobId, setMediaJobId] = useState(soundtrack?.mediaJobId || null);
+ // Only a render started here counts as live before its first status read; a
+ // persisted id the queue no longer knows (archived, lost on restart) is idle.
+ const [startedId, setStartedId] = useState(null);
useEffect(() => {
setPrompt(soundtrack?.prompt || '');
@@ -77,7 +80,7 @@ export default function CodeAnimationSoundtrack({ jobId, soundtrack, audioUrl, d
}, { enabled: !!engine && !!prompt.trim() });
const progress = useMediaJobProgress(mediaJobId, { kind: 'audio' });
- const live = progress.status === 'queued' || progress.status === 'running' || (mediaJobId && progress.status === 'unknown');
+ const live = progress.status === 'queued' || progress.status === 'running' || (!!mediaJobId && mediaJobId === startedId && progress.status === 'unknown');
// Refetch the animation once the take lands so the preview and export use it.
const settledRef = useRef(null);
useEffect(() => {
@@ -101,11 +104,15 @@ export default function CodeAnimationSoundtrack({ jobId, soundtrack, audioUrl, d
return null;
});
setStarting(false);
- if (started?.mediaJobId) setMediaJobId(started.mediaJobId);
+ if (started?.mediaJobId) {
+ setStartedId(started.mediaJobId);
+ setMediaJobId(started.mediaJobId);
+ }
};
const percent = Math.round((progress.progress || 0) * 100);
- const hasTake = !!soundtrack?.trackId && !!audioUrl;
+ // The job's audio is the generated track only once a take has rendered onto it.
+ const hasTake = !!soundtrack?.trackId && !!audioUrl && audioTrackId === soundtrack.trackId;
return (
<section className="space-y-3 rounded-lg border border-port-border bg-port-card p-3" aria-labelledby="ca-soundtrack-heading">
diff --git a/client/src/components/codeAnimation/CodeAnimationSoundtrack.test.jsx b/client/src/components/codeAnimation/CodeAnimationSoundtrack.test.jsx
index aad5e51f08..88afd5d04b 100644
--- a/client/src/components/codeAnimation/CodeAnimationSoundtrack.test.jsx
+++ b/client/src/components/codeAnimation/CodeAnimationSoundtrack.test.jsx
@@ -66,9 +66,19 @@ describe('CodeAnimationSoundtrack', () => {
expect(screen.getByText('Rendering the score')).toBeTruthy();
progress.current = { status: 'completed', progress: 1 };
- rerender(<CodeAnimationSoundtrack jobId={JOB_ID} durationSeconds={120} soundtrack={soundtrack} onReady={onReady} audioUrl="/data/music/take.wav" />);
+ rerender(<CodeAnimationSoundtrack jobId={JOB_ID} durationSeconds={120} soundtrack={soundtrack} onReady={onReady} audioUrl="/data/music/take.wav" audioTrackId="track-1" />);
await waitFor(() => expect(onReady).toHaveBeenCalledTimes(1));
expect(screen.getByLabelText('Generated soundtrack').getAttribute('src')).toBe('/data/music/take.wav');
expect(screen.getByRole('button', { name: 'Regenerate audio' })).toBeTruthy();
});
+
+ it('stays usable when the saved render is gone from the queue, and never calls older audio the take', async () => {
+ // A 404 hydrate leaves the media job "unknown"; that is not a live render.
+ const soundtrack = { trackId: 'track-1', mediaJobId: 'media-archived', prompt: 'Warm synths' };
+ render(<CodeAnimationSoundtrack jobId={JOB_ID} durationSeconds={120} soundtrack={soundtrack} audioUrl="/api/uploads/original.mp3" audioTrackId={undefined} />);
+ const button = await screen.findByRole('button', { name: 'Generate audio' });
+ await waitFor(() => expect(button.disabled).toBe(false));
+ expect(screen.getByLabelText('Describe the music').disabled).toBe(false);
+ expect(screen.queryByLabelText('Generated soundtrack')).toBeNull();
+ });
});
diff --git a/client/src/pages/CodeAnimation.jsx b/client/src/pages/CodeAnimation.jsx
index e0f1a9f1b3..b218767092 100644
--- a/client/src/pages/CodeAnimation.jsx
+++ b/client/src/pages/CodeAnimation.jsx
@@ -799,6 +799,7 @@ function FastCodeAnimation() {
jobId={job.id}
soundtrack={job.soundtrack}
audioUrl={job.audioUrl}
+ audioTrackId={job.input?.audio?.trackId}
durationSeconds={job.frame?.durationSeconds}
onReady={jobResource.refetch}
/>