Repository navigation
add image paste support to chat input - #238
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for pasting clipboard images directly into the chat panel prompt input. It adds a paste event handler, refactors file ingestion into a reusable ingestFiles method, and includes corresponding unit tests. Feedback is provided regarding the ensureFileName method, where file.name is typically always populated in modern browsers (e.g., as 'blob' or 'image.png'), rendering the current fallback check ineffective and potentially leading to duplicate filenames. A suggestion is made to detect these generic names and generate unique, timestamped filenames instead.
⚡ A2UI Composer PR PreviewYour automated preview is successfully live (commit
|
| } | ||
| } | ||
|
|
||
| if (imageFiles.length === 0 && clipboardData.files && clipboardData.files.length > 0) { |
There was a problem hiding this comment.
Why do we only do this if the loop above doesn't add anything to the imageFiles?
There was a problem hiding this comment.
I think in modern browsers, clipboardData.items is always a superset of clipboardData.files, in which case we don't want to add duplicates in the second loop, but in some legacy browsers, clipboardData.files may be the only way to get the data? I can either add a comment explaining, or remove the second loop.
There was a problem hiding this comment.
added a comment explaining this.
There was a problem hiding this comment.
Not sure what constitutes a "legacy" browser -- depending how old we're talking about, maybe just don't bother?
Description
Add image paste support to chat input. Shares existing file attachment mechanism. New test added covering image paste.