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: a saved direction without a medium revises as photographic (#9549)

[._.]/ Adam Eivy3332314ae447
diff --git a/server/services/musicVideo/castAndSetsDirection.js b/server/services/musicVideo/castAndSetsDirection.js
index c51c8efd14..711333e35b 100644
--- a/server/services/musicVideo/castAndSetsDirection.js
+++ b/server/services/musicVideo/castAndSetsDirection.js
@@ -180,7 +180,8 @@ const PROCEDURAL_OUTPUT_SHAPE = `{
* `medium` defaults to the previous direction's, else the project's.
*/
export function buildCastAndSetsPrompt(project, { moodImages = [], board = null, track = null, previous = null, notes = [], medium = null } = {}) {
- const procedural = (medium || previous?.medium || castAndSetsMedium(project)) === 'procedural';
+ // A saved direction without a medium predates the procedural one: photographic.
+ const procedural = (medium || (previous ? (previous.medium || 'photographic') : castAndSetsMedium(project))) === 'procedural';
const concept = project?.concept || {};
const analysis = project?.audioAnalysis || {};
const sections = songSections(project);
diff --git a/server/services/musicVideo/castAndSetsDirection.test.js b/server/services/musicVideo/castAndSetsDirection.test.js
index 1c38cbb753..69d18e3321 100644
--- a/server/services/musicVideo/castAndSetsDirection.test.js
+++ b/server/services/musicVideo/castAndSetsDirection.test.js
@@ -132,6 +132,8 @@ describe('Cast & Sets procedural medium', () => {
expect(prompt).not.toMatch(/"face"|"hair"|"tests"/);
expect(buildCastAndSetsPrompt(project)).toContain('"face"');
// A revision keeps the medium the saved direction was made in, whatever the project says now.
+ // ...and a saved photographic direction (no medium) stays photographic under a code-first project.
+ expect(buildCastAndSetsPrompt(procedural, { previous: { protagonist: { name: 'Nova' } }, notes: [{ text: 'x' }] })).toContain('"face"');
expect(buildCastAndSetsPrompt(project, { previous: { medium: 'procedural' }, notes: [{ text: 'bigger sail' }] })).toContain('PROCEDURAL');
});
diff --git a/server/services/musicVideo/castAndSetsService.js b/server/services/musicVideo/castAndSetsService.js
index 8b097c0dcd..7b42eaf570 100644
--- a/server/services/musicVideo/castAndSetsService.js
+++ b/server/services/musicVideo/castAndSetsService.js
@@ -170,7 +170,8 @@ async function runDirection(projectId, { providerId, model, notes = [], forceKey
// A revision keeps the medium it was directed in; a fresh pass resolves it
// from the project's policy and tools, so a saved direction is never
// silently re-cast into the other medium.
- const medium = (notes.length && previous?.medium) || castAndSetsMedium(project);
+ // A saved direction without a medium predates the procedural one: photographic.
+ const medium = notes.length && previous ? (previous.medium || 'photographic') : castAndSetsMedium(project);
const prompt = buildCastAndSetsPrompt(project, { moodImages, board, track, previous: notes.length ? previous : null, notes, medium });
let text;
try {