feat(desktop): Allow dragging files into terminal#1141
Conversation
…o terminal Add drag-and-drop support for files from multiple sources (file tree, search results, and changes tab) into the terminal. Paths are automatically shell-escaped when dropped. Refactored drag logic into a reusable `useFileDrag` hook to eliminate duplication across three components (FileItem, FileTreeItem, FileSearchResultItem).
📝 WalkthroughWalkthroughThis PR adds drag-and-drop functionality for files in the workspace UI. A new Changes
Sequence DiagramsequenceDiagram
actor User
participant FileComponent as File Component<br/>(FileItem, FileTree, etc.)
participant useFileDrag as useFileDrag Hook
participant Browser as Browser<br/>Drag/Drop API
participant Terminal as Terminal<br/>Component
User->>FileComponent: Initiates drag on file
FileComponent->>useFileDrag: Calls hook with absolutePath
useFileDrag->>useFileDrag: Returns draggable & onDragStart
FileComponent->>Browser: onDragStart fires
Browser->>Browser: Sets dataTransfer data<br/>(text/plain: file path)
Browser->>Browser: Restricts effect to copy
User->>Terminal: Drops content
Terminal->>Terminal: Receives drop event
alt Files in dataTransfer
Terminal->>Terminal: Map files to system paths
Terminal->>Terminal: Escape paths
else Plain text in dataTransfer
Terminal->>Terminal: Read text/plain data
Terminal->>Terminal: Escape text
end
Terminal->>Terminal: Write to terminal via writeRef
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🚀 Preview Deployment🔗 Preview Links
Preview updates automatically with new commits |
Description
Add drag-and-drop support to the terminal for files from the file tree, search results, and changes tabs. When files are dragged into the terminal, their paths are automatically shell-escaped for safe terminal use.
Type of Change
Implementation
useFileDraghook to eliminate duplicationTesting
Drag files from:
Drop into any terminal pane to insert the shell-escaped path.
Summary by CodeRabbit
Release Notes