Skip to content

feat(ai): support dragging explorer paths into agent context#230

Open
shiva-manu wants to merge 3 commits into
crynta:mainfrom
shiva-manu:feature/drag-files-to-agent-cli
Open

feat(ai): support dragging explorer paths into agent context#230
shiva-manu wants to merge 3 commits into
crynta:mainfrom
shiva-manu:feature/drag-files-to-agent-cli

Conversation

@shiva-manu
Copy link
Copy Markdown
Contributor

@shiva-manu shiva-manu commented May 13, 2026

What

Adds drag-and-drop support for passing files and folders from the Explorer
into agent workflows.

Files dropped onto the AI composer are attached to the next agent message,
while paths dropped into terminal-based agent CLIs are inserted with shell-
safe quoting.

Why

Explorer items could be dragged, but dropping them into the agentic CLI or AI
input did not pass usable file/folder context to the agent.

How

Introduces a shared Explorer drag payload using application/x-terax-path,
then handles that payload in both the AI composer and terminal pane.

For folders, the composer attaches a directory listing as context. For
terminal drops, paths are shell-quoted before being written into the terminal.

Testing

Verified the code builds successfully and the changed TypeScript paths
compile.

  • pnpm exec tsc --noEmit clean
  • Manual smoke-test of the affected feature
  • (If you touched src-tauri/) cargo check clean
  • (If UI) tested in pnpm tauri dev

Additional validation run:

  • npm run build clean
  • git diff --check clean

Screenshots / GIFs

Screencast.from.2026-05-14.00-39-33.mp4

#229

Copilot AI review requested due to automatic review settings May 13, 2026 19:23
@shiva-manu shiva-manu requested a review from crynta as a code owner May 13, 2026 19:23
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

Adds end-to-end drag-and-drop support for transferring Explorer file/folder paths into agent surfaces (AI composer + terminal), using a shared internal drag MIME payload.

Changes:

  • Introduces a shared Explorer drag payload (application/x-terax-path) with read/write helpers.
  • Enables dragging Explorer nodes and dropping them into the AI composer (attach file contents or directory listing).
  • Enables dropping Explorer paths into terminal panes, inserting shell-quoted paths.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/modules/terminal/TerminalPane.tsx Accepts TERAX path drops and writes shell-quoted paths into the terminal session.
src/modules/terminal/lib/shellQuote.ts Adds shell-quoting utilities for dropped path insertion (POSIX + Windows).
src/modules/explorer/lib/dragPayload.ts Defines the shared internal drag MIME type and helpers to read/write payloads.
src/modules/explorer/FileTreeNode.tsx Marks tree nodes draggable and writes the shared drag payload on drag start.
src/modules/ai/lib/composer.tsx Adds path-based attachment handling, including directory listing fallback.
src/modules/ai/components/AiInputBar.tsx Handles drops for TERAX path payloads and file drops to attach to the next message.

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

Comment on lines +3 to +5
/** Chars that are always safe unquoted in both cmd/PowerShell and POSIX shells. */
const SAFE_CHARS = /^[A-Za-z0-9_\-+.,/:@=%]+$/;

size: number,
fallbackName?: string,
) => {
const name = path.split("/").pop() || fallbackName || path;
Comment on lines 181 to +186
} catch (e) {
console.error("attachFileByPath failed:", e);
try {
const entries = await native.readDir(path);
const text = formatDirectoryAttachment(path, entries);
addPathAttachment(path, text, text.length, "Directory");
} catch {
Comment on lines +88 to +91
const paths = readPathDragPayload(e.dataTransfer);
if (paths.length === 0) return;
e.preventDefault();
setIsPathDragOver(false);
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