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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
keep on-disk reference paths out of the generate response and let an embedded page post its own recording
[._.]/ Adam Eivye9c56e480e0b
diff --git a/client/src/components/codeAnimation/CodeAnimationPreview.jsx b/client/src/components/codeAnimation/CodeAnimationPreview.jsxindex 77369fea2f..75f37e2bff 100644--- a/client/src/components/codeAnimation/CodeAnimationPreview.jsx+++ b/client/src/components/codeAnimation/CodeAnimationPreview.jsx@@ -85,6 +85,7 @@ export default function CodeAnimationPreview({ html, audioUrl, messages, audioGl}, [html, audioGlobal, audio]);useEffect(() => {+ clearTimeout(recordTimerRef.current);setMeta(null);setRecording(false);setVideo(null);diff --git a/client/src/pages/CodeAnimation.jsx b/client/src/pages/CodeAnimation.jsxindex ad0b4e03d9..ddaaa752d9 100644--- a/client/src/pages/CodeAnimation.jsx+++ b/client/src/pages/CodeAnimation.jsx@@ -160,8 +160,12 @@ export default function CodeAnimation() {const jobSettled = job?.id === jobId && job.status !== 'running';const pollJob = useCallback(async () => {const requested = jobId;- const next = await getCodeAnimationJob(requested, { silent: true })- .catch((error) => ({ id: requested, status: 'missing', error: error.message }));+ // Only a 404 means the job is gone; any other failure rethrows so the+ // poller keeps trying on its next tick.+ const next = await getCodeAnimationJob(requested, { silent: true }).catch((error) => {+ if (error.status === 404) return { id: requested, status: 'missing', error: error.message };+ throw error;+ });if (jobIdRef.current !== requested) return;setJob(next);if (next.status === 'completed' && next.html) setPreview({ html: next.html, audioUrl: next.audioUrl, frame: next.frame });@@ -229,7 +233,7 @@ export default function CodeAnimation() {});setStarting(false);if (!started) return;- setBuilt({ prompt: started.prompt, attachments: started.attachments, frame: started.frame, audioUrl: started.audioUrl, briefKey });+ setBuilt({ prompt: started.prompt, attachments: started.attachments, frame: started.frame, audioUrl: started.audioUrl, moodBoardId: started.moodBoardId, briefKey });setJob(started);setPreview(null);const next = new URLSearchParams(searchParams);diff --git a/server/routes/codeAnimation.test.js b/server/routes/codeAnimation.test.jsindex 8bd1af0fd9..906ca684eb 100644--- a/server/routes/codeAnimation.test.js+++ b/server/routes/codeAnimation.test.js@@ -151,7 +151,11 @@ describe('POST /api/code-animation/generate', () => {runPromptThroughProvider.mockResolvedValue({ text: 'I wrote the file to disk.', provider: { id: 'cli-1' } });const app = makeApp();const res = await request(app).post('/api/code-animation/generate').send({ ...brief, providerId: 'cli-1' });- expect(runPromptThroughProvider.mock.calls[0][0].screenshots).toEqual([]);+ const call = runPromptThroughProvider.mock.calls[0][0];+ expect(call.screenshots).toEqual([]);+ // The agent reads references from disk; the client gets the copy form.+ expect(call.prompt).toContain(join(PATHS.images, 'pin.png'));+ expect(res.body.prompt).not.toContain(PATHS.data);const job = await pollUntilSettled(app, res.body.id);expect(job.status).toBe('failed');expect(job.error).toMatch(/did not contain an HTML document/);diff --git a/server/services/codeAnimation/index.js b/server/services/codeAnimation/index.jsindex 02cf7481cb..9966c66010 100644--- a/server/services/codeAnimation/index.js+++ b/server/services/codeAnimation/index.js@@ -180,7 +180,7 @@ export async function buildCodeAnimationRequest(input, { delivery = 'copy' } = {: Math.max(0, CODE_ANIMATION_LIMITS.referenceImagesMax - uploads.length - universeImages.length),});const referenceImages = [...uploads, ...universeImages, ...boardImages];- const prompt = buildCodeAnimationPrompt({+ const promptInput = {title: input.title,concept: input.concept,onScreenText: input.onScreenText,@@ -193,10 +193,13 @@ export async function buildCodeAnimationRequest(input, { delivery = 'copy' } = {universe,moodBoard: board,referenceImages,- delivery,- });+ };+ const prompt = buildCodeAnimationPrompt({ ...promptInput, delivery });return {prompt,+ // The copy form describes references as attachments; the CLI form embeds+ // their on-disk paths, which must not reach the client.+ copyPrompt: delivery === 'copy' ? prompt : buildCodeAnimationPrompt({ ...promptInput, delivery: 'copy' }),moodBoardId: moodBoardId || null,frame: { ...resolveFrameSize(input.format.aspectRatio, input.format.resolution), fps: input.format.fps, durationSeconds: input.format.durationSeconds },// Absolute paths never leave the server — the client gets served URLs only.@@ -229,7 +232,7 @@ function settleJob(id, patch) {jobs.set(id, { ...job, ...patch, completedAt: new Date().toISOString(), updatedAtMs: Date.now() });}-async function runGeneration(jobId, { provider, model, effort, prompt, referencePaths }) {+async function runGeneration({ provider, model, effort, prompt, referencePaths }) {const { runPromptThroughProvider } = await import('../promptRunner.js');const result = await runPromptThroughProvider({provider,@@ -279,7 +282,7 @@ export async function startCodeAnimationGeneration(input) {updatedAtMs: Date.now(),});console.log(`🎞️ Code animation generation ${id.slice(0, 8)} started on ${provider.id}`);- runGeneration(id, { provider, model: input.model, effort: input.effort, prompt: built.prompt, referencePaths: built.referencePaths })+ runGeneration({ provider, model: input.model, effort: input.effort, prompt: built.prompt, referencePaths: built.referencePaths }).then(({ html, provider: ranOn, model, runId }) => {settleJob(id, { status: 'completed', html, providerId: ranOn, model, runId });console.log(`✅ Code animation generation ${id.slice(0, 8)} completed (${html.length} chars)`);@@ -289,7 +292,7 @@ export async function startCodeAnimationGeneration(input) {settleJob(id, { status: 'failed', error: message });console.error(`❌ Code animation generation ${id.slice(0, 8)} failed: ${message}`);});- return { ...publicJob(jobs.get(id)), prompt: built.prompt, attachments: built.attachments };+ return { ...publicJob(jobs.get(id)), prompt: built.copyPrompt, attachments: built.attachments, moodBoardId: built.moodBoardId };}export function getCodeAnimationJob(id) {diff --git a/server/services/codeAnimation/prompt.js b/server/services/codeAnimation/prompt.jsindex e8454caf92..fb36a3f57f 100644--- a/server/services/codeAnimation/prompt.js+++ b/server/services/codeAnimation/prompt.js@@ -182,7 +182,7 @@ function runtimeContract({ width, height, fps, durationSeconds, interactive, has3. \`window.renderFrame(t)\` draws the frame at time t (seconds, 0 ≤ t ≤ ${durationSeconds}) DETERMINISTICALLY: use a seeded PRNG, never Math.random/Date.now/performance.now inside drawing, and derive all motion from t (plus audio analysis while audio plays). Scrubbing to the same t twice must look the same.4. A requestAnimationFrame loop advances a clock and calls renderFrame(clock). The film loops back to 0 at the end unless it is recording.5. A minimal controls overlay OUTSIDE the canvas (so it never appears in a recording): play/pause, restart, a scrub bar with the current time, and a Record button. Autoplay on load when the browser allows it; otherwise show a clear play prompt.-6. \`window.recordAnimation()\` returns a Promise<Blob>: restart at t=0, capture \`canvas.captureStream(${fps})\` with MediaRecorder (prefer "video/webm;codecs=vp9", fall back to "video/webm"), play exactly ${durationSeconds}s, stop, and resolve the Blob.${audioTrack} The Record button calls it and downloads the result as a .webm file when the page is not embedded (window.parent === window).+6. \`window.recordAnimation()\` returns a Promise<Blob>: restart at t=0, capture \`canvas.captureStream(${fps})\` with MediaRecorder (prefer "video/webm;codecs=vp9", fall back to "video/webm"), play exactly ${durationSeconds}s, stop, and resolve the Blob.${audioTrack} The Record button calls it; when embedded (window.parent !== window) it posts the result to the host exactly as item 7 does, otherwise it downloads the result as a .webm file.7. postMessage handshake with the embedding host (always target "*"):- once ready: \`parent.postMessage({ type: '${m.ready}', meta: window.ANIMATION_META }, '*')\`- listen for \`{ type: '${m.record}' }\` → run recordAnimation(); while recording post \`{ type: '${m.progress}', t }\` about once per second; on success post \`{ type: '${m.recorded}', blob, mimeType }\`; on failure post \`{ type: '${m.error}', message }\`.${interaction}