feat: support pasting file paths copied from file manager (fixes #529) - #536
Open
wuxiangru915 wants to merge 2 commits into
Open
feat: support pasting file paths copied from file manager (fixes #529)#536wuxiangru915 wants to merge 2 commits into
wuxiangru915 wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:fileUriToPath: convertsfile://URIs to native OS paths, handling Windows drive letters (file:///C:/...), Unix paths, percent-encoding/spaces (%20, Unicode characters), and UNC paths.extractPathsFromClipboardData: extracts file paths fromFile.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), andtext/plainfile URIs.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:convertWindowsPathToWsl: automatically converts Windows drive paths (e.g.C:\Users\...orC:/...) to WSL mount paths (/mnt/c/Users/...) when running on Linux/WSL.components/DirectoryPicker.tsx:onPastehandler to directory path input box to automatically paste copied file/folder paths.components/ChatInput.tsx:handlePasteso non-image files copied from file manager insert their formatted file paths directly into the message textarea.components/PluginsConfig.tsx:onPasteon the plugin source input to support pasting folder/package file paths.components/ChatWindow.tsx:app/api/cwd/browse/route.ts:lib/clipboard-paths.test.mjs(12 tests), updatedlib/directory-browser.test.mjsandlib/paths.test.mjs, and addedcomponents/DirectoryPicker.test.mjs.Fixes #529.