[Feature Request] Add config option to disable copy-on-select behavior #7504

Open
opened 2026-02-16 18:07:22 -05:00 by yindo · 10 comments
Owner

Originally created by @cbrunnkvist on GitHub (Jan 25, 2026).

Originally assigned to: @rekram1-node on GitHub.

OC implements "XTerm / GPM"-style copy-on-select

Selecting text with the mouse automatically copies it to the clipboard when the mouse button is released. As far as I can find, there is no way to disable this behavior.

I'd like to be able to turn off copy-on-select via opencode.json config because frankly it interferes with the way I read and mark text on screen, in particular when screen sharing or pair coding. And I really don't appreciate accidental clipboard overwrites when scrolling/selecting to read text.

I understand that the TUI is mouse-aware, and I am aware that in e.g. Ghostty's config I can set mouse-shift-capture = never to make shift+click always selects text, without notifying the app, but I'd still like to prevent OC from bungling my current clipboard contents.

Proposed Solution

I guess a tui.copy_on_select config option would suffice. Keep its default as true to avoid surprising existing users.

{
  "tui": {
    "copy_on_select": false
  }
}

Current Behavior

Mouse selection → automatic clipboard copy

Expected Behavior (when disabled)

Allows users to select text visually without side effects

Originally created by @cbrunnkvist on GitHub (Jan 25, 2026). Originally assigned to: @rekram1-node on GitHub. ## OC implements "XTerm / GPM"-style copy-on-select Selecting text with the mouse automatically copies it to the clipboard when the mouse button is released. As far as I can find, there is no way to disable this behavior. I'd like to be able to turn off copy-on-select via `opencode.json` config because frankly it interferes with the way I read and mark text on screen, in particular when screen sharing or pair coding. And I really don't appreciate accidental clipboard overwrites when scrolling/selecting to read text. I understand that the TUI is mouse-aware, and I am aware that in e.g. Ghostty's config I can set `mouse-shift-capture = never` to make shift+click always selects text, without notifying the app, but I'd still like to prevent OC from bungling my current clipboard contents. ## Proposed Solution I guess a `tui.copy_on_select` config option would suffice. Keep its default as `true` to avoid surprising existing users. ```json { "tui": { "copy_on_select": false } } ``` ## Current Behavior Mouse selection → automatic clipboard copy ## Expected Behavior (when disabled) Allows users to select text visually without side effects
yindo added the opentui label 2026-02-16 18:07:22 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 25, 2026):

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

  • #7926: feat: Add option to disable mouse capture in TUI for better terminal multiplexer compatibility
  • #6824: [FEATURE]: add a settings to disable mouse
  • #2845: How to disable text selection and clipboard overrides?

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

@github-actions[bot] commented on GitHub (Jan 25, 2026): This issue might be a duplicate of existing issues. Please check: - #7926: feat: Add option to disable mouse capture in TUI for better terminal multiplexer compatibility - #6824: [FEATURE]: add a settings to disable mouse - #2845: How to disable text selection and clipboard overrides? Feel free to ignore if none of these address your specific case.
Author
Owner

@ariane-emory commented on GitHub (Jan 25, 2026):

Instead of making this a new setting in opencode.json and changing the shape of the config schema, I think that a better implementation would be to control it using a new menu item in the System category of the command_list, appearing as either "Disable copy-on-select" or "Enable-copy-on-select" (dependant upon it's current state) whose current state is persisted to the kv.json file.

@ariane-emory commented on GitHub (Jan 25, 2026): Instead of making this a new setting in `opencode.json` and changing the shape of the config schema, I think that a better implementation would be to control it using a new menu item in the System category of the `command_list`, appearing as either "Disable copy-on-select" or "Enable-copy-on-select" (dependant upon it's current state) whose current state is persisted to the `kv.json` file.
Author
Owner

@ariane-emory commented on GitHub (Jan 25, 2026):

Upon review, a OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT flag was added in the merged PR #4996. To me, this flag seems entirely adequate to resolve the issue, I'll leave this be.

@ariane-emory commented on GitHub (Jan 25, 2026): Upon review, a OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT flag was added in the merged PR #4996. To me, this flag seems entirely adequate to resolve the issue, I'll leave this be.
Author
Owner

@cbrunnkvist commented on GitHub (Jan 26, 2026):

Ah, thanks @ariane-emory, I failed to find that despite fuzzy searching for "copy on select" ...

I can confirm that OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1 opencode, while still not retaining the text-selection highlight at least prevents it from clobbering the clipboard. I'll be using that for now; thanks again.

(I thought I kind of knew terminal programming, but I realize I actually have no idea about what control codes or -modes are used by mouse extensions)

@cbrunnkvist commented on GitHub (Jan 26, 2026): Ah, thanks @ariane-emory, I failed to find that despite fuzzy searching for "copy on select" ... I can confirm that `OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1 opencode`, while still not retaining the text-selection highlight _at least_ prevents it from clobbering the clipboard. I'll be using that for now; thanks again. (I thought I kind of knew terminal programming, but I realize I actually have no idea about what control codes or -modes are used by mouse extensions)
Author
Owner

@tonglil commented on GitHub (Jan 27, 2026):

@ariane-emory the problem with OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT is that it no longer lets me select text in the terminal (and keep it selected). It's acting like "DISABLE_SELECT" all together.

I want to be able to select some text in the terminal, and optionally copy it if I want to with cmd+c.

Image

@tonglil commented on GitHub (Jan 27, 2026): @ariane-emory the problem with `OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT` is that it no longer lets me select text in the terminal (and keep it selected). It's acting like "DISABLE_SELECT" all together. I want to be able to select some text in the terminal, and optionally copy it if I want to with cmd+c. ![Image](https://github.com/user-attachments/assets/e4aea422-8476-40ba-ad79-9976a31385ff)
Author
Owner

@ariane-emory commented on GitHub (Jan 27, 2026):

That's interesting that might have something to do with which terminal you're running it in? I'm afraid I'm not sure if there's another way to disable the copy on select behaviour, sorry.

@ariane-emory commented on GitHub (Jan 27, 2026): That's interesting that might have something to do with which terminal you're running it in? I'm afraid I'm not sure if there's another way to disable the copy on select behaviour, sorry.
Author
Owner

@tonglil commented on GitHub (Jan 27, 2026):

I'm using iterm2.
You can see the select behavior works as expected in other apps.

Here's another capture that demonstrates selection working for claude code and not in opencode, this time in the mac's default terminal.

Image

As soon as you release the mouse, the selection disappears.

@tonglil commented on GitHub (Jan 27, 2026): I'm using iterm2. You can see the select behavior works as expected in other apps. Here's another capture that demonstrates selection working for claude code and not in opencode, this time in the mac's default terminal. ![Image](https://github.com/user-attachments/assets/348b2061-f2cb-4d8e-856d-8848104287b5) As soon as you release the mouse, the selection disappears.
Author
Owner

@cbrunnkvist commented on GitHub (Jan 28, 2026):

Yeah that’s precisely the behavior I described as “swallows my selection”.
I’m using Ghostty. Basically the selection still works identically to the
sock OpenCode behavior (when you let go of the button the selection
disappear) but with the exception that it leaves the clipboard untouched.

On Wed, 28 Jan 2026 at 01:57 Tony Li @.***> wrote:

tonglil left a comment (anomalyco/opencode#10490)
https://github.com/anomalyco/opencode/issues/10490#issuecomment-3806944203

I'm using iterm2.
You can see the select behavior works as expected in other apps.

Here's another capture that demonstrates selection working for claude code
and not in opencode, this time in the mac's default terminal.

gif.gif (view on web)
https://github.com/user-attachments/assets/348b2061-f2cb-4d8e-856d-8848104287b5

As soon as you release the mouse, the selection disappears.


Reply to this email directly, view it on GitHub
https://github.com/anomalyco/opencode/issues/10490#issuecomment-3806944203,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAIJVTRIP4GSJZIAPXFHCD4I6YHZAVCNFSM6AAAAACSZTMHNWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQMBWHE2DIMRQGM
.
You are receiving this because you authored the thread.Message ID:
@.***>

@cbrunnkvist commented on GitHub (Jan 28, 2026): Yeah that’s precisely the behavior I described as “swallows my selection”. I’m using Ghostty. Basically the selection still works identically to the sock OpenCode behavior (when you let go of the button the selection disappear) but with the exception that it leaves the clipboard untouched. On Wed, 28 Jan 2026 at 01:57 Tony Li ***@***.***> wrote: > *tonglil* left a comment (anomalyco/opencode#10490) > <https://github.com/anomalyco/opencode/issues/10490#issuecomment-3806944203> > > I'm using iterm2. > You can see the select behavior works as expected in other apps. > > Here's another capture that demonstrates selection working for claude code > and not in opencode, this time in the mac's default terminal. > > gif.gif (view on web) > <https://github.com/user-attachments/assets/348b2061-f2cb-4d8e-856d-8848104287b5> > > As soon as you release the mouse, the selection disappears. > > — > Reply to this email directly, view it on GitHub > <https://github.com/anomalyco/opencode/issues/10490#issuecomment-3806944203>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AAAIJVTRIP4GSJZIAPXFHCD4I6YHZAVCNFSM6AAAAACSZTMHNWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQMBWHE2DIMRQGM> > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> >
Author
Owner

@ariane-emory commented on GitHub (Jan 28, 2026):

@jhrudden I've got a fix that seemingly works correctly for:

  • iTerm2, ghostty, Kitty on MacOS.
  • The stock terminal on recent versions of Fedora and Ubuntu.

Just waiting to hear back from a Windows user about whether the fix works for them there.

@ariane-emory commented on GitHub (Jan 28, 2026): @jhrudden I've got a fix that seemingly works correctly for: - iTerm2, ghostty, Kitty on MacOS. - The stock terminal on recent versions of Fedora and Ubuntu. Just waiting to hear back from a Windows user about whether the fix works for them there.
Author
Owner

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

This feature request is now critical for VS Code Remote SSH users.

With v1.1.49's OSC52 clipboard (which doesn't work in VS Code Remote SSH), copy-on-select:

  1. Intercepts mouse selection
  2. Clears the selection
  3. Shows "copied" (but OSC52 silently fails)
  4. Nothing in clipboard, selection gone

There's literally no way to copy text from opencode in VS Code Remote SSH without this config option.

See #11909 for the full context. The tui.copy_on_select: false option would at least let us manually select + Cmd+C as a workaround.

@ErcinDedeoglu commented on GitHub (Feb 3, 2026): This feature request is now **critical** for VS Code Remote SSH users. With v1.1.49's OSC52 clipboard (which doesn't work in VS Code Remote SSH), copy-on-select: 1. Intercepts mouse selection 2. Clears the selection 3. Shows "copied" (but OSC52 silently fails) 4. **Nothing in clipboard, selection gone** There's literally **no way to copy text** from opencode in VS Code Remote SSH without this config option. See #11909 for the full context. The `tui.copy_on_select: false` option would at least let us manually select + Cmd+C as a workaround.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7504