Repository navigation
Description
Feature hasn't been suggested before.
- I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
I use the OpenCode TUI both locally and remotely (via SSH). Sometimes I use tmux, sometimes not. And I use OpenCode from inside different OSes. This makes it difficult to reliably interact with OpenCode's clipboard: most frequently, I select a snippet via the mouse, OpenCode tells me the snippet has been copied to the clipboard, but the snippet is not available in the OS clipboard.
This has been raised before for specific environments in issues and PRs:
- several issues are still open related to SSH, tmux, OSC52, etc.: tui: "Copied to clipboard" does not update local clipboard over SSH and tmux #50208, TUI: "Copied to clipboard" toast shown even when nothing was copied (OSC52 "attempted" treated as success) #59664
- a Linux fix: feat(tui): add linux_clipboard_selection config for primary buffer support #32370
- another tmux fix: fix(tui): copy through tmux to the client showing the pane #63578
- some WSL compatibility fix: fix(tui): mirror WSL copies through Windows interop #66641
- an xclip fix: feat(tui): fall back to wl-clipboard/xclip when the native clipboard is unavailable #67307
I would like to propose a different approach: a new context.clipboard.onWrite(...) API allowing users to listen for clipboard notifications. Those of us with slightly different environments can work around clipboard issues by writing an OpenCode plugin to do exactly what we need with a copied snippet. This new API would work by:
- registering a new clipboard listener :
const unsubscribe = context.clipboard.onWrite(handler) - sending off the clipped text in
handlerto whatever OS- or environment-specific tool we want - optionally unregistering the clipboard listener when finished:
unsubscribe()
This is all modeled the same way context.data.on works. I have a branch ready for a PR (diff) but wanted to get feedback on the idea before submitting it.
Activity
opencodejr commentedon Nov 30, 2026
Thanks for the detailed proposal, and for linking the earlier clipboard reports and fixes.
To restate it: you'd like a TUI plugin API,
context.clipboard.onWrite(handler)returning an unsubscribe function likecontext.data.on. A plugin could then receive every snippet OpenCode copies and send it to whatever tool works in its own environment (SSH, tmux, WSL, different OSes), instead of relying only on the built-in clipboard delivery.I looked for an existing request for a clipboard plugin hook and did not find one, nor an open pull request adding it. These open issues are closely related:
Maintainers will consider the idea and give feedback on the design before you open the PR from your branch.