Skip to content

[FEATURE]: clipboard event listeners #67385

Backlog

Description

@abrown

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:

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:

  1. registering a new clipboard listener : const unsubscribe = context.clipboard.onWrite(handler)
  2. sending off the clipped text in handler to whatever OS- or environment-specific tool we want
  3. 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

  1. opencodejr commented on Nov 30, 2026

    @opencodejr
    Contributor

    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 like context.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.

  2. added
    area/plugins
    type/feature
    version/v2
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/pluginstype/featureversion/v2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions