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 escape sequence handling into a single writeOsc52() function within Clipboard.copy(), eliminating code duplication across three UI components. This ensures consistent clipboard support over SSH connections and in terminal multiplexers.

  • Removed 20 lines of duplicate OSC 52 code from app.tsx, dialog.tsx, and session/index.tsx
  • Added centralized writeOsc52() function with TTY check (process.stdout.isTTY)
  • Added GNU Screen support via STY environment variable (in addition to existing TMUX support)
  • Both tmux and GNU Screen use the same DCS passthrough wrapper format
  • Added JSDoc documentation explaining the purpose of OSC 52
  • All copy operations (text selection, copy last message, copy transcript) now consistently use OSC 52

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Clean refactoring that centralizes duplicate code into a single well-documented function. The implementation correctly handles TTY detection, tmux/screen passthrough, and maintains backward compatibility. All duplicate OSC 52 blocks removed cleanly.
  • No files require special attention

Important Files Changed

Filename Overview
packages/opencode/src/cli/cmd/tui/util/clipboard.ts Added centralized writeOsc52() function with TTY check, JSDoc, and tmux/screen support
packages/opencode/src/cli/cmd/tui/app.tsx Removed duplicate OSC 52 code from two locations, now delegates to Clipboard.copy()
packages/opencode/src/cli/cmd/tui/ui/dialog.tsx Removed duplicate OSC 52 code, now delegates to Clipboard.copy()
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx Removed duplicate OSC 52 code, now delegates to Clipboard.copy()

Sequence Diagram

sequenceDiagram
    participant User
    participant UI as UI Component
    participant Clipboard as Clipboard.copy()
    participant OSC52 as writeOsc52()
    participant Terminal as Terminal Emulator
    
    User->>UI: Select text and trigger copy
    UI->>Clipboard: Clipboard.copy(text)
    Clipboard->>OSC52: writeOsc52(text)
    
    alt TTY detected
        alt In tmux or screen
            OSC52->>Terminal: Write DCS passthrough wrapper
        else Direct terminal
            OSC52->>Terminal: Write OSC 52 sequence
        end
        Terminal->>Terminal: Set local clipboard
    else Non-TTY
        Note over OSC52: Skip OSC 52 output
    end
    
    Clipboard->>Clipboard: Call platform copy method
    Clipboard-->>UI: Return success or error
    UI->>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".

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.

1 participant