Repository navigation
Description
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
- Most reliable workaround: Click on a previous user prompt in the chat, then press
- Once selection starts working, it appears to stay working for the rest of the session
- The environment variable
OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=truedoes 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
- Can't copy text from opencode through mouse selection in Windows Terminal #5046 - Can't copy text from opencode through mouse selection in Windows Terminal
- can not copy and paste in opencode CLI #13984 - Can not copy and paste in opencode CLI
- Ctrl+V paste not working on Windows 11 TUI #13800 - Ctrl+V paste not working on Windows 11 TUI
Steps to reproduce
- Open VS Code
- Start OpenCode in the integrated terminal
- Send a message and wait for a response
- Try to select text in the assistant's response with the mouse
- Result: Selection does not work — the mouse has no effect in the chat area
- Now click on your previous user message in the chat (the "Message actions" dialog appears)
- Press
Escto close the dialog - Try selecting text in the chat again
- Result: Selection now works and continues working for the rest of the session
Activity
jjnxpct commentedon Feb 26, 2026
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.
alexzoo commentedon Feb 26, 2026
the same problem on Mac
surak commentedon Feb 27, 2026
+1 for Mac OS/VSCode. It works as intended on MacOS' terminal.
surak commentedon Feb 27, 2026
@jjnxpct perhaps you can update the issue's title as it's not exclusive to Windows, but to VSCode.
[-]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)[/+]kommander commentedon Feb 27, 2026
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].jjnxpct commentedon Feb 27, 2026
@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.
alterdaemon commentedon Mar 1, 2026
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)
philtomson commentedon Mar 27, 2026
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.
github-actions commentedon Jul 4, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.