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

Show a retry when music models fail to load; mock the new APIs in the page test

Claude4e751c5d391e
diff --git a/client/src/components/codeAnimation/CodeAnimationSoundtrack.jsx b/client/src/components/codeAnimation/CodeAnimationSoundtrack.jsx
index c1d25040b2..add23f5f68 100644
--- a/client/src/components/codeAnimation/CodeAnimationSoundtrack.jsx
+++ b/client/src/components/codeAnimation/CodeAnimationSoundtrack.jsx
@@ -2,6 +2,8 @@ import { useEffect, useMemo, useRef, useState } from 'react';
import { LoaderCircle, Music2 } from 'lucide-react';
import toast from '../ui/Toast';
import ModelInputPreview from '../media/ModelInputPreview';
+import ListLoadError from '../ui/ListLoadError';
+import useListResource from '../../hooks/useListResource';
import useMediaJobProgress from '../../hooks/useMediaJobProgress';
import { useModelInputPreview } from '../../hooks/useModelInputPreview';
import { generateCodeAnimationSoundtrack, listMusicEngines, previewMusicPrompt } from '../../services/api';
@@ -21,6 +23,8 @@ const readChoice = () => {
return stored && typeof stored === 'object' ? stored : {};
};
+const fetchEngines = async () => (await listMusicEngines({ silent: true }))?.engines;
+
const fits = (engine, filmSec) => !Number.isFinite(engine.maxDurationSec) || engine.maxDurationSec >= filmSec;
function engineNote(engine, filmSec) {
@@ -36,7 +40,8 @@ function engineNote(engine, filmSec) {
*/
export default function CodeAnimationSoundtrack({ jobId, soundtrack, audioUrl, durationSeconds, onReady }) {
const filmSec = Math.ceil(Number(durationSeconds) || 0);
- const [engines, setEngines] = useState(null);
+ const engineList = useListResource(fetchEngines);
+ const engines = engineList.state === 'ready' ? engineList.items : null;
const [choice, setChoice] = useState(readChoice);
const [prompt, setPrompt] = useState(soundtrack?.prompt || '');
const [starting, setStarting] = useState(false);
@@ -47,12 +52,6 @@ export default function CodeAnimationSoundtrack({ jobId, soundtrack, audioUrl, d
setMediaJobId(soundtrack?.mediaJobId || null);
}, [jobId, soundtrack?.mediaJobId]);
- useEffect(() => {
- listMusicEngines({ silent: true })
- .then((data) => setEngines(Array.isArray(data?.engines) ? data.engines : []))
- .catch(() => setEngines([]));
- }, []);
-
const usable = useMemo(() => (engines || []).filter((engine) => engine.ready && fits(engine, filmSec)), [engines, filmSec]);
const engine = useMemo(() => {
const list = engines || [];
@@ -118,7 +117,7 @@ export default function CodeAnimationSoundtrack({ jobId, soundtrack, audioUrl, d
<label htmlFor="ca-soundtrack-engine" className={labelClass}>Music model</label>
<select id="ca-soundtrack-engine" value={engine?.id || ''} disabled={!engines?.length || live}
onChange={(event) => updateChoice({ engine: event.target.value, modelId: '' })} className={inputClass}>
- {engines === null && <option value="">Loading models…</option>}
+ {engines === null && <option value="">{engineList.state === 'error' ? 'Models unavailable' : 'Loading models…'}</option>}
{engines?.length === 0 && <option value="">No music models</option>}
{(engines || []).map((item) => {
const note = engineNote(item, filmSec);
@@ -136,6 +135,7 @@ export default function CodeAnimationSoundtrack({ jobId, soundtrack, audioUrl, d
</div>
)}
</div>
+ {engineList.state === 'error' && <ListLoadError what="music models" error={engineList.error} onRetry={engineList.retry} />}
{engine && engineBlocked === 'not installed' && (
<p className="text-xs text-port-warning">{engine.name} is not installed. Install it in Music › Generate, or pick another model.</p>
)}
diff --git a/client/src/pages/CodeAnimation.test.jsx b/client/src/pages/CodeAnimation.test.jsx
index 11a9c4e366..55ddc0c916 100644
--- a/client/src/pages/CodeAnimation.test.jsx
+++ b/client/src/pages/CodeAnimation.test.jsx
@@ -35,6 +35,9 @@ vi.mock('../services/api', () => ({
generateCodeAnimationBrief: vi.fn(),
getCodeAnimationJob: vi.fn(),
getCodeAnimationOptions: vi.fn(),
+ generateCodeAnimationSoundtrack: vi.fn(),
+ listMusicEngines: vi.fn().mockResolvedValue({ engines: [] }),
+ previewMusicPrompt: vi.fn(),
getFilmStyle: vi.fn(),
listFilmStyles: vi.fn(),
listCodeAnimationJobPage: vi.fn().mockResolvedValue({ items: [], total: 0, counts: { running: 0, completed: 0 }, nextCursor: null }),