Skip to content

[FEATURE]: Toggle to disable mouse tracking in the TUI #36266

Closed as not planned
Closed as not planned

Description

@vokasug

Problem

There is no way to toggle mouse tracking in the OpenCode TUI from inside the session. When running OpenCode on a remote machine over SSH from the macOS Terminal app, this makes it impossible to copy text from the TUI reliably.

Repro

  1. SSH into a remote host (e.g. ssh user@host).
  2. Run opencode on the remote host.
  3. Try to select text with the mouse and copy it.
  4. Expected: the selected text lands in the local macOS clipboard.
  5. Actual: text is not copied. Cmd+C is intercepted by the TUI and does nothing useful. Mouse selection is captured by the TUI itself, so it never reaches the terminal's native selection buffer either.

Why this happens

OpenCode's TUI captures mouse input by default (enableMouse() in the renderer setup). On selection it tries to write to the clipboard via OSC52 (console.onCopySelection).

That only works when the local terminal actually implements OSC52. macOS Terminal.app only gained OSC52 support in macOS Sonoma 14.4 / Terminal 2.13. On older Terminal.app, on remote SSH sessions where OSC52 is filtered or unsupported by the mux, or when running inside tmux/screen without set-clipboard on, the selection silently disappears into the TUI and the user has no way to copy.

The existing escape hatch is OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1, but it only disables the intercept("key", ...) handler. It does not disable mouse tracking, so the TUI still captures mouse drag selections and the text still does not reach the terminal's native selection buffer.

Proposed solution

Expose a user-facing toggle to disable mouse tracking in the TUI. Either of these would solve the problem:

  • A /mouse slash command that toggles mouse capture on/off.
  • A configurable hotkey for the same.
  • An opt-in config field under tui (e.g. tui.mouse = false or tui.mouse_tracking = false) that defaults to current behavior but can be turned off.

When mouse tracking is off, the user gets normal terminal mouse selection and can copy via Cmd+C / Shift+drag / the terminal's own copy mechanism, regardless of OSC52 support.

For reference, hermes-agent already ships a /mouse toggle for exactly this use case and it works well there.

Environment

  • opencode 1.17.15
  • macOS Terminal.app (no third-party terminal)
  • Connected over SSH to a remote Linux host
  • OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1 does not help (see above)

Activity

  1. github-actions commented on Jul 10, 2026

    @github-actions
    Contributor

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

  2. github-actions commented on Sep 9, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  3. lucassing commented on Sep 24, 2026

    @lucassing

    having the same issue at the moment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions