[Bug] Enter pressed the instant a / menu opens submits raw text instead of selecting
Description
showCompletions and selectedCompletionIndex are read from a stale render closure. A fast typer who presses Enter right after typing a slash-command fragment sends the raw, unfinished text to the model as a chat message instead of running (or even attempting to select) a command.
Parent: #907
Steps to Reproduce
- Type a slash-command fragment that doesn't exactly match a command (e.g.
/xy). - Press Enter immediately, with no pause, as soon as the last character is typed.
Expected Behavior
Either the completion menu stays open for a real selection, or nothing submits until a valid command is chosen.
Actual Behavior
The raw fragment gets sent to the model as an ordinary chat message.
Recording
Root Cause
source/components/user-input.tsx:869-897 gates Enter's "select the completion" behavior on showCompletions and selectedCompletionIndex, both read from a closure that can be stale relative to the latest keystroke.
Suggested Fix
Gate Enter on the memoized commandCompletions value (computed at render time, never stale) instead of the closed-over state variables.
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs on the latest
main
Hey @akramcodez, I’m interested in taking this up could you assign it to me?