fix(clipboard): improve OSC 52 escape sequence for SSH compatibility#9008
Open
Son0fSun wants to merge 1 commit intoanomalyco:devfrom
Open
fix(clipboard): improve OSC 52 escape sequence for SSH compatibility#9008Son0fSun wants to merge 1 commit intoanomalyco:devfrom
Son0fSun wants to merge 1 commit intoanomalyco:devfrom
Conversation
Fix clipboard operations not working over SSH by improving the OSC 52 escape sequence implementation with proper terminal multiplexer support. ## Problems Fixed 1. **BEL vs ST terminator**: Changed from BEL (\x07) to ST (\x1b\\) for better compatibility. Some terminals don't handle BEL correctly inside DCS passthrough sequences. 2. **GNU Screen passthrough**: Fixed incorrect format - Screen uses DCS without the `tmux;` prefix that was being applied to both. - Before: `\x1bPtmux;\x1b<seq>\x1b\\` (wrong for Screen) - After: `\x1bP<seq>\x1b\\` (correct for Screen) 3. **Nested tmux sessions**: Added detection of tmux nesting level via comma count in TMUX env var, doubling escapes for each level. ## Technical Details OSC 52 format: ESC ] 52 ; c ; <base64> ST Passthrough wrapping: - tmux: `ESC P tmux; ESC ESC <seq> ESC \` - screen: `ESC P ESC ESC <seq> ESC \` The escape characters must be doubled inside DCS sequences so they pass through to the outer terminal emulator. ## Supported Terminals - iTerm2, Kitty, Alacritty, Windows Terminal - tmux (including nested sessions) - GNU Screen - Most modern terminal emulators Fixes: anomalyco#6111 Fixes: anomalyco#2773 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one potentially related PR: PR #7028: fix(clipboard): add OSC 52 fallback for SSH/tmux environments This PR appears to address similar issues with OSC 52 clipboard functionality in SSH and tmux environments. You should check if this PR was already merged or if it's still open, as it may cover some or all of the same fixes being proposed in PR #9008. |
Contributor
|
this should be resolved in by #8974 |
|
Can we just get an option to disable the clipboard outright so that we can use the normal right click copy and paste? |
Contributor
|
that was built -> OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT |
00637c0 to
71e0ba2
Compare
f1ae801 to
08fa7f7
Compare
4 tasks
5 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
Problem
Clipboard copy operations fail when running OpenCode over SSH. The existing OSC 52 implementation had several issues:
\x07) terminator which some terminals don't handle correctly inside DCS sequencestmux;prefix) to GNU Screen, which uses a different formatFixes #6111
Fixes #2773
Solution
1. BEL → ST Terminator
ST (String Terminator) is more reliably handled inside DCS passthrough sequences.
2. Correct GNU Screen Format
3. Nested tmux Support
Detect nesting level from TMUX environment variable (comma-separated) and double escapes for each level:
Supported Environments
Test plan
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com