Skip to content

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

feat([issue-1933]): surface Creative Director music-bed render failures in the UI

Adam Eivyb754db264e64
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 92f90f1bfb..0c94d49a6d 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -88,6 +88,7 @@
- **[issue-2196] Video Gen now takes an exact custom Width×Height.** The `/media/video` page only offered a 9-item resolution preset dropdown, so a size the presets didn't cover was only reachable via URL params, remix/continue, or aspect-snap on upload. Two numeric Width and Height inputs now sit beside the preset select — type any dimensions and the render uses them (the server still rounds each down to a multiple of 64 and enforces the per-tier pixel budget). Uploading a source image still auto-snaps the size to the image's aspect ratio by default, until you take the dimensions into your own hands.
- **[issue-2197] First-run model downloads now show GB progress instead of raw text.** The video and image generation handlers now parse byte sizes from `DOWNLOAD:` markers and tqdm progress bars, displaying a formatted "Downloading model · first run · X.X GB / Y.Y GB" message instead of the raw protocol output. Progress frames include `downloadedBytes`/`totalBytes` numeric fields so the UI can build download progress bars. Phase tracking (`isDownloading`, `currentPhase`) ensures the formatting only applies during actual download phases.
- **[issue-2198] A wedged local video render that produces no output is now killed automatically instead of pinning the GPU queue.** The existing completion watchdog only guards a render that finishes and then hangs in teardown — it never armed for a render that stalls *before emitting anything* (a known MLX/Metal failure mode where the job never exits and never prints), which held the serialized GPU lane until you manually canceled. A new idle-stall deadline arms at spawn and resets on every child output line (stdout or stderr); if a render produces no output for a generous window (default 10 minutes, tunable via `VIDEOGEN_IDLE_STALL_MS`) it's SIGKILLed and surfaced as a failed job, so the next queued render can start. The window is deliberately generous so a legitimately slow first-token render (weights load + Metal kernel compile) is never killed, and a manual cancel still works and always wins. (`server/services/videoGen/local.js`)
+- **[issue-1933] Creative Director's first-pass music-bed render now surfaces failures in the UI.** When you opt into "+ music bed" on Auto-cast, the background render used to be invisible on failure — an engine crash, OOM, or sidecar error left `project.musicBed` silently unpopulated, discoverable only by polling the Render Queue. The `audio` media-job kind now rides the same socket bridge as image/video renders (`audio-gen:started|progress|completed|failed`), and the Creative Director detail page watches the queued job: a failed render raises an error toast with the reason, and a completed one confirms the music bed landed. (`server/services/socket.js`, `client/src/hooks/useMediaJobProgress.js`, `client/src/pages/CreativeDirectorDetail.jsx`, `client/src/components/creative-director/OverviewTab.jsx`)
- **[issue-2124] Add and manage custom image/video base models from HuggingFace — no more hand-editing a JSON file and restarting.** Base models used to be addable only by editing `data/media-models.json` and restarting the server, while LoRAs had a first-class "install from HuggingFace" flow. The Media Models page (`/media/models`) now has that same self-service experience for base models: paste a HuggingFace repo (URL or `org/name`), and PortOS inspects its files + model card to detect whether it's an image or video model and which runtime loads it, then appends a registry entry and hot-reloads it live (no restart). The catalog lists every built-in model read-only alongside your added ones, which you can rename, retune (steps/guidance), or remove inline. Formats no runtime can load are **refused up front with a clear reason** — a GGUF-only repo (e.g. `unsloth/LTX-2.3-GGUF`), a Wan or HunyuanVideo repo (which need a dedicated BYO venv), or anything unclassifiable — so a bad add can never wedge the model picker. For a GGUF LTX build specifically, the refusal points you at the native MLX Q4 model PortOS already ships. The multi-GB weight download still happens through the existing per-model download badge on the gen form once the entry exists.
## MeatSpace POST
diff --git a/client/src/components/creative-director/OverviewTab.jsx b/client/src/components/creative-director/OverviewTab.jsx
index 87ccfd9b55..6eb566d172 100644
--- a/client/src/components/creative-director/OverviewTab.jsx
+++ b/client/src/components/creative-director/OverviewTab.jsx
@@ -107,6 +107,10 @@ export default function OverviewTab({ project, onProjectUpdate, onAsyncWorkQueue
const composing = Boolean(result?.composing);
const firstPassQueued = result?.firstPass?.enqueued?.length || 0;
const musicBedQueued = Boolean(result?.firstPassMusicBed?.enqueued);
+ // The music-bed render is a single background `audio` media job — hand its
+ // id up so the detail page can watch `audio-gen:*` and toast a failure the
+ // user would otherwise only find by polling the Render Queue (#1933).
+ const musicBedJobId = result?.firstPassMusicBed?.jobId || null;
// When the director starts composing, optimistically flip the status to
// 'planning' as well — the detail page disables polling for 'draft'
// projects, so without this the treatment + runs the agent produces stay
@@ -123,7 +127,7 @@ export default function OverviewTab({ project, onProjectUpdate, onAsyncWorkQueue
// 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?.();
+ if (firstPassQueued > 0 || musicBedQueued) onAsyncWorkQueued?.({ musicBedJobId });
// 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/hooks/useMediaJobProgress.js b/client/src/hooks/useMediaJobProgress.js
index 93f0c4849e..6278ddbefe 100644
--- a/client/src/hooks/useMediaJobProgress.js
+++ b/client/src/hooks/useMediaJobProgress.js
@@ -4,10 +4,11 @@ import { getMediaJob } from '../services/apiMediaJobs';
import { usePreviousSync } from './usePrevious.js';
/**
- * Subscribe to live progress for a single mediaJobQueue job (image-gen
- * today, video-gen once a caller passes kind='video'). Filters socket
- * events by jobId so multiple instances of this hook coexist (one per
- * comic panel / storyboard scene) without cross-talk.
+ * Subscribe to live progress for a single mediaJobQueue job. `kind`
+ * selects the socket namespace: 'image' (default) → image-gen, 'video' →
+ * video-gen, 'audio' → audio-gen (first-pass music-bed, #1933). Filters
+ * socket events by jobId so multiple instances of this hook coexist (one
+ * per comic panel / storyboard scene) without cross-talk.
*
* Returns:
* {
@@ -82,7 +83,7 @@ export default function useMediaJobProgress(jobId, { kind = 'image' } = {}) {
// when the parent already has the completed render's filename.
});
- const evtPrefix = kind === 'video' ? 'video-gen' : 'image-gen';
+ const evtPrefix = kind === 'video' ? 'video-gen' : kind === 'audio' ? 'audio-gen' : 'image-gen';
const onStarted = (data) => {
if (data.generationId !== jobId) return;
setState((prev) => {
diff --git a/client/src/hooks/useMediaJobProgress.test.jsx b/client/src/hooks/useMediaJobProgress.test.jsx
index 82658bc6ff..eb26f39ecd 100644
--- a/client/src/hooks/useMediaJobProgress.test.jsx
+++ b/client/src/hooks/useMediaJobProgress.test.jsx
@@ -48,6 +48,25 @@ describe('useMediaJobProgress — canceled handling (#1791)', () => {
expect(handlers.has('image-gen:canceled')).toBe(false);
});
+ // Audio (first-pass music-bed, #1933) rides the audio-gen:* namespace so the
+ // Creative Director detail page can surface a failed background render.
+ it('subscribes to audio-gen:* events when kind=audio', () => {
+ renderHook(() => useMediaJobProgress('job-1', { kind: 'audio' }));
+ expect(handlers.has('audio-gen:failed')).toBe(true);
+ expect(handlers.has('audio-gen:completed')).toBe(true);
+ expect(handlers.has('image-gen:failed')).toBe(false);
+ });
+
+ it('settles to failed on a matching audio-gen:failed with the error', async () => {
+ const { result } = renderHook(() => useMediaJobProgress('job-1', { kind: 'audio' }));
+ await waitFor(() => expect(result.current.status).toBe('running'));
+ // Re-fetch after :failed returns the still-failed job (not a canceled one).
+ getMediaJob.mockResolvedValueOnce({ status: 'failed', error: 'sidecar crashed' });
+ fire('audio-gen:failed', { generationId: 'job-1', error: 'sidecar crashed' });
+ await waitFor(() => expect(result.current.status).toBe('failed'));
+ expect(result.current.error).toBe('sidecar crashed');
+ });
+
it('a :failed for a user-canceled running job still corrects to canceled via re-fetch', async () => {
const { result } = renderHook(() => useMediaJobProgress('job-1'));
await waitFor(() => expect(result.current.status).toBe('running'));
diff --git a/client/src/pages/CreativeDirectorDetail.jsx b/client/src/pages/CreativeDirectorDetail.jsx
index aa7eeb2e03..96ec8f71b0 100644
--- a/client/src/pages/CreativeDirectorDetail.jsx
+++ b/client/src/pages/CreativeDirectorDetail.jsx
@@ -16,6 +16,7 @@ import ActiveAgentsBanner from '../components/creative-director/ActiveAgentsBann
import { getCosAgents } from '../services/apiAgents.js';
import { useAutoRefetch } from '../hooks/useAutoRefetch';
import { useValidTab } from '../hooks/useValidTab';
+import useMediaJobProgress from '../hooks/useMediaJobProgress';
const TERMINAL_PROJECT_STATUSES = new Set(['complete', 'failed', 'paused', 'draft']);
@@ -41,8 +42,20 @@ export default function CreativeDirectorDetail() {
// would otherwise never pick up the result without a manual Refresh.
const [pendingAsyncWork, setPendingAsyncWork] = useState(false);
const pendingAsyncWorkTimerRef = useRef(null);
- const extendPollingForAsyncWork = useCallback(() => {
+ // Watch the queued first-pass music-bed job (#1933). Its completion attaches
+ // to `project.musicBed` via a durable server-side hook (picked up by polling),
+ // but a FAILURE (engine crash/OOM/sidecar error) has no other client-visible
+ // signal — so subscribe to `audio-gen:*` for the single job id and toast the
+ // outcome. Held in a ref alongside the id so the terminal-state effect below
+ // only toasts once per render, even though polling keeps re-rendering.
+ const [musicBedJobId, setMusicBedJobId] = useState(null);
+ const musicBedToastedRef = useRef(null);
+ const extendPollingForAsyncWork = useCallback((opts) => {
setPendingAsyncWork(true);
+ if (opts?.musicBedJobId) {
+ musicBedToastedRef.current = null;
+ setMusicBedJobId(opts.musicBedJobId);
+ }
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
@@ -52,6 +65,27 @@ export default function CreativeDirectorDetail() {
}, []);
useEffect(() => () => clearTimeout(pendingAsyncWorkTimerRef.current), []);
+ // Toast the music-bed render's terminal state exactly once. Success is mostly
+ // cosmetic (polling already renders the Music bed field), but confirms the
+ // background render the user opted into actually landed; failure is the whole
+ // point of #1933 — otherwise a crashed render is silently invisible.
+ const musicBed = useMediaJobProgress(musicBedJobId, { kind: 'audio' });
+ useEffect(() => {
+ if (!musicBedJobId || musicBedToastedRef.current === musicBedJobId) return;
+ if (musicBed.status === 'failed') {
+ musicBedToastedRef.current = musicBedJobId;
+ toast.error(`Music-bed render failed: ${musicBed.error || 'unknown error'}`);
+ setMusicBedJobId(null);
+ } else if (musicBed.status === 'completed') {
+ musicBedToastedRef.current = musicBedJobId;
+ toast.success('First-pass music bed ready');
+ setMusicBedJobId(null);
+ } else if (musicBed.status === 'canceled') {
+ musicBedToastedRef.current = musicBedJobId;
+ setMusicBedJobId(null);
+ }
+ }, [musicBedJobId, musicBed.status, musicBed.error]);
+
const fetchProject = useCallback(async () => {
const p = await getCreativeDirectorProject(id).catch(() => null);
setProject(p);
@@ -94,6 +128,10 @@ export default function CreativeDirectorDetail() {
// 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);
+ // Stop watching the prior project's music-bed job on a route swap so its
+ // late failure/completion toast can't land on the newly-opened project.
+ setMusicBedJobId(null);
+ musicBedToastedRef.current = null;
clearTimeout(pendingAsyncWorkTimerRef.current);
refetchPoll();
}, [id, refetchPoll]);
diff --git a/server/services/socket.js b/server/services/socket.js
index 886ad49ef8..ab43e7a8d1 100644
--- a/server/services/socket.js
+++ b/server/services/socket.js
@@ -26,6 +26,7 @@ import { catalogEvents } from './catalogEvents.js';
import { writersRoomEvents } from './writersRoomEvents.js';
import { musicVideoEvents } from './musicVideo/events.js';
import { videoGenEvents } from './videoGen/events.js';
+import { audioGenEvents } from './audioGen/events.js';
import { aiStatusEvents } from './aiStatusEvents.js';
import { wireProactiveTriggers } from './voice/proactiveTriggers.js';
import * as shellService from './shell.js';
@@ -946,13 +947,34 @@ function setupMediaGenEventForwarding() {
if (ioInstance) ioInstance.emit('video-gen:failed', data);
});
- // Map a media-job kind to its gen-event namespace prefix. Only image/video
- // jobs drive scene spinners and have `*-gen:*` consumers; the shared media
- // queue also runs `training` (LoRA) jobs, which have their own UI and NO
+ // Audio (first-pass music-bed, #1928/#1933) rides the same gen-event contract
+ // as image/video. Forward it onto `audio-gen:*` so a user-triggered music-bed
+ // render surfaces progress/failure like any other media job, rather than only
+ // populating `project.musicBed` silently (or silently failing) with the user
+ // left to poll the Render Queue to notice a crash/OOM/sidecar error.
+ audioGenEvents.on('started', (data) => {
+ if (ioInstance) ioInstance.emit('audio-gen:started', data);
+ });
+ audioGenEvents.on('progress', (data) => {
+ if (ioInstance) ioInstance.emit('audio-gen:progress', data);
+ });
+ audioGenEvents.on('completed', (data) => {
+ if (ioInstance) ioInstance.emit('audio-gen:completed', data);
+ });
+ audioGenEvents.on('failed', (data) => {
+ if (ioInstance) ioInstance.emit('audio-gen:failed', data);
+ });
+
+ // Map a media-job kind to its gen-event namespace prefix. image/video/audio
+ // jobs drive per-job spinners/toasts and have `*-gen:*` consumers; the shared
+ // media queue also runs `training` (LoRA) jobs, which have their own UI and NO
// `*-gen:*` listener — so they must NOT be forwarded onto the image channel
// (returning null skips them) rather than falling through to `image-gen:*`.
const genEvtPrefix = (kind) =>
- kind === 'video' ? 'video-gen' : kind === 'image' ? 'image-gen' : null;
+ kind === 'video' ? 'video-gen'
+ : kind === 'image' ? 'image-gen'
+ : kind === 'audio' ? 'audio-gen'
+ : null;
// Bridge media-job cancellation onto a `*-gen:canceled` socket event keyed by
// `generationId` (#1791). The internal gen modules emit started/progress/
diff --git a/server/services/socket.test.js b/server/services/socket.test.js
index 3e65b2b564..b4feb1c3dc 100644
--- a/server/services/socket.test.js
+++ b/server/services/socket.test.js
@@ -61,6 +61,7 @@ vi.mock('../sockets/voice.js', () => ({ registerVoiceHandlers: vi.fn() }));
import { initSocket } from './socket.js';
import { cosEvents } from './cosEvents.js';
import { mediaJobEvents } from './mediaJobQueue/index.js';
+import { audioGenEvents } from './audioGen/events.js';
import { detachSocketSessions } from './shell.js';
import * as shellService from './shell.js';
@@ -182,6 +183,31 @@ describe('socket.js — initSocket', () => {
expect(io.emitted.some(([ev]) => ev === 'image-gen:canceled' || ev === 'video-gen:canceled')).toBe(false);
});
+ // ===========================================================================
+ // Audio (first-pass music-bed) gen bridge (#1933): audio jobs ride the same
+ // gen-event contract as image/video, so both the mediaJobEvents queue-level
+ // bridge AND the direct audioGenEvents forwarding must reach `audio-gen:*`.
+ // ===========================================================================
+ it('bridges a failed audio job to audio-gen:failed keyed by generationId with the error', () => {
+ mediaJobEvents.emit('failed', { id: 'aud-fail', kind: 'audio', error: 'audio-gen sidecar crashed' });
+ expect(io.emitted).toContainEqual(['audio-gen:failed', { generationId: 'aud-fail', error: 'audio-gen sidecar crashed' }]);
+ });
+
+ it('bridges a canceled audio job to audio-gen:canceled', () => {
+ mediaJobEvents.emit('canceled', { id: 'aud-1', kind: 'audio' });
+ expect(io.emitted).toContainEqual(['audio-gen:canceled', { generationId: 'aud-1' }]);
+ });
+
+ it('forwards audioGenEvents failed straight onto audio-gen:failed', () => {
+ audioGenEvents.emit('failed', { generationId: 'aud-run-fail', error: 'OOM during render' });
+ expect(io.emitted).toContainEqual(['audio-gen:failed', { generationId: 'aud-run-fail', error: 'OOM during render' }]);
+ });
+
+ it('forwards audioGenEvents completed onto audio-gen:completed', () => {
+ audioGenEvents.emit('completed', { generationId: 'aud-ok', filename: 'bed.wav', durationSec: 12 });
+ expect(io.emitted).toContainEqual(['audio-gen:completed', { generationId: 'aud-ok', filename: 'bed.wav', durationSec: 12 }]);
+ });
+
it('two independent sockets can both subscribe to cos independently', () => {
const s1 = makeSocket('s1');
const s2 = makeSocket('s2');