Show it a video you love. Get a new video in the same style. An AI crew (Claude Code or Codex) plans, builds and reviews it with you.
JavaScript 2d-animationai-agentsai-videoanimationclaude-codecodexmulti-agentstyle-transfervideo-generation
fix: report the alignment outcome when the song upload triggers it
Oliver Pemberton730038bc27fd
diff --git a/app/server/index.ts b/app/server/index.tsindex ed66ae6..ed9166e 100644--- a/app/server/index.ts+++ b/app/server/index.ts@@ -7,6 +7,7 @@ import { existsSync, mkdirSync, renameSync, unlinkSync } from 'node:fs';import { join, extname, resolve, sep } from 'node:path';import { createAgentCache } from './agents-cache.ts';import * as J from './jobs.ts';+import { L, chat } from './store.ts';// Ctrl+C / kill: stop the agents first (the next start marks their turns interrupted, and Retry resumes them)for (const sig of ['SIGINT', 'SIGTERM']) process.on(sig, () => { J.stopAll(); setTimeout(() => process.exit(0), 800); });@@ -69,7 +70,17 @@ app.post('/api/projects/:id/inputs', upload.array('inputs', 20), async (req, res}// ?for=<required input id>: these files answer that item (any file name); lyrics text/timing is handled thereif (!attach && req.query.for) J.provideInput(req.params.id, String(req.query.for), saved);- else if (!attach) J.alignIfReady(req.params.id).catch(() => null); // background: lyrics waiting for music+ // The upload of the song is the one moment waiting lyrics finally get timed - report the outcome+ // instead of dropping it. The upload response must not wait on the alignment either way.+ else if (!attach) J.alignIfReady(req.params.id)+ .then((r) => {+ if (r && !r.ok) chat(req.params.id, 'system', L(req.params.id,+ '無法為歌詞對時;流程會繼續,之後重新貼上歌詞即可再試一次',+ 'Lyrics could not be timed; the run continues, and pasting them again later will retry the alignment'));+ })+ .catch((e: Error) => chat(req.params.id, 'system', L(req.params.id,+ '無法為歌詞對時;流程會繼續',+ `Lyrics could not be timed (${e.message}); the run continues`)));J.touch(req.params.id);res.json({ ...J.snapshot(req.params.id), saved });});diff --git a/app/server/upload-align.test.ts b/app/server/upload-align.test.tsnew file mode 100644index 0000000..b853298--- /dev/null+++ b/app/server/upload-align.test.ts@@ -0,0 +1,46 @@+// POST /api/projects/:id/inputs (no ?for=): uploading the song is when waiting lyrics get timed.+// With a failing aligner the outcome must reach the chat instead of vanishing.+// Starts the real server on a spare port against a throwaway projects folder; PYTHON is bogus on+// purpose so the aligner cannot run. No agent is started.+import { after, test } from 'node:test';+import assert from 'node:assert/strict';+import { spawn } from 'node:child_process';+import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';++const TMP = mkdtempSync(join(tmpdir(), 'reelmimic-test-'));+const PORT = 20000 + Math.floor(Math.random() * 20000);+const server = spawn(process.execPath, [join(import.meta.dirname, 'index.ts')], { env: { ...process.env, PORT: String(PORT), REELMIMIC_PROJECTS: TMP, PYTHON: 'reelmimic-no-such-python' }, stdio: 'ignore' });+after(() => { server.kill(); rmSync(TMP, { recursive: true, force: true }); });++const ID = 't-align';+const D = join(TMP, ID);+mkdirSync(join(D, 'inputs'), { recursive: true });+writeFileSync(join(D, 'job.json'), JSON.stringify({ id: ID, title: 't', agent: 'claude', lang: 'en', stage: 'plan_review', chat: [], needs: [], pipeline: {} }));+writeFileSync(join(D, 'plan.json'), JSON.stringify({ music: { file: 'inputs/song.mp3' } }));+writeFileSync(join(D, 'inputs', 'lyrics.txt'), 'la la la\n');+writeFileSync(join(D, 'inputs', 'song.mp3'), '');++const get = async (path: string) => {+ for (let i = 0; i < 100; i++) { try { return await fetch(`http://127.0.0.1:${PORT}${path}`); } catch { await new Promise((r) => setTimeout(r, 100)); } }+ throw new Error('server did not start');+};++test('a failed alignment on upload answers the upload and says so in the chat', async () => {+ await get('/api/health');+ const fd = new FormData();+ fd.append('inputs', new Blob([new Uint8Array([1, 2, 3])]), 'extra.bin');+ const up = await fetch(`http://127.0.0.1:${PORT}/api/projects/${ID}/inputs`, { method: 'POST', body: fd });+ assert.equal(up.status, 200, 'the upload itself must succeed');+ let chat: { role?: string; text?: string }[] = [];+ for (let i = 0; i < 60; i++) {+ chat = ((await (await get(`/api/projects/${ID}`)).json()) as { job?: { chat?: { role?: string; text?: string }[] } }).job?.chat || [];+ if (chat.length) break;+ await new Promise((r) => setTimeout(r, 100));+ }+ const last = chat.at(-1);+ assert.equal(last?.role, 'system');+ assert.match(last?.text || '', /could not be timed/i);+ assert.ok(!existsSync(join(D, 'analysis', 'lyrics', 'subs.lrc')), 'no subs.lrc without a run');+});