Conversation
The completion menu opens in an effect a commit after the keystroke that changed the input, so an Enter landing in between saw showCompletions still false and submitted the raw fragment. When the menu state says closed, the Enter gate now falls back to the memoized completions the effect is about to show, under the same suppression rules the effect uses (now shared). Selecting a completion marks that input closed, like Escape, so Enter still submits a command once it has been selected. Closes Nano-Collective#1327.
nc-review: nothing to raise@addyCooks — nothing to raise from the automated review. Fixes the Enter-on-stale-completions race from #1327 by gating Enter on the memoized 🔴 blocking · 🟠 a reviewer would ask for a change · ⚪ optional Automated code review — correctness, security, design, tests, plus duplicates and scope. A human still decides; this is not a substitute for review and is not exhaustive. The required status checks separately cover lint, formatting, types, unused dependencies, the test suite and the build. This bot never merges. Maintainers can rerun with |
Closes #1327
Description
Pressing Enter immediately after typing a slash-command fragment submitted the raw fragment instead of selecting a completion.
Cause. The completion menu is opened by an effect that runs a commit after the keystroke that changed
input. Ink re-subscribes theuseInputhandler in the same passive-effect flush, so for a turn or two the live handler sees the newinputbutshowCompletionsstillfalse. Enter in that window skipped the "select the completion" branch and fell through tohandleSubmit. Instrumenting the handler confirmed it: Enter one or two event-loop turns after the fragment rendered sawinput="/test-h",showCompletions=false, one memoized match, and submitted/test-h.Why not gate purely on
commandCompletions(the issue's suggestion): right after a completion is selected, the completed command still has matches, so a memo-only gate would re-select on every Enter and never submit.Fix (
source/components/user-input.tsx):isMenuSuppressedForso the two cannot drift.Recording
Type of Change
Changeset
pnpm changeset) describing this change for the changelogTesting
Automated Tests
.spec.ts/tsxfilespnpm test:allcompletes successfully)Manual Testing
Checklist