docs/archives/121-context-editor-refactor/implementation.md
通过spec工作流系统分析,识别出以下废弃组件:
ConversationMessageEditor.vue - 功能已内联到ConversationManagerConversationSection.vue - 已被ConversationManager替代# 移除的文件
rm packages/ui/src/components/ConversationMessageEditor.vue
rm packages/ui/src/components/ConversationSection.vue
在 packages/ui/src/index.ts 中移除:
// 移除的导出
export { default as ConversationMessageEditor } from './components/ConversationMessageEditor.vue'
export { default as ConversationSection } from './components/ConversationSection.vue'
在 packages/ui/src/types/index.ts 中移除:
// 移除的类型导出
ConversationSectionProps,
ConversationSectionEmits,
更新了以下测试文件以移除对废弃组件的引用:
tests/unit/components/TestAreaPanel.spec.tstests/unit/components/test-area-e2e.spec.tstests/unit/components/test-area-integration.spec.ts移除了ConversationSection相关的mock代码:
// 移除的mock
vi.mock('../../../src/components/ConversationSection.vue', () => ({
// mock内容
}))
通过代码分析发现以下未使用的props:
:is-predefined-variable - 只在默认值中定义,未实际使用:replace-variables - 只在默认值中定义,未实际使用发现并移除:
:is-predefined-variable - 在ContextEditor中未使用在 packages/web/src/App.vue 中移除未使用的props传递:
ConversationManager (行155-165):
<!-- 移除前 -->
<ConversationManager
:is-predefined-variable="(name) => variableManager?.variableManager.value?.isPredefinedVariable(name) || false"
:replace-variables="(content, vars) => variableManager?.variableManager.value?.replaceVariables(content, vars) || content"
<!-- 其他props -->
/>
<!-- 移除后 -->
<ConversationManager
<!-- 只保留实际使用的props -->
/>
ContextEditor (行296-308):
<!-- 移除前 -->
<ContextEditor
:is-predefined-variable="(name) => variableManager?.variableManager.value?.isPredefinedVariable(name) || false"
<!-- 其他props -->
/>
<!-- 移除后 -->
<ContextEditor
<!-- 保留scan-variables和replace-variables,因为ContextEditor中实际使用了这些 -->
/>
发现Vue 3的自动命名转换机制:
:available-variables 自动映射到 availableVariables@open-variable-manager 自动映射到 openVariableManager使用以下方法分析props实际使用情况:
# 查找props使用
grep -n "props\." ComponentName.vue
# 查找emit调用
grep -n "emit(" ComponentName.vue
采用了以下验证策略:
- 构建时间: 无明显变化
- 包体积: UI包大小略有减小
- 运行时性能: 无明显差异
- 内存使用: 组件数量减少,理论上内存占用略有优化
如果需要回滚,可以按以下步骤进行:
备注:由于移除的都是废弃功能,实际上不太需要回滚。
技术栈: Vue 3 + TypeScript + Vite 工具: Spec Workflow + Playwright Browser Automation 验证方式: 功能测试 + 构建验证 + 开发服务器测试