fix(file-tree): support dragging files from Finder into vault folders#121
fix(file-tree): support dragging files from Finder into vault folders#121spamsch wants to merge 8 commits into
Conversation
Tauri's onDragDropEvent only handled drops onto editor panes; drops over the file tree were silently discarded. - Add copy_external_file_to_vault backend command: copies an external file (absolute path) into a vault-relative folder using the existing dedup logic, then emits a vault change event - Add EXTERNAL_FILE_TREE_DRAG_EVENT so MultiPaneWorkspace can broadcast hover state to the file tree without prop-drilling - Extend onDragDropEvent: on enter/over emit folder hover events; on drop, if the cursor is over a data-folder-path element, copy files into that folder instead of opening them in an editor pane - FileTree listens for the event and sets dragOverPath, activating the existing accent-tinted folder highlight
Code Review (Claude Opus)Verdict: Solid fix. The core flow is right, the backend command mirrors the existing Issues to fix1. Silent failure on copy — no user feedback
2. 3. Race with internal mouse-drag — shared Fix: guard the external event handler with an early return if 4. Payload cast is duplicated const payload = event.payload as { position?: { x: number; y: number }; paths?: string[] };5. 6. Multiple files → multiple vault refreshes Worth noting7. Deduplication is silent 8. Note rows also carry What's done well
Recommend: address #1 (error reporting) and #3 (internal-drag guard) before merge. Everything else is nice-to-have. |
- Switch Promise.all to Promise.allSettled in copyExternalFilesToVaultFolder so one bad file doesn't silently drop the rest; log each failure via logError - Guard the EXTERNAL_FILE_TREE_DRAG_EVENT handler in FileTree with an early return when dragStateRef.current is set, preventing a Tauri cancel/leave event from clearing dragOverPath mid-internal-drag - Mock document.elementsFromPoint in MultiPaneWorkspace tests (jsdom does not implement it); returning [] makes resolveFileTreeFolderAtPoint return null so existing editor-pane drop tests are unaffected
|
Addressed the must-fix items from the review (f73a1b8):
|
…rag-to-file-tree # Conflicts: # .gitignore
|
LGTM |
Closes #120
Summary
copy_external_file_to_vault(Rust): new Tauri command that takes an absolute source path + a vault-relative target folder, copies the file using the existingprepare_binary_file_targetdedup logic, and emits a vault change event so the file tree refreshes.EXTERNAL_FILE_TREE_DRAG_EVENT(dragEvents.ts): lightweight custom DOM event that carries a hover phase and folder path — letsMultiPaneWorkspacetalk toFileTreewithout prop-drilling.MultiPaneWorkspace.tsx: on Tauri "enter"/"over", queriesdata-folder-pathat the cursor and emits hover events; on "drop", if the cursor is over a file tree folder the files are copied there instead of being opened in an editor pane.FileTree.tsx: listens for the event and setsdragOverPath, activating the existing accent-tinted folder highlight (same visual as internal drag-and-drop).Test plan
prepare_binary_file_target)