Skip to content

fix(tui): copy selection on Cmd+C when copy-on-select is disabled#27059

Open
astron8t-voyagerx wants to merge 1 commit into
anomalyco:devfrom
astron8t-voyagerx:fix/cmd-c-copy-on-select-disabled
Open

fix(tui): copy selection on Cmd+C when copy-on-select is disabled#27059
astron8t-voyagerx wants to merge 1 commit into
anomalyco:devfrom
astron8t-voyagerx:fix/cmd-c-copy-on-select-disabled

Conversation

@astron8t-voyagerx
Copy link
Copy Markdown

@astron8t-voyagerx astron8t-voyagerx commented May 12, 2026

Issue for this PR

Closes #27058

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

In handleSelectionKey (packages/opencode/src/cli/cmd/tui/util/selection.ts), the copy shortcut only matched event.ctrl. opencode enables the Kitty Keyboard Protocol (useKittyKeyboard: {} in app.tsx), so macOS Cmd+C reaches the app as event.super — but no branch matched, and the function fell through to renderer.clearSelection(), wiping the highlight without copying.

Fix: accept meta and super in addition to ctrl. The SelectionKeyEvent type is widened to mirror the actual KeyEvent shape from @opentui/core/lib/KeyHandler.

Follow-up to #4996, which introduced the flag.

How did you verify your code works?

  • Traced the key path: parseKittyKeyboard sets key.super = true when Cmd is held (modifier bit 8 in fromKittyMods). The widened condition matches it.
  • Monorepo typecheck passes (pre-push hook ran bun turbo typecheck — 14/14 successful).
  • Manual TUI test on Ghostty / macOS with OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1: drag-select → Cmd+C copies to clipboard and shows the "Copied to clipboard" toast. Ctrl+C still works (no regression). Without the env var, the existing copy-on-select behavior is unchanged.
  • Note: terminals that don't forward Cmd+C (Terminal.app, Warp, etc.) are unaffected by this change — that's a terminal-side limitation outside this PR's scope.

Screenshots / recordings

N/A — not a visual change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

handleSelectionKey only matched event.ctrl, so on macOS with Kitty
Keyboard Protocol (Ghostty, Kitty, WezTerm) Cmd+C arrived as
event.super and fell through to renderer.clearSelection(), wiping the
highlight without copying. Accept meta and super in addition to ctrl.

Fixes anomalyco#27058

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels May 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

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

1 participant