Skip to content

TUI copy should preserve logical text instead of rendered layout #47165

Open

Description

@old-square-eyes

Description

When OpenCode runs over direct SSH in macOS Terminal, enabling mouse reporting lets the TUI capture drag selection, but its copy action reports success, while the local clipboard remains unchanged.

I feel this feature has some use but really seeks to browser-fi an inherently mouse-less solution that a TUI /CLI should be. That would be fine if we had a choice. Instead I'm stuck with this over-engineered, unworkable solution.

Disabling mouse reporting in macOS terminal (under "View" menu) restores normal terminal copy/paste, but then copying assistant code blocks captures the rendered terminal layout rather than the source text. Visual wrapping becomes literal newlines, and sidebar/gutter content and whitespace is included in the clipboard. A command displayed as one logical shell line comes with new lines and unwanted artefacts, therefore pastes as multiple commands and fails.

This makes copy/paste unusable for normal terminal-first use for any wrapped lines.

Please provide keyboard-first copy actions for assistant messages and code blocks that copy the underlying logical text, independent of display wrapping and layout. Mouse interception should be optional rather than required for correct copying. For users that want it... please look at supporting, first-class over-ssh usage.

Plugins

No response

OpenCode version

No response

Steps to reproduce

Fail mode #1 - Log into host via ssh, start opencode, use drag-copy, fail to have clipboard populated.
Fail mode #2 - Turn off mouse reporting in macOS terminal (under "View" menu), try to copy any multiple line agent output, loose your mind reconstructing/reformatting it after you have pasted it to your intended destination (especially if that destination is another CLI).

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. github-actions commented on Sep 3, 2026

    @github-actions
    Contributor

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

    If your report covers the same root cause, please add a comment there instead so the discussion stays in one place.

  2. disarticulate commented on Sep 12, 2026

    @disarticulate

    copy paste doesnt work anywhere because who ever decided to override normal terminal behavior fails to read issues.

  3. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the detailed write-up! As I understand it, you'd like keyboard-first ways to copy assistant output and individual code blocks as their source text, not the wrapped layout on screen, and you don't want mouse capture to be required for copying to work.

    Some of this may already help in the current v2 TUI:

    • Mouse capture is optional. Set "mouse": false in your TUI config, or toggle Mouse in the config dialog. Your terminal's own selection then works as usual.
    • /copy (default <leader>y) copies the last assistant message's source text, so it isn't affected by wrapping, the sidebar or the gutter.

    Two limits remain. There's no keyboard way yet to copy a single code block, or a message other than the last one; that's the new part of your request, and maintainers will consider it. And macOS Terminal.app doesn't support OSC 52, the escape sequence a program on the SSH host uses to set your local clipboard. So over plain SSH from Terminal.app, a copy made inside OpenCode can't reach your Mac's clipboard, and showing "Copied" anyway is misleading. That part is tracked separately (see below). A terminal that supports OSC 52, such as iTerm2, Ghostty, kitty or WezTerm, should let copies reach your clipboard over SSH.

    Related issues:

    If you can share your OpenCode version (opencode --version), that would help too.

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