You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: Add config option to disable copy-on-select #4751
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.
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".
Reacted by Adam Vlasák, Daniel Vélez, Mauricio Scheffer, Wayne Walker, mhrf, Jean Bertrand, Julian Lopez, Hexiang Geng, Alexander Momchilov, Vickram Jain and 6 more
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 👍
/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 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.
@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.
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 :/
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.
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.
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)
Reacted by justinclift-prvidr, jouwntes, Davide Bizzarri and Oscar Mederos
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.
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.
Activity
github-actions commentedon Nov 25, 2025
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
awwright commentedon Nov 29, 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".
adamvlasak commentedon 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 👍
rekram1-node commentedon Dec 2, 2025
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 commentedon 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
opencode-agent commentedon Dec 2, 2025
Created PR #4996
opencode session | github run
rekram1-node commentedon Dec 2, 2025
added in next release just:
export OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=...
set to truthy value like 1 or "true"
adamvlasak commentedon Dec 2, 2025
Thanks again!
tiberiuichim commentedon Dec 4, 2025
I've tried the following scenario: run opencode natively installed via npm in ubuntu running in wsl in windows terminal.
So the flag makes it worse.
rekram1-node commentedon 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
tiberiuichim commentedon 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.
andy-blum commentedon Dec 4, 2025
So don't use this flag, then?
I'm seeing a different issue after adding this flag, however:
Scenario 1:
Scenario 2:
tiberiuichim commentedon 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.andy-blum commentedon 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.
tiberiuichim commentedon 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.
anula commentedon 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 :/
awwright commentedon 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.
wwalker commentedon Jan 14, 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 commentedon Jan 14, 2026
PR #4996 (
OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT) does NOT fix this issue in any way.This ticket should be reopened.
mhrf commentedon Jan 17, 2026
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)
justinclift-prvidr commentedon 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.
homerl commentedon Feb 3, 2026
Once you experience a bug in this feature, you'll realize there's a clear reason to turn it off.
b1zzu commentedon Apr 17, 2026
This is a game-changer, now I can drop Claude, you have no idea how much I was bother by the previous behavior 🤟
gduquesnay commentedon Jun 26, 2026
Why is this an ENV var rather than being a setting in the opencode config file?
awwright commentedon Jul 11, 2026
Why is this still in at all? Copy and paste is my terminal's responsibility, not you
titanventura commentedon Oct 17, 2026
has this not been fixed yet ?