feat(tui): support mid-prompt slash commands - #2496
Conversation
🦋 Changeset detectedLatest commit: ec0e4a6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Allow selected slash commands to appear when typing `/` mid-prompt, and activate skills/plugins embedded in free text on submit. Builtins that only make sense at the start stay leading-only.
- applyCompletion only rewrites a /token prefix as a command name when the item is a registered slash command, so a mid-prompt path completion (e.g. 'please /tm' -> '/tmp/') no longer produces a doubled slash with a stray trailing space. - Update plugin-commands test expectations for the midPrompt flag. - Drop the now-unused isAtStartOfMessage helper from pi-tui's editor. - Treat tab as a separator in the leading-command argument guard, matching the tokenizer.
Selecting a builtin offered by the mid-prompt slash menu now executes it in place instead of inserting its name into the draft: the /token is dropped from the text (undoable) and the command runs with the draft preserved. Settings, help, tasks, mcp, plugins and provider join the mid-prompt set alongside the existing toggles and info panels; skill and plugin commands keep insert-on-select and activate on submit. applyCompletion can now return preventSubmit so confirming such a completion does not fall through to submitting the draft (pi-tui submits slash-prefix completions on Enter). Blocked commands only show the busy error without touching the in-place draft, and immediate items are labeled 'runs immediately' in the mid-prompt menu.
Add a Mid-prompt commands section to the slash-commands reference and mention the new completion in the interaction guide, in both locales. Drop the outdated note that a slash after leading whitespace is treated as plain text — indented slash input now opens command completion.
9d7a55b to
ec0e4a6
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9d7a55b069
ℹ️ 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".
| // No command matched: fall through so path completion can still run | ||
| // for mid-prompt tokens that look like paths. | ||
| if (slashToken.isLeading) return null; |
There was a problem hiding this comment.
Prevent Enter on mid-prompt path completions from submitting
When a mid-prompt /... token has no command match, this fallthrough can return ordinary path suggestions with a prefix like /tm; in the editor, any accepted completion whose prefix starts with / falls through to submit, so pressing Enter to accept /tmp/ in please /tm sends the prompt immediately instead of just completing the path. This only affects prompt-mode mid-prompt path completions; either avoid returning slash-prefixed path suggestions there or mark them so Enter does not submit.
Useful? React with 👍 / 👎.
| if (char === "/" && this.isSlashMenuAllowed()) { | ||
| const currentLine = this.state.lines[this.state.cursorLine] || ""; |
There was a problem hiding this comment.
Allow mid-prompt slash completion past the first line
This new mid-prompt trigger is still gated by isSlashMenuAllowed(), which only allows cursor line 0, so typing / on the second or later line of a multi-line prompt never opens the slash completion menu even though inline slash tokens are resolved from the full submitted text. This leaves users composing multi-line prompts unable to discover or insert skill/plugin commands anywhere after the first line.
Useful? React with 👍 / 👎.
|
Thank you for your interest in contributing to Kimi Code. For new features, please discuss fisrt. We are not currently accepting pull requests for new features. |
Related Issue
No linked issue — the problem is explained below.
Problem
Slash commands only work at the very start of the input: a skill or plugin
command can't be embedded in a natural prompt, and flipping a mode or opening
a panel (plan, model…) means clearing a half-typed prompt first.
What changed
/mid-prompt (at a word boundary) now offers slash completions:skill/plugin commands plus a curated builtin set; other builtins stay
leading-only. Bash mode and path fall-through behave as before.
/skill:nameor/plugin:commandactivates it with the surrounding text as args(exact-name match only, so
/tmpstays plain text). Blocked activationsrestore the draft.
/tokenis dropped from the draft (undoable) and the menu labels these
"runs immediately". The set: plan, yolo, auto, permission, model, effort,
secondary_model, usage, status, plus newly added settings, help, tasks,
mcp, plugins, provider.
applyCompletioncan returnpreventSubmitso confirming a completiondoesn't also submit the editor text.
tests added for parsing/resolution, menu filtering and apply behavior,
immediate triggers, and
preventSubmit.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.