Skip to content

Conversation

@jcampuza
Copy link
Contributor

@jcampuza jcampuza commented Jan 19, 2026

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:
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

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@rekram1-node
Copy link
Collaborator

/review

@jcampuza
Copy link
Contributor Author

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

@rekram1-node rekram1-node merged commit 091e88c into anomalyco:dev Jan 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opencode CLI doesn't distinguish input mode when using mouse vs keyboard

2 participants