Skip to content

Conversation

@opencode-agent
Copy link
Contributor

@opencode-agent opencode-agent bot commented Dec 2, 2025

Perfect! I've successfully implemented the feature. Here's a summary of the changes:

Changes Made

1. Added flag to flag.ts (line 20):

  • Added OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT flag that reads from the OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT environment variable
  • When set to "true" or "1", it will disable the copy-on-select behavior

2. Updated app.tsx (lines 464-467):

  • Imported the Flag namespace
  • Modified the onMouseUp handler to check if Flag.OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT is enabled
  • If the flag is enabled, it clears the selection without copying to the clipboard and returns early
  • Otherwise, it proceeds with the normal copy-on-select behavior

How to Use

Users can now disable copy-on-select by setting the environment variable:

export OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=true
opencode

Or with value "1":

OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1 opencode

This will allow users to highlight text without automatically polluting their clipboard, addressing the issue raised in #2845.

Closes #4751

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

Co-authored-by: rekram1-node <rekram1-node@users.noreply.github.com>
@rekram1-node rekram1-node changed the title Copy-on-select can now be disabled with env var. add OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT Dec 2, 2025
@rekram1-node rekram1-node merged commit 8c0690f into dev Dec 2, 2025
5 checks passed
github-actions bot pushed a commit that referenced this pull request Dec 2, 2025
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: rekram1-node <rekram1-node@users.noreply.github.com>
spmurrayzzz pushed a commit to spmurrayzzz/opencode that referenced this pull request Dec 5, 2025
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: rekram1-node <rekram1-node@users.noreply.github.com>
backgroundColor={theme.background}
onMouseUp={async () => {
if (Flag.OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT) {
renderer.clearSelection()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason the user selection is being cleared here? It prevents the user from copying it themselves, if desired.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants