Skip to content

Commit 2062247

Browse files
authored
fix: support clipboard image paste (Ctrl+V) on Windows (anomalyco#5919)
1 parent 8785bec commit 2062247

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

  • packages/opencode/src/cli/cmd/tui/component/prompt

packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,23 @@ export function Prompt(props: PromptProps) {
731731
e.preventDefault()
732732
return
733733
}
734+
// Handle clipboard paste (Ctrl+V) - check for images first on Windows
735+
// This is needed because Windows terminal doesn't properly send image data
736+
// through bracketed paste, so we need to intercept the keypress and
737+
// directly read from clipboard before the terminal handles it
738+
if (keybind.match("input_paste", e)) {
739+
const content = await Clipboard.read()
740+
if (content?.mime.startsWith("image/")) {
741+
e.preventDefault()
742+
await pasteImage({
743+
filename: "clipboard",
744+
mime: content.mime,
745+
content: content.data,
746+
})
747+
return
748+
}
749+
// If no image, let the default paste behavior continue
750+
}
734751
if (keybind.match("input_clear", e) && store.prompt.input !== "") {
735752
input.clear()
736753
input.extmarks.clear()

0 commit comments

Comments
 (0)