Skip to content

TUI: Can not paste certain string #11148

Closed

Description

@acidnik

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

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Jan 29, 2026
  2. github-actions commented on Jan 29, 2026

    @github-actions
    Contributor

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

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

  3. yanosh-k commented on Jan 30, 2026

    @yanosh-k
    Contributor

    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

  4. yanosh-k commented on Feb 20, 2026

    @yanosh-k
    Contributor

    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.

  5. github-actions commented on Apr 22, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingopentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions