Skip to content

feat(chat): drag-and-drop + paste to attach files - #490

Open
bambinounos wants to merge 1 commit into
shridarpatil:mainfrom
bambinounos:feat/drag-drop-paste-attachments
Open

feat(chat): drag-and-drop + paste to attach files#490
bambinounos wants to merge 1 commit into
shridarpatil:mainfrom
bambinounos:feat/drag-drop-paste-attachments

Conversation

@bambinounos

Copy link
Copy Markdown
Contributor

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/media pipeline unchanged:

  1. Drag-and-drop a file anywhere onto the open conversation pane — a "Drop file to attach" overlay appears while dragging.
  2. Paste (Ctrl+V) an image/file into the message box — great for screenshots.

How

  • Extract the picker's validate-and-preview core (handleFileSelect) into a shared openFileForPreview(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().
  • Drop handlers (@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.
  • @paste on the composer textarea; only intercepts when the clipboard carries a file (plain-text paste is untouched).
  • i18n key chat.dropToAttach added to all 5 locales (en/es translated; ar/hi/ta English placeholder).

Notes

  • One file at a time (files[0]), matching the current picker; multi-file queue could be a follow-up.
  • Frontend only; no new deps, no backend changes. First drag-drop/paste in the app.

Testing

vite build passes; 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.

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>
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.

1 participant