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: bound music video context and discard canceled setup
[._.]/ Adam Eivy57d99c032d4f
diff --git a/client/src/components/creative-director/CreativeDirectorModelsDrawer.test.jsx b/client/src/components/creative-director/CreativeDirectorModelsDrawer.test.jsxindex e441d80918..6285cfd77b 100644--- a/client/src/components/creative-director/CreativeDirectorModelsDrawer.test.jsx+++ b/client/src/components/creative-director/CreativeDirectorModelsDrawer.test.jsx@@ -190,7 +190,8 @@ describe('CreativeDirectorModelsDrawer', () => {});renderDrawer({ id: 'cd-1', name: 'Demo', modelOverrides: {} });await waitFor(() => expect(screen.getByLabelText('Scene evaluation provider')).toBeTruthy());- await waitFor(() => expect(getVisionModels).toHaveBeenCalled());+ // Request start does not mean assignments and capabilities have rendered.+ await waitFor(() => expect(screen.getByLabelText('Scene evaluation provider').disabled).toBe(false));fireEvent.change(screen.getByLabelText('Scene evaluation provider'), { target: { value: 'ollama' } });@@ -221,7 +222,8 @@ describe('CreativeDirectorModelsDrawer', () => {models: [{ providerId: 'ollama', backend: 'ollama', id: 'muse-glimmer:30b', vision: true }],});renderDrawer({ id: 'cd-1', name: 'Demo', modelOverrides: {} });- await waitFor(() => expect(getVisionModels).toHaveBeenCalled());+ // Request start does not mean assignments and capabilities have rendered.+ await waitFor(() => expect(screen.getByLabelText('Scene evaluation provider').disabled).toBe(false));fireEvent.change(screen.getByLabelText('Scene evaluation provider'), { target: { value: 'ollama' } });@@ -284,7 +286,8 @@ describe('CreativeDirectorModelsDrawer', () => {],});renderDrawer({ id: 'cd-1', name: 'Demo', modelOverrides: {} });- await waitFor(() => expect(getVisionModels).toHaveBeenCalled());+ // Request start does not mean assignments and capabilities have rendered.+ await waitFor(() => expect(screen.getByLabelText('Scene evaluation provider').disabled).toBe(false));fireEvent.change(screen.getByLabelText('Scene evaluation provider'), { target: { value: 'ollama' } });diff --git a/client/src/components/musicVideo/CreativeSetupPanel.jsx b/client/src/components/musicVideo/CreativeSetupPanel.jsxindex 6ee9e95a49..8fe500ed67 100644--- a/client/src/components/musicVideo/CreativeSetupPanel.jsx+++ b/client/src/components/musicVideo/CreativeSetupPanel.jsx@@ -25,7 +25,7 @@ export default function CreativeSetupPanel({ project, onSave, onPendingChange })const [newDescription, setNewDescription] = useState('');const [selectedCanon, setSelectedCanon] = useState([]);const universeId = draft?.universeId ?? project.concept?.universeId ?? '';- const subjects = draft?.subjects || project.concept?.subjects || [];+ const subjects = editing ? (draft?.subjects || []) : (project.concept?.subjects || []);const idFor = (name) => `mv-creative-${project.id}-${name}`;useEffect(() => {diff --git a/client/src/components/musicVideo/CreativeSetupPanel.test.jsx b/client/src/components/musicVideo/CreativeSetupPanel.test.jsxindex 1eca0702ca..4810047f1c 100644--- a/client/src/components/musicVideo/CreativeSetupPanel.test.jsx+++ b/client/src/components/musicVideo/CreativeSetupPanel.test.jsx@@ -45,6 +45,17 @@ describe('creative setup', () => {] }, visualSpec: { moodBoardId: 'b1' },});});+ it('discards an unsaved cast when the director cancels setup', () => {+ const onSave = open();+ fireEvent.change(screen.getByLabelText('Name'), { target: { value: 'Unsaved singer' } });+ fireEvent.click(screen.getByText('Add to production'));+ fireEvent.click(screen.getByText('Cancel'));+ expect(screen.queryByText(/Unsaved singer/)).toBeNull();+ expect(onSave).not.toHaveBeenCalled();+ fireEvent.click(screen.getByText('Set up creative direction'));+ expect(screen.queryByText(/Unsaved singer/)).toBeNull();+ });+it('ignores stale universe responses and retains the draft when saving fails', async () => {let resolveOld;getUniverse.mockImplementation((id) => id === 'u1' ? new Promise((resolve) => { resolveOld = resolve; }) : Promise.resolve({ id: 'u2', name: 'Other universe', characters: [] }));diff --git a/server/lib/musicVideoCreativeContext.js b/server/lib/musicVideoCreativeContext.jsindex e26ccff0ba..c25c726a9b 100644--- a/server/lib/musicVideoCreativeContext.js+++ b/server/lib/musicVideoCreativeContext.js@@ -1,11 +1,26 @@-/** Shared creative bible for planning, local media generation and external handoff. */+import { trimTo } from './textUtils.js';++const CONTEXT_MAX = 6000;+const BIBLE_HEADER = 'Production bible (use the subjects relevant to this shot; preserve their identity; descriptions may be abbreviated):';++/** Shared, bounded creative bible for planning, media generation and handoff. */export function musicVideoCreativeContext(concept) {if (!concept) return '';- const subjects = (concept.subjects || []).map((s) =>- `${s.kind}${s.kind === 'character' && s.role ? ` (${s.role})` : ''}: ${s.name}${s.description ? ` — ${s.description}` : ''}`);- return [- concept.universeStyle && `Universe style: ${concept.universeStyle}`,- concept.moodBoardStyle && `Mood board style: ${concept.moodBoardStyle}`,- subjects.length && `Production bible (use the subjects relevant to this shot; preserve their identity):\n${subjects.join('\n')}`,- ].filter(Boolean).join('\n');+ const styles = [+ concept.universeStyle && `Universe style: ${trimTo(concept.universeStyle, 800)}`,+ concept.moodBoardStyle && `Mood board style: ${trimTo(concept.moodBoardStyle, 800)}`,+ ].filter(Boolean);+ const subjects = (concept.subjects || []).slice(0, 24);+ const identities = subjects.map((s) =>+ `${s.kind}${s.kind === 'character' && s.role ? ` (${s.role})` : ''}: ${trimTo(s.name, 120)}`);+ // Reserve every identity first; share the remaining description budget so+ // a large cast cannot crowd later characters out of the prompt entirely.+ const fixedSize = styles.join('\n').length + BIBLE_HEADER.length + identities.join('\n').length + 4;+ const descriptionLimit = subjects.length+ ? Math.max(0, Math.min(300, Math.floor((CONTEXT_MAX - fixedSize) / subjects.length) - 3)) : 0;+ const lines = subjects.map((subject, i) => {+ const description = trimTo(subject.description, descriptionLimit);+ return `${identities[i]}${description ? ` — ${description}` : ''}`;+ });+ return [...styles, ...(lines.length ? [BIBLE_HEADER, ...lines] : [])].join('\n').slice(0, CONTEXT_MAX);}diff --git a/server/services/musicVideo/planner.test.js b/server/services/musicVideo/planner.test.jsindex 28e1ebce0c..7d05625d0a 100644--- a/server/services/musicVideo/planner.test.js+++ b/server/services/musicVideo/planner.test.js@@ -210,6 +210,20 @@ describe('planShots', () => {});describe('buildScenePlanPrompt', () => {+ it('bounds a maximal production bible without dropping cast identities', () => {+ const subjects = Array.from({ length: 24 }, (_, index) => ({+ id: `subject-${index}`, kind: 'character', role: 'protagonist',+ name: `Subject ${index} ${'n'.repeat(105)}`, description: 'd'.repeat(1000),+ }));+ const base = makeProject({ concept: {} });+ const prompt = buildScenePlanPrompt({ ...base, concept: {+ universeStyle: 'u'.repeat(4000), moodBoardStyle: 'm'.repeat(4000), subjects,+ } }, []);+ expect(prompt.length - buildScenePlanPrompt(base, []).length).toBeLessThanOrEqual(6000);+ for (const subject of subjects) expect(prompt).toContain(subject.name);+ expect(prompt).toContain('descriptions may be abbreviated');+ });+it('includes the concept, style, and per-shot section/duration/energy/lyrics/intent', () => {const { shots } = planShots(SECTIONS, {beats: BEATS,