fix(shell): show exact-match slash command in completion menu#1787
fix(shell): show exact-match slash command in completion menu#1787kevinWangSheng wants to merge 1 commit intoMoonshotAI:mainfrom
Conversation
The slash command completer previously bailed out entirely when the typed text exactly matched a command name or alias, to suppress noise like `/mcp` expanding to `/mcp-server` (MoonshotAI#666). That also hid the exact-match entry itself, so `/editor` showed no menu at all and ↓ did nothing (MoonshotAI#1752). Restore the menu for exact matches by yielding only the matched command (with its description) and skipping the fuzzy fallback. This preserves MoonshotAI#666's intent — no unrelated prefix hits — while letting users confirm the command and read its description as requested in MoonshotAI#1752. Closes MoonshotAI#1752
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 92915966c3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| yield Completion( | ||
| text=f"/{cmd.name}", | ||
| start_position=-len(token), | ||
| display=f"/{cmd.name}", | ||
| display_meta=cmd.description, |
There was a problem hiding this comment.
Prevent double-Enter on exact slash command input
Returning a completion for an already-complete token (e.g. typing /editor and yielding /editor) causes a UX regression in interactive mode: because this prompt uses complete_while_typing=True and binds Enter to has_completions, the first Enter is consumed by apply_completion instead of submitting the command, so users must press Enter twice to run exact-match slash commands. This was not the previous behavior for exact matches and is likely to surprise users who type full command names directly.
Useful? React with 👍 / 👎.
Related Issue
Resolve #1752
Description
Typing an exact command name like
/editorshowed no completion menu, and pressing↓did nothing. A prefix like/editstill worked fine.Root cause: #666 added an early return in
SlashCommandCompleter.get_completionswhenever the typed token matched a command name or alias exactly. The intent was to hide noise like/mcppulling in/mcp-server, but it also hid the exact-match entry itself.Fix: on exact match, yield just the matched command (with its description) and skip the fuzzy fallback.
/mcpstill won't surface/mcp-server, but/editornow shows/editorin the menu so you can read the description before hitting Enter.Tests updated to match the new behaviour, plus one new test to pin the description being carried on exact match.
Changelog added by hand in
CHANGELOG.mdand the en/zh release-notes mirrors —make gen-changelogneeds a logged-in kimi, which I didn't have in the working environment.Checklist
make gen-changelogto update the changelog.make gen-docsto update the user documentation.