Skip to content

Conversation

@b3nw
Copy link

@b3nw b3nw commented Jan 16, 2026

Summary

  • Centralizes OSC 52 escape sequence handling in Clipboard.copy() so all clipboard operations work over SSH
  • Removes duplicate OSC 52 code from app.tsx, dialog.tsx, and session/index.tsx
  • Adds TTY check, JSDoc documentation, and GNU Screen support

Resolves anomalyco#2773

Changes

File Change
clipboard.ts +16 lines: writeOsc52() with JSDoc, TTY check, tmux/screen passthrough
app.tsx -10 lines: removed duplicate OSC 52 blocks
dialog.tsx -5 lines: removed duplicate OSC 52 block
session/index.tsx -5 lines: removed duplicate OSC 52 block

Testing

Verified locally:

  • ✅ Text selection copy (local terminal)
  • ✅ Copy last message (Ctrl+X Y)
  • ✅ Copy session transcript
  • ✅ Clipboard works over SSH
  • ✅ Clipboard works in tmux

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:

  • Added writeOsc52() helper with TTY check and JSDoc documentation
  • Removed 20 lines of duplicate OSC 52 code from app.tsx, dialog.tsx, and session/index.tsx
  • Added support for tmux and GNU Screen multiplexer passthrough

Issue found:

  • GNU Screen passthrough uses tmux's DCS format instead of Screen's specific format, which will prevent clipboard from working in Screen sessions

Confidence Score: 4/5

  • Safe to merge with one logic fix needed for GNU Screen support
  • The refactoring successfully centralizes OSC 52 logic and removes code duplication. However, the GNU Screen passthrough sequence uses the tmux format instead of Screen's specific DCS format, which will prevent clipboard from working correctly in GNU Screen sessions.
  • Pay attention to packages/opencode/src/cli/cmd/tui/util/clipboard.ts - the Screen passthrough needs correction

Important Files Changed

Filename Overview
packages/opencode/src/cli/cmd/tui/util/clipboard.ts Centralized OSC 52 implementation with TTY check and multiplexer support; GNU Screen passthrough uses tmux sequence instead of DCS

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
Loading

@greptile-apps
Copy link

greptile-apps bot commented Jan 16, 2026

Greptile's behavior is changing!

From now on, if a review finishes with no comments, we will not post an additional "statistics" comment to confirm that our review found nothing to comment on. However, you can confirm that we reviewed your changes in the status check section.

This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR".

@shuv1337
Copy link
Collaborator

Merged via #308

@shuv1337 shuv1337 closed this Jan 17, 2026
@shuv1337 shuv1337 reopened this Jan 17, 2026
@shuv1337 shuv1337 changed the base branch from integration to shuvcode-dev January 17, 2026 22:45
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@b3nw b3nw force-pushed the fix/issue-2773-osc52-shuvcode branch from d0a63f5 to 97b3ff7 Compare January 17, 2026 22:53
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.

clipboard copy not works in remote SSH console.

2 participants