Clipboard copy broken in terminals without OSC52 support #8447

Closed
opened 2026-02-16 18:09:59 -05:00 by yindo · 2 comments
Owner

Originally created by @MartinWie on GitHub (Feb 3, 2026).

Originally assigned to: @rekram1-node on GitHub.

Problem

After #11744 introduced OSC52 clipboard support, clipboard copy stopped working in terminals that don't have OSC52 enabled.

The issue is in packages/opencode/src/cli/cmd/tui/util/clipboard.ts:

const copied = renderer.copyToClipboardOSC52(text)
if (copied) return  // <-- early return skips native clipboard

copyToClipboardOSC52() returns true after writing the escape sequence, but the terminal may not actually support or process OSC52. The early return skips the native fallback (osascript on macOS, xclip on Linux).

Steps to Reproduce

  1. Use a terminal with OSC52 disabled (e.g., iTerm2 without "Applications in terminal may access clipboard")
  2. Try to copy text in OpenCode (e.g., <leader>y)
  3. Clipboard is empty

Expected Behavior

Clipboard copy should work regardless of OSC52 support by always falling back to native methods.

Environment

  • macOS with iTerm2
  • OSC52 disabled in terminal settings
Originally created by @MartinWie on GitHub (Feb 3, 2026). Originally assigned to: @rekram1-node on GitHub. ## Problem After #11744 introduced OSC52 clipboard support, clipboard copy stopped working in terminals that don't have OSC52 enabled. The issue is in `packages/opencode/src/cli/cmd/tui/util/clipboard.ts`: ```typescript const copied = renderer.copyToClipboardOSC52(text) if (copied) return // <-- early return skips native clipboard ``` `copyToClipboardOSC52()` returns `true` after writing the escape sequence, but the terminal may not actually support or process OSC52. The early return skips the native fallback (osascript on macOS, xclip on Linux). ## Steps to Reproduce 1. Use a terminal with OSC52 disabled (e.g., iTerm2 without "Applications in terminal may access clipboard") 2. Try to copy text in OpenCode (e.g., `<leader>y`) 3. Clipboard is empty ## Expected Behavior Clipboard copy should work regardless of OSC52 support by always falling back to native methods. ## Environment - macOS with iTerm2 - OSC52 disabled in terminal settings
yindo added the opentui label 2026-02-16 18:09:59 -05:00
yindo closed this issue 2026-02-16 18:09:59 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 3, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #11909: OSC52 clipboard doesn't work with VS Code Remote SSH - need fallback or detection
  • #2773: clipboard copy not works in remote SSH console

Both issues relate to clipboard copy failures when OSC52 is not available or not working. The root cause appears to be similar: the early return after copyToClipboardOSC52() succeeds skips native clipboard fallbacks, leaving users without a working clipboard solution.

Feel free to ignore if your specific case is different, but these issues likely share the same underlying problem and solution.

@github-actions[bot] commented on GitHub (Feb 3, 2026): This issue might be a duplicate of existing issues. Please check: - #11909: OSC52 clipboard doesn't work with VS Code Remote SSH - need fallback or detection - #2773: clipboard copy not works in remote SSH console Both issues relate to clipboard copy failures when OSC52 is not available or not working. The root cause appears to be similar: the early return after `copyToClipboardOSC52()` succeeds skips native clipboard fallbacks, leaving users without a working clipboard solution. Feel free to ignore if your specific case is different, but these issues likely share the same underlying problem and solution.
Author
Owner

@MartinWie commented on GitHub (Feb 3, 2026):

Closing because the fix was already merged

@MartinWie commented on GitHub (Feb 3, 2026): Closing because the fix was already merged
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8447