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
fix: match excerpt typography to the full music video (#10703)
Adam Eivya376d4c1758d
diff --git a/server/services/musicVideo/composition.js b/server/services/musicVideo/composition.jsindex fe26ae22b8..0c0804ff40 100644--- a/server/services/musicVideo/composition.js+++ b/server/services/musicVideo/composition.js@@ -230,6 +230,16 @@ export function renderableCues(composition, durationSec) {.sort((a, b) => a.startSec - b.startSec);}+/** Shared absolute-song-time cues and style for full renders and draft excerpts. */+export function projectTypographyPlan(project, clips, sections, durationSec) {+ const graphicLanguage = project.treatment?.brief?.graphicLanguage;+ return {+ cues: [...renderableCues(project.composition, durationSec), ...sectionCardCues(clips, sections, durationSec, graphicLanguage)]+ .sort((a, b) => a.startSec - b.startSec),+ style: { ...project.composition?.style, graphicLanguage },+ };+}+/*** A title card's text (#8985), drawn by the typography layer for exactly its* section on the output timebase (`sections` from buildMusicVideoFfmpegArgs),diff --git a/server/services/musicVideo/excerptRender.js b/server/services/musicVideo/excerptRender.jsindex c9eabb42db..ddf1218fc3 100644--- a/server/services/musicVideo/excerptRender.js+++ b/server/services/musicVideo/excerptRender.js@@ -36,7 +36,7 @@ import { assertCurrentPerformanceTakes } from './performanceShot.js';import { assertCurrentClipDependencies, planMusicVideoRender, buildMusicVideoFfmpegArgs, excerptBoundaryTimes, isLocalRenderMark, resolveMasterAudioPath, resolveSoundBedPath } from './render.js';import { encodeCodeComposition, prepareCodeRender, writeCodeProofSheet } from './codeRender.js';import { encodeDocumentComposition, prepareDocumentRender } from './documentRender.js';-import { renderableCues, sectionCardCues } from './composition.js';+import { projectTypographyPlan } from './composition.js';import { renderTypographyOverlays, removeCompositionScratch } from './compositionRender.js';import { startExcerptOnProject, applyExcerptPatch } from './excerpt.js';import { markRevisionRendering, settleRevisionRender } from './revision.js';@@ -318,10 +318,8 @@ export async function startExcerptRender(projectId, { startSec, endSec, aspect =// Only the cue/card windows overlapping the window are worth capturing —// typography outside it never survives the final trim.- const allCues = composed- ? [...renderableCues(project.composition, probe.totalDuration), ...sectionCardCues(clips, probe.sections, probe.totalDuration)]- .sort((a, b) => a.startSec - b.startSec)- : [];+ const { cues: plannedCues, style } = projectTypographyPlan(project, clips, probe.sections, probe.totalDuration);+ const allCues = composed ? plannedCues : [];const cues = allCues.filter((c) => c.startSec < endClamped && c.endSec > startSec);const composition = cues.length > 0 ? project.composition : null;@@ -470,7 +468,7 @@ export async function startExcerptRender(projectId, { startSec, endSec, aspect =// anything before `startSec` anyway, so nothing visible is lost.const captureCues = cues.map((c) => ({ ...c, startSec: Math.max(c.startSec, startSec) }));renderTypographyOverlays({- jobId, cues: captureCues, style: composition.style, width: probe.canonW, height: probe.canonH, fps: probe.fps, durationSec: endClamped, signal,+ jobId, cues: captureCues, style, width: probe.canonW, height: probe.canonH, fps: probe.fps, durationSec: endClamped, signal,onProgress: (fraction) => broadcastSse(job, { type: 'progress', progress: 0.5 * fraction }),}).then((overlays) => {signal.throwIfAborted();diff --git a/server/services/musicVideo/excerptRender.test.js b/server/services/musicVideo/excerptRender.test.jsindex 4bed2341d3..17d813b72b 100644--- a/server/services/musicVideo/excerptRender.test.js+++ b/server/services/musicVideo/excerptRender.test.js@@ -60,7 +60,10 @@ vi.mock('./compositionRender.js', () => ({import { startExcerptRender, cancelExcerptRender } from './excerptRender.js';import { unlink } from 'fs/promises';import { broadcastSse } from '../../lib/sseUtils.js';-import { removeCompositionScratch } from './compositionRender.js';+import { buildTypographyDocument } from './composition.js';+import { planMusicVideoRender, buildMusicVideoFfmpegArgs, excerptBoundaryTimes } from './render.js';+import { encodeFileContactSheetAtTimes } from '../htmlComposition/encode.js';+import { renderTypographyOverlays, removeCompositionScratch } from './compositionRender.js';import { musicVideoEvents } from './events.js';const prime = (id, composition = null) => h.store.set(id, { id, name: 'Test', scenes: [], excerpts: [], composition });@@ -143,3 +146,38 @@ describe('excerpt render cancellation', () => {await vi.waitFor(() => expect(terminalFrames(again.jobId)).toHaveLength(1));});});+++describe('excerpt typography parity (#10703)', () => {+ it.each([['HUD counters', 'pop', 'Menlo'], [undefined, 'fade', 'Georgia']])('preserves treatment %s, song-time clipping and contact-sheet cues', async (graphicLanguage, template, font) => {+ const id = `typography-${template}`;+ prime(id, { mode: 'composed', style: { font: 'serif', graphicLanguage: 'HUD' }, textCues: [+ { id: 'before', text: 'Before', startSec: 0, endSec: 1 },+ { id: 'inside', text: 'Inside', startSec: 1.5, endSec: 2.5 },+ { id: 'after', text: 'After', startSec: 3, endSec: 4 },+ ] });+ h.store.get(id).treatment = { brief: { graphicLanguage } };+ const clips = [{ sceneId: 'card', layer: 'card', cardText: 'Count' }];+ const sections = [{ sceneId: 'card', layer: 'card', startSec: 0, endSec: 4 }];+ planMusicVideoRender.mockResolvedValueOnce({ ffmpeg: 'ffmpeg', audioPath: '/test/song.wav', clips, composed: true, audioDurationSec: 4, soundBed: null });+ buildMusicVideoFfmpegArgs.mockReturnValueOnce({ args: [], totalDuration: 4, canonW: 64, canonH: 64, fps: 24, sections });+ const { jobId } = await startExcerptRender(id, { startSec: 1, endSec: 3 });+ const options = renderTypographyOverlays.mock.calls[0][0];+ expect(options.cues).toEqual([+ expect.objectContaining({ id: 'card-card', template, startSec: 1, endSec: 4 }),+ expect.objectContaining({ id: 'inside', startSec: 1.5, endSec: 2.5 }),+ ]);+ expect(options).toMatchObject({ durationSec: 3, style: { font: 'serif', graphicLanguage } });+ expect(buildTypographyDocument(options)).toContain(font);+ h.overlays.resolve([]);+ await vi.waitFor(() => expect(h.procs).toHaveLength(1));+ lastProc().emit('spawn');+ lastProc().emit('close', 0, null);+ await vi.waitFor(() => expect(terminalFrames(jobId)).toHaveLength(1));+ expect(excerptBoundaryTimes).toHaveBeenCalledWith(sections, [+ expect.objectContaining({ id: 'card-card', template, startSec: 0, endSec: 4 }),+ expect.objectContaining({ id: 'inside', startSec: 1.5, endSec: 2.5 }),+ ], 1, 3, { fps: 24 });+ expect(encodeFileContactSheetAtTimes).toHaveBeenCalledWith(expect.any(String), expect.any(String), [0], { width: 64, height: 64, fps: 24 });+ });+});diff --git a/server/services/musicVideo/render.js b/server/services/musicVideo/render.jsindex b4e4799cba..9d3e025d17 100644--- a/server/services/musicVideo/render.js+++ b/server/services/musicVideo/render.js@@ -42,7 +42,7 @@ import { getTrack } from '../tracks/index.js';import { getProject, listProjects, updateProject, mutateProjectRecord } from './projects.js';import { applyProjectPatch } from './projectsLogic.js';import { isSelfDrawnLayer, sceneHasAuthoredSpan, sceneVisualLayer } from '../../lib/musicVideoLayers.js';-import { renderableCues, sectionCardCues } from './composition.js';+import { projectTypographyPlan } from './composition.js';import { encodeCodeComposition, prepareCodeRender, writeCodeProofSheet } from './codeRender.js';import { encodeDocumentComposition, prepareDocumentRender, sweepDocumentScratch } from './documentRender.js';import { renderTypographyOverlays, removeCompositionScratch, sweepCompositionScratch } from './compositionRender.js';@@ -843,8 +843,7 @@ async function renderAdmittedMusicVideo(projectId, options, permit) {// #8984: a composed project lays its timed text cues over the cut, and a// title card's text (#8985) joins them over its own section. No renderable// cue (plain mode, or nothing timed) skips the overlay capture entirely.- const cues = [...renderableCues(project.composition, totalDuration), ...sectionCardCues(clips, sections, totalDuration, project.treatment?.brief?.graphicLanguage)]- .sort((a, b) => a.startSec - b.startSec);+ const { cues, style } = projectTypographyPlan(project, clips, sections, totalDuration);const composition = cues.length > 0 ? project.composition : null;await assertCurrentRenderApproval(projectId, project, options);@@ -1034,7 +1033,7 @@ async function renderAdmittedMusicVideo(projectId, options, permit) {job.overlayAbort = new AbortController();const { signal } = job.overlayAbort;renderTypographyOverlays({- jobId, cues, style: { ...composition.style, graphicLanguage: project.treatment?.brief?.graphicLanguage }, width: canonW, height: canonH, fps, durationSec: totalDuration, signal,+ jobId, cues, style, width: canonW, height: canonH, fps, durationSec: totalDuration, signal,onProgress: (fraction) => broadcastSse(job, { type: 'progress', progress: 0.5 * fraction }),}).then(async (overlays) => {await assertCurrentRenderApproval(projectId, project, options);diff --git a/server/services/musicVideo/render.terminal.test.js b/server/services/musicVideo/render.terminal.test.jsindex a3b366acb7..c97207f402 100644--- a/server/services/musicVideo/render.terminal.test.js+++ b/server/services/musicVideo/render.terminal.test.js@@ -77,6 +77,7 @@ vi.mock('./compositionRender.js', () => ({vi.mock('./projects.js', () => ({ getProject: vi.fn(), listProjects: vi.fn(async () => []), updateProject: vi.fn(async () => ({})), mutateProjectRecord: vi.fn() }));vi.mock('../instanceIdentity.js', () => ({ ensureInstanceId: vi.fn(async () => 'inst-self') }));+import { buildTypographyDocument } from './composition.js';import { renderMusicVideo, getRenderJobStatus, cancelRender } from './render.js';import { removeCompositionScratch } from './compositionRender.js';import { findFfmpeg, generateThumbnail } from '../../lib/ffmpeg.js';@@ -577,6 +578,20 @@ describe('layered sections (#8985)', () => {expect(args[args.lastIndexOf('-map') + 1]).toBe('2:a');});+ it.each([['HUD counters', 'pop', 'Menlo'], [undefined, 'fade', 'Georgia']])('applies shared card and font treatment %s at the full render entrypoint', async (graphicLanguage, template, font) => {+ const id = `typography-${template}`;+ primeLayered(id, 'composed');+ const project = await getProject(id);+ getProject.mockResolvedValue({ ...project, composition: { ...project.composition, style: { font: 'serif' } }, treatment: { brief: { graphicLanguage } } });+ const { jobId } = await renderMusicVideo(id);+ const options = h.overlays.calls[0];+ expect(options.cues[0]).toMatchObject({ id: 'card-s3', template });+ expect(options.style).toEqual({ font: 'serif', graphicLanguage });+ expect(buildTypographyDocument(options)).toContain(font);+ cancelRender(jobId);+ await tick();+ });+it('refuses a still with no reference frame and an untimed card, without spawning', async () => {primeLayered('no-frame', 'composed', [{ sceneId: 's1', order: 0, visualLayer: 'still', referenceImageId: null, startSec: 0, endSec: 2 }]);await expect(renderMusicVideo('no-frame')).rejects.toMatchObject({ status: 404, code: 'MISSING_STILLS', context: { sceneIds: ['s1'] } });