You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(app-components): extract shared tool card and task list setup hooks - #5543
I have linked a related issue (external PRs: issue must have a maintainer's /approve).(内部重构前置 PR,无关联 issue)
I have added tests that prove my feature works.(复用 app-components 现有 1018 个组件与工具输出单测验证等价性,保留 goalToolOutput.test.ts 全部断言)
The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
Ran gen-changesets skill, or this PR needs no changeset.(私有 app-* UI 层内部重构,无用户可感知变化,无需 changeset)
Ran gen-docs skill, or this PR needs no doc update.(不改变用户可见功能,无需更新用户文档)
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
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
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.
Requirement or Bug
为后续移除
packages/app-components内部对自身公共桶文件(@moonshot-ai/app-components)的自引用做准备。当前工具卡片(chat/tool-calls/*Tool.vue)与任务面板(SubagentGrid.vue、TasksPane.vue)的<script setup>头部存在大段复制粘贴的样板代码,多对组件已有超过 60 tokens 的相同片段;一旦仅修改 import 路径,既有重复片段的指纹就会变化,从而触发 CIlint中的check:duplication(jscpd)新增重复门禁。本 PR 先将这些公共 setup 收敛为业务 hooks,消除存量重复,让后续断环 PR 保持纯粹的 import 路径调整。Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
核心思路
按「业务逻辑收敛到 hooks,UI 组件组合 hooks 驱动视图」的方式提取公共 setup,不改变任何组件的模板结构、样式、交互行为与持久化存储键。浏览器相关组件(
BrowserTool.vue、browser/*)不在本 PR 范围内,未做改动。新增与调整的模块
chat/tool-calls/useToolCard.ts(新增)ToolCardProps;useToolCard(props)提供panelApi、status、kind、args、argText、toolNameLabel、label、summary、summaryFull、hasOutput(均为惰性computed,未使用不求值);useToolCardExpansion(props, canExpand)负责useHistoryState折叠状态持久化与defaultExpanded自动展开监听chat/dock/useTaskList.ts(新增)TaskListProps/TaskListEmits;useTaskList(props, t)提供SubagentGrid与TasksPane共用的panelApi、modelDisplay、subagentEffort、isCancelling、stateLabel、durationLabelchat/tool-calls/goalToolOutput.tsupdateGoalVisibleOutput导出及既有单测;新增GOAL_TOOL_KIND常量、goalHeadline、goalVisibleOutput与useGoalToolCard,将 Goal 卡片标题/预算/状态文案与展开逻辑收拢为纯函数与 hook.vue+ 2 个任务面板.vue旧路径功能清单与等价性对照
status运行时值原样透传给ToolDisclosure(原代码用as 'running'|'ok'|'error'窄化类型)useToolCard返回真实ToolStatus,运行时值完全不变;ToolDisclosure本身已支持'cancelled',无需类型强转tool:${tool.id}:openuseToolCardExpansion中保持完全相同的 key 与初始值defaultExpanded === true && canExpandwatch[defaultExpanded, output?.length, status, name];同一 toolCall 的name不变,与原先监听前 3 项行为一致EditTool(初始open=false、无自动展开 watch)、ReadTool(everOpened跟踪)EditTool保留自身的useHistoryState;ReadTool保留everOpenedwatchAgentTool、AskUserTool、PlanTool、SelectToolsTool、SwarmTool、TodoTool、BashTool、CronTool)TasksPane状态文案stateLabel(task)useTaskList的stateLabel(state),模板改为stateLabel(task.state)vue-i18n的使用方式useI18n()保持在各.vue组件中单独调用;需要翻译的 hooks / 纯函数(useTaskList、useGoalToolCard、goalHeadline)通过参数接收t,不在业务 hooks 内二次包装useI18n同时运行
ratchet.mjs --update与app-boundaries.mjs --update下调基线:SubagentGrid.vue、TasksPane.vue、GoalTool.vue已提前退出app-components运行时循环依赖环。Behavior Changes and Affected Users
updateGoalVisibleOutputgoalToolOutput.ts纯函数,规则与原单测保持一致验证记录
pnpm --filter kimi-code-app run typecheck:通过。pnpm exec vitest run --reporter=agent packages/app-components:101 个测试文件、1018/1018 通过。pnpm lint:通过(0 退出),oxlint-ratchet与app-boundaries基线均已下调。pnpm run check:duplication origin/main:本 PR 涉及的app-components重复片段已全部消除;本地 macOS(jscpd-darwin-arm64@5.1.2)在 diff 非空时会对未触碰的packages/core/src/tool/tool-executor.ts:403-444同文件自克隆报出基线指纹缺失(纯净origin/main无 diff 时不触发),本 PR 未修改core,以 CI Linux 门禁结果为准。Checklist
/approve).(内部重构前置 PR,无关联 issue)app-components现有 1018 个组件与工具输出单测验证等价性,保留goalToolOutput.test.ts全部断言)gen-changesetsskill, or this PR needs no changeset.(私有app-*UI 层内部重构,无用户可感知变化,无需 changeset)gen-docsskill, or this PR needs no doc update.(不改变用户可见功能,无需更新用户文档)