fix: centralize OSC 52 clipboard support for SSH sessions #304
+38
−61
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
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 clipboard escape sequence handling into
Clipboard.copy()to enable clipboard operations over SSH, removing duplicate code from three UI components.Key improvements:
writeOsc52()helper with TTY check and JSDoc documentationapp.tsx,dialog.tsx, andsession/index.tsxIssue found:
Confidence Score: 4/5
packages/opencode/src/cli/cmd/tui/util/clipboard.ts- the Screen passthrough needs correctionImportant Files Changed
Sequence Diagram
sequenceDiagram participant User participant App/Dialog/Session as UI Component participant Clipboard participant Terminal User->>UI Component: Select text & trigger copy UI Component->>Clipboard: Clipboard.copy(text) Clipboard->>Clipboard: writeOsc52(text) alt isTTY Clipboard->>Clipboard: Encode text to base64 Clipboard->>Clipboard: Build OSC 52 sequence alt TMUX detected Clipboard->>Terminal: Write tmux DCS passthrough else STY detected Clipboard->>Terminal: Write screen DCS passthrough else No multiplexer Clipboard->>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/xsel else Windows Clipboard->>Terminal: Execute powershell Set-Clipboard else Fallback Clipboard->>Terminal: Use clipboardy library end Clipboard-->>UI Component: Success/Error UI Component->>User: Show toast notification