Skip to content

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

fix([issue-863]): place full cue list before dropping un-rendered cues

[._.]/ Adam Eivy9b018901e089
diff --git a/server/services/creativeDirector/stitchRunner.js b/server/services/creativeDirector/stitchRunner.js
index 75b0fa1d47..9a41274ff0 100644
--- a/server/services/creativeDirector/stitchRunner.js
+++ b/server/services/creativeDirector/stitchRunner.js
@@ -156,10 +156,15 @@ async function maybeMuxPipelineAudio(project, finalEntry) {
// are no placed+rendered cues.
if (audioMode === 'generated') {
const cues = Array.isArray(issue.stages?.audio?.cues) ? issue.stages.audio.cues : [];
- const rendered = cues.filter((c) => c?.trackFilename);
- if (rendered.length) {
+ const hasRendered = cues.some((c) => c?.trackFilename);
+ if (hasRendered) {
const totalSec = await probeVideoDuration(videoPath);
- const placed = selectPlacedCues(placeCuesOnTimeline(rendered, totalSec));
+ // Place the FULL ordered cue list first so each cue keeps its own arc slot,
+ // THEN drop the un-rendered ones (selectPlacedCues filters on trackFilename).
+ // Placing only the rendered subset would collapse the timeline onto it — a
+ // single rendered "climax" cue would stretch across the whole episode
+ // instead of staying in its slot, leaving the un-rendered slots as silence.
+ const placed = selectPlacedCues(placeCuesOnTimeline(cues, totalSec));
if (placed.length) {
console.log(`🎼 CD stitch mux: laying ${placed.length} generated cue(s)${voLines.length ? ` + ${voLines.length} VO line(s)` : ''} onto ${finalEntry.filename}`);
const result = await muxCueBed(videoPath, { cues: placed, voLines });
diff --git a/server/services/pipeline/audioMux.test.js b/server/services/pipeline/audioMux.test.js
index 0d5c42e2a1..50f8433e7a 100644
--- a/server/services/pipeline/audioMux.test.js
+++ b/server/services/pipeline/audioMux.test.js
@@ -66,6 +66,7 @@ vi.mock('child_process', async () => {
});
const { muxMusicBed, muxVoLines, buildVoMuxArgs, buildCueMuxArgs, muxCueBed, muxStripAudio, selectPlacedVoLines, selectPlacedCues, resolveMusicTrackPath, DEFAULT_MUSIC_GAIN } = await import('./audioMux.js');
+const { placeCuesOnTimeline } = await import('./audioCuePlacement.js');
beforeEach(async () => {
spawnCalls.length = 0;
@@ -439,6 +440,23 @@ describe('selectPlacedCues', () => {
expect(selectPlacedCues(null)).toEqual([]);
expect(selectPlacedCues(undefined)).toEqual([]);
});
+
+ it('keeps a partially-rendered cue in its OWN arc slot (place full list, then filter)', () => {
+ // The stitcher places the FULL ordered cue list, THEN drops un-rendered
+ // cues. A lone rendered "climax" (cue 2 of 3) must stay in its middle slot,
+ // not stretch across the whole episode (the bug from placing only rendered).
+ const cues = [
+ { id: 'a', label: 'Setup' }, // un-rendered
+ { id: 'b', label: 'Climax', trackFilename: 'b.wav' }, // rendered
+ { id: 'c', label: 'Resolution' }, // un-rendered
+ ];
+ const placed = selectPlacedCues(placeCuesOnTimeline(cues, 90));
+ expect(placed).toHaveLength(1);
+ // 90s / 3 cues → the climax owns its 30..60 middle slot, not 0..90.
+ expect(placed[0].startSec).toBeCloseTo(30, 5);
+ expect(placed[0].endSec).toBeCloseTo(60, 5);
+ expect(placed[0].path).toMatch(/b\.wav$/);
+ });
});
describe('buildCueMuxArgs', () => {