Skip to content

Cannot select text in chat messages - mouse capture stuck in prompt field ( VSCode terminal) #15212

Closed as not planned

Description

@jjnxpct

Description

Description

Text selection in the chat area is broken when running OpenCode in the VS Code integrated terminal. The mouse cannot select text in assistant or user messages. It appears the prompt input field captures all mouse events and does not release them to the chat area.

Observed behavior

  • After starting OpenCode, mouse selection in the chat area never works initially
  • The problem returns every time OpenCode is (re)started, including after restarting VS Code
  • Certain actions can "unlock" selection, but not all are consistent:
    • Most reliable workaround: Click on a previous user prompt in the chat, then press Esc — this releases mouse capture and selection starts working
    • Switching the VS Code color theme (which triggers a terminal re-render) also works
    • Clicking outside VS Code and back sometimes works
    • Sending a question/response sometimes works, but not always
  • Once selection starts working, it appears to stay working for the rest of the session
  • The environment variable OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=true does not help

Best workaround found

Click on any previous user message in the chat (which opens "Message actions"), then press Esc. This releases the mouse capture and enables text selection for the remainder of the session.

Root cause hypothesis

The prompt input field claims exclusive mouse capture at startup, preventing normal mouse selection in the chat area. Actions that trigger a focus cycle (clicking a message + Esc, theme switch, window focus loss/gain) reset this capture state. The bug is in the initial mouse capture state of the TUI — it is set too aggressively at startup and not properly scoped to the prompt input area only.

My Environment

  • OpenCode version: 1.2.15
  • OS: Windows 11
  • Terminal: VS Code integrated terminal (PowerShell)
  • VS Code version: latest

Related issues

Steps to reproduce

  1. Open VS Code
  2. Start OpenCode in the integrated terminal
  3. Send a message and wait for a response
  4. Try to select text in the assistant's response with the mouse
  5. Result: Selection does not work — the mouse has no effect in the chat area
  6. Now click on your previous user message in the chat (the "Message actions" dialog appears)
  7. Press Esc to close the dialog
  8. Try selecting text in the chat again
  9. Result: Selection now works and continues working for the rest of the session

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Feb 26, 2026
  2. jjnxpct commented on Feb 26, 2026

    @jjnxpct
    Author

    Additional finding: The selection issue does NOT occur when running OpenCode in Windows Terminal (standalone). It only occurs in VS Code's integrated terminal. This confirms the root cause is in how the TUI interacts with VS Code's terminal mouse handling, not in OpenCode's TUI itself.

    Workaround: Run OpenCode in Windows Terminal instead of VS Code's integrated terminal, or use the click-previous-prompt + Esc workaround described above.

  3. alexzoo commented on Feb 26, 2026

    @alexzoo

    the same problem on Mac

  4. surak commented on Feb 27, 2026

    @surak

    +1 for Mac OS/VSCode. It works as intended on MacOS' terminal.

  5. surak commented on Feb 27, 2026

    @surak

    @jjnxpct perhaps you can update the issue's title as it's not exclusive to Windows, but to VSCode.

  6. changed the title [-]Cannot select text in chat messages - mouse capture stuck in prompt field (Windows 11 / VS Code terminal)[/-] [+]Cannot select text in chat messages - mouse capture stuck in prompt field ( VSCode terminal)[/+] on Feb 27, 2026
  7. kommander commented on Feb 27, 2026

    @kommander
    Contributor

    There is no exclusive mouse capture. Might be something odd with how mouse events are triggered. Did it work properly in an earlier version? If so could you identify the version where the issue started happening? You can switch to an explicit version with opencode upgrade [version].

  8. jjnxpct commented on Feb 27, 2026

    @jjnxpct
    Author

    @kommander Hi! I just started using Open Code so I can't tell when this started happening. Sorry.

    As a workaround I now start Open Code in a terminal outside VSC. In this external window I can select (and copy) text OK. So this is related to the use inside VSC.

  9. alterdaemon commented on Mar 1, 2026

    @alterdaemon

    I confirm the problem occurs also on Linux (Debian).
    Can't select and copy TUI chat text.

    Sometimes (hard to determine when exactly) it works fine within vscode main window integrated terminal but it never works properly when vscode integrated terminal pane is moved out into the new vscode window (besides main vscode window)

  10. philtomson commented on Mar 27, 2026

    @philtomson

    Can confirm that this also happens in Fedora 42 when OpenCode (1.3.3) is run in a terminal. Mouse clicking, wheel works for a while and then stops working. Also notice that if I have multiple terminal tabs it effects each tab even the ones where OpenCode is not running.

  11. removed
    bugSomething isn't working
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on May 3, 2026
  12. github-actions commented on Jul 4, 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