OpenReel Video - Professional browser-based video editor. Open source CapCut alternative. 100% browser-based, no installation, no cloud uploads, no watermarks.
TypeScript
fix(timeline,assets): drop onto lane targets correct track, relink uses source metadata
lvalics7c2238bd70e0
diff --git a/apps/web/src/components/editor/AssetsPanel.tsx b/apps/web/src/components/editor/AssetsPanel.tsxindex b336b520..7772edc5 100644--- a/apps/web/src/components/editor/AssetsPanel.tsx+++ b/apps/web/src/components/editor/AssetsPanel.tsx@@ -570,21 +570,25 @@ export const AssetsPanel: React.FC = () => {// Persist the directory handle for future auto-restoretry { await saveDirectoryHandle(project.id, dirHandle); } catch { /* best-effort */ }- // Build a filename → {File, handle} map (keyed by lowercase name)+ // Build a name:size → {File, handle} map for reliable matchingconst fileMap = new Map<string, { file: File; handle: FileSystemFileHandle }>();const entries = (dirHandle as unknown as { entries: () => AsyncIterableIterator<[string, FileSystemHandle]> }).entries();for await (const [, fh] of entries) {if ((fh as FileSystemHandle).kind === "file") {const fileHandle = fh as FileSystemFileHandle;const file = await fileHandle.getFile();- fileMap.set(file.name.toLowerCase(), { file, handle: fileHandle });+ fileMap.set(`${file.name.toLowerCase()}:${file.size}`, { file, handle: fileHandle });}}setIsImporting(true);let linked = 0;for (const item of placeholders) {- const entry = fileMap.get(item.name.toLowerCase());+ // Match on original source file name + size (same strategy as auto-restore)+ const key = item.sourceFile+ ? `${item.sourceFile.name.toLowerCase()}:${item.sourceFile.size}`+ : null;+ const entry = key ? fileMap.get(key) : null;if (entry) {setImportProgress(`Relinking ${item.name}…`);try {diff --git a/apps/web/src/components/editor/Timeline.tsx b/apps/web/src/components/editor/Timeline.tsxindex 1d818bbe..26d1db79 100644--- a/apps/web/src/components/editor/Timeline.tsx+++ b/apps/web/src/components/editor/Timeline.tsx@@ -476,9 +476,13 @@ export const Timeline: React.FC = () => {}, [isBoxSelecting, handleBoxSelectionEnd]);const handleDropMedia = useCallback(- async (_trackId: string, mediaId: string, startTime: number) => {- const { addClipToNewTrack } = useProjectStore.getState();- await addClipToNewTrack(mediaId, startTime);+ async (trackId: string, mediaId: string, startTime: number) => {+ const { addClip, addClipToNewTrack } = useProjectStore.getState();+ if (trackId) {+ await addClip(trackId, mediaId, startTime);+ } else {+ await addClipToNewTrack(mediaId, startTime);+ }},[],);diff --git a/apps/web/src/components/editor/timeline/TrackLane.tsx b/apps/web/src/components/editor/timeline/TrackLane.tsxindex 8bbae35e..22497a11 100644--- a/apps/web/src/components/editor/timeline/TrackLane.tsx+++ b/apps/web/src/components/editor/timeline/TrackLane.tsx@@ -128,7 +128,7 @@ export const TrackLane: React.FC<TrackLaneProps> = ({snapSettings,pixelsPerSecond,);- const { importMedia, addClipToNewTrack } = useProjectStore.getState();+ const { importMedia, addClip } = useProjectStore.getState();for (const file of Array.from(e.dataTransfer.files)) {try {const beforeIds = new Set(@@ -140,15 +140,8 @@ export const TrackLane: React.FC<TrackLaneProps> = ({.getState().project.mediaLibrary.items.find(i => !beforeIds.has(i.id));if (newItem) {- await addClipToNewTrack(newItem.id, snapResult.time);- const addedTrack = useProjectStore- .getState()- .project.timeline.tracks.find(t =>- t.clips.some(c => c.mediaId === newItem.id)- );- if (addedTrack) {- toast.success(`Added to ${addedTrack.name}`, file.name);- }+ await addClip(track.id, newItem.id, snapResult.time);+ toast.success(`Added to ${track.name}`, file.name);}}} catch (err) {@@ -191,7 +184,7 @@ export const TrackLane: React.FC<TrackLaneProps> = ({// Silently ignore parse errors}},- [track.id, pixelsPerSecond, scrollX, onDropMedia],+ [track.id, track.name, pixelsPerSecond, scrollX, onDropMedia],);const handleResizeStart = useCallback(