Skip to content

Bug: OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT clears selection on Ctrl/Cmd+C instead of copying #27058

Description

@astron8t-voyagerx

Description

When OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=true, drag-selecting text and then pressing Ctrl/Cmd+C does not copy — it clears the selection. On macOS the keyboard shortcut never copies; on terminals using the Kitty Keyboard Protocol (Ghostty, Kitty, WezTerm), Cmd+C reaches the app but is silently swallowed.

Root cause is in packages/opencode/src/cli/cmd/tui/util/selection.ts:

  • handleSelectionKey only matches event.ctrl && event.name === "c". It does not handle event.meta (xterm modifier 32) or event.super (Kitty Keyboard Protocol modifier bit 8, which is what macOS Cmd maps to in fromKittyMods).
  • When the match fails and the focused renderable has no inner selection, the function falls through to renderer.clearSelection(), actively wiping the highlight.

Note: opencode enables Kitty Keyboard Protocol explicitly (useKittyKeyboard: {} in app.tsx), so on supporting terminals Cmd+C does reach the app — it's just not recognized.

This is a follow-up bug to PR #4996 (which introduced the flag). Reports of the same behavior live in the #4751 thread (andy-blum's Scenario 2, mhrf's note that Ctrl+C works in Ghostty but Cmd+C does not).

Steps to reproduce

  1. OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=true opencode in Ghostty on macOS
  2. Drag-select any text in the TUI
  3. Press Cmd+C
  4. Expected: text copied to clipboard, selection cleared by the copy action
  5. Actual: nothing copied, selection wiped without copying

Operating System

macOS 26 (Darwin 25.4.0)

OpenCode version

1.14.48

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions