Skip to content

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

Closed

Description

@naydenoff

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)

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Jan 13, 2026
  2. github-actions commented on Jan 13, 2026

    @github-actions
    Contributor

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

    These issues suggest a broader clipboard handling problem affecting multiple platforms (macOS, Windows, Linux) and terminals (WezTerm, Windows Terminal, MobaXterm). Your specific OSC 52 sequence issue on macOS + WezTerm might be the root cause affecting all platforms.

    Feel free to ignore if your issue has specific differences from these.

  3. naydenoff commented on Jan 13, 2026

    @naydenoff
    Author

    Closing as duplicate of #4283. The root cause appears to be the same: broken OSC 52 clipboard handling. Adding my findings to that issue.

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

Metadata

Metadata

Assignees

Labels

opentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions