Skip to content

[FEATURE]: Add config option to disable copy-on-select #4751

Closed

Description

@andy-blum

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

I have a habit of highlighting lines of text as I read them, and this leads to opencode polluting my clipboard and throwing away previously copied text. I've looked for a way to disable this functionality but I've not been able to find a way to make this happen.

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Nov 25, 2025
  2. github-actions commented on Nov 25, 2025

    @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. awwright commented on Nov 29, 2025

    @awwright

    Why is open code even taking responsibility for this? Copying on select is a feature of the terminal itself. If that's what I wanted, I would enable it in my terminal.

    Filling my paste buffer should be limited to menu options like "Copy code block" or "Copy entire chat history".

  4. adamvlasak commented on Dec 2, 2025

    @adamvlasak

    Agree. I am trying to run opencode inside my headless vm for my development. I noticed copy on select does not work as in other terminal apps. Then I realized I should install Xvfb just to have clipboard? This is the only reason I won't use otherwise very nice app. Thanks for adding this option! Looking forward to use opencode one day 👍

  5. rekram1-node commented on Dec 2, 2025

    @rekram1-node
    Contributor

    Why is open code even taking responsibility for this

    Because opencode is a tui, we have to implement some of these things ourself. There are tradeoffs, this being one of the annoyances

  6. rekram1-node commented on Dec 2, 2025

    @rekram1-node
    Contributor

    /oc add an environment variable for the tui called OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT, add it to flag.ts and then make sure to read over cmd/tui/... find where the copy on select logic lies and if the flag is truthy then disable that behavior

  7. opencode-agent commented on Dec 2, 2025

    @opencode-agent
    Contributor

    Created PR #4996

    New%20session%20-%202025-12-02T20%3A09%3A17.632Z
    opencode session  |  github run

  8. rekram1-node commented on Dec 2, 2025

    @rekram1-node
    Contributor

    added in next release just:

    export OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=...

    set to truthy value like 1 or "true"

  9. adamvlasak commented on Dec 2, 2025

    @adamvlasak

    Thanks again!

  10. tiberiuichim commented on Dec 4, 2025

    @tiberiuichim

    I've tried the following scenario: run opencode natively installed via npm in ubuntu running in wsl in windows terminal.

    • Without the flag, the "copy to clipboard" on text selection runs fine
    • with the flag, there's nothing copied to the clipboard.

    So the flag makes it worse.

  11. rekram1-node commented on Dec 4, 2025

    @rekram1-node
    Contributor

    Um maybe I misunderstand you but the entire point of the flag is to not copy on select?, that's what it does

    What is the expectation

  12. tiberiuichim commented on Dec 4, 2025

    @tiberiuichim

    @rekram1-node Indeed, it does not copy on selection, but it also obstructs the terminal from registering the text selection.

    My expectation as a user is that, when I highlight text, it is automatically copied to the clipboard. This is a facility that is provided by X terminals and Windows terminal copied it. If opencode tui can't properly copy to clipboard without the flag, then my expectation is that, by forbiding it to use its own "copy to clipboard" feature, I would fall back to the terminal's implicit behavior, of copying selected text.

  13. andy-blum commented on Dec 4, 2025

    @andy-blum
    Author

    My expectation as a user is that, when I highlight text, it is automatically copied to the clipboard.

    So don't use this flag, then?

    I'm seeing a different issue after adding this flag, however:

    Scenario 1:

    • Select text that I do intend to copy
    • Release the mousebutton
    • text is unselected on mouseup, preventing me from copying

    Scenario 2:

    • Select text that I do intend to copy
    • Hold the mousebutton, use keyboard copy shortcut, nothing is copied
  14. tiberiuichim commented on Dec 4, 2025

    @tiberiuichim

    @andy-blum ok, so what's your proposal on how to deal with this scenario:

    As a user connected through ssh to a machine that runs opencode, that doesn't have clipboard forwarding, when I select text in the terminal using the mouse, I expect that my terminal identifies the characters it displays on its screen and copies the text to the clipboard.

    Edit: I'm sorry for the way the above sentence came out, but it's supposed to resemble a "user story"

    Without the flag, the opencode tui "copies to clipboard", and my terminal does not register the mouse. With the flag, the behavior is the same, except opencode no longer toasts with the "copied to clipboard".

    I'm basically looking for the equivalent of set mouse= in vim.

  15. andy-blum commented on Dec 4, 2025

    @andy-blum
    Author

    I'm just a man, looking at the AI output in his local terminal, wanting to copy it like I would out of a word doc.

  16. tiberiuichim commented on Dec 4, 2025

    @tiberiuichim

    @andy-blum like-wise. It's just that the terminal "won't listen" to me because it pretends it's a GUI.

  17. anula commented on Jan 10, 2026

    @anula

    Just to add to this - it is currently impossible to copy anything out of this tool unless it runs locally in a non sandboxed environment.
    If you run it remotely it would copy to the remote machine's clipboard. If you sandbox it, it has no access to anyone's clipboard.
    But the selection still disappears so I cannot just copy out of the terminal normally :/

  18. awwright commented on Jan 13, 2026

    @awwright

    I'm not really sure what people were thinking with this "feature"... Please consider as general rule, don't try to add features to an executable program that would be more suitable as features of the terminal itself, or that a terminal already does perfectly well.

  19. wwalker commented on Jan 14, 2026

    @wwalker

    I can, finally, get around this TERRIBLE application behavior.

    I use XTerm as a terminal. In the Cntrl-> Right Button menu, I can UN check "Allow Mouse Ops". This allows "normal, PROPER" selection and copy to clipboard (or to Primary) to work again!!!! That won't help anyone not using an XTerm though.

  20. wwalker commented on Jan 14, 2026

    @wwalker

    PR #4996 (OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT) does NOT fix this issue in any way.

    This ticket should be reopened.

  21. mhrf commented on Jan 17, 2026

    @mhrf

    I can, finally, get around this TERRIBLE application behavior.

    I use XTerm as a terminal. In the Cntrl-> Right Button menu, I can UN check "Allow Mouse Ops". This allows "normal, PROPER" selection and copy to clipboard (or to Primary) to work again!!!! That won't help anyone not using an XTerm though.

    If you use OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=true,
    until they fix the code to not clear selection, you can shift+mouse drag, this way it wont clear the selection. Then you can copy to clipboard ctrl+c normally. (works in GhosTTY)

  22. justinclift-prvidr commented on Jan 23, 2026

    @justinclift-prvidr

    Thanks @mhrf, that's working for me. Without using shift, then copying error text from out of the terminal using any kind of mouse selection (even with the above env variable set) was non-functional. 🤦

    As others have said, this bug should probably be re-opened as the feature is presently not fixed.

  23. homerl commented on Feb 3, 2026

    @homerl

    Why is open code even taking responsibility for this? Copying on select is a feature of the terminal itself. If that's what I wanted, I would enable it in my terminal.

    Filling my paste buffer should be limited to menu options like "Copy code block" or "Copy entire chat history".

    Once you experience a bug in this feature, you'll realize there's a clear reason to turn it off.

  24. b1zzu commented on Apr 17, 2026

    @b1zzu

    This is a game-changer, now I can drop Claude, you have no idea how much I was bother by the previous behavior 🤟

  25. gduquesnay commented on Jun 26, 2026

    @gduquesnay

    Why is this an ENV var rather than being a setting in the opencode config file?

  26. awwright commented on Jul 11, 2026

    @awwright

    Why is this still in at all? Copy and paste is my terminal's responsibility, not you

  27. titanventura commented on Oct 17, 2026

    @titanventura

    has this not been fixed yet ?

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

    discussionUsed for feature requests, proposals, ideas, etc. Open discussion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions