My setup: from my Mac I ssh into a Linux box, run tmux there, and surface opencode (an AI coding TUI) through display-popup. It kept reporting “Copied to clipboard” — yet prefix ] pasted nothing and tmux show-buffer was empty.
The cause
opencode detects tmux via the $TMUX env var and wraps its OSC 52 clipboard escape in tmux’s passthrough sequence (\ePtmux;…\e\\). Passthrough tells tmux: don’t interpret this, forward it verbatim to the outer terminal. So tmux never parses it as a clipboard request, and never creates a buffer.
That’s a sensible default — passthrough guarantees the copy reaches your real terminal’s clipboard no matter how tmux is configured, which is what most people want. neovim and vim do the same thing. The cost is that tmux’s own paste buffer stays empty.
ssh isn’t the cause, but the stack complicates it
ssh is a transparent byte pipe; it carries OSC 52 untouched and is never the problem. What complicates things is the rest of the stack. The popup runs a nested tmux attach, so the opencode session is viewed by an inner tmux client, behind an overlay, behind ssh. And display-popup is an overlay, not a pane — tmux doesn’t forward OSC 52 out of an overlay. So even the system clipboard fails in the popup: anything copied there is sealed in, reaching neither the buffer nor the terminal.
The whole path
flowchart TD
OC["opencode copies text"] --> Q{"Is $TMUX set?"}
Q -->|"yes — default"| W["Wrap OSC 52 in tmux passthrough"]
Q -->|"no — env -u TMUX"| P["Plain OSC 52"]
W --> FWD["tmux forwards verbatim, never parses"]
FWD --> NB["No tmux buffer"]
P --> CAP["tmux captures it (set-clipboard on)"]
CAP --> BUF["tmux buffer — prefix ] works"]
CAP --> VC{"Who's viewing the session?"}
VC -->|"regular pane"| MAC["System clipboard — over ssh, transparently"]
VC -->|"display-popup"| DEAD["Overlay seals it — no system clipboard"]
classDef ok fill:#163,stroke:#2a8,color:#fff
classDef bad fill:#611,stroke:#a33,color:#fff
class BUF,MAC ok
class NB,DEAD bad
The fix
Start opencode without $TMUX:
|
|
opencode now thinks it’s on a bare terminal and emits plain OSC 52. tmux captures it: with set-clipboard on you get a paste buffer, and in a normal pane tmux also forwards it to the system clipboard.
tmux re-injects $TMUX into every pane it spawns, so strip it on the command itself — not in the surrounding shell — including inside any new-session / display-popup keybinding.
The catch
Inside the popup you’ll still get only the tmux buffer, never the system clipboard — the overlay seal blocks outbound OSC 52 regardless. If you need the system clipboard, run opencode in a normal window instead.
The trade, in one line: default opencode gives you a config-independent system clipboard; unsetting $TMUX swaps it for a tmux buffer that depends on your tmux config.