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: show retryable errors for timeline clip and audio libraries (#12389)
[._.]/ Adam Eivybfbe17f5579b
diff --git a/client/src/pages/VideoTimelineEditor.jsx b/client/src/pages/VideoTimelineEditor.jsxindex 1d7a0816a3..4fd78108c2 100644--- a/client/src/pages/VideoTimelineEditor.jsx+++ b/client/src/pages/VideoTimelineEditor.jsx@@ -113,6 +113,9 @@ export default function VideoTimelineEditor() {return <TimelineProjectEditor key={projectId} projectId={projectId} />;}+const CLIPS_LOAD_ERROR = "Couldn't load your clips.";+const MUSIC_LOAD_ERROR = "Couldn't load the shared music library.";+function TimelineProjectEditor({ projectId }) {const navigate = useNavigate();const [project, setProject] = useState(null);@@ -123,6 +126,10 @@ function TimelineProjectEditor({ projectId }) {const [musicTracks, setMusicTracks] = useState([]);// Which catalogues have actually been fetched — see knownAbsent below.const [loaded, setLoaded] = useState({ clips: false, images: false, music: false });+ // Per-catalogue load failure and in-flight retry for the clip and audio+ // libraries. A failed list keeps its last good rows; the inline error and+ // Retry replace the "No clips" / "No audio" copy that would otherwise lie.+ const [catalogStatus, setCatalogStatus] = useState({ clips: { error: null, pending: false }, music: { error: null, pending: false } });// Real lengths the browser measured for the beds' audio files, keyed by asset// identity (`music/<file>`). The preview resolves each placement against its// file's length exactly as the export's probe does; an asset with no entry@@ -185,6 +192,8 @@ function TimelineProjectEditor({ projectId }) {// StrictMode's setup/cleanup cycle and any late conflict-triggered reload.const activeRef = useRef(false);const refreshGenerationRef = useRef(0);+ // Per-catalogue retry generations so a superseded Retry cannot overwrite a newer one.+ const catalogGenerationRef = useRef({ clips: 0, music: 0 });const refresh = useCallback(async () => {if (!activeRef.current) return;const generation = ++refreshGenerationRef.current;@@ -230,6 +239,13 @@ function TimelineProjectEditor({ projectId }) {if (Array.isArray(hist)) setHistory(hist);if (Array.isArray(gallery)) setImages(gallery);if (library) setMusicTracks(Array.isArray(library.tracks) ? library.tracks : []);+ // A refresh supersedes any Retry still in flight for the same catalogue.+ catalogGenerationRef.current.clips += 1;+ catalogGenerationRef.current.music += 1;+ setCatalogStatus({+ clips: { error: Array.isArray(hist) ? null : CLIPS_LOAD_ERROR, pending: false },+ music: { error: library ? null : MUSIC_LOAD_ERROR, pending: false },+ });// Whether each library actually loaded, so the "missing source" badges can// stay silent about a lane whose catalogue we never received.setLoaded((prev) => ({@@ -240,6 +256,26 @@ function TimelineProjectEditor({ projectId }) {setLoading(false);}, [projectId]);+ // Retries one library without reloading the project, so edits made while+ // the list was failing stay untouched.+ const retryCatalog = useCallback(async (kind) => {+ const generation = ++catalogGenerationRef.current[kind];+ setCatalogStatus((prev) => ({ ...prev, [kind]: { ...prev[kind], pending: true } }));+ const fetchCatalog = kind === 'clips' ? api.listVideoHistory : api.listMusicLibrary;+ const result = await fetchCatalog({ silent: true }).catch(() => null);+ if (!activeRef.current || catalogGenerationRef.current[kind] !== generation) return;+ const ok = kind === 'clips' ? Array.isArray(result) : !!result;+ if (ok) {+ if (kind === 'clips') setHistory(result);+ else setMusicTracks(Array.isArray(result.tracks) ? result.tracks : []);+ setLoaded((prev) => ({ ...prev, [kind]: true }));+ }+ setCatalogStatus((prev) => ({+ ...prev,+ [kind]: { error: ok ? null : (kind === 'clips' ? CLIPS_LOAD_ERROR : MUSIC_LOAD_ERROR), pending: false },+ }));+ }, []);+// Keep the stable-position mirror of the current selection current so refresh()// can reattach it after it regenerates lane _keys.useEffect(() => {@@ -862,6 +898,23 @@ function TimelineProjectEditor({ projectId }) {const laneWidth = Math.max(240, total * pxPerSec);const playheadSec = Math.min(t, total);+ const catalogNotice = (kind) => {+ const status = catalogStatus[kind];+ if (!status.error) return null;+ return (+ <div role="alert" className="text-xs text-port-error px-1 py-2 flex flex-wrap items-center gap-2">+ <span>{status.error}</span>+ <button+ type="button"+ onClick={() => retryCatalog(kind)}+ disabled={status.pending}+ className="min-h-[44px] text-port-accent disabled:opacity-50"+ >+ {status.pending ? 'Retrying…' : 'Retry'}+ </button>+ </div>+ );+ };const libraryPanel = showLibrary ? (<divid="timeline-library"@@ -879,8 +932,9 @@ function TimelineProjectEditor({ projectId }) {className="mb-2"/>+ {libraryTab === 'clips' && catalogNotice('clips')}{libraryTab === 'clips' && (libraryClips.length === 0 ? (- <div className="text-xs text-gray-500 px-1 py-4">No clips. Generate some on the Video page.</div>+ !catalogStatus.clips.error && <div className="text-xs text-gray-500 px-1 py-4">No clips. Generate some on the Video page.</div>) : (<div className="grid grid-cols-1 gap-2">{libraryClips.map((clip) => (@@ -907,8 +961,9 @@ function TimelineProjectEditor({ projectId }) {</div>))}+ {libraryTab === 'audio' && catalogNotice('music')}{libraryTab === 'audio' && (musicTracks.length === 0 ? (- <div className="text-xs text-gray-500 px-1 py-4">No audio in the shared music library.</div>+ !catalogStatus.music.error && <div className="text-xs text-gray-500 px-1 py-4">No audio in the shared music library.</div>) : (<div className="grid grid-cols-1 gap-1.5">{musicTracks.map((track) => (diff --git a/client/src/pages/VideoTimelineEditor.test.jsx b/client/src/pages/VideoTimelineEditor.test.jsxindex 2b8396c525..2a75154ca8 100644--- a/client/src/pages/VideoTimelineEditor.test.jsx+++ b/client/src/pages/VideoTimelineEditor.test.jsx@@ -39,13 +39,15 @@ const api = vi.hoisted(() => ({music: { tracks: [] },galleryThrows: false,updateTimelineProject: vi.fn(async () => ({ updatedAt: 'u2' })),+ listHistory: vi.fn(),+ listMusic: vi.fn(),}));vi.mock('../services/api', () => ({getTimelineProject: (...args) => api.getTimelineProject(...args),- listVideoHistory: async () => api.history,+ listVideoHistory: (...args) => api.listHistory(...args),getGalleryImages: (...args) => api.getGalleryImages(...args),- listMusicLibrary: async () => api.music,+ listMusicLibrary: (...args) => api.listMusic(...args),updateTimelineProject: (...args) => api.updateTimelineProject(...args),renderTimelineProject: async () => ({ jobId: 'j1' }),}));@@ -82,6 +84,8 @@ beforeEach(() => {api.gallery = [{ filename: 'plate.png' }, { filename: 'logo.png' }];api.music = { tracks: [{ filename: 'bed.mp3', label: 'Bed' }] };api.galleryThrows = false;+ api.listHistory.mockReset().mockImplementation(async () => api.history);+ api.listMusic.mockReset().mockImplementation(async () => api.music);api.getTimelineProject.mockReset().mockImplementation(async () => api.project);api.getGalleryImages.mockReset().mockImplementation(async (filenames) => {if (api.galleryThrows) throw new Error('network');@@ -650,3 +654,47 @@ describe('timeline navigation after save failure', () => {} finally { vi.useRealTimers(); }});});++describe('clip and audio library load failures', () => {+ it('shows a failed clip load with Retry instead of the empty copy, and recovers on retry', async () => {+ // Two rejections: the initial load and the first Retry both fail, so the+ // error must stay visible and actionable until a retry actually succeeds.+ const failure = new Error('network');+ api.listHistory.mockRejectedValueOnce(failure).mockRejectedValueOnce(failure);+ await renderEditor();++ const alert = await screen.findByRole('alert');+ expect(alert).toHaveTextContent("Couldn't load your clips.");+ expect(screen.queryByText(/No clips/)).not.toBeInTheDocument();++ fireEvent.click(within(alert).getByRole('button', { name: 'Retry' }));+ await waitFor(() => expect(screen.getByRole('button', { name: 'Retry' })).toBeEnabled());+ expect(screen.getByRole('alert')).toBeInTheDocument();++ fireEvent.click(screen.getByRole('button', { name: 'Retry' }));+ expect(await screen.findByRole('button', { name: 'Add to timeline' })).toBeInTheDocument();+ expect(screen.queryByRole('alert')).not.toBeInTheDocument();+ });++ it('tells a successful empty audio library apart from a failed one', async () => {+ api.music = { tracks: [] };+ await renderEditor();+ fireEvent.click(within(screen.getByRole('tablist', { name: 'Clip library' })).getAllByRole('tab')[2]);+ expect(screen.getByText('No audio in the shared music library.')).toBeInTheDocument();+ expect(screen.queryByRole('alert')).not.toBeInTheDocument();+ });++ it('shows a failed audio load with Retry, then lists the tracks once the retry succeeds', async () => {+ api.listMusic.mockRejectedValueOnce(new Error('network'));+ await renderEditor();+ fireEvent.click(within(screen.getByRole('tablist', { name: 'Clip library' })).getAllByRole('tab')[2]);++ const alert = await screen.findByRole('alert');+ expect(alert).toHaveTextContent("Couldn't load the shared music library.");+ expect(screen.queryByText('No audio in the shared music library.')).not.toBeInTheDocument();++ fireEvent.click(within(alert).getByRole('button', { name: 'Retry' }));+ expect(await screen.findByText('Bed')).toBeInTheDocument();+ expect(screen.queryByRole('alert')).not.toBeInTheDocument();+ });+});