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

Closed
opened 2026-02-16 17:38:42 -05:00 by yindo · 22 comments
Owner

Originally created by @andy-blum on GitHub (Nov 25, 2025).

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.

Originally created by @andy-blum on GitHub (Nov 25, 2025). ### Feature hasn't been suggested before. - [x] 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.
yindo added the discussion label 2026-02-16 17:38:42 -05:00
yindo closed this issue 2026-02-16 17:38:42 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Nov 25, 2025):

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

  • #2845: How to disable text selection and clipboard overrides? - User explicitly requests ability to disable clipboard behavior during text selection
  • #1210: Mouse text selection has unexpected behavior in terminal - Describes how selection immediately copies to clipboard on release
  • #2755: feat: Copy Mode for OpenCode - Comprehensive feature request addressing copy functionality and text selection behavior

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

@github-actions[bot] commented on GitHub (Nov 25, 2025): This issue might be a duplicate of existing issues. Please check: - #2845: How to disable text selection and clipboard overrides? - User explicitly requests ability to disable clipboard behavior during text selection - #1210: Mouse text selection has unexpected behavior in terminal - Describes how selection immediately copies to clipboard on release - #2755: feat: Copy Mode for OpenCode - Comprehensive feature request addressing copy functionality and text selection behavior Feel free to ignore if none of these address your specific case.
Author
Owner

@awwright commented on GitHub (Nov 28, 2025):

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".

@awwright commented on GitHub (Nov 28, 2025): 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".
Author
Owner

@adamvlasak commented on GitHub (Dec 2, 2025):

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 👍

@adamvlasak commented on GitHub (Dec 2, 2025): 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 👍
Author
Owner

@rekram1-node commented on GitHub (Dec 2, 2025):

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

@rekram1-node commented on GitHub (Dec 2, 2025): > 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
Author
Owner

@rekram1-node commented on GitHub (Dec 2, 2025):

/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

@rekram1-node commented on GitHub (Dec 2, 2025): /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
Author
Owner

@opencode-agent[bot] commented on GitHub (Dec 2, 2025):

Created PR #4996

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

@opencode-agent[bot] commented on GitHub (Dec 2, 2025): Created PR #4996 <a href="https://opencode.ai/s/ok5CPKeY"><img width="200" alt="New%20session%20-%202025-12-02T20%3A09%3A17.632Z" src="https://social-cards.sst.dev/opencode-share/TmV3IHNlc3Npb24gLSAyMDI1LTEyLTAyVDIwOjA5OjE3LjYzMlo=.png?model=opencode/claude-haiku-4-5&version=1.0.127&id=ok5CPKeY" /></a> [opencode session](https://opencode.ai/s/ok5CPKeY)&nbsp;&nbsp;|&nbsp;&nbsp;[github run](/sst/opencode/actions/runs/19871999779)
Author
Owner

@rekram1-node commented on GitHub (Dec 2, 2025):

added in next release just:

export OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=...

set to truthy value like 1 or "true"

@rekram1-node commented on GitHub (Dec 2, 2025): added in next release just: export OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=... set to truthy value like 1 or "true"
Author
Owner

@adamvlasak commented on GitHub (Dec 2, 2025):

Thanks again!

@adamvlasak commented on GitHub (Dec 2, 2025): Thanks again!
Author
Owner

@tiberiuichim commented on GitHub (Dec 4, 2025):

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.

@tiberiuichim commented on GitHub (Dec 4, 2025): 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.
Author
Owner

@rekram1-node commented on GitHub (Dec 4, 2025):

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

@rekram1-node commented on GitHub (Dec 4, 2025): 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
Author
Owner

@tiberiuichim commented on GitHub (Dec 4, 2025):

@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.

@tiberiuichim commented on GitHub (Dec 4, 2025): @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.
Author
Owner

@andy-blum commented on GitHub (Dec 4, 2025):

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
@andy-blum commented on GitHub (Dec 4, 2025): > 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_
Author
Owner

@tiberiuichim commented on GitHub (Dec 4, 2025):

@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.

@tiberiuichim commented on GitHub (Dec 4, 2025): @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.
Author
Owner

@andy-blum commented on GitHub (Dec 4, 2025):

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.

@andy-blum commented on GitHub (Dec 4, 2025): 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.
Author
Owner

@tiberiuichim commented on GitHub (Dec 4, 2025):

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

@tiberiuichim commented on GitHub (Dec 4, 2025): @andy-blum like-wise. It's just that the terminal "won't listen" to me because it pretends it's a GUI.
Author
Owner

@anula commented on GitHub (Jan 10, 2026):

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 :/

@anula commented on GitHub (Jan 10, 2026): 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 :/
Author
Owner

@awwright commented on GitHub (Jan 13, 2026):

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.

@awwright commented on GitHub (Jan 13, 2026): 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.
Author
Owner

@wwalker commented on GitHub (Jan 13, 2026):

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.

@wwalker commented on GitHub (Jan 13, 2026): 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.
Author
Owner

@wwalker commented on GitHub (Jan 13, 2026):

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

This ticket should be reopened.

@wwalker commented on GitHub (Jan 13, 2026): PR #4996 (`OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT`) does NOT fix this issue in any way. This ticket should be reopened.
Author
Owner

@mhrf commented on GitHub (Jan 17, 2026):

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)

@mhrf commented on GitHub (Jan 17, 2026): > 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)
Author
Owner

@justinclift-prvidr commented on GitHub (Jan 23, 2026):

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.

@justinclift-prvidr commented on GitHub (Jan 23, 2026): 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.
Author
Owner

@homerl commented on GitHub (Feb 3, 2026):

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.

@homerl commented on GitHub (Feb 3, 2026): > 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3120