Skip to content

Support file tree path drops into terminal tabs#296

Open
AkaraChen wants to merge 1 commit into
devfrom
terminal/file-tree-drop-input
Open

Support file tree path drops into terminal tabs#296
AkaraChen wants to merge 1 commit into
devfrom
terminal/file-tree-drop-input

Conversation

@AkaraChen
Copy link
Copy Markdown
Owner

Summary

  • add file-tree drag payload helpers for terminal drops
  • let terminal tab and active pane refs accept file-tree drop events and write raw paths into the PTY
  • prevent drag gestures from immediately opening files while preserving normal click behavior
  • add focused coverage for file-tree payloads and terminal path drop handling

Validation

  • Not run per request

@netlify
Copy link
Copy Markdown

netlify Bot commented May 30, 2026

Deploy Preview for grand-selkie-225f87 canceled.

Name Link
🔨 Latest commit f1abc51
🔍 Latest deploy log https://app.netlify.com/projects/grand-selkie-225f87/deploys/6a1a63109397cc0008a5aad1

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

Warning

Review limit reached

@AkaraChen, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 27 minutes and 55 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3167f61b-f6c5-4805-9de3-f7c69eac5aae

📥 Commits

Reviewing files that changed from the base of the PR and between 15dfbff and f1abc51.

📒 Files selected for processing (8)
  • src/features/projects/FileTreePanel.test.tsx
  • src/features/projects/FileTreePanel.tsx
  • src/features/terminal/TabStrip.tsx
  • src/features/terminal/TerminalTabs.test.tsx
  • src/features/terminal/TerminalTabs.tsx
  • src/shared/lib/fileTreeTerminalDrop.test.ts
  • src/shared/lib/fileTreeTerminalDrop.ts
  • src/test/setup.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch terminal/file-tree-drop-input

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.

@AkaraChen
Copy link
Copy Markdown
Owner Author

@codex review

Repository owner deleted a comment from chatgpt-codex-connector Bot May 30, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for dragging file-tree paths into terminal tabs/panes and writing those paths into the target PTY session.

Changes:

  • Added shared file-tree terminal drop payload helpers.
  • Wired file-tree drag start/end handling to dispatch terminal drop events.
  • Added terminal tab/pane drop targets and tests for payload/drop handling.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/shared/lib/fileTreeTerminalDrop.ts Defines the drag payload format, serialization helpers, target lookup, and terminal input formatting.
src/shared/lib/fileTreeTerminalDrop.test.ts Adds coverage for payload round-tripping and path formatting.
src/features/projects/FileTreePanel.tsx Creates file-tree drag payloads and dispatches custom terminal drop events on drag end.
src/features/projects/FileTreePanel.test.tsx Adds coverage for click suppression and drag payload generation.
src/features/terminal/TerminalTabs.tsx Registers terminal tabs/pane as drop targets and writes dropped paths to PTY sessions.
src/features/terminal/TerminalTabs.test.tsx Adds terminal drop behavior coverage.
src/features/terminal/TabStrip.tsx Exposes tab element refs so terminal tabs can be marked as drop targets.
src/test/setup.ts Adds a writeToPty mock for tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +148 to +149
fireEvent.dragOver(terminalTab, { dataTransfer });
fireEvent.drop(terminalTab, { dataTransfer });
Comment on lines +103 to +105
return paths
.filter((path) => path.length > 0)
.join(" ");
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f1abc51a1a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +102 to +105
export function formatTerminalPathInput(paths: readonly string[]) {
return paths
.filter((path) => path.length > 0)
.join(" ");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Escape dropped paths before writing them

When any dropped file or directory contains spaces, this formatter writes the raw absolute path into the PTY and separates paths with a single space, so a normal shell command like cat /root/path with spaces/file.ts is parsed as multiple arguments instead of one path. This affects common project/file names with spaces; quote or shell-escape each path before joining so the terminal receives usable path arguments.

Useful? React with 👍 / 👎.

Comment on lines +1011 to +1016
if (payload) {
const target = getFileTreeTerminalDropTargetAtPoint(
event.clientX,
event.clientY,
);
target?.dispatchEvent(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Ignore canceled drags before dispatching terminal drops

This dispatches the terminal-drop event for any dragend that finishes over a terminal target, even if the user canceled the drag (for example by pressing Escape while hovering over the terminal); MDN documents dropEffect === "none" on dragend for canceled drags (https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#finishing_the_drag). In that scenario the path is still written into the PTY despite no drop being performed, so the handler needs to distinguish a real accepted drop from cancellation.

Useful? React with 👍 / 👎.

Comment on lines +148 to +149
fireEvent.dragOver(terminalTab, { dataTransfer });
fireEvent.drop(terminalTab, { dataTransfer });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Dispatch the custom terminal-drop event in this test

This test fires native dragOver/drop events, but the component added in this change only listens for FILE_TREE_TERMINAL_DROP_EVENT via addEventListener, not for the browser drop event. As written, handleTerminalPathDrop never runs and writeToPtyMock remains uncalled, so the new test fails unless it dispatches the same custom event that FileTreePanel sends on drag end.

Useful? React with 👍 / 👎.

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.

2 participants