-
Notifications
You must be signed in to change notification settings - Fork 3
fix: centralize OSC 52 clipboard support for SSH sessions #303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: centralize OSC 52 clipboard support for SSH sessions #303
Conversation
…lity (anomalyco#8658) Co-authored-by: Mark Henderson <[email protected]> Co-authored-by: Aiden Cline <[email protected]>
Co-authored-by: Bot <[email protected]>
This reverts commit f4086ac.
…co#8678) Signed-off-by: assagman <[email protected]>
…co#7681) Co-authored-by: Aiden Cline <[email protected]>
Co-authored-by: Github Action <[email protected]>
…info as to current date
This reverts commit 88fd6a2.
Co-authored-by: Leka74 <[email protected]> Co-authored-by: Leka74 <[email protected]>
…anomalyco#8944)" This reverts commit 8fd1b92.
|
Closing in favor of a cleaner PR based on shuvcode's integration branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
124 files reviewed, 1 comment
| const osc52 = `\x1b]52;c;${base64}\x07` | ||
| // tmux and screen require DCS passthrough wrapping | ||
| const passthrough = process.env["TMUX"] || process.env["STY"] | ||
| const sequence = passthrough ? `\x1bPtmux;\x1b${osc52}\x1b\\` : osc52 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: uses tmux DCS passthrough for both tmux and GNU Screen, but Screen requires \x1bP\x1b${osc52}\x1b\\ (without "tmux;")
| const sequence = passthrough ? `\x1bPtmux;\x1b${osc52}\x1b\\` : osc52 | |
| const sequence = process.env["TMUX"] ? `\x1bPtmux;\x1b${osc52}\x1b\\` : process.env["STY"] ? `\x1bP\x1b${osc52}\x1b\\` : osc52 |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/opencode/src/cli/cmd/tui/util/clipboard.ts
Line: 19:19
Comment:
**logic:** uses tmux DCS passthrough for both tmux and GNU Screen, but Screen requires `\x1bP\x1b${osc52}\x1b\\` (without "tmux;")
```suggestion
const sequence = process.env["TMUX"] ? `\x1bPtmux;\x1b${osc52}\x1b\\` : process.env["STY"] ? `\x1bP\x1b${osc52}\x1b\\` : osc52
```
How can I resolve this? If you propose a fix, please make it concise.
Summary
Clipboard.copy()so all clipboard operations work over SSHapp.tsx,dialog.tsx, andsession/index.tsxResolves anomalyco#2773
Changes
clipboard.tswriteOsc52()with JSDoc, TTY check, tmux/screen passthroughapp.tsxdialog.tsxsession/index.tsxTesting
Verified locally:
Ctrl+X Y)Also submitted as anomalyco/opencode#8974
Greptile Summary
Centralizes OSC 52 escape sequence handling in
Clipboard.copy()to enable clipboard operations over SSH for all clipboard operations in the TUI. The implementation adds a newwriteOsc52()function with TTY detection, Base64 encoding, and DCS passthrough wrapping for tmux/screen.Key changes:
writeOsc52()function inclipboard.tswith JSDoc, TTY check (process.stdout.isTTY), and automatic tmux/screen DCS passthrough detectionapp.tsx(2 locations),dialog.tsx, andsession/index.tsxIssues found:
Confidence Score: 4/5
clipboard.ts:19- the GNU Screen passthrough needs correctionImportant Files Changed
writeOsc52()function with TTY check, tmux/screen DCS passthrough wrappingSequence Diagram
sequenceDiagram participant User participant App as app.tsx/dialog.tsx/session participant Clipboard as Clipboard.copy() participant WriteOsc52 as writeOsc52() participant Terminal as Terminal Emulator participant OS as OS Clipboard User->>App: Select text & copy App->>Clipboard: Clipboard.copy(text) Clipboard->>WriteOsc52: writeOsc52(text) alt is TTY WriteOsc52->>WriteOsc52: Base64 encode text WriteOsc52->>WriteOsc52: Build OSC 52 sequence alt TMUX or STY env set WriteOsc52->>WriteOsc52: Wrap with DCS passthrough end WriteOsc52->>Terminal: Write escape sequence to stdout Terminal->>OS: Copy to local clipboard else not TTY WriteOsc52-->>Clipboard: Return (skip OSC 52) end Clipboard->>Clipboard: getCopyMethod() Clipboard->>OS: Platform-specific copy (osascript/wl-copy/xclip/etc)