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: ship music-bed bytes to federated peers, keep the open Overview tab polling for it
[._.]/ Adam Eivyf208f5907c46
diff --git a/client/src/components/creative-director/OverviewTab.jsx b/client/src/components/creative-director/OverviewTab.jsxindex cacafe0e96..87ccfd9b55 100644--- a/client/src/components/creative-director/OverviewTab.jsx+++ b/client/src/components/creative-director/OverviewTab.jsx@@ -4,7 +4,7 @@ import { Sparkles, Loader2 } from 'lucide-react';import { updateCreativeDirectorProject, applyCreativeDirectorAutoCast } from '../../services/apiCreativeDirector.js';import toast from '../ui/Toast';-export default function OverviewTab({ project, onProjectUpdate }) {+export default function OverviewTab({ project, onProjectUpdate, onAsyncWorkQueued }) {const [disableAudio, setDisableAudio] = useState(project.disableAudio === true);const [saving, setSaving] = useState(false);const [autoCasting, setAutoCasting] = useState(false);@@ -115,6 +115,15 @@ export default function OverviewTab({ project, onProjectUpdate }) {cast: result?.project?.cast || [],...(composing ? { status: 'planning' } : {}),});+ // Portraits land on a catalog ingredient (no project-status change to+ // ride), and the music bed lands on `project.musicBed` directly — both+ // attach asynchronously, well after this response. A project that+ // hasn't been started/composed yet stays at status 'draft', which the+ // detail page's poll gate treats as terminal (no compose flip to+ // escape it, unlike the `composing` branch above). Tell the parent to+ // extend polling for a bit so either result actually shows up in the+ // open tab instead of requiring a manual Refresh / navigate-away.+ if (firstPassQueued > 0 || musicBedQueued) onAsyncWorkQueued?.();// Suffix the portrait-gen count + music-bed status onto whichever// success toast fires, so a user who opted into either first-pass gen// sees it kicked off in one place.diff --git a/client/src/pages/CreativeDirectorDetail.jsx b/client/src/pages/CreativeDirectorDetail.jsxindex 8c6598cf69..aa7eeb2e03 100644--- a/client/src/pages/CreativeDirectorDetail.jsx+++ b/client/src/pages/CreativeDirectorDetail.jsx@@ -1,4 +1,4 @@-import { useEffect, useState, useCallback } from 'react';+import { useEffect, useState, useCallback, useRef } from 'react';import { useParams, useNavigate, Link } from 'react-router-dom';import { ArrowLeft, Play, Pause, RefreshCw } from 'lucide-react';import toast from '../components/ui/Toast';@@ -33,6 +33,24 @@ export default function CreativeDirectorDetail() {const [project, setProject] = useState(null);const [loading, setLoading] = useState(true);const [activeAgents, setActiveAgents] = useState([]);+ // Extends polling past the terminal-status gate below for a bounded window+ // after the Overview tab queues a first-pass portrait/music-bed render+ // (#1818/#1928) — those attach asynchronously to a catalog ingredient or+ // `project.musicBed` without changing the project's lifecycle status, so a+ // still-'draft' project (no compose flip to escape TERMINAL_PROJECT_STATUSES)+ // would otherwise never pick up the result without a manual Refresh.+ const [pendingAsyncWork, setPendingAsyncWork] = useState(false);+ const pendingAsyncWorkTimerRef = useRef(null);+ const extendPollingForAsyncWork = useCallback(() => {+ setPendingAsyncWork(true);+ clearTimeout(pendingAsyncWorkTimerRef.current);+ // 3 minutes covers a cold model load + render for the local image/audio+ // gen backends in the common case; if it runs longer the user can still+ // hit the manual Refresh button. Not tied to a job-completion signal —+ // this component has no socket/SSE channel into the media job queue.+ pendingAsyncWorkTimerRef.current = setTimeout(() => setPendingAsyncWork(false), 3 * 60 * 1000);+ }, []);+ useEffect(() => () => clearTimeout(pendingAsyncWorkTimerRef.current), []);const fetchProject = useCallback(async () => {const p = await getCreativeDirectorProject(id).catch(() => null);@@ -53,8 +71,10 @@ export default function CreativeDirectorDetail() {}, [id]);// Only poll while the agent could still mutate the project. Once the- // status reaches a terminal state, the visibility-paused hook stops firing.- const pollEnabled = !project?.status || !TERMINAL_PROJECT_STATUSES.has(project.status);+ // status reaches a terminal state, the visibility-paused hook stops firing+ // — except during the bounded `pendingAsyncWork` window above, which+ // overrides the terminal gate so a queued first-pass render still surfaces.+ const pollEnabled = !project?.status || !TERMINAL_PROJECT_STATUSES.has(project.status) || pendingAsyncWork;const poll = useCallback(async () => {await Promise.all([fetchProject(), fetchAgents()]);return null;@@ -71,6 +91,10 @@ export default function CreativeDirectorDetail() {useEffect(() => {setLoading(true);setProject(null);+ // A pending-async-work window is per-project intent — don't carry it+ // across a route swap (the new project has its own poll-gate state).+ setPendingAsyncWork(false);+ clearTimeout(pendingAsyncWorkTimerRef.current);refetchPoll();}, [id, refetchPoll]);@@ -149,7 +173,13 @@ export default function CreativeDirectorDetail() {<div className="flex-1 overflow-auto p-6"><ActiveAgentsBanner agents={activeAgents} />- {activeTab === 'overview' && <OverviewTab project={project} onProjectUpdate={(updates) => setProject((p) => p ? { ...p, ...updates } : p)} />}+ {activeTab === 'overview' && (+ <OverviewTab+ project={project}+ onProjectUpdate={(updates) => setProject((p) => p ? { ...p, ...updates } : p)}+ onAsyncWorkQueued={extendPollingForAsyncWork}+ />+ )}{activeTab === 'treatment' && <TreatmentTab project={project} />}{activeTab === 'segments' && <SegmentsTab project={project} activeAgents={activeAgents} />}{activeTab === 'runs' && <RunsTab project={project} />}diff --git a/server/services/sharing/peerSyncAssets.js b/server/services/sharing/peerSyncAssets.jsindex 53cf7bbcaa..5c1786c7da 100644--- a/server/services/sharing/peerSyncAssets.js+++ b/server/services/sharing/peerSyncAssets.js@@ -353,20 +353,34 @@ export async function buildTrackAssetManifest(track) {}/**- * Hash a Creative Director project's direct image input (`startingImageFile`) so- * the receiver can pull the bytes from `/data/images/`. `startingImageFilename`- * returns null for an external URL / non-local path, so those never ship (the- * receiver resolves the same URL itself). Scene VIDEO renders are NOT hashed- * here: they live in the project's linked media collection, which federates as- * its own record and ships its bytes via that collection's manifest — duplicating- * them here would double the transfer. This mirrors buildAuthorAssetManifest:- * one direct asset, missing-local-file skipped silently.+ * Hash a Creative Director project's direct image input (`startingImageFile`)+ * and first-pass music bed (`musicBed.filename`, #1928) so the receiver can+ * pull the bytes from `/data/images/` and `/data/music/` respectively.+ * `startingImageFilename` returns null for an external URL / non-local path,+ * so those never ship (the receiver resolves the same URL itself). Scene+ * VIDEO renders are NOT hashed here: they live in the project's linked media+ * collection, which federates as its own record and ships its bytes via that+ * collection's manifest — duplicating them here would double the transfer.+ * The music bed has no such alternate channel (unlike scene video, it isn't+ * filed into the linked collection), so without bundling it here a subscribed+ * peer would receive a dangling `musicBed.filename` reference — mirrors how+ * `buildTrackAssetManifest` / `buildMusicVideoAssetManifest` bundle their+ * `PATHS.music` audio. Each direct asset is missing-local-file skipped+ * silently (mirrors buildAuthorAssetManifest).*/export async function buildProjectAssetManifest(project) {- const filename = startingImageFilename(project?.startingImageFile);- if (!filename) return [];- const entry = await hashImageForManifest(filename);- return entry ? [entry] : [];+ const entries = [];+ const imageFilename = startingImageFilename(project?.startingImageFile);+ if (imageFilename) {+ const imageEntry = await hashImageForManifest(imageFilename);+ if (imageEntry) entries.push(imageEntry);+ }+ const musicBedFilename = project?.musicBed?.filename;+ if (isStr(musicBedFilename)) {+ const musicEntry = await hashSimpleAsset(musicBedFilename, 'music', PATHS.music);+ if (musicEntry) entries.push(musicEntry);+ }+ return entries;}// `data/video-history.json` is a FLAT array of video-generation rowsdiff --git a/server/services/sharing/peerSyncAssets.test.js b/server/services/sharing/peerSyncAssets.test.jsindex 9a21ff0216..f907a2dd31 100644--- a/server/services/sharing/peerSyncAssets.test.js+++ b/server/services/sharing/peerSyncAssets.test.js@@ -14,7 +14,7 @@ vi.mock('../../lib/fileUtils.js', async () => {const actual = await vi.importActual('../../lib/fileUtils.js');return makePathsProxy(actual, {dataRoot: () => tempRoot,- extraOverrides: (root) => ({ music: join(root, 'music') }),+ extraOverrides: (root) => ({ music: join(root, 'music'), images: join(root, 'images') }),});});@@ -27,7 +27,7 @@ vi.mock('../tracks/index.js', async () => ({}));const { getTrack } = await import('../tracks/index.js');-const { buildMusicVideoAssetManifest } = await import('./peerSyncAssets.js');+const { buildMusicVideoAssetManifest, buildProjectAssetManifest } = await import('./peerSyncAssets.js');const sha = (buf) => createHash('sha256').update(buf).digest('hex');@@ -37,6 +37,12 @@ function writeMusic(filename, bytes) {writeFileSync(join(dir, filename), bytes);}+function writeImage(filename, bytes) {+ const dir = join(tempRoot, 'images');+ mkdirSync(dir, { recursive: true });+ writeFileSync(join(dir, filename), bytes);+}+describe('buildMusicVideoAssetManifest — master audio', () => {beforeEach(() => {tempRoot = mkdtempSync(join(tmpdir(), 'portos-mv-assets-'));@@ -95,3 +101,49 @@ describe('buildMusicVideoAssetManifest — master audio', () => {expect(audio[0]).toEqual({ filename: 'shared.mp3', kind: 'music', sha256: sha(bytes) });});});++describe('buildProjectAssetManifest — first-pass music bed (#1928)', () => {+ beforeEach(() => {+ tempRoot = mkdtempSync(join(tmpdir(), 'portos-cd-assets-'));+ });+ afterEach(() => {+ if (tempRoot) rmSync(tempRoot, { recursive: true, force: true });+ });++ it('returns an empty manifest for a bare project (no image, no music bed)', async () => {+ const manifest = await buildProjectAssetManifest({ startingImageFile: null, musicBed: null });+ expect(manifest).toEqual([]);+ });++ it('bundles the music bed so a subscribed peer does not get a dangling reference', async () => {+ const bytes = Buffer.from('music-bed-bytes');+ writeMusic('music-gen-abc.wav', bytes);+ const manifest = await buildProjectAssetManifest({+ startingImageFile: null,+ musicBed: { filename: 'music-gen-abc.wav', durationSec: 12, engine: 'musicgen' },+ });+ expect(manifest).toEqual([{ filename: 'music-gen-abc.wav', kind: 'music', sha256: sha(bytes) }]);+ });++ it('skips a music bed whose file is absent on disk (never ships a null hash)', async () => {+ const manifest = await buildProjectAssetManifest({+ startingImageFile: null,+ musicBed: { filename: 'never-written.wav' },+ });+ expect(manifest).toEqual([]);+ });++ it('bundles both the starting image and the music bed together', async () => {+ const imageBytes = Buffer.from('starting-image-bytes');+ const musicBytes = Buffer.from('music-bed-bytes-2');+ writeImage('start.png', imageBytes);+ writeMusic('music-gen-def.wav', musicBytes);+ const manifest = await buildProjectAssetManifest({+ startingImageFile: 'start.png',+ musicBed: { filename: 'music-gen-def.wav' },+ });+ expect(manifest).toContainEqual({ filename: 'start.png', kind: 'image', sha256: sha(imageBytes) });+ expect(manifest).toContainEqual(expect.objectContaining({ filename: 'music-gen-def.wav', kind: 'music', sha256: sha(musicBytes) }));+ expect(manifest).toHaveLength(2);+ });+});