Skip to content

feat: auto-submit slash commands upon selection from completion menu#1509

Closed
Br1an67 wants to merge 1 commit intoMoonshotAI:mainfrom
Br1an67:feat/slash-autoexec
Closed

feat: auto-submit slash commands upon selection from completion menu#1509
Br1an67 wants to merge 1 commit intoMoonshotAI:mainfrom
Br1an67:feat/slash-autoexec

Conversation

@Br1an67
Copy link
Copy Markdown

@Br1an67 Br1an67 commented Mar 19, 2026

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:

  1. Continue typing after the completion is applied (the space prevents auto-submit).
  2. Type the full command manually without triggering completion.

Example

Before After
Type /y → select /yolo → press Enter again Type /y → select /yolo → executed immediately
Type /c → select /clear → press Enter again Type /c → select /clear → executed immediately
Type /compact → want to add args → press Enter, type hint Same behavior — user can still add args

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.

Open with Devin

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

Comment on lines +1023 to +1026
# 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()
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 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 👍 / 👎.

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

@RealKai42 RealKai42 closed this Mar 20, 2026
wbxl2000 added a commit to wbxl2000/kimi-cli that referenced this pull request Apr 3, 2026
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>
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 commands execute immediately upon selection.

2 participants