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

keep document-sourced storyboard shots when scoping an authoring batch, and only scope real subsets

[._.]/ Adam Eivy6ef4fafeba3b
diff --git a/server/services/musicVideo/codeGeneration.js b/server/services/musicVideo/codeGeneration.js
index cc99e9a068..6772270d58 100644
--- a/server/services/musicVideo/codeGeneration.js
+++ b/server/services/musicVideo/codeGeneration.js
@@ -34,16 +34,22 @@ export async function styleLinesFor(project) {
}
}
+// A shot with no time window counts as overlapping every section.
+const overlapsAny = (shot, sections) => !Number.isFinite(shot.startSec) || !Number.isFinite(shot.endSec)
+ || sections.some((section) => shot.startSec < section.endSec && shot.endSec > section.startSec);
+
/**
* The approved procedural direction's definitions and rules, for a code-authoring request.
- * `sceneIds` scopes the guide's shot choreography to the scenes a batch authors: every
- * shot of a long storyboard otherwise rides in each section's prompt.
+ * `sceneIds` (with the batch's `sections`) scopes the guide's shot choreography to what a
+ * batch authors: every shot of a long storyboard otherwise rides in each section's prompt.
+ * A shot bound to a scene is kept when its scene is; a document shot (no `sceneId`) when its
+ * own time window overlaps a section, or when it has none.
*/
-export const castAndSetsCodeContext = (project, { sceneIds = null } = {}) => {
+export const castAndSetsCodeContext = (project, { sceneIds = null, sections = [] } = {}) => {
const draft = project.productionReview?.draft;
const wanted = sceneIds ? new Set(sceneIds) : null;
const guide = draft && wanted && Array.isArray(draft.storyboard)
- ? { ...draft, storyboard: draft.storyboard.filter((shot) => wanted.has(shot.sceneId)) }
+ ? { ...draft, storyboard: draft.storyboard.filter((shot) => (shot.sceneId ? wanted.has(shot.sceneId) : overlapsAny(shot, sections))) }
: draft;
return [
productionFeedbackContext(project),
diff --git a/server/services/musicVideo/codeGeneration.test.js b/server/services/musicVideo/codeGeneration.test.js
index 3be1e54b72..2fb0077190 100644
--- a/server/services/musicVideo/codeGeneration.test.js
+++ b/server/services/musicVideo/codeGeneration.test.js
@@ -25,7 +25,7 @@ vi.mock('./projects.js', () => ({
mutateProjectRecord: vi.fn(async (_id, transform) => transform(h.project)),
}));
-const { generateMusicVideoCode, regenerateMusicVideoCodeSection } = await import('./codeGeneration.js');
+const { castAndSetsCodeContext, generateMusicVideoCode, regenerateMusicVideoCodeSection } = await import('./codeGeneration.js');
const { buildMusicVideoCodePrompt } = await import('../codeAnimation/prompt.js');
const base = () => ({
@@ -156,3 +156,25 @@ it('refuses standalone authoring when a lyric changes during provider preparatio
await expect(generateMusicVideoCode('mv-code')).rejects.toMatchObject({ code: 'MUSIC_VIDEO_REVIEW_STALE' });
expect(h.calls).toBe(0);
});
+
+describe('castAndSetsCodeContext batch scope', () => {
+ const shot = (fields) => ({ lyricCueIds: [], staging: '', camera: '', transition: '', ...fields });
+ it('keeps scene shots of the batch and document shots that overlap its sections', () => {
+ const project = { productionReview: { draft: { storyboard: [
+ shot({ sceneId: 'scene-1', action: 'SCENE ONE' }),
+ shot({ sceneId: 'scene-2', action: 'SCENE TWO' }),
+ shot({ id: 'doc-a', startSec: 0, endSec: 5, action: 'DOC EARLY' }),
+ shot({ id: 'doc-b', startSec: 20, endSec: 25, action: 'DOC LATE' }),
+ shot({ id: 'doc-c', action: 'DOC UNTIMED' }),
+ ] } } };
+ const scoped = castAndSetsCodeContext(project, { sceneIds: ['scene-1'], sections: [{ startSec: 0, endSec: 10 }] });
+ expect(scoped).toContain('SCENE ONE');
+ expect(scoped).not.toContain('SCENE TWO');
+ expect(scoped).toContain('DOC EARLY');
+ expect(scoped).not.toContain('DOC LATE');
+ expect(scoped).toContain('DOC UNTIMED');
+ // Unscoped (a whole-song request) keeps every shot.
+ const whole = castAndSetsCodeContext(project);
+ for (const text of ['SCENE ONE', 'SCENE TWO', 'DOC EARLY', 'DOC LATE', 'DOC UNTIMED']) expect(whole).toContain(text);
+ });
+});
diff --git a/server/services/musicVideo/documentGeneration.js b/server/services/musicVideo/documentGeneration.js
index bba79dff8f..a9ebbd0195 100644
--- a/server/services/musicVideo/documentGeneration.js
+++ b/server/services/musicVideo/documentGeneration.js
@@ -205,7 +205,7 @@ async function authoringContext(project) {
export const LOCAL_PROMPT_BUDGET_CHARS = 100_000;
// The scenes overlapping any of `sections` (all of them when every section is listed).
-export function batchScenes(scenes, sections) {
+function batchScenes(scenes, sections) {
return (scenes || []).filter((scene) => !Number.isFinite(scene.startSec) || !Number.isFinite(scene.endSec)
|| sections.some((section) => scene.startSec < section.endSec && scene.endSec > section.startSec));
}
@@ -293,12 +293,13 @@ async function runAuthoring(projectId, { providerId, model, effort, sectionId =
const sections = context.song.sections.filter((section) => batchIds.includes(section.id));
// Only the scenes (and storyboard shots) a batch's sections cover: a long storyboard would
// otherwise put every shot in each batch and push it past a local model's budget.
- const scenes = batchScenes(context.scenes, sections);
+ const scoped = batchIds.length < ids.length;
+ const scenes = scoped ? batchScenes(context.scenes, sections) : context.scenes;
return buildMixedMediaDocumentPrompt({
renderer: musicVideoDocumentRenderer(project), mediaMode: musicVideoMediaMode(project),
title: project.name, song: { ...context.song, sections }, palette: context.palette, treatment: project.treatment,
visualSpec: project.visualSpec, scenes, styleLines: sharedStyle.styleLines,
- onlySectionId: sectionId, sharedStyle, directionContext: castAndSetsCodeContext(project, { sceneIds: scenes.map((scene) => scene.sceneId) }),
+ onlySectionId: sectionId, sharedStyle, directionContext: castAndSetsCodeContext(project, scoped ? { sceneIds: scenes.map((scene) => scene.sceneId), sections } : {}),
});
};
const withFeedback = (prompt) => (feedback ? `${prompt}\n\nReview findings for this section (retain the approved medium and selected assets; never invent a footage fallback):\n${feedback.slice(0, 8000)}` : prompt);