nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] Enter pressed the instant a / menu opens submits raw text instead of selecting

Open addyCooks opened this issue 2 months ago • 1 comments

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

  1. Type a slash-command fragment that doesn't exactly match a command (e.g. /xy).
  2. 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

Image

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

addyCooks avatar Sep 15 '26 18:09 addyCooks

Hey @akramcodez, I’m interested in taking this up could you assign it to me?

addyCooks avatar Sep 15 '26 18:09 addyCooks