fix: centralize OSC 52 clipboard support for SSH sessions #309
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
Merges PR #304 which centralizes OSC 52 clipboard support for SSH sessions, resolving issue anomalyco#2773. Also includes release v1.1.23.
Changes
Fixes
clipboard.ts)app.tsx,session/index.tsx, anddialog.tsxInfrastructure
Breaking Changes
None
Testing
Existing tests cover changes. Manual testing recommended for SSH clipboard operations.
Greptile Summary
Excellent refactoring that centralizes OSC 52 clipboard handling into
Clipboard.copy(), enabling clipboard operations over SSH sessions. Removes 20 lines of duplicate OSC 52 code from three UI components (app.tsx,dialog.tsx,session/index.tsx).Key improvements:
writeOsc52()helper with TTY check, JSDoc documentation, and proper base64 encodingTechnical verification:
\x1bP${osc52}\x1b\\is correct (does not require tmux's protocol prefix or ESC doubling)Confidence Score: 5/5
Important Files Changed
writeOsc52()helper with TTY check, base64 encoding, and multiplexer passthrough support for tmux and GNU ScreenClipboard.copy()Sequence Diagram
sequenceDiagram participant User participant UI as UI Component participant Clipboard as Clipboard.copy() participant OSC52 as writeOsc52() participant Terminal User->>UI: Select text and copy UI->>Clipboard: Clipboard.copy(text) Clipboard->>OSC52: writeOsc52(text) alt isTTY check passes OSC52->>OSC52: Encode to base64 OSC52->>OSC52: Build OSC 52 sequence alt TMUX detected OSC52->>Terminal: Write tmux DCS passthrough else STY detected OSC52->>Terminal: Write screen DCS passthrough else No multiplexer OSC52->>Terminal: Write raw OSC 52 end end Clipboard->>Clipboard: getCopyMethod() alt macOS Clipboard->>Terminal: Execute osascript else Linux Wayland Clipboard->>Terminal: Execute wl-copy else Linux X11 Clipboard->>Terminal: Execute xclip or xsel else Windows Clipboard->>Terminal: Execute powershell else Fallback Clipboard->>Terminal: Use clipboardy library end Clipboard-->>UI: Return success or error UI->>User: Show toast notification