Add automated fix workflow for AI nutritionist page

- Create .fixes/ directory structure for tracking repairs
- Add FIX-001 to FIX-009 repair tasks based on Cursor review
- Add automation scripts (start-fix.sh, complete-fix.sh)
- Update HEARTBEAT.md with repair checklist
- Create AUTOMATION_PLAN.md with workflow documentation

Fixes address:
- Remove fake initial data
- Add clear chat button
- Split oversized component
- Optimize multi-image upload
- Fix scroll behavior
- Remove dead code
- Extract hardcoded config
This commit is contained in:
2026-02-28 06:56:43 +08:00
parent 14d29d51c0
commit 6122f94818
14 changed files with 628 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
# FIX-001: 移除初始假数据
**状态**: 待开始
**创建时间**: 2026-02-28
**优先级**: 高
**负责人**: msh-agent
---
## 问题描述
当前 `ai-nutritionist.vue` 页面 `data()``messageList` 数组包含两条写死的示例消息用户问香蕉、AI回答用户首次进入会误以为有历史对话记录。
### 当前行为
页面加载后自动显示两条假对话消息。
### 预期行为
首次进入时 `messageList` 为空,仅显示欢迎语(欢迎语固定在模板中)。
---
## 修复方案
**方案A推荐**:将 `messageList` 初始值设为空数组 `[]`,保留欢迎语在模板中的展示。
---
## 实施步骤
- [ ] 1. 备份原文件
- [ ] 2. 修改 `data()``messageList: []`
- [ ] 3. 本地 H5 测试
- [ ] 4. 微信小程序测试
- [ ] 5. 提交代码
---
## 文件变更
修改 `pages/tool/ai-nutritionist.vue` 第 115-128 行:
```javascript
// 修改前
messageList: [
{ role: 'user', content: '我今天想吃香蕉,可以吗?', type: 'text' },
{ role: 'ai', content: '香蕉含钾量较高...', type: 'text' }
]
// 修改后
messageList: []
```

View File

@@ -0,0 +1,32 @@
# FIX-002: 添加清空对话按钮
**状态**: 待开始
**创建时间**: 2026-02-28
**优先级**: 中
**负责人**: msh-agent
---
## 问题描述
`clearChat()` 方法已实现清空消息列表和会话ID但在模板中没有对应的触发按钮用户无法清空对话。
### 预期行为
在页面顶部导航栏或输入区域提供"清空对话"按钮。
---
## 修复方案
`promo-banner` 右侧添加清空按钮图标,绑定 `@click="clearChat"`
---
## 实施步骤
- [ ] 1. 备份原文件
- [ ] 2. 在 `promo-banner` 区域添加清空按钮
- [ ] 3. 绑定 `@click="clearChat"`
- [ ] 4. 添加样式
- [ ] 5. 测试确认对话框
- [ ] 6. 多端测试

View File

@@ -0,0 +1,32 @@
# FIX-003: 拆分单文件组件
**状态**: 待开始
**创建时间**: 2026-02-28
**优先级**: 高
**负责人**: msh-agent
---
## 问题描述
`ai-nutritionist.vue` 单文件超过 550 行,包含聊天、语音、图片、状态管理等多个功能模块,可维护性差。
---
## 修复方案
拆分为以下组件:
- `components/ai-chat/ChatMessage.vue` - 消息气泡
- `components/ai-chat/ChatInput.vue` - 输入框
- `components/ai-chat/VoiceRecorder.vue` - 语音录制
- `components/ai-chat/ImageUploader.vue` - 图片上传
---
## 实施步骤
- [ ] 1. 备份原文件
- [ ] 2. 创建 `components/ai-chat/` 目录
- [ ] 3. 逐个提取组件
- [ ] 4. 在主文件引入组件
- [ ] 5. 测试所有功能正常

View File

@@ -0,0 +1,18 @@
# FIX-004: 多图合并为一轮对话
**状态**: 待开始
**创建时间**: 2026-02-28
**优先级**: 中
**负责人**: msh-agent
---
## 问题描述
当前多图时每张单独一轮 Coze 对话AI 回复会一条条出现,且无法把"多图+一句说明"作为同一上下文。
---
## 修复方案
若 Coze 支持,一次 `additionalMessages` 里带多条(文本+多图),减少轮次、统一上下文。

View File

@@ -0,0 +1,18 @@
# FIX-005: 消息列表使用稳定 key
**状态**: 待开始
**创建时间**: 2026-02-28
**优先级**: 中
**负责人**: msh-agent
---
## 问题描述
`:key="index"` 在列表中间增删时可能影响复用与动画,建议改为稳定 id。
---
## 修复方案
为每条消息生成唯一 id如 uuid 或服务端 id`:key="msg.id"`

View File

@@ -0,0 +1,18 @@
# FIX-006: 优化滚动到底部实现
**状态**: 待开始
**创建时间**: 2026-02-28
**优先级**: 低
**负责人**: msh-agent
---
## 问题描述
`scrollToBottom` 使用 99998/99999 magic number在部分机型上可能不生效。
---
## 修复方案
改为:先设一个很大的数触底,再在 `@scroll` 里记录实际 scrollTop下次用 `lastScrollTop + 1` 等小步进触发一次滚动。

View File

@@ -0,0 +1,12 @@
# FIX-007: 删除废弃方法
**状态**: 待开始
**创建时间**: 2026-02-28
**优先级**: 低
**负责人**: msh-agent
---
## 问题描述
`sendImageMessage` 方法注释"已废弃,逻辑合并到 sendMessage",建议删除该方法,避免误导。

View File

@@ -0,0 +1,26 @@
# FIX-008: 提取硬编码配置
**状态**: 待开始
**创建时间**: 2026-02-28
**优先级**: 中
**负责人**: msh-agent
---
## 问题描述
`botId`、轮询次数(60/30)、轮询间隔(1000/2000)、最大录音 60s 等硬编码,建议提到 `data` 或单独 config。
---
## 修复方案
创建配置对象集中管理:
```javascript
const CHAT_CONFIG = {
botId: '7591133240535449654',
maxPollAttempts: 60,
pollInterval: 1000,
maxRecordDuration: 60
}
```

View File

@@ -0,0 +1,18 @@
# FIX-009: H5 语音输入降级优化
**状态**: 待开始
**创建时间**: 2026-02-28
**优先级**: 低
**负责人**: msh-agent
---
## 问题描述
H5 环境仅提示"暂不支持语音输入",可考虑集成 Web Speech API 作为降级方案。
---
## 修复方案
使用 Web Speech API (webkitSpeechRecognition) 作为 H5 环境的语音输入方案。