TUI: Can not paste certain string #7954

Open
opened 2026-02-16 18:08:46 -05:00 by yindo · 2 comments
Owner

Originally created by @acidnik on GitHub (Jan 29, 2026).

Originally assigned to: @kommander on GitHub.

Description

any string, containing 'whatever.EXT` (without backticks) where EXT is png, jpg, webp - are not pastable

Plugins

No response

OpenCode version

1.1.42

Steps to reproduce

  1. copy string test.png to clipboard
  2. press Shift+Ins in opencode console client

expected result: string is pasted
actual result: nothing happens

Screenshot and/or share link

No response

Operating System

Linux

Terminal

Ghostty

Originally created by @acidnik on GitHub (Jan 29, 2026). Originally assigned to: @kommander on GitHub. ### Description any string, containing 'whatever.EXT` (without backticks) where EXT is png, jpg, webp - are not pastable ### Plugins _No response_ ### OpenCode version 1.1.42 ### Steps to reproduce 1. copy string `test.png` to clipboard 2. press Shift+Ins in opencode console client expected result: string is pasted actual result: nothing happens ### Screenshot and/or share link _No response_ ### Operating System Linux ### Terminal Ghostty
yindo added the opentuibug labels 2026-02-16 18:08:46 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 29, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #10780: Can't paste - general paste functionality issue
  • #7897: Unable to paste filenames from MacOS finder - filename/path pasting issue
  • #4754: Copy and Paste behaviour under Linux - clipboard handling issues

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 29, 2026): This issue might be a duplicate of existing issues. Please check: - #10780: Can't paste - general paste functionality issue - #7897: Unable to paste filenames from MacOS finder - filename/path pasting issue - #4754: Copy and Paste behaviour under Linux - clipboard handling issues Feel free to ignore if none of these address your specific case.
Author
Owner

@yanosh-k commented on GitHub (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 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 loop
if (!existsSync(filepath)) {
  throw new Error('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 {}

More on Bun I/O here: https://bun.com/docs/runtime/file-io

@yanosh-k commented on GitHub (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 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`) : ```typescript import { existsSync } from 'node:fs' ``` and before the first image check `if (file.type === "image/svg+xml")` we put: ```typescript // 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 loop if (!existsSync(filepath)) { throw new Error('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 {}` More on Bun I/O here: https://bun.com/docs/runtime/file-io
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7954