Skip to content

feat(tui): Support clipboard image paste in chat input #45198

Closed

Description

@kisungbae-goorm

Feature Request

Summary

When a user pastes an image from the clipboard into the TUI chat input, OpenCode should automatically save it as a temporary file and insert the @/path/to/image reference into the input field — rather than silently ignoring the image data.

Proposed Behavior

  1. User copies an image (screenshot, etc.) to clipboard
  2. User presses Ctrl+V in the TUI chat input
  3. OpenCode detects the clipboard content is an image (not text)
  4. Saves it to a temp file (e.g. /tmp/opencode-paste-<timestamp>.png)
  5. Inserts @/tmp/opencode-paste-<timestamp>.png into the input field
  6. User can then add a prompt and send as usual

Why This Matters

Currently the only way to attach an image in TUI is to manually save the file and type @path. This is cumbersome for common workflows like:

  • Pasting a screenshot of an error
  • Sharing a UI mockup for review
  • Attaching a diagram for architecture discussion

The Web UI already supports image drag-and-drop/paste, so TUI is inconsistent in this regard.

Implementation Notes

  • Detect if clipboard data is image binary (not text) on paste event
  • Save to /tmp/opencode-paste-<unix_timestamp>.png (or similar)
  • Auto-insert @<path> into the input buffer
  • Works with existing @file reference handling — no new infrastructure needed

This would make TUI image workflow consistent with Web UI, with minimal implementation complexity.

Activity

  1. github-actions commented on Aug 26, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of or closely related to an existing issue. Please check:

  2. simonklee commented on Aug 26, 2026

    @simonklee
    Member

    I've implemented this in V2 which you can start using today.

    Image Image
  3. strubloid commented on Sep 28, 2026

    @strubloid

    I do feel this might broke something in there, since last week when I updated opencode from 1 to 2, it lost the option of paste images, maybe you should double check for the process of clipboard, maybe when was added the task for images, forgot that images can get in different ways, losing the skill to paste images from the clipboard, I will need to rollback to version 1 because of it, sad, i was curious about version 2

  4. simonklee commented on Sep 28, 2026

    @simonklee
    Member

    I do feel this might broke something in there, since last week when I updated opencode from 1 to 2, it lost the option of paste images, maybe you should double check for the process of clipboard, maybe when was added the task for images, forgot that images can get in different ways, losing the skill to paste images from the clipboard, I will need to rollback to version 1 because of it, sad, i was curious about version 2

    Can you share more about your setup, so i can try to reproduce the issue.

  5. strubloid commented on Sep 28, 2026

    @strubloid

    I do feel this might broke something in there, since last week when I updated opencode from 1 to 2, it lost the option of paste images, maybe you should double check for the process of clipboard, maybe when was added the task for images, forgot that images can get in different ways, losing the skill to paste images from the clipboard, I will need to rollback to version 1 because of it, sad, i was curious about version 2

    Can you share more about your setup, so i can try to reproduce the issue.

    I was using the version 1.18.16 and I got a news that we had a version 2, I just installed as recommended:

    curl -fsSL https://opencode.ai/v2/install | bash
    

    After that the image support isnt working anymore, I tried to use as normal, and i noticed it wasn't working, i went to foruns to check it more information, i tried to change some configurations to seek some kind of solution, and I coulnd't find a way, so I downgraded to the version 1, working fine.

  6. simonklee commented on Sep 28, 2026

    @simonklee
    Member

    Thanks, for the reply, but could you share:

    • terminal
    • os (and distro if linux)
    • what exactly isn't working, do you get an error when you try to paste an image, does anything happen.
    • if possible, run with opencode --log-level all, try to paste an image, then share the relevant part from ~/.local/share/opencode/log/opencode.log

    Again, thanks for the help!

  7. rme-scf commented on Sep 28, 2026

    @rme-scf

    Thanks, for the reply, but could you share:

    • terminal
      Bash
    • os (and distro if linux)
      ubuntu 26.04
    • what exactly isn't working, do you get an error when you try to paste an image, does anything happen.
      No error, just i got that i can't paste the content, i didn't went to debug of it, as i tried to use, and noticed that wasnt working, so i rolled it back, to a functional version.
    • if possible, run with opencode --log-level all, try to paste an image, then share the relevant part from ~/.local/share/opencode/log/opencode.log

    When you suggested this, wont work in opencode 1

    opencode --log-level all
                                     ▄     
    █▀▀█ █▀▀█ █▀▀█ █▀▀▄ █▀▀▀ █▀▀█ █▀▀█ █▀▀█
    █  █ █  █ █▀▀▀ █  █ █    █  █ █  █ █▀▀▀
    ▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀
    
    Commands:
      opencode completion          generate shell completion script
      opencode acp                 start ACP (Agent Client Protocol) server
      opencode mcp                 manage MCP (Model Context Protocol) servers
      opencode [project]           start opencode tui                                          [default]
      opencode attach <url>        attach to a running opencode server
      opencode run [message..]     run opencode with a message
      opencode debug               debugging and troubleshooting tools
      opencode providers           manage AI providers and credentials                   [aliases: auth]
      opencode agent               manage agents
      opencode upgrade [target]    upgrade opencode to the latest or a specific version
      opencode uninstall           uninstall opencode and remove all related files
      opencode serve               starts a headless opencode server
      opencode web                 start opencode server and open web interface
      opencode models [provider]   list all available models
      opencode stats               show token usage and cost statistics
      opencode export [sessionID]  export session data as JSON
      opencode import <file>       import session data from JSON file or URL
      opencode github              manage GitHub agent
      opencode pr <number>         fetch and checkout a GitHub PR branch, then run opencode
      opencode session             manage sessions
      opencode plugin <module>     install plugin and update config                      [aliases: plug]
      opencode db                  database tools
    
    Positionals:
      project  path to start opencode in                                                        [string]
    
    Options:
      -h, --help          show help                                                            [boolean]
      -v, --version       show version number                                                  [boolean]
          --print-logs    print logs to stderr                                                 [boolean]
          --log-level     log level                 [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"]
          --pure          run without external plugins                                         [boolean]
          --port          port to listen on                                        [number] [default: 0]
          --hostname      hostname to listen on                          [string] [default: "127.0.0.1"]
          --mdns          enable mDNS service discovery (defaults hostname to 0.0.0.0)
                                                                              [boolean] [default: false]
          --mdns-domain   custom domain name for mDNS service (default: opencode.local)
                                                                    [string] [default: "opencode.local"]
          --cors          additional domains to allow for CORS                     [array] [default: []]
      -m, --model         model to use in the format of provider/model                          [string]
      -c, --continue      continue the last session                                            [boolean]
      -s, --session       session id to continue                                                [string]
          --fork          fork the session when continuing (use with --continue or --session)  [boolean]
          --prompt        prompt to use                                                         [string]
          --agent         agent to use                                                          [string]
          --auto          auto-approve permissions that are not explicitly denied (dangerous!)
                                                                              [boolean] [default: false]
          --mini          start the minimal interactive interface             [boolean] [default: false]
          --no-replay     disable mini session history replay on resume and after resize       [boolean]
          --replay-limit  cap visible mini replay to the newest N messages                      [number]
    
    

    Again, thanks for the help!
    Cheers I am trying to help, but to be honest i tried to share everything here, no new configuration than installing of the version 2, i was using the version one, normally, doing everything fine, when i updated to version 2, the paste command does not show, one thing that i noticed while debuging it is:

    I could see while i was trying to debug that the wl-paste wasnt showing an image, but i could see that i could go to chatgpt.com and add an image there from the clipboard fine without any issues, so that is why i said should be an opencode issue:

    wl-paste --list-types
    text/html
    STRING
    chromium/x-source-url
    TEXT
    text/plain;charset=utf-8
    chromium/x-internal-source-rfh-token
    UTF8_STRING
    text/plain;charset=utf-8
    text/plain
    

    I tried to also fix by adding a different keybind

    {
      "$schema": "https://opencode.ai/v2/cli.json",
      "diffs": {
        "wrap": "word"
      },
      "session": {
        "sidebar": "auto",
        "scrollbar": false,
        "thinking": "hide"
      },
      "prompt": {
        "image_preview": true
      },
      "keybinds": {
        "prompt.paste": {
          "key": "ctrl+v",
          "event": "press",
          "preventDefault": false,
          "fallthrough": false
        }
      },
      "animations": true
    }
    

    Did not work even with image preview true (i thoght as was introduced this new feature, coult it be this config with a false there and something could be breaking, but wasnt)

    Fyi: With the same configurations i have in my computer, when i rolled it back to version 1, all the things are working fine, so maybe could be something related to wl-clipboard ? as i am using the same configs and works, but for the version 2 is missing something.

    I hope be able to help!

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions