refactor(web): extract input-history recall into a composable#1011
Merged
Conversation
Move the shell-style up/down recall of previously sent messages out of Composer into useInputHistory. The composable owns the history list, the browsing cursor, and the textarea caret/selection work needed to apply a recalled entry, taking the text ref, textarea ref, and autosize as deps. The composer keeps the keydown orchestration (which also juggles the slash and mention menus) and calls into the composable for push / recall / caret / browsing state. Composer.vue: 2104 -> 2050 lines. No behavior change.
🦋 Changeset detectedLatest commit: 3fa8402 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: |
Add unit tests for the extracted input-history composable: push dedup and empty-skip, walking backward/forward through entries, restoring the live draft (empty and non-empty), empty-history no-op, resetBrowsing, and the caretAtFirstLine gate.
5 tasks
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 #998 Sidebar→WorkspaceGroup, #1001 ChatPane helpers, #1010 ConversationPane→ConversationToc). This is the first, lowest-risk step of splittingComposer.vue(the hot-path component deferred to last). No standalone issue.Problem
Composer.vueis the largest remaining god component (~2100 lines) and the hottest input path: it owns the draft, the slash and mention menus, attachment upload, the toolbar, and the keydown orchestration. The plan calls for splitting it into focused composables. This PR takes the cleanest, least-coupled slice first — the shell-style ↑/↓ recall of previously sent messages — which touches only the text ref, the textarea ref, and autosize, and has no dependency on props or emits.What changed
apps/kimi-web/src/composables/useInputHistory.ts:{ text, textareaRef, autosize }as deps (same DI shape as the existinguseXxx(rawState, deps)client modules) and returnspush,caretAtFirstLine,recallOlder,recallNewer,resetBrowsing,isBrowsing,hasHistory.Composer.vue:const history = useInputHistory({ text, textareaRef, autosize });.handleInputcallshistory.resetBrowsing(); submit/steer callhistory.push(trimmed); the keydown handler readshistory.isBrowsing()/history.hasHistory()/history.caretAtFirstLine()and callshistory.recallOlder()/history.recallNewer().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— 40 passedpnpm --filter @moonshot-ai/kimi-web build— passoxlint --type-awareon the two changed files — 0 warnings, 0 errorsChecklist
vue-tsc --noEmitis the safety net, plus manual verification.)gen-changesetsskill, or this PR needs no changeset. (Added.changeset/web-extract-composer-input-history.md,patchon@moonshot-ai/kimi-code.)gen-docsskill, or this PR needs no doc update. (No user-facing change.)