Commit 21368fa
committed
fix(conversation): 修复多轮对话历史记录恢复问题并全面优化版本管理
核心修复:
- 修复多轮对话模式下 V2 及以上迭代版本无法正确恢复的 bug
- 修复消息顺序优化后历史记录恢复时,部分消息错误回溯到原始 (V0) 状态的 bug
- 在 iterateMessage 中手动预计算版本号,确保快照中的 appliedVersion 与实际保存的版本号一致
- 重构 useConversationOptimization.ts 中 getMessageAppliedVersion 函数,统一版本语义,使用 record.version 属性而非数组索引进行匹配
- 修正优化快照 (conversationSnapshot) 构建逻辑,确保当前优化消息的 appliedVersion 和 content 始终准确无误
- 改进 conversation optimizer 中的版本匹配机制,使用修剪后的字符串比较防止错误版本不匹配
功能增强:
- 新增完整的 iterateMessage 方法,支持多轮对话的消息级迭代优化
- 传递完整上下文数据(messages、selectedMessageId)给底层服务
- 对比测试时分别维护 originalToolCalls 和 optimizedToolCalls,确保工具调用结果互不干扰
- 在 prompt optimizer 历史元数据中添加 conversationSnapshot 以支持准确的状态恢复
- 重构优化流程,optimizeMessage 现在强制重置状态,避免状态污染
UI 优化:
- 调整版本标签显示顺序为 v3 v2 v1 v0(最新版本在前,v0 固定在最后)
- 优化版本切换交互体验
国际化支持:
- 修复 prompt optimizer 中的硬编码中文字符串,替换为 i18n 键
- 为多轮对话优化添加缺失的 i18n 键
代码质量:
- 删除所有调试日志(console.log)
- 添加模板处理边界情况注释(Mustache 空数组 vs undefined)
- 更新 App.vue (Web 和 Extension) 的历史记录恢复逻辑,通过 record.version 精确查找版本,增强了对历史记录删除(导致版本数组稀疏)的健壮性
- 为对话优化功能暂存未跟踪的新文件1 parent b8cf182 commit 21368fa
File tree
54 files changed
+5335
-958
lines changed- docs/workspace
- packages
- core
- src
- services
- favorite
- history
- prompt
- template
- default-templates
- optimize/context
- tests
- services/favorite
- unit/template
- desktop
- extension/src
- ui
- src
- components
- context-mode
- types
- composables/prompt
- i18n/locales
- types
- tests
- e2e
- integration
- unit/components
- web/src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
54 files changed
+5335
-958
lines changedLarge diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
7 | 19 | | |
8 | 20 | | |
9 | 21 | | |
| |||
40 | 52 | | |
41 | 53 | | |
42 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
43 | 65 | | |
44 | 66 | | |
45 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
35 | 42 | | |
36 | 43 | | |
37 | 44 | | |
38 | 45 | | |
39 | 46 | | |
40 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
41 | 54 | | |
42 | | - | |
| 55 | + | |
| 56 | + | |
43 | 57 | | |
44 | 58 | | |
45 | 59 | | |
| |||
66 | 80 | | |
67 | 81 | | |
68 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
69 | 89 | | |
70 | 90 | | |
71 | 91 | | |
72 | 92 | | |
73 | 93 | | |
74 | 94 | | |
75 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
76 | 102 | | |
77 | | - | |
| 103 | + | |
| 104 | + | |
78 | 105 | | |
79 | 106 | | |
80 | 107 | | |
| |||
0 commit comments