Skip to content

fix(desktop): attach OS file drops instead of inserting their paths - #6934

Open
Muammer06 wants to merge 2 commits into
block:mainfrom
Muammer06:fix/desktop-composer-file-drop
Open

fix(desktop): attach OS file drops instead of inserting their paths#6934
Muammer06 wants to merge 2 commits into
block:mainfrom
Muammer06:fix/desktop-composer-file-drop

Conversation

@Muammer06

Copy link
Copy Markdown

Fixes #6933

Problem

Dragging a photo or file from the OS file manager into the composer inserts the filesystem path as chat text instead of attaching the file. Reproduced on Linux WebKitGTK against a self-hosted relay.

Paperclip + clipboard image paste already work. Drop does not.

Cause

  • dragDropEnabled is false, so drops go to the webview.
  • The form onDrop only reads dataTransfer.files.
  • Linux WebKitGTK often omits File objects and instead delivers text/uri-list / text/plain with file://… or an absolute path.
  • Tiptap/ProseMirror has no editorProps.handleDrop, so it inserts that path as text.

Fix

  • Claim OS file drops in editorProps.handleDrop (message + forum composers) before ProseMirror inserts text, and stopPropagation so the form handler does not double-upload.
  • Recover absolute paths from text/uri-list / text/plain when files is empty (require a basename with an extension so /usr/bin/env python is not treated as a file).
  • Upload recovered paths through a new upload_dropped_media command that uses the same TOCTOU-safe process_picked_path pipeline as the paperclip picker (HEIC transcode, MIME deny-list, size caps).
  • Treat text/uri-list as a file drag for the drop overlay and window preventDefault (avoids file:/// navigation).

Tests

cd desktop && pnpm exec node --import ./test-loader.mjs --experimental-strip-types --test \
  src/features/messages/lib/droppedFiles.test.mjs \
  src/features/messages/lib/useMediaUpload.test.mjs

40 passed (15 new path/URI cases + existing slot tests).

Rust validate_dropped_path tests added; not compiled here (GTK syslibs missing on this machine).

Manual test

  1. just desktop-dev or a local Tauri build.
  2. Drag a JPEG/PNG from the file manager onto the composer (onto the text area, not only the paperclip).
  3. Expect the upload preview, not /home/…/photo.png in the input.
  4. Send; the image should appear in the channel.
  5. Drag ordinary selected text into the composer — it should still insert as text.
  6. Forum composer: same drop behavior.

No UI screenshots: behavior is drop → attach; the overlay already existed.

None found for this specific path-as-text bug; closest existing work is the form-level handleDrop that only sees dataTransfer.files.

Linux WebKitGTK (and some other webviews) deliver file-manager drops as
file:// URIs or absolute paths instead of File objects. ProseMirror then
inserts the path as composer text.

Claim those drops in editorProps.handleDrop, recover paths from
text/uri-list, and upload them through the same TOCTOU-safe pipeline as
the paperclip picker.

Signed-off-by: Muammer <muammer@clonifylabs.com>
@Muammer06
Muammer06 requested a review from a team as a code owner August 27, 2026 11:53
Copilot AI lite review requested due to automatic review settings August 27, 2026 11:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

WebKitGTK on GNOME/Wayland advertises Files on dragover then delivers
an empty dataTransfer on drop. Ignore dummy File objects, set
dropEffect=copy, and read the real paths from GTK drag-data-received.

Signed-off-by: Muammer <muammer@clonifylabs.com>
@Muammer06

Copy link
Copy Markdown
Author
Screenshot From 2026-08-27 16-07-26

It's working like that

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.

Desktop: dragging files into chat pastes the filesystem path instead of attaching

2 participants