From 639058a8b6b15f35218c01bc02ba824628c165b0 Mon Sep 17 00:00:00 2001 From: Brendan Whiting Date: Fri, 12 Jun 2026 09:48:48 -0700 Subject: [PATCH] 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] --- .../agents/ported/CloudPromptBar.tsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ui/src/components/agents/ported/CloudPromptBar.tsx b/ui/src/components/agents/ported/CloudPromptBar.tsx index 0260ed31..32559a7e 100644 --- a/ui/src/components/agents/ported/CloudPromptBar.tsx +++ b/ui/src/components/agents/ported/CloudPromptBar.tsx @@ -271,6 +271,24 @@ export const CloudPromptBar = memo(function CloudPromptBarComponent({ [addFiles] ) + const handlePaste = useCallback( + (e: React.ClipboardEvent) => { + const items = e.clipboardData?.items + if (!items) return + const files: Array = [] + 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) => { 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(