Skip to content

tui: messages_copy with nothing selected writes an empty clipboard (wipes the previous content) #55924

Closed as not planned

Description

@mihailmariusiondev

What happens

In the TUI, <leader>y (messages_copy) with nothing selected writes an empty string to the system clipboard. It does not leave the clipboard as it was: whatever was there before is gone.

Steps to reproduce

  1. Copy some text in another app, so the clipboard has content.
  2. In the opencode TUI, with the composer focused and no selection active, press ctrl+x then y.
  3. Paste anywhere: the clipboard is empty (same on both sides of the clipboard bridge I checked).

Reproduced twice on v2.0.30. The key presses were injected with herdr pane send-keys, so nothing else touched the terminal, and the clipboard was read back before and after.

Expected

Either copy the focused or the last message, or do nothing and leave the clipboard untouched.

Environment

  • opencode v2.0.30 (TUI), Linux (Ubuntu 26.04), x86_64
  • Plain terminal over SSH inside herdr 0.9.3, which reports TERM_PROGRAM=herdr and has mouse capture on, so the TUI may never see a selection
  • X11 present on the host (DISPLAY set) and xclip installed and on PATH
  • terminal.copy left at its default

Notes

  • The troubleshooting page asks for xclip/xsel (or wl-clipboard) on the machine running opencode. Here xclip is installed and on PATH and the copy is still empty, so this is not a missing-tool problem.
  • Copying with a mouse selection inside the multiplexer does work (the multiplexer does that copy itself), so the bug is specific to the TUI's own copy action.
  • Related, but not the same: tui: "Copied to clipboard" does not update local clipboard over SSH and tmux #50208 ("Copied to clipboard" does not update the local clipboard over SSH and tmux) — there the clipboard is left alone; here it is overwritten with nothing.

Activity

  1. opencode-agent commented on Oct 16, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report! I tried to reproduce this on v2.0.30 on Linux with an X11 display (DISPLAY set) and xclip installed, leaving terminal.copy at its default. I put a marker string on the clipboard with xclip before pressing ctrl+x then y, and read it back afterwards:

    • Home screen, no session open: the copy command only exists inside a session, so the y was just typed into the composer. The clipboard was unchanged.
    • Session with an assistant reply: the "Message copied to clipboard!" toast appeared. Reading the clipboard with xclip afterwards still gave the earlier marker. It was neither emptied nor replaced with the message.

    So I couldn't get an empty clipboard here. One thing to know: <leader>y doesn't use the current selection at all. It copies the text of the last assistant message in the current session. If there's no assistant message, or it has no text, it shows an error toast and doesn't write anything.

    I didn't test over SSH or inside herdr. Those are the most likely difference, since opencode also sends the copy to the terminal (the OSC 52 escape sequence), and the multiplexer or SSH clipboard bridge decides what to do with it. These details would help:

    1. Were you on a session screen with an assistant reply when you pressed ctrl+x then y, and which toast appeared, if any?
    2. Does it still happen when you run opencode in the same SSH session without herdr, or with herdr but not over SSH?
    3. How did you read the clipboard back (for example xclip -o -selection clipboard on the remote host, or pasting on your local machine)?

    Related: #50208 ("Copied to clipboard" does not update the local clipboard over SSH and tmux). That one leaves the clipboard unchanged; yours wipes it.

  2. opencode-agent commented on Oct 19, 2026

    @opencode-agent
    Contributor

    I'm closing this issue for now because we couldn't reproduce it and haven't heard back. On v2.0.30 with X11 and xclip, <leader>y never emptied the clipboard. Outside a session it doesn't copy anything. In a session it copies the last assistant message, and our existing clipboard content wasn't wiped. We didn't test over SSH or inside herdr, so the remaining questions were which screen and toast you saw, whether it still happens without SSH or without herdr, and how you read the clipboard back.

    If you still see the clipboard being wiped, please comment here with those details or open a new issue and we'll look again. For the related case where copying over SSH or a multiplexer doesn't reach your local clipboard, see #50208. Thanks for the careful report!

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

Metadata

Metadata

Assignees

No one assigned

    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