Skip to content

feat: Copy Mode for OpenCode #2755

Closed as not planned
Closed as not planned

Description

@thuanpham582002

Summary

OpenCode currently lacks a proper copy mode, making it difficult for users to selectively copy text from chat
messages, code blocks, and other content displayed in the viewport. While basic message copying exists (ctrl+x y), users need vim/tmux-like copy mode for precise text selection and copying.

Problem Statement

Current Limitations

  1. No Keyboard-based Text Selection: Users cannot select text using keyboard only
  2. Limited Copy Functionality: Only entire message copying is available (ctrl+x y)
  3. Incompatible with tmux Copy Mode: OpenCode runs as a TUI application but doesn't integrate with tmux's copy
    mode
  4. Poor UX for Code Review: Cannot selectively copy code snippets, error messages, or specific parts of
    responses
  5. Mouse Dependency: Users must rely on mouse for text selection, which is inefficient in terminal
    environments

User Impact

  • Developers: Cannot quickly copy code snippets from AI responses
  • Power Users: Keyboard-driven workflow is broken when needing to copy text
  • Terminal Enthusiasts: Expect vim/tmux-like navigation and selection
  • Accessibility: Mouse-dependent selection is not accessible to all users

Why Copy Mode is Essential

1. Terminal Workflow Compatibility

OpenCode is a TUI (Terminal User Interface) application that runs in terminal emulators. Terminal users expect:

  • Vim-like navigation and selection
  • Keyboard-driven text manipulation
  • Integration with existing terminal tools

2. tmux Integration Problem

When OpenCode runs inside tmux:

  • tmux's copy mode (prefix+[) doesn't work properly, it only can select and copy one page that currently visible of opencode.

3. Pager-like Applications Need Copy Mode

OpenCode functions as a pager for chat messages and code:

  • Similar to less, more, or vim
  • All major pagers have copy/select functionality
  • Users expect to be able to select and copy content

4. Developer Productivity

Developers using OpenCode need to:

  • Copy code snippets from AI responses
  • Select error messages for debugging
  • Extract specific parts of long responses
  • Maintain keyboard-driven workflow

What Already Exists (✅)

  1. Selection System:
    type selection struct {
        startX int
        endX   int
        startY int
        endY   int
    }
• Mouse-based selection is implemented
• Coordinate tracking works correctly

2. Highlight System:
```go
type highlightInfo struct {
    lineStart, lineEnd int
    lines map[int][2]int
}

• Viewport has robust highlighting
• Multi-line highlighting supported
• SetHighlights(), HighlightNext(), HighlightPrevious() available
3. Navigation Keymap:

type KeyMap struct {
    PageDown, PageUp key.Binding
    HalfPageUp, HalfPageDown key.Binding
    Down, Up key.Binding
    Left, Right key.Binding
}

• Vim-like keys already implemented: j/k, h/l, f/b, d/u
• Navigation system is mature
4. Clipboard Integration:
• cmds = append(cmds, app.SetClipboard(lastTextPart.Text))
• app.SetClipboard() function exists
• Toast notification system available

Activity

  1. github-actions commented on Sep 24, 2025

    @github-actions
    Contributor

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

    Feel free to ignore if none of these address your specific case.

  2. rekram1-node commented on Sep 24, 2025

    @rekram1-node
    Collaborator

    yeah copying could be better, tui is being rewritten currently so features like this can best be addressed after the fact.

    Ultimately all ux goes through @adamdotdevin

  3. jonahbenton commented on Nov 19, 2025

    @jonahbenton

    Voting +1. Would also like selection by mouse and keyboard navigation.

  4. itse4elhaam commented on Dec 10, 2025

    @itse4elhaam

    +1

    Incompatible with tmux Copy Mode: OpenCode runs as a TUI application but doesn't integrate with tmux's copy
    mode

    This is one of the painpoints.

  5. jkirkpatrick commented on Jan 25, 2026

    @jkirkpatrick

    +1

    The "Copied to Clipboard" notification is a lie - not an error or omission.

    It should be removed (and gated behind a feature flag) until tested and confirmed working.

  6. fadedlamp42 commented on Feb 6, 2026

    @fadedlamp42

    A decent workaround, for now, is to:

    1. Use ^x x to "Export session transcript"
    2. Hold ^w to clear out the default filename and replace with /tmp/s[croll] (or whatever you prefer)
    3. Upon submitting, a child $EDITOR /tmp/s opens (nvim for me) which provides access to the full conversation. A simple G and you can pretend you're in tmux scroll mode

    EDIT: These make things not as bad, too

        "messages_page_up": "pageup,ctrl+alt+b",
        "messages_page_down": "pagedown,ctrl+alt+f",
        "messages_line_up": "ctrl+alt+y",
        "messages_line_down": "ctrl+alt+e",
        "messages_half_page_up": "ctrl+alt+u",
        "messages_half_page_down": "ctrl+alt+d",
        "messages_first": "ctrl+g,home",
        "messages_last": "ctrl+alt+g,end",
    
  7. piraz commented on Mar 2, 2026

    @piraz

    What about a float window with raw script for keyboard users, or raw/partial raw to editor? That will go to neovim btw and inside there is fair game.

  8. leohenon commented on Mar 20, 2026

    @leohenon

    I maintain ocv, an opencode fork with vim keybindings. It already supports visual mode with yank/put in the input. Full copy mode for the output buffer in the tui is coming soon.

    brew install leohenon/tap/ocv

  9. silentjay commented on Mar 25, 2026

    @silentjay

    I maintain ocv, an opencode fork with vim keybindings. It already supports visual mode with yank/put in the input. Full copy mode for the output buffer in the tui is coming soon.

    Superb work! I need to look into running this on sidekick.nvim

  10. leohenon commented on Mar 26, 2026

    @leohenon

    @silentjay Im currently working on integrating my fork with this plugin opencode.nvim by nickjvandyke for a sidekick type integration but with vim mode in the opencode tui.

  11. leohenon commented on Mar 26, 2026

    @leohenon

    On a side note, copy mode is now fully implemented in the latest release of ocv.

    Image

  12. silentjay commented on Mar 26, 2026

    @silentjay

    @silentjay Im currently working on integrating my fork with this plugin opencode.nvim by nickjvandyke for a sidekick type integration but with vim mode in the opencode tui.

    That's interesting as I was planning on giving opencode.nvim a whirl at some point as well, although at this point I don't think I could live without the copilot NES functionality of sidekick.nvim!

  13. leohenon commented on Mar 27, 2026

    @leohenon

    That's interesting as I was planning on giving opencode.nvim a whirl at some point as well, although at this point I don't think I could live without the copilot NES functionality of sidekick.nvim!

    Interesting, I haven’t used sidekick's NES much, just copilot tabbing. I might give it a shot and look into running ocv with sidekick.nvim is possible.

  14. egoarka commented on Apr 10, 2026

    @egoarka

    any progress? does not seem to work. tmux support?

  15. egoarka commented on Apr 10, 2026

    @egoarka

    just used mappings with xremap ( c-d / c-u ). and copy mode from alacritty.

  16. AnatolyHohuda commented on Apr 14, 2026

    @AnatolyHohuda

    also wondering if Tmux copy mode support will be improved.

    I'm mostly concerned about the text input at the bottom. sometimes questions/decisions tool is triggered by model and it takes up to 30% of the height of the terminal.

    when that happens in the Claude Code I'm still able to scroll up with Tmux copy mode to take a look at things and then come back to the input. but in opencode, it's searching needle in the half of the screen height hay stack.

    Image
  17. github-actions commented on Jun 14, 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.

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