Repository navigation
Description
Summary
Copying from the OpenCode TUI silently fails to reach the system clipboard when OpenCode runs inside tmux. The root cause is in OpenTUI (anomalyco/opentui, the TUI toolkit OpenCode's terminal UI is built on), not in tmux: OpenTUI wraps its OSC 52 clipboard write in a tmux DCS passthrough escape, which tmux (3.3+) silently drops unless allow-passthrough is enabled. A plain (unwrapped) OSC 52 works fine through tmux's set-clipboard on path, so wrapping the clipboard write appears to be counterproductive.
Environment
- opencode version: 2.1.4 (latest)
- OS: Linux x86_64 (7.2.9-x64v3-xanmod1)
- Terminal: WezTerm (OSC 52-capable) → tmux 3.4 (
TERM=tmux-256colorinside); tmux reportsclient_termfeaturesincludesclipboard - Shell: /bin/bash
- Install/channel: npm (
@opencode/cli), release - Active plugins:
@slkiser/opencode-quota@latest - tmux config:
set -g set-clipboard on;allow-passthroughleft at its default (off)
Reproduction
-
Start tmux 3.4 with default options plus
set -g set-clipboard on, inside an OSC 52-capable terminal. -
Sanity-check the clipboard chain from a shell pane — this works:
printf '\033]52;c;%s\033\\' "$(printf 'hello' | base64)"
Pasting into a GUI app yields
hello. ✔ -
In the OpenCode TUI, copy something:
<leader>y(messages.copy, leader defaults toctrl+x), or select text (copy-on-select is the defaultterminal.copymode). -
Paste into a GUI app → nothing is pasted. No tmux paste buffer is created either.
Reproducible consistently.
Expected Behavior
Copy (messages.copy, copy-on-select) puts the text on the system clipboard when running inside tmux with set-clipboard on and an OSC 52-capable outer terminal — the plain-OSC 52 test above proves the chain works.
Actual Behavior
The copy action completes without any error, but the clipboard is unchanged.
Root cause: when OpenTUI detects tmux, Terminal.writeClipboard() wraps the OSC 52 sequence in a tmux DCS passthrough (ESC Ptmux; <ESC-doubled OSC 52> ESC \) instead of emitting it plainly — see writeClipboard in opentui packages/core/src/zig/terminal.zig. tmux ≥ 3.3 silently discards passthrough sequences unless allow-passthrough is enabled, so the write never reaches the outer terminal.
Additional Context
- Setting
set -s allow-passthrough onin~/.tmux.conffixes it (verified). But every tmux layer must opt in, and the failure mode is completely silent —clipboard.tswrite()reports success when the terminal destination status is merely"attempted". - Since a plain OSC 52 works through tmux's
set-clipboard on(tmux forwards it to the outer terminal itself), consider not wrapping clipboard writes for tmux, or documenting theallow-passthroughrequirement. - The host-clipboard fallback (xclip/wl-copy) doesn't help in SSH panes without a display, which is where this bites most.
- Nested tmux (e.g. opencode inside tmux on a remote host inside local tmux): OpenTUI wraps only a single level, so each layer needs the right option even with the workaround.
Activity
opencode-agent commentedon Oct 26, 2026
Thanks for the detailed write-up and root-cause analysis! I think this is a duplicate of #50208. That issue reports the same thing on v2: inside tmux with
allow-passthroughoff, copying shows success but the outer clipboard never changes, and comments there also confirm thatset -s allow-passthrough onworks around it.Possible duplicates and related issues, ordered from most to least likely:
allow-passthrough offon v2, and enabling passthrough fixes it.allow-passthroughis off), closed as stale.Your findings would be very useful on #50208: OpenTUI's
writeClipboardwraps the OSC 52 write in a DCS passthrough, plain OSC 52 works throughset-clipboard on, andclipboard.tscounts"attempted"as success. Please consider adding them there.The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.
opencode-agent commentedon Oct 27, 2026
We haven't heard back, so I'm closing this as a duplicate of #50208. It covers the same problem: inside tmux with
allow-passthroughoff, copying in the TUI silently fails to reach the outer clipboard. Please follow that issue for updates. Your root-cause notes would be a helpful addition there: OpenTUI'swriteClipboardwraps OSC 52 in a tmux DCS passthrough, a plain OSC 52 works throughset-clipboard on, andclipboard.tscounts"attempted"as success. Until it's fixed,set -s allow-passthrough onworks around it.If your problem turns out to be different from #50208, reply here and explain how. Thanks again for the thorough report!