fix: insert native file path when dropping or pasting non-image files#885
fix: insert native file path when dropping or pasting non-image files#885mfazekas wants to merge 1 commit intopingdotgg:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
d912835 to
3698cab
Compare
Previously, only image files could be attached to the composer. Dropping or pasting any other file type (e.g. .riv, .csv, .json) silently failed with an "unsupported file type" error, making it impossible to reference data or asset files by path. Closes pingdotgg#557. Implementation ────────────── contracts/ipc.ts Added getPathForFile(file) to the DesktopBridge interface. preload.ts Exposed webUtils.getPathForFile(file) via contextBridge. Electron's sandbox blocks the legacy file.path property on File objects; the webUtils API (available since Electron 32) is the official replacement. ComposerPromptEditor Added insertText(text) to ComposerPromptEditorHandle. Uses Lexical's native selection.insertText() to insert at the real cursor position, which correctly handles existing @mention nodes. Manipulating the plain-text snapshot and calling setPrompt() was not an option: Lexical's editor.update() is async, so a synchronous focusComposer() call after would read a stale snapshotRef and overwrite the inserted text via onChange. ChatView - COMPOSER_FILE_PATH_SEPARATOR constant replaces the magic " " literal. - addComposerAttachments(files) is a new unified helper (placed next to addComposerImages) that partitions files into images and non-images. Images are handled by the existing addComposerImages path. Non-image files have their native path resolved via desktopBridge.getPathForFile (fallback: file.name in non-Electron contexts), auto-quoted when the path contains spaces, joined by COMPOSER_FILE_PATH_SEPARATOR, and inserted into the composer via insertText(). - onComposerDrop and onComposerPaste both delegate to addComposerAttachments, eliminating the duplicated partition logic. onComposerDrop additionally calls focusComposer() only when no non-image files were dropped, since insertText() focuses the editor internally as a prerequisite for obtaining a Lexical selection. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3698cab to
61dab45
Compare
|
Speaking of images, can you please attach a before and after if possible? |
@binbandit there is before/after video in the description, do you need still images as well? |
Video or GIF is fine, but currently none load.
|
@binbandit My bad - was using |

What Changed
When dropping or pasting non-image files (e.g.
.csv,.json,.txt,.riv) onto the chat composer, their native filesystem path is now inserted at the cursor position instead of being silently ignored. Fixes #557.addComposerAttachmentshelper partitions files into images and non-images. BothonComposerDropandonComposerPastedelegate to it. Non-image paths are auto-quoted when containing spaces.insertText(text)using Lexical'sselection.insertText()to insert at the real cursor position, correctly handling @mention nodes.webUtils.getPathForFile(file)via contextBridge (required since Electron's sandbox blocksfile.path).getPathForFiletoDesktopBridgeinterface.Why
Dropping or pasting any non-image file silently failed with an "unsupported file type" error
UI Changes
Screen.Recording.2026-03-11.at.7.40.34.mov
Screen.Recording.2026-03-11.at.7.45.35.mov
Checklist
Note
Insert native file paths when dropping or pasting non-image files into the composer
addComposerAttachmentsin ChatView.tsx to split dropped/pasted files into images (handled as before) and non-images (inserted as paths).window.desktopBridge?.getPathForFile(file)(Electron) or fall back tofile.name; paths containing spaces are quoted and joined with a space separator.insertTextAndFocus(text)toComposerPromptEditorHandlein ComposerPromptEditor.tsx, inserting text at the current Lexical selection with automatic focus.getPathForFileondesktopBridgein preload.ts via Electron'swebUtils.getPathForFile.Macroscope summarized 61dab45.