Copy to clipboard broken over SSH (MobaXterm & Windows Terminal) #3832

Closed
opened 2026-02-16 17:41:37 -05:00 by yindo · 6 comments
Owner

Originally created by @b3nw on GitHub (Dec 24, 2025).

Originally assigned to: @kommander on GitHub.

When running OpenCode over SSH from Windows, the "Copy Message" feature (ctrl+x then y) displays "copied to clipboard" notification, but pasting on Windows does not work. The clipboard contains only the previous content.

This issue makes OpenCode unusable for SSH connections from Windows. Other CLI agents such as Claude Code and Gemini CLI do not block clipboard operations over SSH - they allow normal copy/paste functionality. OpenCode is the only agent with this clipboard limitation.

Steps to Reproduce

  1. Connect from Windows to Debian host via SSH using MobaXterm
  2. Run opencode
  3. Open a session or continue an existing one
  4. Press ctrl+x then y to copy a message
  5. See "copied to clipboard" notification
  6. Paste in Windows (ctrl+v or right-click) - contains old clipboard content only

Expected Behavior
Text should be copied to Windows clipboard and available for pasting

Actual Behavior
Clipboard shows "copied to clipboard" but pasting returns previous clipboard content (often just -`)

Environment

  • OpenCode version: v1.0.132+ (TUI with opentui)
  • Platform: Windows 11
  • Terminal: MobaXterm (latest)
  • SSH target: Debian Linux
  • Connection: Windows → MobaXterm → SSH → Debian → opencode

Additional Testing

  1. Same issue occurs with Windows Terminal instead of MobaXterm
  2. Tested with OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1 - stops auto-copy-on-select but manual copy (ctrl+x then y) still fails
  3. Without the env var, auto-copy shows same issue (clipboard contains -`)
Originally created by @b3nw on GitHub (Dec 24, 2025). Originally assigned to: @kommander on GitHub. When running OpenCode over SSH from Windows, the "Copy Message" feature (ctrl+x then y) displays "copied to clipboard" notification, but pasting on Windows does not work. The clipboard contains only the previous content. This issue makes OpenCode unusable for SSH connections from Windows. Other CLI agents such as Claude Code and Gemini CLI do not block clipboard operations over SSH - they allow normal copy/paste functionality. OpenCode is the only agent with this clipboard limitation. **Steps to Reproduce** 1. Connect from Windows to Debian host via SSH using MobaXterm 2. Run `opencode` 3. Open a session or continue an existing one 4. Press `ctrl+x` then `y` to copy a message 5. See "copied to clipboard" notification 6. Paste in Windows (ctrl+v or right-click) - contains old clipboard content only **Expected Behavior** Text should be copied to Windows clipboard and available for pasting **Actual Behavior** Clipboard shows "copied to clipboard" but pasting returns previous clipboard content (often just -`) **Environment** - OpenCode version: v1.0.132+ (TUI with opentui) - Platform: Windows 11 - Terminal: MobaXterm (latest) - SSH target: Debian Linux - Connection: Windows → MobaXterm → SSH → Debian → opencode **Additional Testing** 1. Same issue occurs with Windows Terminal instead of MobaXterm 2. Tested with OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1 - stops auto-copy-on-select but manual copy (ctrl+x then y) still fails 3. Without the env var, auto-copy shows same issue (clipboard contains -`)
yindo added the windowsopentui labels 2026-02-16 17:41:37 -05:00
yindo closed this issue 2026-02-16 17:41:37 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 24, 2025):

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

  • #2773: clipboard copy not works in remote SSH console
  • #4283: Copy To Clipboard is not working
  • #5046: Can't copy text from opencode through mouse selection in Windows Terminal

These issues all describe similar clipboard functionality problems in various SSH and Windows environments. Feel free to ignore if your specific case differs from these.

@github-actions[bot] commented on GitHub (Dec 24, 2025): This issue might be a duplicate of existing issues. Please check: - #2773: clipboard copy not works in remote SSH console - #4283: Copy To Clipboard is not working - #5046: Can't copy text from opencode through mouse selection in Windows Terminal These issues all describe similar clipboard functionality problems in various SSH and Windows environments. Feel free to ignore if your specific case differs from these.
Author
Owner

@nikhilmaddirala commented on GitHub (Jan 17, 2026):

I am experiencing this exact issue running OpenCode inside Zellij over SSH.

Environment:

  • Local: Local Machine (Terminal Emulator)
  • Remote: Linux Server
  • Session: SSH -> Zellij -> OpenCode
  • OpenCode Version: v1.1.13

Behavior:

  1. I select text in OpenCode and hit copy.
  2. OpenCode UI says "Copied to clipboard".
  3. Pasting on my local machine yields old clipboard content.
  4. Contrast: Running neovim in the same Zellij session allows copying perfectly (likely because Neovim handles OSC 52 correctly).

It seems OpenCode is attempting to write to the remote system clipboard rather than emitting the OSC 52 escape sequence required for remote terminals/multiplexers like Zellij.

@nikhilmaddirala commented on GitHub (Jan 17, 2026): I am experiencing this exact issue running OpenCode inside Zellij over SSH. **Environment:** - **Local:** Local Machine (Terminal Emulator) - **Remote:** Linux Server - **Session:** SSH -> Zellij -> OpenCode - **OpenCode Version:** v1.1.13 **Behavior:** 1. I select text in OpenCode and hit copy. 2. OpenCode UI says "Copied to clipboard". 3. Pasting on my local machine yields old clipboard content. 4. **Contrast:** Running `neovim` in the same Zellij session allows copying perfectly (likely because Neovim handles OSC 52 correctly). It seems OpenCode is attempting to write to the remote system clipboard rather than emitting the OSC 52 escape sequence required for remote terminals/multiplexers like Zellij.
Author
Owner

@b3nw commented on GitHub (Jan 17, 2026):

this got resolved in #8974 so should be apart of the next version.

@b3nw commented on GitHub (Jan 17, 2026): this got resolved in #8974 so should be apart of the next version.
Author
Owner

@skironDotNet commented on GitHub (Jan 23, 2026):

Same on putty, although I don't think SSH client matters it seems like opencode runs some terminal UI that is not passthru the copy/paste happens inside the UI. The normal Ctrl+C sends terminate signal, so copy can be invoked via right click but this paste the text back immediately. The is no right click context menu to copy selected text. Copy/paste host/SSH is necessary or create own client SSH software to interact with opencode via SSH

@skironDotNet commented on GitHub (Jan 23, 2026): Same on putty, although I don't think SSH client matters it seems like opencode runs some terminal UI that is not passthru the copy/paste happens inside the UI. The normal Ctrl+C sends terminate signal, so copy can be invoked via right click but this paste the text back immediately. The is no right click context menu to copy selected text. Copy/paste host/SSH is necessary or create own client SSH software to interact with opencode via SSH
Author
Owner

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

Vamos a hacerlo permanente:

● Update(.tmux.conf)
⎿  Added 3 lines
38 set -g default-terminal "tmux-256color"
39 set -ga terminal-overrides ",*:Tc"
40
41 +# OSC 52 clipboard passthrough (needed for OpenCode and other TUI apps
+ over SSH)
42 +set -g allow-passthrough on
43 +
44 set -s extended-keys off
45
46 # Modo vim

● Listo. El problema era simple al final: tmux bloqueaba las secuencias OSC 52 que
OpenCode usa para comunicarse con tu clipboard de Windows a través de WezTerm.

Resumen:
┌───────────────────┬───────┬─────────┐
│ Configuración │ Antes │ Después │
├───────────────────┼───────┼─────────┤
│ allow-passthrough │ off │ on │
└───────────────────┴───────┴─────────┘
Las otras aplicaciones funcionaban porque probablemente usan el clipboard interno de
tmux (set-clipboard external), mientras que OpenCode envía secuencias OSC 52 directas
que necesitan pasar a través de tmux sin modificar.

Ya quedó configurado permanentemente en tu .tmux.conf. Problema resuelto. 🎯

@jrevenga commented on GitHub (Feb 3, 2026): Vamos a hacerlo permanente: ● Update(.tmux.conf) ⎿  Added 3 lines 38 set -g default-terminal "tmux-256color" 39 set -ga terminal-overrides ",*:Tc" 40 41 +# OSC 52 clipboard passthrough (needed for OpenCode and other TUI apps + over SSH) 42 +set -g allow-passthrough on 43 + 44 set -s extended-keys off 45 46 # Modo vim ● Listo. El problema era simple al final: tmux bloqueaba las secuencias OSC 52 que OpenCode usa para comunicarse con tu clipboard de Windows a través de WezTerm. Resumen: ┌───────────────────┬───────┬─────────┐ │ Configuración │ Antes │ Después │ ├───────────────────┼───────┼─────────┤ │ allow-passthrough │ off │ on │ └───────────────────┴───────┴─────────┘ Las otras aplicaciones funcionaban porque probablemente usan el clipboard interno de tmux (set-clipboard external), mientras que OpenCode envía secuencias OSC 52 directas que necesitan pasar a través de tmux sin modificar. Ya quedó configurado permanentemente en tu .tmux.conf. Problema resuelto. 🎯
Author
Owner

@skironDotNet commented on GitHub (Feb 5, 2026):

I just expose the built in Web UI and no need to talk via terminal. I think many people may be missing the concept. You just run opencode web and work via UI
If you run oc from a docker container then just expose the web port.
You can configure web access specifics via ~/.config/opencode/opencode.json

If using docker container you can mount that file from your host.
The ~/.config/opencode/opencode.json does not exist by default so you need to create it if you want to customize. It's all well documented. If in doubt ask AI ;)

@skironDotNet commented on GitHub (Feb 5, 2026): I just expose the built in Web UI and no need to talk via terminal. I think many people may be missing the concept. You just run `opencode web` and work via UI If you run oc from a docker container then just expose the web port. You can configure web access specifics via `~/.config/opencode/opencode.json` If using docker container you can mount that file from your host. The `~/.config/opencode/opencode.json` does not exist by default so you need to create it if you want to customize. It's all well documented. If in doubt ask AI ;)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3832