Skip to content

fix(shell): show exact-match slash command in completion menu#1787

Open
kevinWangSheng wants to merge 1 commit intoMoonshotAI:mainfrom
kevinWangSheng:fix/slash-completer-exact-match
Open

fix(shell): show exact-match slash command in completion menu#1787
kevinWangSheng wants to merge 1 commit intoMoonshotAI:mainfrom
kevinWangSheng:fix/slash-completer-exact-match

Conversation

@kevinWangSheng
Copy link
Copy Markdown

@kevinWangSheng kevinWangSheng commented Apr 8, 2026

Related Issue

Resolve #1752

Description

Typing an exact command name like /editor showed no completion menu, and pressing did nothing. A prefix like /edit still worked fine.

Root cause: #666 added an early return in SlashCommandCompleter.get_completions whenever the typed token matched a command name or alias exactly. The intent was to hide noise like /mcp pulling 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. /mcp still won't surface /mcp-server, but /editor now shows /editor in 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.md and the en/zh release-notes mirrors — make gen-changelog needs a logged-in kimi, which I didn't have in the working environment.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked the related issue, if any.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have run make gen-changelog to update the changelog.
  • I have run make gen-docs to update the user documentation.

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
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +151 to +155
yield Completion(
text=f"/{cmd.name}",
start_position=-len(token),
display=f"/{cmd.name}",
display_meta=cmd.description,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slash command completion menu should appear for exact match (e.g. /editor)

1 participant