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: explain silent Code Animation exports (#9391)

Adam Eivye2be837e0a20
diff --git a/client/src/components/codeAnimation/CodeAnimationPreview.jsx b/client/src/components/codeAnimation/CodeAnimationPreview.jsx
index b390e111b6..4c9817de3f 100644
--- a/client/src/components/codeAnimation/CodeAnimationPreview.jsx
+++ b/client/src/components/codeAnimation/CodeAnimationPreview.jsx
@@ -90,7 +90,9 @@ export default function CodeAnimationPreview({ html, audioUrl, messages, audioGl
// Frame-exact export runs server-side on the media queue; its progress and
// result stream from the composition job's SSE channel.
const [exportJob, setExportJob] = useState(null);
+ const [exportNotes, setExportNotes] = useState([]);
const [exportStarting, setExportStarting] = useState(false);
+ const exportRequestRef = useRef(0);
const exportUrl = exportJob ? `/api/html-composition/${encodeURIComponent(exportJob)}/events` : null;
const { latest: exportFrame } = useSseProgress(exportUrl, { enabled: !!exportUrl });
const exportResult = exportFrame?.type === 'complete' ? exportFrame.result : null;
@@ -104,6 +106,9 @@ export default function CodeAnimationPreview({ html, audioUrl, messages, audioGl
useEffect(() => {
setExportJob(null);
+ setExportNotes([]);
+ setExportStarting(false);
+ return () => { exportRequestRef.current += 1; };
}, [jobId]);
useEffect(() => {
@@ -198,13 +203,16 @@ export default function CodeAnimationPreview({ html, audioUrl, messages, audioGl
const handleExport = async () => {
if (!jobId || exporting || exportStarting) return;
+ const request = ++exportRequestRef.current;
setExportStarting(true);
const queued = await exportCodeAnimation(jobId, { silent: true }).catch((error) => {
- toast.error(error.message || 'Failed to start the export');
+ if (request === exportRequestRef.current) toast.error(error.message || 'Failed to start the export');
return null;
});
+ if (request !== exportRequestRef.current) return;
setExportStarting(false);
if (!queued?.jobId) return;
+ setExportNotes(queued.notes || []);
for (const note of queued.notes || []) toast(note);
setExportJob(queued.jobId);
};
@@ -335,6 +343,12 @@ export default function CodeAnimationPreview({ html, audioUrl, messages, audioGl
</span>
</div>
+ {exportNotes.length > 0 && (
+ <div role="status" aria-label="Export notes" className="space-y-1 rounded-lg border border-port-border bg-port-card p-3 text-sm text-gray-400">
+ {exportNotes.map((note) => <p key={note}>{note}</p>)}
+ </div>
+ )}
+
{exportResult?.path && (
<div className="space-y-2 rounded-lg border border-port-border bg-port-card p-3">
<video src={exportResult.path} controls className="max-h-80 w-full rounded bg-black" aria-label="Exported animation" />
diff --git a/client/src/components/codeAnimation/CodeAnimationPreview.test.jsx b/client/src/components/codeAnimation/CodeAnimationPreview.test.jsx
index 6c5339cb9a..1139f025e2 100644
--- a/client/src/components/codeAnimation/CodeAnimationPreview.test.jsx
+++ b/client/src/components/codeAnimation/CodeAnimationPreview.test.jsx
@@ -124,6 +124,36 @@ describe('CodeAnimationPreview', () => {
});
describe('CodeAnimationPreview frame-exact export', () => {
+ it('retains sound limitations beside the completed export and clears them when switching animations', async () => {
+ const user = userEvent.setup();
+ const note = 'Procedural Web Audio is not rendered offline; the frame-exact export is silent.';
+ exportCodeAnimation.mockResolvedValue({ jobId: 'media-1', notes: [note] });
+ const { rerender } = renderPreview({ jobId: 'job-1' });
+ await user.click(screen.getByRole('button', { name: /export mp4/i }));
+ expect(screen.getByRole('status', { name: 'Export notes' })).toHaveTextContent(note);
+ useSseProgress.mockReturnValue({ latest: { type: 'complete', result: { path: '/data/videos/example.mp4' } } });
+ const preview = (jobId) => <MemoryRouter><CodeAnimationPreview html={HTML} jobId={jobId} /></MemoryRouter>;
+ rerender(preview('job-1'));
+ expect(screen.getByLabelText('Exported animation')).toBeInTheDocument();
+ expect(screen.getByRole('status', { name: 'Export notes' })).toHaveTextContent(note);
+ useSseProgress.mockReturnValue({ latest: null });
+ rerender(preview('job-2'));
+ expect(screen.queryByRole('status', { name: 'Export notes' })).toBeNull();
+ });
+
+ it('drops a queued export response after switching to a different animation', async () => {
+ const user = userEvent.setup();
+ let finish;
+ exportCodeAnimation.mockImplementationOnce(() => new Promise((resolve) => { finish = resolve; }));
+ const { rerender } = renderPreview({ jobId: 'job-1' });
+ await user.click(screen.getByRole('button', { name: /export mp4/i }));
+ rerender(<MemoryRouter><CodeAnimationPreview html={HTML} jobId="job-2" /></MemoryRouter>);
+ await act(async () => finish({ jobId: 'old-export', notes: ['Old soundtrack limitation'] }));
+ expect(screen.queryByRole('status', { name: 'Export notes' })).toBeNull();
+ expect(useSseProgress).toHaveBeenLastCalledWith(null, { enabled: false });
+ expect(screen.getByRole('button', { name: /export mp4/i })).toBeEnabled();
+ });
+
it('offers export only for a saved job, queues it, and follows the composition job stream', async () => {
const user = userEvent.setup();
exportCodeAnimation.mockResolvedValue({ jobId: 'media-1', notes: [] });
diff --git a/server/routes/codeAnimation.test.js b/server/routes/codeAnimation.test.js
index ec84e3c8f1..c88ee323ba 100644
--- a/server/routes/codeAnimation.test.js
+++ b/server/routes/codeAnimation.test.js
@@ -51,6 +51,9 @@ vi.mock('../services/promptRunner.js', () => ({
resolveProviderAndModel: vi.fn(),
assertProvider: vi.fn(),
}));
+vi.mock('../services/mediaJobQueue/index.js', () => ({
+ enqueueJob: vi.fn(async () => ({ jobId: 'media-export', position: 1, status: 'queued' })),
+}));
import { emitCodeAnimationChanged } from '../services/socket.js';
import { PATHS } from '../lib/paths.js';
@@ -60,6 +63,7 @@ import { getProviderById } from '../services/providers.js';
import { getTrack } from '../services/tracks/index.js';
import { listCodeAnimationJobPage, listCodeAnimationJobRecords, readCodeAnimationHtml, saveCodeAnimationHtml, saveCodeAnimationJobRecord } from '../services/codeAnimation/jobStore.js';
import { assertProvider, resolveProviderAndModel, runPromptThroughProvider } from '../services/promptRunner.js';
+import { enqueueJob } from '../services/mediaJobQueue/index.js';
import routes from './codeAnimation.js';
const makeApp = () => {
@@ -119,6 +123,34 @@ beforeEach(() => {
resolveProviderAndModel.mockResolvedValue({ provider: { id: 'api-1', type: 'api' }, selectedModel: 'example-model' });
});
+describe('Code Animation fast-export audio notes', () => {
+ it('distinguishes omitted procedural/upload audio from intentional silence without generating sound', async () => {
+ const id = '00000000-0000-4000-8000-000000000001';
+ const job = { id, status: 'completed', frame: { width: 1920, height: 1080, fps: 24, durationSeconds: 15 } };
+ codeAnimationHtml.set(id, '<!doctype html><html><head></head><body><canvas></canvas></body></html>');
+ const app = makeApp();
+ for (const [fields, note] of [
+ [{ input: { soundtrack: 'procedural' } }, /Procedural Web Audio.*export is silent/],
+ [{ audioUrl: '/api/uploads/example.wav' }, /Uploaded audio is not muxed.*export is silent/],
+ [{ input: { soundtrack: 'none' } }, /No soundtrack was requested.*intentionally silent/],
+ [{}, null], // Unknown legacy intent is not declared intentional silence.
+ ]) {
+ codeAnimationRecords.set(id, { ...job, ...fields });
+ const response = await request(app).post(`/api/code-animation/${id}/export`);
+ expect(response.status).toBe(202);
+ expect(response.body).toMatchObject({ jobId: 'media-export', status: 'queued' });
+ expect(response.body.notes).toEqual(note ? [expect.stringMatching(note)] : []);
+ }
+ expect(enqueueJob.mock.calls).toHaveLength(4);
+ for (const [queued] of enqueueJob.mock.calls) {
+ expect(queued).toEqual({ kind: 'html-composition', params: {
+ directory: expect.stringMatching(new RegExp(`^code-animation-exports/${id}/[0-9a-f-]{36}$`)),
+ } });
+ }
+ expect(runPromptThroughProvider).not.toHaveBeenCalled();
+ });
+});
+
describe('Code Animation portable packages', () => {
const id = '00000000-0000-4000-8000-000000000001';
const html = '<!doctype html><html><body><script>window.renderFrame = t => t;</script></body></html>\n';
diff --git a/server/services/codeAnimation/export.js b/server/services/codeAnimation/export.js
index 6f804c3141..8f6d855a2d 100644
--- a/server/services/codeAnimation/export.js
+++ b/server/services/codeAnimation/export.js
@@ -133,6 +133,12 @@ export async function startCodeAnimationExport(id, deps = {}) {
const musicTrack = musicTrackOf(job);
const notes = [];
if (job.audioUrl && !musicTrack) notes.push('Uploaded audio is not muxed; the export is silent. Attach a Music-library track to include it.');
+ if (!job.audioUrl && job.input?.soundtrack === 'procedural') {
+ notes.push('Procedural Web Audio is not rendered offline; the frame-exact export is silent. Attach a Music-library track to include audio.');
+ }
+ if (!job.audioUrl && !job.input?.audio && job.input?.soundtrack === 'none') {
+ notes.push('No soundtrack was requested; the export is intentionally silent.');
+ }
if (durationSeconds > EXPORT_MAX_DURATION_SEC) notes.push(`The export is capped at ${EXPORT_MAX_DURATION_SEC}s; this animation runs ${durationSeconds}s.`);
const song = musicTrack ? await beatGrid(musicTrack) : null;
// One staging directory per export: a queued render snapshots its directory
diff --git a/server/services/codeAnimation/prompt.js b/server/services/codeAnimation/prompt.js
index 71c9e5ea0a..54314c63a4 100644
--- a/server/services/codeAnimation/prompt.js
+++ b/server/services/codeAnimation/prompt.js
@@ -277,7 +277,7 @@ export function buildCodeAnimationPrompt({
sections.push(`SOUND:\n${audioSection({ audio, soundtrack, durationSeconds })}`);
sections.push(`FORMAT: ${format.aspectRatio} at ${width}×${height}px, ${fps}fps, ${durationSeconds}s. ${RENDERER_GUIDANCE[renderer] || RENDERER_GUIDANCE.auto}`);
sections.push(DIRECTION);
- sections.push(runtimeContract({ width, height, fps, durationSeconds, interactive, hasAudio: !!audio }));
+ sections.push(runtimeContract({ width, height, fps, durationSeconds, interactive, hasAudio: !!audio || soundtrack === 'procedural' }));
sections.push(SELF_REVIEW);
sections.push(`OUTPUT: Return ONLY the finished HTML document in a single \`\`\`html fenced code block, starting with <!DOCTYPE html>. No explanation before or after it.${delivery === 'cli' ? ' Do not create or edit any files — print the document as your final answer.' : ''}`);
return sections.join('\n\n');
diff --git a/server/services/codeAnimation/prompt.test.js b/server/services/codeAnimation/prompt.test.js
index 3d55b7f4bd..807392390c 100644
--- a/server/services/codeAnimation/prompt.test.js
+++ b/server/services/codeAnimation/prompt.test.js
@@ -86,7 +86,10 @@ describe('buildCodeAnimationPrompt', () => {
const procedural = buildCodeAnimationPrompt({ concept: 'x', format, soundtrack: 'procedural' });
expect(procedural).toContain('procedural soundtrack');
expect(procedural).toContain('Silence is a beat');
- expect(buildCodeAnimationPrompt({ concept: 'x', format })).toContain('The animation is silent');
+ expect(procedural).toContain('MediaStreamAudioDestinationNode');
+ const silent = buildCodeAnimationPrompt({ concept: 'x', format });
+ expect(silent).toContain('The animation is silent');
+ expect(silent).not.toContain('MediaStreamAudioDestinationNode');
});
it('gives CLI agents on-disk reference paths and keeps them out of a copied prompt', () => {