You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can confirm that this issue still exists, but the proposed PR won't work fully.
Calling const content = await file.text().catch(() => { }) (or any other function with await) before event.preventDefault(), when the file exists, will paste the file name and the placeholder text (e.g. my-pages-image.png[Image 1]), which is not the intended default behavior.
This is because event handlers will yielded control back to the event loop if you call await inside of them.
I propose to do a synchronous file check (e.g. existsSync) :
import{existsSync}from'node:fs'
and before the first image check if (file.type === "image/svg+xml") we put:
// Note that Bun lazy-loads files and we need to// check that the file actually exists because type is// inferred from the extension. We cannot use file.exists()// as it is async and `await` will yielded control back// to the event loopif(!existsSync(filepath)){thrownewError('File does not exist')}
As the whole block is wrapped in a try/catch, this would allow for very long texts looking like file paths to be still pasted as [Pasted n lines] in the checks after the catch {}
In opencode v1.2.7 the file type check is no longer using Bun's File I/O, but the lookup function from the mime-types library. This function does not check if the files exits and just matches the file extension, meaning that the issue persists - pasting strings with image extensions does not work.
The proposed fix is still viable. In packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx, before any mime type checking is done (line 937) a check if the file exists and throwing an exception if it does not, fixes the problem.
Activity
github-actions commentedon Jan 29, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
yanosh-k commentedon Jan 30, 2026
I can confirm that this issue still exists, but the proposed PR won't work fully.
Calling
const content = await file.text().catch(() => { })(or any other function withawait) beforeevent.preventDefault(), when the file exists, will paste the file name and the placeholder text (e.g.my-pages-image.png[Image 1]), which is not the intended default behavior.This is because event handlers will yielded control back to the event loop if you call
awaitinside of them.I propose to do a synchronous file check (e.g.
existsSync) :and before the first image check
if (file.type === "image/svg+xml")we put:As the whole block is wrapped in a try/catch, this would allow for very long texts looking like file paths to be still pasted as
[Pasted n lines]in the checks after thecatch {}More on Bun I/O here: https://bun.com/docs/runtime/file-io
yanosh-k commentedon Feb 20, 2026
In opencode
v1.2.7the file type check is no longer using Bun's File I/O, but the lookup function from themime-typeslibrary. This function does not check if the files exits and just matches the file extension, meaning that the issue persists - pasting strings with image extensions does not work.The proposed fix is still viable. In
packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx, before any mime type checking is done (line 937) a check if the file exists and throwing an exception if it does not, fixes the problem.github-actions commentedon Apr 22, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.