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): bundle scene reference frames in the music-video sync manifest
[._.]/ Adam Eivy61a8160dae1d
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 31012c4de0..d5bc903773 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -21,8 +21,8 @@- **[issue-1760] Groundwork: offline beat/tempo/section analysis of an audio track (Phase 0 spike).** The first slice of the planned Music Video production mode proves the riskiest unknown — that a music track's BPM, beat grid, 4/4 downbeats, and a coarse section map can be extracted **fully offline with no new dependency**, using only ffmpeg (already required) plus a pure-JS DSP core (onset-strength envelope → tempo-weighted autocorrelation → beat-phase fit → energy-novelty sections). No Python, no ML model download, no network — so it runs the same in CI and on every install. There's no user-facing surface yet; this is the analyzer the upcoming director scene board and beat-snapped render build on. (`server/services/musicVideo/audioAnalysis.js`)- **[issue-1760] Director scene board: create a Music Video project, analyze its track, and storyboard beat-aligned scenes (Phase 1).** Builds the first user-facing surface on top of the Phase 0 analyzer: a new **Create → Music Video** page (also reachable via `⌘K` and voice) where you pick an existing track (or name an uploaded audio file), create a project, and run the offline analyzer with one click — the detected BPM, beat/downbeat counts, and section map render inline. From there you storyboard the video as an ordered list of **scenes**, each with a label, a start/end time, a beat-aligned flag, and image/frame prompts; scenes can be added, edited (blur-to-save), reordered, and removed. Projects persist through a db-primary store (PostgreSQL `music_video_projects` with a file-backend fallback for dev/test), mirroring the creative-director pattern with soft-delete tombstones and LWW timestamps. Cross-machine federation of projects, per-scene reference-frame/image generation + image-to-video, and the beat-snapped render with a master audio bed are filed as follow-ups on #1760. (`server/services/musicVideo/`, `server/routes/musicVideo.js`, `server/lib/musicVideoValidation.js`, `client/src/pages/MusicVideo.jsx`, `client/src/services/apiMusicVideo.js`)- **[issue-1770] Music Video projects now sync across your federated machines.** Phase 1 shipped the project store as local-only; it now federates over the same peer-sync pipeline your other creative records use. A new **Music Video** toggle on the Instances page enables it per peer — when on, creating, editing, reordering scenes on, or deleting a project on one machine propagates to the others, with newest-edit-wins conflict resolution and deletions that an out-of-date peer can't resurrect. Conflicting edits are surfaced in the Conflicts UI for restore. Referenced media (the uploaded audio track and rendered scene clips) is not bundled in this phase and is tracked as a follow-up. (Closes #1770)-- **[issue-1772] Music Video project media now federates with the project.** #1770 synced the project record but shipped an empty asset manifest, so a peer that subscribed to just one project received the metadata and beat-aligned scenes but none of the bytes. The push now bundles the project's referenced media: the **uploaded audio track** (as a `music` asset) and each scene's **rendered clip** (resolved from its `videoHistoryId` through `video-history.json` to the file under `data/videos/`, with a `<id>.mp4` fallback when the metadata row hasn't synced yet). A track-linked project ships no audio here — the linked track federates its own. Tombstones still ship nothing, and missing files are skipped so a stale reference never forces a peer to re-request bytes the sender doesn't have. Scene reference-frame images (`referenceImageId`) wait on the unshipped Phase 1b render pipeline that populates them. (Closes #1772)-- **[issue-1760] Generate a reference frame for each scene on the director board (Phase 1b).** Each scene now has a **frame prompt** and a **Generate frame** button: it renders a still image (through your configured image generator — local, Codex, or external SD-API) that seeds the shot, suffixed with the project's global concept style. The frame thumbnail shows inline once it lands, and the button re-renders it on demand. Long local/Codex renders complete **durably in the background** — the image is filed onto the scene even if you navigated away or refreshed before it finished, and it appears the moment it's ready (no manual refresh). Because the attach goes through the normal project store, a generated frame also propagates to your federated machines. This is the first half of Phase 1b; turning the reference frame into a moving clip (image-to-video) and the beat-snapped render remain follow-ups on #1760. (`server/services/musicVideoSceneImageHook.js`, `server/services/musicVideo/events.js`, `server/routes/imageGen.js`, `client/src/pages/MusicVideo.jsx`)+- **[issue-1772] Music Video project media now federates with the project.** #1770 synced the project record but shipped an empty asset manifest, so a peer that subscribed to just one project received the metadata and beat-aligned scenes but none of the bytes. The push now bundles the project's referenced media: the **uploaded audio track** (as a `music` asset) and each scene's **rendered clip** (resolved from its `videoHistoryId` through `video-history.json` to the file under `data/videos/`, with a `<id>.mp4` fallback when the metadata row hasn't synced yet). A track-linked project ships no audio here — the linked track federates its own. Tombstones still ship nothing, and missing files are skipped so a stale reference never forces a peer to re-request bytes the sender doesn't have. (Per-scene reference-frame stills are bundled too, once Phase 1b populates them — see below.) (Closes #1772)+- **[issue-1760] Generate a reference frame for each scene on the director board (Phase 1b).** Each scene now has a **frame prompt** and a **Generate frame** button: it renders a still image (through your configured image generator — local, Codex, or external SD-API) that seeds the shot, suffixed with the project's global concept style. The frame thumbnail shows inline once it lands, and the button re-renders it on demand. Long local/Codex renders complete **durably in the background** — the image is filed onto the scene even if you navigated away or refreshed before it finished, and it appears the moment it's ready (no manual refresh). Because the attach goes through the normal project store, a generated frame also propagates to your federated machines. This is the first half of Phase 1b; turning the reference frame into a moving clip (image-to-video) and the beat-snapped render remain follow-ups on #1760. (`server/services/musicVideoSceneImageHook.js`, `server/services/musicVideo/events.js`, `server/routes/imageGen.js`, `server/services/sharing/peerSync.js`, `client/src/pages/MusicVideo.jsx`)## Devtoolsdiff --git a/server/services/sharing/peerSync.js b/server/services/sharing/peerSync.jsindex d61ef02aed..1bf95ef739 100644--- a/server/services/sharing/peerSync.js+++ b/server/services/sharing/peerSync.js@@ -1791,13 +1791,15 @@ async function videoHistoryFilenamesById() {* `videoHistory` dataSync category; this adds the bytes. Falls back to the* `<id>.mp4` convention (`collectionVideoRefToFilename`) when the row hasn't* synced yet — a missing file is skipped, so a wrong guess never ships.+ * - per-scene reference-frame stills (`scene.referenceImageId`, #1760 Phase 1b+ * — a gallery basename under PATHS.images, the same store every other gen'd+ * image uses). Hashed sidecar-aware via `hashImageForManifest` so a peer that+ * receives the synced scene record also gets the thumbnail bytes instead of a+ * dangling `/data/images/<file>` reference.*- * Scene reference-frame images (`scene.referenceImageId`) are intentionally NOT- * hashed: the i2v render pipeline that populates them is Phase 1b (unshipped)- * and its reference-image store/dir convention isn't defined yet — federating- * them is a follow-up. Path-traversal-guarded + missing-file-skipped via- * hashSimpleAsset; dedup by `<kind>:<filename>` so two scenes pointing at the- * same render ship once.+ * All three kinds are path-traversal-guarded + missing-file-skipped (a wrong/+ * stale reference never forces a peer to re-request bytes the sender lacks);+ * dedup by `<kind>:<filename>` so two scenes pointing at the same render ship once.*/async function buildMusicVideoAssetManifest(project) {const dedup = new Map();@@ -1818,6 +1820,15 @@ async function buildMusicVideoAssetManifest(project) {if (entry) dedup.set(`${entry.kind}:${entry.filename}`, entry);}}+ const imageNames = [...new Set(+ scenes.map((s) => (isStr(s?.referenceImageId) ? s.referenceImageId : null)).filter(Boolean),+ )];+ if (imageNames.length) {+ const entries = await Promise.all(imageNames.map((name) => hashImageForManifest(name)));+ for (const entry of entries) {+ if (entry) dedup.set(`${entry.kind}:${entry.filename}`, entry);+ }+ }return [...dedup.values()];}diff --git a/server/services/sharing/peerSync.test.js b/server/services/sharing/peerSync.test.jsindex 6d07f1910c..3b15f58bab 100644--- a/server/services/sharing/peerSync.test.js+++ b/server/services/sharing/peerSync.test.js@@ -2299,17 +2299,21 @@ describe('peerSync', () => {}]);};- it('bundles uploaded audio + rendered scene clips for a music video project push', async () => {+ it('bundles uploaded audio + rendered scene clips + reference-frame stills for a music video project push', async () => {// #1772: the project record federated but shipped an empty manifest, so a// selectively-subscribed peer never received the referenced media. Audio// rides as a `music` entry (PATHS.music); each scene's videoHistoryId- // resolves through video-history.json to its `<filename>` under PATHS.videos.+ // resolves through video-history.json to its `<filename>` under PATHS.videos;+ // each scene's referenceImageId (#1760 Phase 1b) rides as a sidecar-aware+ // `image` entry (a gallery basename under PATHS.images).enableMusicVideoPeer();PATHS.videos = join(tmp, 'videos');await mkdir(PATHS.videos, { recursive: true });+ await mkdir(PATHS.images, { recursive: true });await writeFile(join(PATHS.music, 'mv-song.mp3'), Buffer.from('audio bytes'));await writeFile(join(PATHS.videos, 'scene-one.mp4'), Buffer.from('clip one'));await writeFile(join(PATHS.videos, 'scene-two.webm'), Buffer.from('clip two'));+ await writeFile(join(PATHS.images, 'ref-x.png'), Buffer.from('frame bytes'));// video-history.json maps each videoHistoryId → its on-disk basename.await writeFile(join(tmp, 'video-history.json'), JSON.stringify([{ id: 'vh-1', filename: 'scene-one.mp4' },@@ -2319,7 +2323,7 @@ describe('peerSync', () => {id: 'mv-1', name: 'My Video', mode: 'director', trackId: null,uploadedAudioFilename: 'mv-song.mp3',scenes: [- { sceneId: 's-1', order: 0, videoHistoryId: 'vh-1', referenceImageId: 'ref-x' },+ { sceneId: 's-1', order: 0, videoHistoryId: 'vh-1', referenceImageId: 'ref-x.png' },{ sceneId: 's-2', order: 1, videoHistoryId: 'vh-2', referenceImageId: null },{ sceneId: 's-3', order: 2, videoHistoryId: null, referenceImageId: null },],@@ -2338,8 +2342,9 @@ describe('peerSync', () => {const byKind = (k) => captured.assetManifest.filter(a => a.kind === k).map(a => a.filename).sort();expect(byKind('music')).toEqual(['mv-song.mp3']);expect(byKind('video')).toEqual(['scene-one.mp4', 'scene-two.webm']);- // referenceImageId is Phase 1b — no image entry ships yet.- expect(byKind('image')).toEqual([]);+ // referenceImageId (Phase 1b) now ships as a gallery `image` asset so the+ // peer renders the thumbnail instead of a dangling /data/images/ reference.+ expect(byKind('image')).toEqual(['ref-x.png']);});it('falls back to the <id>.mp4 convention when a scene clip has no video-history row', async () => {