{{ message }}
fix(clipboard): write OSC52 to /dev/tty instead of stdout#12129
Open
alse-sym wants to merge 2 commits into
Open
fix(clipboard): write OSC52 to /dev/tty instead of stdout#12129alse-sym wants to merge 2 commits into
alse-sym wants to merge 2 commits into
Conversation
Fixes clipboard copy failing in terminal multiplexers like Zellij, tmux, and screen. These tools intercept OSC52 escape sequences written to stdout but do not forward them to the outer terminal. Writing to /dev/tty (or SSH_TTY when connected via SSH) bypasses the multiplexer's PTY layer and sends OSC52 directly to the terminal emulator. Falls back to stdout if /dev/tty is unavailable (e.g., on Windows). Fixes anomalyco#12082 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
5 tasks
Contributor
|
Just wanted to flag that this PR also fixes a related issue with Zellij's auto-select-copy feature (see #14385). When |
Contributor
|
I'm seeing this issue too. Would be great to have it fixed. |
6 tasks
|
Also seeing this issue. When can we get a fix? |
Keep sync `fs` import for OSC52 /dev/tty writes; use `fs.promises.rm` for async cleanup; add Filesystem/Process/which imports from upstream. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
rjshrjndrn
added a commit
to rjshrjndrn/pi.nvim
that referenced
this pull request
Apr 2, 2026
OpenCode's clipboard.ts checks process.env.TMUX || process.env.STY and, when either is set, wraps its OSC 52 clipboard sequence in a DCS tmux passthrough frame (\x1bPtmux;\x1b...\x1b\). When OpenCode runs inside a Neovim terminal buffer that is itself inside tmux, those env vars are inherited. Neovim's libvterm does not handle the DCS frame cleanly: the nested \x1b]52;c;<base64> sequence gets routed back to OpenCode's stdin where Bubble Tea parses the OSC start (\x1b]) and leaves 52;c;<base64> as typed characters in the input area. Setting TMUX="" and STY="" in the termopen env makes the JS falsy check evaluate to false, so OpenCode emits a plain OSC 52 instead. libvterm handles plain OSC 52 via its clipboard callback without writing anything back to the child's stdin. OpenCode's native clipboard path (wl-copy / xclip / xsel) is unaffected. Upstream fix tracked at anomalyco/opencode#12129 (write OSC 52 to /dev/tty instead of stdout) - still open as of 2026-04-02.
6 tasks
3 tasks
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
/dev/ttyinstead ofstdoutto bypass terminal multiplexersSSH_TTYenvironment variable when connected via SSH/dev/ttyis unavailable (e.g., Windows)Problem
Clipboard copy fails in terminal multiplexers (Zellij, tmux, screen) because they intercept OSC52 sequences written to stdout and don't pass them through to the outer terminal.
Solution
Write directly to
/dev/ttywhich bypasses the multiplexer's PTY layer. This is how tools like lazygit and neovim handle clipboard operations in multiplexers.Fixes #12082
Test plan
🤖 Generated with Claude Code