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
address review (codex): accept null to clear scene times; validate merged endSec >= startSec on PATCH
[._.]/ Adam Eivyb8b13d73f2c8
diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.jsindex aa815bcfec..b69e1352f5 100644--- a/server/lib/musicVideoValidation.js+++ b/server/lib/musicVideoValidation.js@@ -55,21 +55,25 @@ export const musicVideoSceneCreateSchema = z.object({sectionLabel: z.string().max(120).nullable().optional(),prompt: z.string().max(8000).optional(),framePrompt: z.string().max(8000).nullable().optional(),- startSec: z.number().min(0).max(36000).optional(),- endSec: z.number().min(0).max(36000).optional(),+ startSec: z.number().min(0).max(36000).nullable().optional(),+ endSec: z.number().min(0).max(36000).nullable().optional(),beatAligned: z.boolean().optional(),}).strict().refine((s) => s.startSec == null || s.endSec == null || s.endSec >= s.startSec,{ message: 'endSec must be >= startSec', path: ['endSec'] },);+// Times are nullable here so clearing a Start/End input (the UI sends `null`)+// is accepted. The endSec >= startSec invariant can't be checked on the partial+// patch alone (the paired value may live on the existing record), so the merged+// range is validated in projectsLogic.applySceneUpdate instead.export const musicVideoSceneUpdateSchema = z.object({label: z.string().max(120).optional(),sectionLabel: z.string().max(120).nullable().optional(),prompt: z.string().max(8000).optional(),framePrompt: z.string().max(8000).nullable().optional(),- startSec: z.number().min(0).max(36000).optional(),- endSec: z.number().min(0).max(36000).optional(),+ startSec: z.number().min(0).max(36000).nullable().optional(),+ endSec: z.number().min(0).max(36000).nullable().optional(),beatAligned: z.boolean().optional(),referenceImageId: z.string().max(256).nullable().optional(),videoHistoryId: z.string().max(64).nullable().optional(),diff --git a/server/services/musicVideo/projectsLogic.js b/server/services/musicVideo/projectsLogic.jsindex da864a658a..ac1ccc77fc 100644--- a/server/services/musicVideo/projectsLogic.js+++ b/server/services/musicVideo/projectsLogic.js@@ -135,6 +135,11 @@ export function applySceneUpdate(project, sceneId, patch) {const idx = scenes.findIndex((s) => s.sceneId === sceneId);if (idx < 0) throw new ServerError('Scene not found', { status: 404, code: 'NOT_FOUND' });const updated = { ...scenes[idx], ...data };+ // The partial-patch schema can't enforce endSec >= startSec (the paired value+ // may be unchanged on the record), so validate the merged range here.+ if (updated.startSec != null && updated.endSec != null && updated.endSec < updated.startSec) {+ throw new ServerError('endSec must be >= startSec', { status: 400, code: 'VALIDATION_ERROR' });+ }const nextScenes = scenes.slice();nextScenes[idx] = updated;const next = touch(project, { scenes: nextScenes });diff --git a/server/services/musicVideo/projectsLogic.test.js b/server/services/musicVideo/projectsLogic.test.jsindex fb6366610a..1de4715ab6 100644--- a/server/services/musicVideo/projectsLogic.test.js+++ b/server/services/musicVideo/projectsLogic.test.js@@ -90,6 +90,18 @@ describe('scene board operations', () => {expect(() => applySceneUpdate(baseProject(), 'nope', { prompt: 'x' })).toThrow(/Scene not found/);});+ it('clears a previously-set scene time when patched with null', () => {+ const { project, scene } = addScene(baseProject(), { startSec: 5, endSec: 10 });+ const { updated } = applySceneUpdate(project, scene.sceneId, { startSec: null });+ expect(updated.startSec).toBeNull();+ expect(updated.endSec).toBe(10);+ });++ it('rejects a patch whose merged endSec precedes the existing startSec', () => {+ const { project, scene } = addScene(baseProject(), { startSec: 10, endSec: 20 });+ expect(() => applySceneUpdate(project, scene.sceneId, { endSec: 5 })).toThrow(/endSec must be >= startSec/);+ });+it('removes a scene and re-sequences order', () => {let p = baseProject();const ids = [];