[PR #9449] fix(opencode): sets input mode based on whether mouse vs keyboard is in use to prevent mouse events firing #13118

Closed
opened 2026-02-16 18:17:59 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/9449

State: closed
Merged: Yes


What does this PR do?

Related to: https://github.com/anomalyco/opencode/pull/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:
mouse-events-firing-when-keyboard-used

After note the highlighted item does not jump to the item the mouse happens to be over while keyboard navigating:
mouse-events-not-fired-when-keyboard-active

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

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/9449 **State:** closed **Merged:** Yes --- ### What does this PR do? Related to: https://github.com/anomalyco/opencode/pull/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: ![mouse-events-firing-when-keyboard-used](https://github.com/user-attachments/assets/df9e704c-b7f1-476b-bdee-e9474878ff08) After note the highlighted item does not jump to the item the mouse happens to be over while keyboard navigating: ![mouse-events-not-fired-when-keyboard-active](https://github.com/user-attachments/assets/948c0ba2-7742-46e2-a2da-deacc8d836e1) 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
yindo added the pull-request label 2026-02-16 18:17:59 -05:00
yindo closed this issue 2026-02-16 18:17:59 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13118