Skip to content

fix: support pasting images from clipboard in chat (#209) - #214

Open
kaixinbaba wants to merge 1 commit into
stephengpope:mainfrom
kaixinbaba:fix/issue-209-clipboard-paste
Open

fix: support pasting images from clipboard in chat (#209)#214
kaixinbaba wants to merge 1 commit into
stephengpope:mainfrom
kaixinbaba:fix/issue-209-clipboard-paste

Conversation

@kaixinbaba

Copy link
Copy Markdown

Summary

Fixes #209 — Copy and Pasting Images from Clipboard Does Not Work

Problem

When a user copies an image (e.g. a screenshot via Cmd+Shift+4 or Ctrl+PrtSc) and presses Ctrl+V / Cmd+V in the chat textarea, nothing happened. The chat input had no onPaste handler to intercept clipboard image data.

Solution

Added a handlePaste callback to lib/chat/components/chat-input.jsx that:

  1. Checks e.clipboardData.items for any items with an image/* MIME type
  2. If image items are found, calls e.preventDefault() to suppress default browser paste behavior
  3. Converts each image item to a File object via item.getAsFile()
  4. Passes the files to the existing handleFiles helper — the same path used by the file picker and drag-and-drop — so images appear in the attachment preview strip before sending

No new dependencies. The fix is minimal and consistent with the existing file attachment flow.

Testing

  • Take a screenshot / copy any image to clipboard
  • Open the chat input and press Cmd+V / Ctrl+V
  • Image should appear in the attachment preview strip, ready to send

@kaixinbaba
kaixinbaba force-pushed the fix/issue-209-clipboard-paste branch 2 times, most recently from 6a19a88 to 920b567 Compare March 13, 2026 16:44
@kaixinbaba

Copy link
Copy Markdown
Author

paste image screen record

paste_test.mp4

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.

Copy and Pasting Images from Clipboard Does Not Work

1 participant