Skip to content

feat: support pasting file paths copied from file manager (fixes #529) - #536

Open
wuxiangru915 wants to merge 2 commits into
agegr:mainfrom
wuxiangru915:support-paste-file-paths
Open

feat: support pasting file paths copied from file manager (fixes #529)#536
wuxiangru915 wants to merge 2 commits into
agegr:mainfrom
wuxiangru915:support-paste-file-paths

Conversation

@wuxiangru915

@wuxiangru915 wuxiangru915 commented Aug 17, 2026

Copy link
Copy Markdown

Description

This PR resolves #529 by supporting pasting file and folder paths directly into input fields when users copy files/folders from their OS file manager (Windows Explorer, macOS Finder, Linux file managers), and adds WSL Windows drive path mapping for Linux/WSL environments.

Changes

  • lib/clipboard-paths.ts:
    • Implemented fileUriToPath: converts file:// URIs to native OS paths, handling Windows drive letters (file:///C:/...), Unix paths, percent-encoding/spaces (%20, Unicode characters), and UNC paths.
    • Implemented extractPathsFromClipboardData: extracts file paths from File.path (Electron/desktop runtimes), text/uri-list, Linux clipboard formats (x-special/nautilus-clipboard, x-special/gnome-copied-files, x-special/mate-copied-files, x-special/xfce4-copied-files, application/x-kde-cutselection), macOS clipboard formats (public.file-url, text/x-moz-url), and text/plain file URIs.
    • Implemented formatPathsForInput: formats single or multiple file paths with automatic quoting for paths containing whitespace.
  • lib/paths.ts & lib/directory-browser.ts & app/api/cwd/validate/route.ts:
    • Added convertWindowsPathToWsl: automatically converts Windows drive paths (e.g. C:\Users\... or C:/...) to WSL mount paths (/mnt/c/Users/...) when running on Linux/WSL.
  • components/DirectoryPicker.tsx:
    • Added onPaste handler to directory path input box to automatically paste copied file/folder paths.
  • components/ChatInput.tsx:
    • Updated handlePaste so non-image files copied from file manager insert their formatted file paths directly into the message textarea.
  • components/PluginsConfig.tsx:
    • Updated onPaste on the plugin source input to support pasting folder/package file paths.
  • components/ChatWindow.tsx:
    • Updated extension custom panel paste handler to handle clipboard file paths.
  • app/api/cwd/browse/route.ts:
    • When browsing a path that points to a file (e.g. pasted into DirectoryPicker), automatically navigates to its parent directory rather than failing.
  • Tests:
    • Added unit test suite lib/clipboard-paths.test.mjs (12 tests), updated lib/directory-browser.test.mjs and lib/paths.test.mjs, and added components/DirectoryPicker.test.mjs.

Fixes #529.

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.

建议支持从文件管理器复制文件后,在输入框中通过 Ctrl+V 粘贴其路径

1 participant