Skip to content

fix: submit an exact slash command on the first Enter - #1446

Closed
RealBhupesh wants to merge 2 commits into
Nano-Collective:mainfrom
RealBhupesh:fix/enter-exact-slash-command
Closed

RealBhupesh wants to merge 2 commits into
Nano-Collective:mainfrom
RealBhupesh:fix/enter-exact-slash-command

Conversation

@RealBhupesh

Copy link
Copy Markdown
Contributor

Fixes #1431.

When the composer text was already the only matching slash command, Enter selected that completion again, closed the menu, and did not run the command. A second Enter was required. An exact single match now falls through to submit.

Test plan

  • exact-command.spec.ts

Made with Cursor

Enter treated a single exact command match as a completion selection, so
it closed the menu and left the command unsent until a second Enter.

Fixes Nano-Collective#1431
@github-actions

Copy link
Copy Markdown
Contributor

No changeset found

This PR does not add a changeset, so it will not appear in the changelog or trigger a release.

If the change is user-facing, add one:

pnpm changeset

Pick a bump (patch / minor / major) and write the changelog entry in our usual voice ("Added X... Thanks to @you. Closes #123."), then commit the generated .changeset/*.md file.

If this PR is docs-only or a chore that needs no release note, you can ignore this — or run pnpm changeset --empty to record that intentionally.

@github-actions

Copy link
Copy Markdown
Contributor

nc-review: comments — 1 important, 2 nits

@RealBhupesh — a few things worth a look, none blocking.

The PR correctly resolves issue #1431 by extracting a small predicate isExactSingleCommand and short-circuiting the Enter-selects-completion branch when the typed text is already the sole, exact command, so the fall-through submit handler runs. The fix is minimal, well-scoped, and the new helper is independently unit-tested. One small completeness gap: the spec covers the predicate but not the user-input wiring, so a regression in the call site would not be caught.

🟠 important · changeset · .changeset

No changeset is included with this PR. This is a user-facing bug fix in the composer key handling of the TUI (Enter behaviour for exact slash commands changes visibly), so per the project rubric a changeset is required. The empty-changeset shape in .changeset/coverage-drop-vs-base.md is for internal-only changes; a behavioural fix needs a real entry such as --- / patch / nanocoder / fix: submit an exact slash command on the first Enter. Add one before merge.

⚪ nit · tests · source/components/exact-command.spec.ts

The spec only asserts isExactSingleCommand in isolation; nothing exercises the wiring in user-input.tsx where the predicate is actually consumed. If a future change removes the && !isExactSingleCommand(...) clause (or inverts it), the helper tests still pass and the bug silently regresses. The wiring is a single && term, so a focused test that mounts UserInput with a settled /model completion and asserts handleSubmit fires on Enter would be the right regression test for this issue. Not blocking because the integration surface is small, but the issue is filed as a bug and the rubric asks for a regression test with a bug fix.

⚪ nit · completeness · source/components/user-input.tsx:1030

input.trim() is compared against /${completionNames[0]} in the helper. A user who has already typed a trailing space intending to add an argument (e.g. /model with the completion menu still open on the single match model) will now have Enter submit the bare /model immediately. This matches the issue's stated expected behaviour and is unlikely to bite in practice, but worth noting in case the maintainers prefer the exact-match predicate to be stricter (e.g. require the input to equal the completed text with no trailing whitespace, or only fire when selectedCompletionIndex === 0 is the sole match). No action required unless the maintainer disagrees.


🔴 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 /re-review.

@github-actions github-actions Bot added the agent:comments nc-review left non-blocking findings label Sep 23, 2026
Biome's import order check failed on the new exact-command import.
@will-lamerton

Copy link
Copy Markdown
Member

Thanks for this, @RealBhupesh, and sorry it sat so long. #1431 was already fixed on main by #1502 (1f411fbd), and that logic has since moved into useCommandCompletions.ts, so this change no longer applies. Closing as superseded. Contributions are very welcome, though; if you'd like to pick up another issue, ask to be assigned first so work isn't duplicated.

@RealBhupesh

Copy link
Copy Markdown
Contributor Author

Thanks @will-lamerton, understood. Glad #1431 got fixed via #1502. I'll ask to be assigned first before picking up anything new.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:comments nc-review left non-blocking findings area:tui Terminal UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Enter on an exact, unambiguous slash-command match closes the completion menu instead of submitting

2 participants