Skip to content

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.

fix: name a project after the brief's first non-empty line; English placeholder for en

kevin9327b153247bccfc
diff --git a/app/server/index.ts b/app/server/index.ts
index 8503385..2efdf64 100644
--- a/app/server/index.ts
+++ b/app/server/index.ts
@@ -41,7 +41,7 @@ app.post('/api/projects', upload.fields([{ name: 'reference', maxCount: 1 }, { n
try { settings = Object.fromEntries(Object.entries(J.cleanRounds(req.body)).filter(([, v]) => v != null)); }
catch (e) { for (const f of Object.values(files || {}).flat()) try { unlinkSync(f.path); } catch {} return res.status(400).json({ error: (e as Error).message }); }
const id = slug();
- const job = J.createJob({ id, title: (title || brief.split('\n')[0] || '未命名').slice(0, 40), agent, brief, lang, settings,
+ const job = J.createJob({ id, title: J.projectTitle(title, brief, lang), agent, brief, lang, settings,
reference: ref ? { type: 'file', src: 'inputs/reference' + (extname(ref.originalname) || '.mp4') } : { type: 'url', src: url.trim() } });
if (ref) renameSync(ref.path, join(J.dirOf(id), job.reference.src));
for (const f of files?.inputs || []) renameSync(f.path, join(J.dirOf(id), 'inputs', fileName(f)));
diff --git a/app/server/jobs.test.ts b/app/server/jobs.test.ts
index 484f89f..e126d65 100644
--- a/app/server/jobs.test.ts
+++ b/app/server/jobs.test.ts
@@ -29,6 +29,24 @@ describe('cleanRounds', () => {
});
});
+describe('projectTitle', () => {
+ test('uses the title when one is given', () => {
+ assert.equal(J.projectTitle('My video', 'a brief', 'en'), 'My video');
+ });
+ test('falls back to the first non-empty line of the brief', () => {
+ assert.equal(J.projectTitle('', '\n \nA video about cats\nmore', 'en'), 'A video about cats');
+ assert.equal(J.projectTitle(' ', 'Line one\r\nLine two', 'zh-TW'), 'Line one');
+ });
+ test('the placeholder follows the project language', () => {
+ assert.equal(J.projectTitle('', '\n', 'en'), 'Untitled');
+ assert.equal(J.projectTitle('', '', 'zh-TW'), '未命名');
+ assert.equal(J.projectTitle(undefined, '', 'zh-CN'), '未命名');
+ });
+ test('cuts at 40 characters without splitting an emoji', () => {
+ assert.equal(J.projectTitle('a'.repeat(39) + '🎬🎬', '', 'en'), 'a'.repeat(39) + '🎬');
+ });
+});
+
describe('project settings', () => {
test('a new project uses the server defaults', () => {
const { id } = newJob();
diff --git a/app/server/jobs.ts b/app/server/jobs.ts
index efcff88..4c4836f 100644
--- a/app/server/jobs.ts
+++ b/app/server/jobs.ts
@@ -158,6 +158,13 @@ export function snapshot(id: string): Snapshot {
};
}
+// Project name: the given title, else the brief's first non-empty line, else a placeholder in the project's language.
+// Cut by characters, not UTF-16 units, so an emoji at the limit isn't split in half.
+export function projectTitle(title: string | undefined, brief: string, lang: Lang) {
+ const name = (title || '').trim() || brief.split('\n').map((l) => l.trim()).find(Boolean) || (lang === 'en' ? 'Untitled' : '未命名');
+ return Array.from(name).slice(0, 40).join('');
+}
+
export function createJob({ id, title, agent, brief, reference, lang = 'zh-TW', settings = {} }: { id: string; title: string; agent: AgentKind; brief: string; reference: Reference; lang?: Lang; settings?: Partial<Rounds> }) {
const d = dirOf(id); mkdirSync(join(d, 'inputs'), { recursive: true }); mkdirSync(join(d, 'analysis'), { recursive: true });
writeFileSync(join(d, 'brief.md'), brief || '');