feat: auto-submit slash commands upon selection from completion menu#1509
feat: auto-submit slash commands upon selection from completion menu#1509Br1an67 wants to merge 1 commit intoMoonshotAI:mainfrom
Conversation
When the user selects a slash command from the completion menu and the result is a bare command (e.g. /yolo, /clear) with no arguments, it is now submitted immediately without requiring a second Enter press. Commands that take arguments (e.g. /compact <hint>) are not affected — the auto-submit only triggers when there is no space in the text, meaning no arguments have been typed. Closes MoonshotAI#751
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d8ba916158
ℹ️ 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".
| # Auto-submit if the result is a bare slash command (no arguments) | ||
| text = buff.text.strip() | ||
| if text.startswith("/") and " " not in text: | ||
| buff.validate_and_handle() |
There was a problem hiding this comment.
Skip auto-submit for slash commands that take arguments
Calling validate_and_handle() immediately after apply_completion() means the user never gets a chance to type the space and arguments that the PR description relies on. In practice, choosing /plan from completion now executes the bare command right away, and src/kimi_cli/soul/slash.py:104-141 treats empty args as a state-changing toggle; similarly, /add-dir and /import (src/kimi_cli/soul/slash.py:145-155 and :247-255) are submitted before a path can be entered. That makes completion actively destructive or unusable for argument-taking slash commands.
Useful? React with 👍 / 👎.
Refs MoonshotAI#751 — selecting a slash command from completion should auto-execute without a second Enter press. The naive approach (calling validate_and_handle() for all bare slash commands) was already rejected in PR MoonshotAI#1509: commands like /plan, /compact, /add-dir, and /import accept arguments, so auto-submitting them is destructive or confusing. Next step: add an `auto_submit` flag to SlashCommand so each command can opt-in explicitly, then wire it into the Enter keybinding. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Related Issue
Resolve #751
Description
When the user selects a slash command from the completion menu by pressing Enter, the command is now submitted immediately — no second Enter press needed.
How it works
After
buff.apply_completion(completion), we check whether the resulting buffer text is a bare slash command (starts with/and contains no spaces). If so,buff.validate_and_handle()is called to auto-submit.Commands that take arguments (e.g.,
/compact <hint>,/plan on) are not affected. The auto-submit only triggers when the buffer contains a single-word slash command. Users who want to type arguments can either:Example
/y→ select/yolo→ press Enter again/y→ select/yolo→ executed immediately/c→ select/clear→ press Enter again/c→ select/clear→ executed immediately/compact→ want to add args → press Enter, type hintChecklist
make gen-changelogto update the changelog.make gen-docsto update the user documentation.