Skip to content

feat(desktop): Allow dragging files into terminal#1141

Merged
Kitenite merged 1 commit into
mainfrom
filtree-drag-into-terminal
Feb 2, 2026
Merged

feat(desktop): Allow dragging files into terminal#1141
Kitenite merged 1 commit into
mainfrom
filtree-drag-into-terminal

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Feb 2, 2026

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

  • New feature
  • Refactor

Implementation

  • Created reusable useFileDrag hook to eliminate duplication
  • Terminal now accepts both native file drops (from Finder) and internal file drags
  • Paths are shell-escaped in both cases for consistency

Testing

Drag files from:

  • Files tab (tree view)
  • Files tab (search results)
  • Changes tab (staged/unstaged files)

Drop into any terminal pane to insert the shell-escaped path.

Summary by CodeRabbit

Release Notes

  • New Features
    • Files can now be dragged from file views for use in external applications
    • Enhanced terminal drop handling to better distinguish between file and text input operations

…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).
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

This PR adds drag-and-drop functionality for files in the workspace UI. A new useFileDrag hook is created to enable dragging file paths. The Terminal component is updated to distinguish between file drops and text drops. File components (FileItem, FileSearchResultItem, FileTreeItem) integrate the new drag hook.

Changes

Cohort / File(s) Summary
Drag Hook Implementation
apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/hooks/useFileDrag.ts, apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/hooks/index.ts
New useFileDrag hook that returns draggable state and drag start handler. Sets drag data as text/plain with copy effect when absolutePath is provided.
File Component Drag Integration
apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/components/FileItem/FileItem.tsx, apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/components/FileSearchResultItem/FileSearchResultItem.tsx, apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/components/FileTreeItem/FileTreeItem.tsx
Consistent integration of useFileDrag hook across file item components, spreading drag props onto rendered elements to enable file dragging.
Terminal Drop Handling
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx
Enhanced drop handler to distinguish between native file drops and internal text drags. Maps dropped files to system paths or reads plain text from dataTransfer with appropriate escaping and validation.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 Files now dance upon the wind,
From branch to leaf, the drags begin—
A text-plain path, or dropped with flair,
To Terminal's home, we drag with care! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(desktop): Allow dragging files into terminal' clearly and specifically describes the main feature being added—drag-and-drop support for files into the terminal.
Description check ✅ Passed The PR description covers the key sections: what the change does (Description), what type of change it is (Type of Change), how it was implemented (Implementation), and testing instructions (Testing). Only the 'Related Issues' section is missing, but all critical information is present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch filtree-drag-into-terminal

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 2, 2026

🚀 Preview Deployment

🔗 Preview Links

Service Status Link
Neon Database (Neon) View Branch
Fly.io Electric (Fly.io) View App
Vercel API (Vercel) Open Preview
Vercel Web (Vercel) Open Preview
Vercel Marketing (Vercel) Open Preview
Vercel Admin (Vercel) Open Preview
Vercel Docs (Vercel) Open Preview

Preview updates automatically with new commits

@Kitenite Kitenite merged commit 5272aa5 into main Feb 2, 2026
13 checks passed
@Kitenite Kitenite deleted the filtree-drag-into-terminal branch February 2, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant