summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMeysam Najafi Fard <[email protected]>2025-11-26 10:04:22 +0330
committerGitHub <[email protected]>2025-11-26 00:34:22 -0600
commit73eae191e9de23905337ce507a4dd152880c4e5a (patch)
treef95f7468a7dd5ac41b630d71b60f53c507b3b322
parent14e823e93878a4bc900696a43a9a90b70e81621f (diff)
downloadopencode-73eae191e9de23905337ce507a4dd152880c4e5a.tar.gz
opencode-73eae191e9de23905337ce507a4dd152880c4e5a.zip
fix: handle remote image URLs in paste handler (#4691)
Co-authored-by: Aiden Cline <[email protected]>
-rw-r--r--packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx38
1 files changed, 20 insertions, 18 deletions
diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
index fdf5b5b52..7249091e9 100644
--- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
+++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
@@ -705,25 +705,27 @@ export function Prompt(props: PromptProps) {
// trim ' from the beginning and end of the pasted content. just
// ' and nothing else
const filepath = pastedContent.replace(/^'+|'+$/g, "").replace(/\\ /g, " ")
- console.log(pastedContent, filepath)
- try {
- const file = Bun.file(filepath)
- if (file.type.startsWith("image/")) {
- event.preventDefault()
- const content = await file
- .arrayBuffer()
- .then((buffer) => Buffer.from(buffer).toString("base64"))
- .catch(console.error)
- if (content) {
- await pasteImage({
- filename: file.name,
- mime: file.type,
- content,
- })
- return
+ const isUrl = /^(https?):\/\//.test(filepath)
+ if (!isUrl) {
+ try {
+ const file = Bun.file(filepath)
+ if (file.type.startsWith("image/")) {
+ event.preventDefault()
+ const content = await file
+ .arrayBuffer()
+ .then((buffer) => Buffer.from(buffer).toString("base64"))
+ .catch(console.error)
+ if (content) {
+ await pasteImage({
+ filename: file.name,
+ mime: file.type,
+ content,
+ })
+ return
+ }
}
- }
- } catch {}
+ } catch {}
+ }
const lineCount = (pastedContent.match(/\n/g)?.length ?? 0) + 1
if (