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
Music video: moving a shot on the scene board swaps it into its neighbor's song slot
Claudeab85db70c92e
diff --git a/client/src/components/musicVideo/SceneCard.jsx b/client/src/components/musicVideo/SceneCard.jsxindex 25f4593842..d7cbedf81f 100644--- a/client/src/components/musicVideo/SceneCard.jsx+++ b/client/src/components/musicVideo/SceneCard.jsx@@ -206,9 +206,16 @@ export default function SceneCard({<SceneRenderProgress kind="Video" generating={generatingVideo} progress={videoProgress} /></summary><div className="space-y-2 p-3 pt-0">+ {/* A move swaps this shot with its neighbor; the song timing and lyric stay with the slot. */}<div className="flex items-center justify-end gap-2">- <button onClick={() => onMove(index, -1)} disabled={index === 0} aria-label="Move up" className="min-h-[44px] min-w-[44px] inline-flex items-center justify-center p-1 disabled:opacity-30" title="Move up"><ArrowUp size={14} /></button>- <button onClick={() => onMove(index, 1)} disabled={isLast} aria-label="Move down" className="min-h-[44px] min-w-[44px] inline-flex items-center justify-center p-1 disabled:opacity-30" title="Move down"><ArrowDown size={14} /></button>+ <button type="button" onClick={() => onMove(index, -1)} disabled={index === 0} title="Swap with the previous shot; the song timing stays put"+ className="min-h-[44px] inline-flex items-center justify-center gap-1 rounded border border-port-border px-2 text-xs disabled:opacity-30 sm:min-h-0 sm:py-1">+ <ArrowUp size={14} aria-hidden="true" /> Move earlier+ </button>+ <button type="button" onClick={() => onMove(index, 1)} disabled={isLast} title="Swap with the next shot; the song timing stays put"+ className="min-h-[44px] inline-flex items-center justify-center gap-1 rounded border border-port-border px-2 text-xs disabled:opacity-30 sm:min-h-0 sm:py-1">+ <ArrowDown size={14} aria-hidden="true" /> Move later+ </button><button onClick={() => onDelete(scene.sceneId)} aria-label="Delete scene" className="min-h-[44px] min-w-[44px] inline-flex items-center justify-center p-1 text-port-error" title="Delete scene"><Trash2 size={14} /></button></div><textareadiff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsxindex 212d9c2e96..eeb9398967 100644--- a/client/src/pages/MusicVideo.jsx+++ b/client/src/pages/MusicVideo.jsx@@ -86,6 +86,7 @@ import { isLtx2FamilyRuntime } from '../lib/runnerFamilies';import { videoPosterForJob } from '../lib/creativeDirectorPreview.js';import { sceneTakeList } from '../lib/musicVideoTakes.js';import { pluralize } from '../lib/textUtils.js';+import { formatTimecode } from '../utils/formatters.js';import { deriveAttentionItems } from '../lib/musicVideoAttention.js';import { latestMusicVideoReviewDraft } from '../../../server/lib/musicVideoReviewDraft.js';import { useMusicVideoReviewDraft } from '../hooks/useMusicVideoReviewDraft.js';@@ -887,8 +888,18 @@ export default function MusicVideo() {if (target < 0 || target >= scenes.length) return;const ids = scenes.map((s) => s.sceneId);[ids[idx], ids[target]] = [ids[target], ids[idx]];+ // The server keeps each slot's song timing and lyric and moves the shots+ // between them, so the moved shot now plays at its neighbor's time.+ const moved = scenes[idx];+ const wasApproved = !!productionReview.readiness?.storyboard?.approved;reorderMusicVideoScenes(selected.id, ids, { silent: true })- .then((proj) => replaceProject(proj))+ .then((proj) => {+ replaceProject(proj);+ const now = (proj.scenes || []).find((s) => s.sceneId === moved.sceneId);+ if (now) seekToScene(now);+ const at = typeof now?.startSec === 'number' ? ` to ${formatTimecode(now.startSec)}` : '';+ toast.success(`Moved ${moved.label || 'shot'}${at}${wasApproved ? '; re-approve the storyboard' : ''}`);+ }).catch((err) => toast.error(err?.message || 'Failed to reorder'));};diff --git a/server/services/musicVideo/projectsLogic.js b/server/services/musicVideo/projectsLogic.jsindex a560ba0daa..8c6160baa2 100644--- a/server/services/musicVideo/projectsLogic.js+++ b/server/services/musicVideo/projectsLogic.js@@ -596,10 +596,24 @@ export function removeScene(project, sceneId) {return touch(project, { scenes: nextScenes });}+// What a board position owns rather than the shot placed in it: the span of+// the song, its section, and the lyric sung there. A reorder leaves these on+// their positions and moves only the shot (prompts, frames, clips, takes,+// direction, camera), so swapping two shots keeps the song timing intact.+const SCENE_SLOT_FIELDS = ['startSec', 'endSec', 'beatAligned', 'sectionIndex', 'sectionLabel', 'lyricText', 'lyricRole'];+const DRAFT_SHOT_SLOT_FIELDS = ['startSec', 'endSec', 'lyricCueIds'];+const pickSlot = (record, fields) => Object.fromEntries(fields.filter((k) => k in record).map((k) => [k, record[k]]));+const withoutSlot = (record, fields) => Object.fromEntries(Object.entries(record).filter(([k]) => !fields.includes(k)));+/*** Reorder the board to the given sceneId order. `orderedIds` must be exactly the* project's current scene ids (a permutation) — a missing/extra/unknown id is a- * 400 so a stale client can't silently drop scenes. Returns the next record.+ * 400 so a stale client can't silently drop scenes. Each board position keeps+ * its song slot (SCENE_SLOT_FIELDS) and the shots move between the slots; the+ * lyric-timed storyboard draft's shots follow their scenes into the new slots,+ * and a revised song's per-shot lyric verdicts stay with their slots.+ * The storyboard and proof approvals hash scene timing and content, so they go+ * stale on their own. Returns the next record.*/export function reorderScenes(project, orderedIds) {const scenes = project.scenes || [];@@ -607,8 +621,32 @@ export function reorderScenes(project, orderedIds) {if (orderedIds.length !== scenes.length || !orderedIds.every((id) => byId.has(id)) || new Set(orderedIds).size !== orderedIds.length) {throw new ServerError('Reorder must list each existing scene id exactly once', { status: 400, code: 'VALIDATION_ERROR' });}- const nextScenes = orderedIds.map((id, i) => ({ ...byId.get(id), order: i }));- return touch(project, { scenes: nextScenes });+ // The scene whose slot each moved scene now fills.+ const slotOwner = new Map(orderedIds.map((id, i) => [id, scenes[i]]));+ const nextScenes = orderedIds.map((id, i) => ({+ ...withoutSlot(byId.get(id), SCENE_SLOT_FIELDS), ...pickSlot(scenes[i], SCENE_SLOT_FIELDS), order: i,+ }));+ const extra = { scenes: nextScenes };+ // A revised song's verdicts are about the lyric in a slot, so they stay with it.+ const sceneReview = project.songRevision?.sceneReview;+ if (sceneReview && typeof sceneReview === 'object') {+ const holder = new Map(scenes.map((s, i) => [s.sceneId, orderedIds[i]]));+ extra.songRevision = { ...project.songRevision,+ sceneReview: Object.fromEntries(Object.entries(sceneReview).map(([id, verdict]) => [holder.get(id) ?? id, verdict])) };+ }+ const draft = project.productionReview?.draft;+ if (!Array.isArray(draft?.storyboard) || draft.storyboardSource === 'document') return touch(project, extra);+ const draftShots = new Map(draft.storyboard.filter((shot) => shot?.sceneId).map((shot) => [shot.sceneId, shot]));+ const storyboard = draft.storyboard.map((shot) => {+ const owner = shot?.sceneId && slotOwner.get(shot.sceneId);+ if (!owner || owner.sceneId === shot.sceneId) return shot;+ // The owner's own draft shot carries that slot's lyric anchors; without one,+ // take the slot's timing and let the storyboard check ask for anchors.+ const slot = draftShots.get(owner.sceneId);+ return slot ? { ...shot, ...pickSlot(slot, DRAFT_SHOT_SLOT_FIELDS) }+ : { ...shot, startSec: owner.startSec ?? shot.startSec, endSec: owner.endSec ?? shot.endSec, lyricCueIds: [] };+ });+ return touch(project, { ...extra, productionReview: { ...project.productionReview, draft: { ...draft, storyboard } } });}// Label suffix budget: the scene label schema caps at 120 characters.diff --git a/server/services/musicVideo/projectsLogic.test.js b/server/services/musicVideo/projectsLogic.test.jsindex 95a8183040..c4fb04f57d 100644--- a/server/services/musicVideo/projectsLogic.test.js+++ b/server/services/musicVideo/projectsLogic.test.js@@ -571,6 +571,34 @@ describe('scene board operations', () => {expect(() => applySceneUpdate(project, scene.sceneId, { lyricRole: 'karaoke' })).toThrow();});+ it('keeps each position\'s song slot and moves the shot between slots', () => {+ let p = baseProject();+ const ids = [];+ for (const [prompt, startSec, endSec, lyricText] of [['fire', 0, 4, 'line one'], ['cave', 4, 10, 'line two']]) {+ const r = addScene(p, { prompt, startSec, endSec, lyricText, sectionLabel: 'Intro', label: prompt });+ p = r.project; ids.push(r.scene.sceneId);+ }+ p = applySceneUpdate(p, ids[0], { referenceImageId: 'fire.png' }).project;+ p = { ...p,+ songRevision: { sceneReview: { [ids[0]]: { status: 'changed' } } },+ productionReview: { draft: { storyboard: [+ { sceneId: ids[0], startSec: 0, endSec: 4, lyricCueIds: ['c1'], action: 'gather' },+ { sceneId: ids[1], startSec: 4, endSec: 10, lyricCueIds: ['c2'], action: 'paint' },+ ] } } };+ const next = reorderScenes(p, [ids[1], ids[0]]);+ expect(next.scenes.map((s) => [s.sceneId, s.label, s.startSec, s.endSec, s.lyricText, s.order])).toEqual([+ [ids[1], 'cave', 0, 4, 'line one', 0],+ [ids[0], 'fire', 4, 10, 'line two', 1],+ ]);+ expect(next.scenes[1].referenceImageId).toBe('fire.png');+ expect(next.productionReview.draft.storyboard).toEqual([+ { sceneId: ids[0], startSec: 4, endSec: 10, lyricCueIds: ['c2'], action: 'gather' },+ { sceneId: ids[1], startSec: 0, endSec: 4, lyricCueIds: ['c1'], action: 'paint' },+ ]);+ // The revised-song verdict was about the first slot's lyric, now under the cave shot.+ expect(next.songRevision.sceneReview).toEqual({ [ids[1]]: { status: 'changed' } });+ });+it('rejects a reorder that is not an exact permutation', () => {let p = baseProject();const r = addScene(p, { prompt: 'a' }); p = r.project;