Repository navigation
fix(input): submit a slash command typed in full on the first Enter - #1502
akramcodez merged 3 commits into
Conversation
When the typed text exactly matches a command, the completion menu opens with that command highlighted. Enter then took the "select completion" branch, which re-applied text that was already in the composer, closed the menu and returned, so every command needed a second Enter to run. Skip the selection when the highlighted completion is already what was typed and fall through to the submit path. Partly typed commands still complete on Enter as before. Closes Nano-Collective#1431
nc-review: comments — 1 nit@addyCooks — a few things worth a look, none blocking. The change correctly fixes the bug: when the typed text exactly matches a slash command, Enter used to fall into the 'select completion' branch, re-apply the same text, and close the menu without submitting. Adding a ⚪ nit · The bullet opens by asserting past behaviour in the present tense ("the completion menu opened with it highlighted, and Enter 'selected' it") rather than describing the user-facing impact in the before/after voice used elsewhere in 🔴 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 |
|
Quick heads up: the red Semgrep Security Scan here isn't from this PR It's flagging The fix is in #1503. It swaps the |
nc-review: match house style by leading with the before/after impact instead of narrating the old behaviour first.
…xact-command-1431
|
As always great work @addyCooks |
|
Thanks @akramcodez : ) |
Closes #1431 (part of #907)
Description
When the typed text exactly matches a slash command, the completion menu opens with that command highlighted. Pressing Enter then took the "select completion" branch, which re-applied text that was already in the composer, closed the menu and returned without ever reaching the submit path. Every command needed a second Enter to run.
This isn't timing-dependent, so it's separate from #1327 (the stale-closure race where Enter submits a non-matching fragment). Gating Enter on fresh state wouldn't fix it, because that branch never checked whether the selection was a no-op.
The selection branch now does nothing when the highlighted completion already equals the input, so Enter falls through to the existing submit path, which also resets the completion state and closes the menu:
A partly typed command (
/mod) is untouched: it still completes to/modelon Enter without submitting, which the second new test guards.source/components/user-input.tsxsource/components/user-input.spec.tsxRecording
Type of Change
Changeset
.changeset/enter-submits-exact-command.md, patch)Testing
/test-helpin full, waits for the menu, presses Enter once and asserts the command is submitted. It fails onmainand passes with the fix./test-he, presses Enter and asserts the input becomes/test-helpwith nothing submitted. It passes on both, guarding the existing completion behaviour.tsc, Biome format and lint cleanpnpm test:knipcould not run locally (out of memory); nothing new is exported or imported, so CI will run it firstNote
UserInput submits slash commands immediately while busyis timing-sensitive: it presses Enter the moment/helprenders, before the input handler has picked up the new value, so it can fail on a loaded machine with or without this change. A short wait before Enter makes it stable. Happy to send that as a follow-up.Checklist