feat: support pasting images from clipboard into prompt bar (#1512)

The prompt bar only accepted images via drag-and-drop or the file picker.
Pasting an image from the clipboard inserted the file name as text instead
of attaching the image. Add an onPaste handler that extracts image files
from the clipboard and attaches them as pending images.

Co-authored-by: Brendan Whiting <16016903+bwhiting2356@users.noreply.github.com>
Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
This commit is contained in:
Brendan Whiting 2026-06-12 09:48:48 -07:00 • committed by GitHub
parent 2e9e25916c
commit 639058a8b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -271,6 +271,24 @@ export const CloudPromptBar = memo(function CloudPromptBarComponent({
[addFiles]
)
const handlePaste = useCallback(
(e: React.ClipboardEvent<HTMLTextAreaElement>) => {
const items = e.clipboardData?.items
if (!items) return
const files: Array<File> = []
for (const item of Array.from(items)) {
if (item.kind === "file") {
const file = item.getAsFile()
if (file && SUPPORTED_IMAGE_TYPES.has(file.type)) files.push(file)
}
}
if (files.length === 0) return
e.preventDefault()
void addFiles(files)
},
[addFiles]
)
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (e.key === "Enter" && !e.shiftKey && canSubmit) {
e.preventDefault()
@ -359,6 +377,7 @@ export const CloudPromptBar = memo(function CloudPromptBarComponent({
value={value}
onChange={(e) => setValue(e.target.value)}
onKeyDown={handleKeyDown}
onPaste={handlePaste}
placeholder={busy ? "Send a message to queue next..." : placeholder}
disabled={disabled}
className={cn(