Uh oh!
There was an error while loading. Please reload this page.
fix(opencode): sets input mode based on whether mouse vs keyboard is in use to prevent mouse events firing - #9449
Conversation
…in use to prevent mosue events firing
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
rekram1-node
commented
Jan 19, 2026
/review |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…t changes causing synthetic mousemove events
jcampuza
commented
Jan 19, 2026
Credit in this PR also goes to @JosXa in https://github.com/anomalyco/opencode/pull/8797/changes#diff-bf5247c375676c0f61719d0548f71ef978381a9ab3c4ba9ad7b20bff2b8fa5f9R596-R601 for figuring out the behavior around mousemove events also being triggered when the filter occurs due to the background element moving around under the cursor causing TUI mousemove events to fire. This PR originally didn't account for that specific case |
Uh oh!
There was an error while loading. Please reload this page.
…in use to prevent mouse events firing (anomalyco#9449)
…in use to prevent mouse events firing (anomalyco#9449)
…in use to prevent mouse events firing (anomalyco#9449)
…in use to prevent mouse events firing (anomalyco#9449)
…in use to prevent mouse events firing (anomalyco#9449)
…in use to prevent mouse events firing (anomalyco#9449)
…in use to prevent mouse events firing (#9449)
What does this PR do?
Related to: #9435 which was present in the web apps.
In the opencode cli there is no distinguishing between when you are currently using the mouse or the keyboard. Due to this if you use keyboard events to navigate, mouse events will still fire. This leads to the highlighted/active item in menus jumping up to whatever the mouse is under since the "dom" (tui) moves around under the mouse triggering the events.
To fix this we can distinguish between if the user is actively using the keyboard and disable certain mouse events from firing while it is the active input mode. On mousemove we set the active mode back to the mouse and those events then continue to fire.
Before the fix note the highlighted item jumps up to wherever the mouse was:

After note the highlighted item does not jump to the item the mouse happens to be over while keyboard navigating:

Credit to @JosXa in https://github.com/anomalyco/opencode/pull/8797/changes for figuring out the behavior around mousemove events also being triggered when the filter occurs due to the background element moving around under the cursor causing TUI mousemove events to fire.
How did you verify your code works?
Using the app, see videos.
Fixes: #9448#8799