Skip to content

Conversation

@JosXa
Copy link
Contributor

@JosXa JosXa commented Jan 16, 2026

Problem 🔽

Autocomplete menus (@ and / in TUI) and dialog select components currently auto-select items when UI elements move under a stationary cursor. This creates two problematic scenarios:

  1. Menu appears under stationary cursor: When a menu opens, if the user's mouse happens to be over where an item renders, that item gets selected immediately even though the user hasn't moved the mouse
  2. Filter changes reorder items: When typing to filter, items shift position and if one lands under the stationary cursor, it gets auto-selected, breaking keyboard navigation

Users expect hover selection to activate only on intentional mouse movement, not when UI elements move under a stationary cursor.

mouse-highlight-bug.mp4

Solution 🔽

WindowsTerminal_zlB4E0m0KW.mp4

Just checked, and it's fixed in the menu aswell:

WindowsTerminal_TTu0nLAE43.mp4

The fix tracks actual mouse movement to distinguish between:

  • Intentional hover: User moves mouse → selection updates normally
  • Accidental hover: Menu appears/items reorder under stationary cursor → selection remains unchanged

This is implemented by:

  1. Setting a hasMouseMoved flag to false when menus open or filter text changes
  2. Listening for mousemove events to set the flag to true
  3. Only updating selection on hover when hasMouseMoved === true

Components updated:

  • Select.tsx: Dialog select menus
  • ChatInput.tsx: Autocomplete menus (@ and /)

This ensures hover selection only activates on deliberate user action, making keyboard navigation reliable and preventing surprising auto-selections.

Closes #8799

@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

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

Based on my search results, no duplicate PRs were found. The only PR returned in all searches is the current PR #8797 itself. While PR #7967 appears in the results related to hover/click support in prompts, it addresses a different component (permission prompt) and is about adding mouse support rather than fixing accidental selection behavior.

@JosXa JosXa closed this Jan 16, 2026
@JosXa JosXa reopened this Jan 16, 2026
Track mouse movement using a global flag that resets when menus open or
filter text changes. Selection only activates when the cursor has moved,
preventing accidental selection when:
- Menu appears under a stationary cursor
- Filter changes reorder items under a stationary cursor

The flag is set on first mouse movement and immediately selects the item
at that moment, allowing responsive hover selection while blocking
initial accidental selection. Terminal layer naturally filters out
1-2px jitter, providing built-in tremor tolerance.
@JosXa
Copy link
Contributor Author

JosXa commented Jan 16, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

Thanks, done: #8799

@rekram1-node
Copy link
Collaborator

/review

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.

[BUG] Leaving mouse stationary underneath autocomplete items selects them on every keystroke

2 participants