refactor(web): extract slash-command menu into a composable#1026
Merged
Conversation
Move the slash menu's open/items/active state, the filter logic, and item selection out of Composer into useSlashMenu. The composable takes the text ref, textarea ref, autosize, a skills getter, and the emit/history-push callbacks as deps. The composer keeps the keydown orchestration (arrow keys, Enter/Tab, Escape) because it also juggles the mention menu and history recall; it consumes the returned open/items/active refs directly and calls update/select. The destructured refs are aliased back to the original names so the rest of the component is unchanged. Composer.vue: 2058 -> 2035 lines. Adds unit tests for useSlashMenu. No behavior change.
🦋 Changeset detectedLatest commit: f7e863f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
commit: |
This was referenced Jun 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
Part of the
apps/kimi-webgod-component split tracked inweb-refactor-plan.md(follows #1011useInputHistory). This is the next Composer slice. No standalone issue.Problem
Composer.vueis still the largest component (~2058 lines). The/slash-command menu is a self-contained feature — its open/items/active state, the filter logic, and item selection — that lived inline in the composer alongside the draft, the mention menu, attachments, and the keydown orchestration.What changed
apps/kimi-web/src/composables/useSlashMenu.ts:open/items/activestate, theupdate()filter logic, andselect(item)(acceptsInput leaves the command in the box; bare commands emit + record history).{ text, textareaRef, autosize, skills, emitCommand, historyPush }as deps — same DI shape asuseInputHistory.Composer.vue:useSlashMenu(...)call, destructured back to the original names (slashOpen,slashItems,slashActive,updateSlashMenu,selectSlashCommand) so the rest of the component — the keydown navigation,handleSubmit,handleSteer, and the<SlashMenu>template binding — is unchanged.test/slash-menu.test.ts(9 cases: open/filter/close rules, skills, select for acceptsInput and bare commands).No user-visible behavior change. Logic moved verbatim; only the call sites were re-wired.
Verification
pnpm --filter @moonshot-ai/kimi-web typecheck— pass (vue-tsc --noEmit)pnpm --filter @moonshot-ai/kimi-web test— 64 passedpnpm --filter @moonshot-ai/kimi-web build— passoxlint --type-awareon the changed files — 0 warnings, 0 errorsChecklist
test/slash-menu.test.ts.)gen-changesetsskill, or this PR needs no changeset. (Added.changeset/web-extract-slash-menu.md,patchon@moonshot-ai/kimi-code.)gen-docsskill, or this PR needs no doc update. (No user-facing change.)