Skip to content

Conversation

@wonderflow
Copy link

@wonderflow wonderflow commented Jan 6, 2026

Problem

Clipboard copy operations (e.g., Ctrl+X Y to copy assistant message) silently fail when running opencode over SSH or in tmux on a remote Linux server without X11/Wayland display.

Root cause: The fallback path uses clipboardy, which relies on xsel/xclip and requires a local display ($DISPLAY or $WAYLAND_DISPLAY). In headless SSH/tmux environments, these tools aren't available or don't work, causing clipboard operations to fail silently.

Solution

Add OSC 52 escape sequence support as a fallback when clipboardy fails.
OSC 52 is a terminal escape sequence standard that allows applications to set the system clipboard through the terminal emulator. It's supported by:

  • iTerm2
  • kitty
  • Alacritty
  • Windows Terminal
  • tmux (with set-clipboard option)
  • Many other modern terminal emulators

Changes

  • Added copyViaOSC52() function that sends OSC 52 escape sequences
  • Handles tmux passthrough wrapping when $TMUX is set
  • Modified fallback logic: try clipboardy first → fall back to OSC 52 on failure

Behavior

Environment Before After
macOS local osascript ✅ osascript ✅ (unchanged)
Linux + X11/Wayland xclip/xsel/wl-copy ✅ xclip/xsel/wl-copy ✅ (unchanged)
Windows powershell ✅ powershell ✅ (unchanged)
SSH/tmux (no display) clipboardy ❌ (silent fail) clipboardy → OSC 52 ✅

No breaking changes - existing behavior preserved for all native clipboard methods.

Testing

  1. SSH into a remote Linux server
  2. Run opencode in tmux with iTerm2 integration
  3. Get a response from the assistant
  4. Press Ctrl+X Y to copy the assistant's message
  5. Cmd+V on local machine to verify clipboard content

Prerequisite

  • Enable "Applications in terminal may access clipboard" in iTerm2 Preferences → General → Selection

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

The following comment was made by an LLM, it may be inaccurate:

Results

No duplicates found.

The search for the current PR (7028: "fix(clipboard): add OSC 52 fallback for SSH/tmux environments") returned only the PR itself.

While there are other clipboard-related PRs in the repository:

These are addressing different clipboard issues and platforms, not the same SSH/tmux OSC 52 fallback feature being implemented in PR #7028.

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.

1 participant