Clipboard copy broken on macOS + WezTerm: appends instead of replacing, plays error sound #5247

Closed
opened 2026-02-16 17:50:29 -05:00 by yindo · 0 comments
Owner

Originally created by @naydenoff on GitHub (Jan 13, 2026).

Originally assigned to: @kommander on GitHub.

Environment

  • OpenCode version: 1.1.16
  • Terminal: WezTerm 20240203-110809-5046fc22
  • OS: macOS 15.5 (Sonoma)

Description

Copy/paste from OpenCode's TUI is broken in recent versions. The TUI selection feature (select text with mouse, release to copy) no longer works reliably.

Symptoms

  1. Appending instead of replacing clipboard: When selecting text, the clipboard content is appended to rather than replaced. Selecting two different lines results in both being concatenated in the clipboard.

  2. macOS "pew" error sound: The system alert sound plays when releasing the mouse selection, indicating a failed or rejected operation.

  3. Multiline selection is especially broken: Single-line selections sometimes work, but multiline selections consistently exhibit the append behavior.

  4. Cmd+C doesn't help: Holding the selection and pressing Cmd+C simultaneously still produces the same broken behavior.

Expected Behavior

  • Selecting text and releasing the mouse should copy ONLY the selected text to clipboard (replacing any previous content)
  • No system error sound should play
  • Cmd+C while selecting should work as a fallback

Workaround

Holding Shift while selecting bypasses OpenCode's TUI mouse handling and uses WezTerm's native selection. This works reliably but loses the OpenCode theme styling on the selection.

Analysis

This appears to be an issue with OpenCode's OSC 52 clipboard escape sequence handling. The append behavior and error sound suggest:

  • Malformed or duplicate OSC 52 sequences being sent
  • Possible conflict between OpenCode's clipboard writes and the terminal's handling

Reproduction Steps

  1. Run opencode in WezTerm on macOS
  2. Start a conversation so there's text to select
  3. Select a single line of text with the mouse and release
  4. Note: sometimes works, sometimes plays "pew" sound
  5. Select a different line of text
  6. Paste - observe BOTH selections are in clipboard (appended)

Additional Context

  • WezTerm config has no custom mouse_bindings (using defaults)
  • OpenCode config is standard, no special TUI settings
  • Issue started in recent OpenCode versions (not a fresh install issue)
Originally created by @naydenoff on GitHub (Jan 13, 2026). Originally assigned to: @kommander on GitHub. ## Environment - **OpenCode version**: 1.1.16 - **Terminal**: WezTerm 20240203-110809-5046fc22 - **OS**: macOS 15.5 (Sonoma) ## Description Copy/paste from OpenCode's TUI is broken in recent versions. The TUI selection feature (select text with mouse, release to copy) no longer works reliably. ## Symptoms 1. **Appending instead of replacing clipboard**: When selecting text, the clipboard content is *appended to* rather than *replaced*. Selecting two different lines results in both being concatenated in the clipboard. 2. **macOS "pew" error sound**: The system alert sound plays when releasing the mouse selection, indicating a failed or rejected operation. 3. **Multiline selection is especially broken**: Single-line selections sometimes work, but multiline selections consistently exhibit the append behavior. 4. **Cmd+C doesn't help**: Holding the selection and pressing Cmd+C simultaneously still produces the same broken behavior. ## Expected Behavior - Selecting text and releasing the mouse should copy ONLY the selected text to clipboard (replacing any previous content) - No system error sound should play - Cmd+C while selecting should work as a fallback ## Workaround Holding **Shift** while selecting bypasses OpenCode's TUI mouse handling and uses WezTerm's native selection. This works reliably but loses the OpenCode theme styling on the selection. ## Analysis This appears to be an issue with OpenCode's OSC 52 clipboard escape sequence handling. The append behavior and error sound suggest: - Malformed or duplicate OSC 52 sequences being sent - Possible conflict between OpenCode's clipboard writes and the terminal's handling ## Reproduction Steps 1. Run `opencode` in WezTerm on macOS 2. Start a conversation so there's text to select 3. Select a single line of text with the mouse and release 4. Note: sometimes works, sometimes plays "pew" sound 5. Select a different line of text 6. Paste - observe BOTH selections are in clipboard (appended) ## Additional Context - WezTerm config has no custom `mouse_bindings` (using defaults) - OpenCode config is standard, no special TUI settings - Issue started in recent OpenCode versions (not a fresh install issue)
yindo added the opentui label 2026-02-16 17:50:29 -05:00
yindo closed this issue 2026-02-16 17:50:29 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#5247