[BUG] Explicit copy (ctrl+c) emits the same OSC 52 clipboard write twice → duplicate clipboard-manager entries and terminal toasts

Open 💬 0 comments Opened Jul 4, 2026 by Martini991

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Copying a mouse selection in the fullscreen TUI with ctrl+c writes the selection to the clipboard via OSC 52 twice, with byte-identical payloads. Terminals that notify on clipboard writes (e.g. ghostty's "Copied to clipboard" toast) show two notifications per copy, and clipboard history managers record duplicate entries.

This is not the "OSC 52 + pbcopy/xclip dual mechanism" suggested in #41954's analysis: the environment below is a container with no xclip/xsel/wl-copy/pbcopy installed, and the duplicate writes were captured on the pane's own output stream (tmux pipe-pane, i.e. raw Claude Code output before the multiplexer processes it) — both writes are OSC 52 sequences emitted by Claude Code on the same tty.

What Should Happen?

Exactly one OSC 52 write per explicit copy action.

Error Messages/Logs

$ tmux pipe-pane -t %0 'cat > /tmp/out.raw'   # capture pane output
# ... select text with mouse, press ctrl+c, then stop the pipe ...
$ grep -o $'\x1b]52;[a-zA-Z]*;[A-Za-z0-9+/=]*' /tmp/out.raw | awk '{print length($0)}' | sort | uniq -c
      2 975
# two OSC 52 writes, identical length; diffing the two extracted sequences shows identical base64 payloads
$ command -v xclip xsel wl-copy pbcopy
# (no output — none installed)

Steps to Reproduce

  1. Run Claude Code (fullscreen TUI) inside tmux, in a terminal that notifies on OSC 52 clipboard writes (ghostty with default app-notifications).
  2. Start a pane-output capture: tmux pipe-pane -t <pane> 'cat > /tmp/out.raw'.
  3. Drag-select some text in the TUI, press ctrl+c once.
  4. Stop the capture and count OSC 52 sequences in /tmp/out.raw (command above): 2 identical writes appear for the single copy. The terminal shows two "Copied to clipboard" toasts.

Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.201 (Claude Code)

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Other

Additional Information

  • Environment: Debian trixie rootless-podman container; outer terminal ghostty 1.3.1 (Pop!\_OS host); tmux 3.6b between them; TERM=tmux-256color inside.
  • tmux is not amplifying the count: with set-clipboard external (tmux's default, pure 1:1 forwarding) the toast count matches the two captured pane writes. (With set-clipboard on tmux adds a third write by re-emitting the buffer, which is tmux behavior, not Claude Code's.)
  • Related but distinct: #41954 (selection re-synced to clipboard on every render during streaming). During this investigation the per-render writes were also observed to be doubled (identical payload pairs), suggesting the same duplicated emit path.
  • copyOnSelect is false; the duplication happens on the explicit ctrl+c copy.

View original on GitHub ↗