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: clear a split performance shot's lip-synced clip selection and tolerate float noise in piece counts (#8977)
[._.]/ Adam Eivy34c0cbc6ac0e
diff --git a/server/lib/musicVideoShotTiming.js b/server/lib/musicVideoShotTiming.jsindex 1a6c6eadc3..61a48b9001 100644--- a/server/lib/musicVideoShotTiming.js+++ b/server/lib/musicVideoShotTiming.js@@ -323,7 +323,10 @@ export function planShotSplit({ startSec, endSec, maxSec, lyricCues, phrases, bereturn { ok: false, code: 'MUSIC_VIDEO_SPLIT_NOT_NEEDED', message: 'This shot already fits in a single take.' };}const candidates = splitCandidates({ lyricCues, phrases, beats });- const fewest = Math.ceil(round6((endSec - startSec) / maxSec));+ // The same 1µs tolerance as the fits-one-take check above: float noise in+ // a span like 29.9999999 must not demand a fourth 10s piece, and no piece+ // may exceed the limit by more than that tolerance.+ const fewest = Math.ceil((endSec - startSec - 1e-6) / maxSec);const base = { startSec, endSec, maxSec, minPieceSec, candidates };const first = cutPieces({ ...base, count: fewest });let chosen = first;diff --git a/server/lib/musicVideoShotTiming.test.js b/server/lib/musicVideoShotTiming.test.jsindex b9c49c9cc6..d57eeeed05 100644--- a/server/lib/musicVideoShotTiming.test.js+++ b/server/lib/musicVideoShotTiming.test.js@@ -66,6 +66,10 @@ describe('planShotSplit', () => {expect(planShotSplit({ startSec: null, endSec: 30, maxSec: 10 })).toMatchObject({ ok: false, code: 'MUSIC_VIDEO_SPLIT_UNTIMED' });expect(planShotSplit({ startSec: 5, endSec: 15, maxSec: 10 })).toMatchObject({ ok: false, code: 'MUSIC_VIDEO_SPLIT_NOT_NEEDED' });expect(planShotSplit({ startSec: 5, endSec: 15.01, maxSec: 10 }).pieces).toHaveLength(2);+ // Just past an exact multiple still needs the extra piece; float noise at it does not.+ expect(planShotSplit({ startSec: 0, endSec: 20.00001, maxSec: 10 }).pieces).toHaveLength(3);+ expect(32.2 - 2.2).toBeGreaterThan(30);+ expect(planShotSplit({ startSec: 2.2, endSec: 32.2, maxSec: 10 }).pieces).toHaveLength(3);});});diff --git a/server/routes/musicVideoSceneSplit.test.js b/server/routes/musicVideoSceneSplit.test.jsindex 1416192293..0c7117482a 100644--- a/server/routes/musicVideoSceneSplit.test.js+++ b/server/routes/musicVideoSceneSplit.test.js@@ -52,7 +52,7 @@ describe('POST /:id/scenes/:sceneId/split', () => {label: 'Verse', prompt: 'singer at the mic', startSec: 30, endSec: 56, shotMode: 'performance', loop: false,});const after = await projects.addProjectScene(project.id, { label: 'Outro', startSec: 56, endSec: 70 });- await projects.updateScene(project.id, shot.sceneId, { referenceImageId: 'singer.png' });+ await projects.updateScene(project.id, shot.sceneId, { referenceImageId: 'singer.png', videoHistoryId: 'clip-whole-verse' });// No backend in the body: the project's pinned fal lane bounds the take.const res = await split(shot.sceneId);@@ -71,14 +71,20 @@ describe('POST /:id/scenes/:sceneId/split', () => {expect(stored.scenes.map((s) => [s.sceneId, s.order])).toEqual([[before.sceneId, 0], [shot.sceneId, 1], [pieces[1].sceneId, 2], [pieces[2].sceneId, 3], [after.sceneId, 4],]);- expect(stored.scenes[1].takes.map((t) => t.assetId)).toEqual(['singer.png']);+ // The lip-synced clip was generated for 30–56s: it stays a candidate take+ // but is no longer selected, so the render never re-cuts it.+ expect(stored.scenes[1].videoHistoryId).toBeNull();+ expect(stored.scenes[1].takes.map((t) => t.assetId)).toEqual(['singer.png', 'clip-whole-verse']);});it('splits a Grok cutaway at its 10-second clip limit when the director renders on Grok', async () => {const shot = await projects.addProjectScene(project.id, { label: 'Bridge', startSec: 30, endSec: 55 });+ await projects.updateScene(project.id, shot.sceneId, { videoHistoryId: 'clip-bridge' });const res = await split(shot.sceneId, { backend: 'grok' });expect(res.status).toBe(200);const pieces = res.body.scenes;+ // A cutaway clip still starts where the first piece does: it stays selected.+ expect(pieces.map((p) => p.videoHistoryId)).toEqual(['clip-bridge', null, null]);expect(pieces).toHaveLength(3);for (const p of pieces) expect(p.endSec - p.startSec).toBeLessThanOrEqual(10);expect(pieces[0].startSec).toBe(30);diff --git a/server/services/musicVideo/projectsLogic.js b/server/services/musicVideo/projectsLogic.jsindex 499ede3fcf..50fbc42154 100644--- a/server/services/musicVideo/projectsLogic.js+++ b/server/services/musicVideo/projectsLogic.js@@ -29,7 +29,7 @@ import { stripMusicVideoLocalRenderPins } from '../../lib/syncWire.js';import { persistedRenderPinFields } from '../../lib/renderTargets.js';import { sanitizeProjectForSync } from '../../lib/projectStoreKit.js';import { isStr } from '../../lib/textUtils.js';-import { planShotSplit, shotSplitLimit } from '../../lib/musicVideoShotTiming.js';+import { isPerformanceScene, planShotSplit, shotSplitLimit } from '../../lib/musicVideoShotTiming.js';import { normalizeLyricCues, normalizePhrases, invalidateTimedText } from './timedText.js';import { ensureSceneTakes, TAKE_SLOT } from './takes.js';import { normalizeComposition, invalidateCompositionTiming } from './composition.js';@@ -461,13 +461,12 @@ function lyricTextWithin(cues, startSec, endSec) {* window, a Grok cutaway at the longest Grok clip. `backend` is the lane the* director will render with ('' / null = the project's pinned backend).*- * The original scene keeps its id, takes and selections and becomes the first- * piece; each later piece is a new scene placed right after it, carrying the- * shot's direction and the selected reference frame (as a take, so the frame- * is ready to animate) but no clip — the old clip was generated for the whole- * span. A performance take on the first piece is then correctly refused by the- * render as re-timed, never silently re-cut. Each piece's `lyricText` is the- * timed lines sung inside it. Returns `{ project, scenes }` (all pieces, in+ * The original scene keeps its id and takes and becomes the first piece (a+ * performance's lip-synced clip selection is cleared — see below). Each later+ * piece is a new scene placed right after it, carrying the shot's direction+ * and the selected reference frame (as a take, so the frame is ready to+ * animate) but no clip — the old clip was generated for the whole span. Each+ * piece's `lyricText` is the timed lines sung inside it. Returns `{ project, scenes }` (all pieces, in* order); throws 400 when the shot is untimed or already fits one take.*/export function splitScene(project, sceneId, { backend = null } = {}) {@@ -503,7 +502,16 @@ export function splitScene(project, sceneId, { backend = null } = {}) {const pieces = plan.pieces.map((piece, i) => {const timing = { label: pieceLabel(i), startSec: piece.startSec, endSec: piece.endSec, lyricText: pieceLyrics(piece) };- if (i === 0) return { ...scene, ...timing, takes: ensureSceneTakes(scene, now) };+ if (i === 0) {+ const takes = ensureSceneTakes(scene, now);+ // A lip-synced take was generated for the old interval and the render+ // refuses it as re-timed, so the selection is cleared (the take stays a+ // candidate) and "Generate missing" fills it. A cutaway clip still starts+ // where the first piece does, so it stays selected and is trimmed.+ return isPerformanceScene(scene)+ ? { ...scene, ...timing, takes, videoHistoryId: null }+ : { ...scene, ...timing, takes };+ }const fresh = buildScene({...parseSceneOrThrow(musicVideoSceneCreateSchema, {sectionLabel: scene.sectionLabel ?? null,