Skip to content

Conversation

@shuv1337
Copy link
Collaborator

@shuv1337 shuv1337 commented Jan 18, 2026

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

  • Centralized OSC 52 clipboard handling into a single utility module (clipboard.ts)
  • Removed duplicate OSC 52 write calls from app.tsx, session/index.tsx, and dialog.tsx
  • Cleaned up bun.lock dependency tree

Infrastructure

  • Release v1.1.23

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:

  • Adds writeOsc52() helper with TTY check, JSDoc documentation, and proper base64 encoding
  • Implements multiplexer passthrough for both tmux and GNU Screen with their respective DCS formats
  • Maintains backward compatibility - OSC 52 now runs before platform-specific clipboard methods
  • Cleans up bun.lock dependency tree

Technical verification:

  • GNU Screen passthrough format \x1bP${osc52}\x1b\\ is correct (does not require tmux's protocol prefix or ESC doubling)
  • All copy operations (text selection, Ctrl+X Y, session transcript) now benefit from SSH clipboard support
  • No breaking changes to existing clipboard functionality

Confidence Score: 5/5

  • Safe to merge - well-executed refactoring with proper centralization and no functional changes
  • This is a clean refactoring that eliminates code duplication without changing behavior. The OSC 52 implementation is technically correct for both tmux and GNU Screen multiplexers. All duplicate code has been properly removed and centralized. The changes are purely additive to the clipboard utility and subtractive from UI components, reducing maintenance burden.
  • No files require special attention

Important Files Changed

Filename Overview
packages/opencode/src/cli/cmd/tui/util/clipboard.ts Added writeOsc52() helper with TTY check, base64 encoding, and multiplexer passthrough support for tmux and GNU Screen
packages/opencode/src/cli/cmd/tui/app.tsx Removed duplicate OSC 52 code blocks from two copy handlers, now delegates to centralized Clipboard.copy()
packages/opencode/src/cli/cmd/tui/ui/dialog.tsx Removed duplicate OSC 52 code from dialog mouse selection handler
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx Removed duplicate OSC 52 code from copy last message handler

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
Loading

@shuv1337 shuv1337 merged commit 9ce3153 into integration Jan 18, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants