feat(chat): drag-and-drop + paste to attach files - #490
Open
bambinounos wants to merge 1 commit into
Open
Conversation
The composer only supported the paperclip picker. Extract the picker's validate + preview core into openFileForPreview(file) and reuse it for two new inputs: drag-and-drop onto the conversation pane (with a 'drop to attach' overlay and an enter/leave depth counter) and paste (Ctrl+V, e.g. screenshots) on the textarea. Both feed the existing media preview modal + /api/messages/media pipeline unchanged. Single file at a time (files[0]), same 16MB/type validation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
The chat composer only supported attaching a file via the paperclip picker. This adds two more ways, both feeding the existing media-preview modal and
POST /api/messages/mediapipeline unchanged:How
handleFileSelect) into a sharedopenFileForPreview(file); the picker, drop, and paste all call it, so they share the same type allowlist, 16 MB cap, preview URL, and the existing media dialog →sendMediaMessage().@dragenter/@dragover/@dragleave/@drop) on the conversation pane with an enter/leave depth counter so hovering child elements doesn't flicker the overlay; gated on an open contact.@pasteon the composer textarea; only intercepts when the clipboard carries a file (plain-text paste is untouched).chat.dropToAttachadded to all 5 locales (en/es translated; ar/hi/ta English placeholder).Notes
files[0]), matching the current picker; multi-file queue could be a follow-up.Testing
vite buildpasses; full image builds. Verified live: drag a file / paste a screenshot → preview modal → send; unsupported type or >16 MB shows the existing error toast; plain-text paste still works.