From 76e6568ac679b5838c9c9dd343b054e4277bcd19 Mon Sep 17 00:00:00 2001 From: ZGaetano Date: Tue, 19 May 2026 11:11:17 -0400 Subject: [PATCH] fix: await handleDropMedia and surface clip-add errors in Timeline - handleDropMedia now returns the ActionResult from addClip/addClipToNewTrack - The tracksRef onDrop handler now awaits handleDropMedia so errors aren't silently lost - Replaces the swallowed catch block with a toast.error + console.error on failure - This makes clip-add failures visible instead of silently doing nothing --- .../apps/web/src/components/editor/Timeline.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/services/editor/apps/web/src/components/editor/Timeline.tsx b/services/editor/apps/web/src/components/editor/Timeline.tsx index 2b66f4e..317b02d 100644 --- a/services/editor/apps/web/src/components/editor/Timeline.tsx +++ b/services/editor/apps/web/src/components/editor/Timeline.tsx @@ -486,13 +486,14 @@ export const Timeline: React.FC = () => { return () => document.removeEventListener("mouseup", handleMouseUp); }, [isBoxSelecting, handleBoxSelectionEnd]); + // Returns the ActionResult so callers can check success and surface errors const handleDropMedia = useCallback( async (trackId: string, mediaId: string, startTime: number) => { const { addClip, addClipToNewTrack } = useProjectStore.getState(); if (trackId) { - await addClip(trackId, mediaId, startTime); + return addClip(trackId, mediaId, startTime); } else { - await addClipToNewTrack(mediaId, startTime); + return addClipToNewTrack(mediaId, startTime); } }, [], @@ -1078,9 +1079,14 @@ export const Timeline: React.FC = () => { if (!rawData) return; const data = JSON.parse(rawData); if (!data?.mediaId) return; - handleDropMedia("", data.mediaId, snappedTime); - } catch { - // ignore + const result = await handleDropMedia("", data.mediaId, snappedTime); + if (result && !result.success) { + console.error("[Timeline] Failed to add clip to timeline:", result.error); + toast.error("Failed to add clip to timeline", result.error?.message ?? ""); + } + } catch (err) { + console.error("[Timeline] Drop error:", err); + toast.error("Failed to add clip to timeline", String(err)); } }} >