fix(conversation): fix failed conversation auto-titles#1992
fix(conversation): fix failed conversation auto-titles#1992piorpua merged 2 commits intoiOfficeAI:mainfrom
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Code Review:fix(conversation): fix failed conversation auto-titles (#1992)变更概述本 PR 重构了会话自动标题功能,将标题来源从当前输入改为对话历史中的第一条用户消息,解决了多轮对话后标题仍为"New Chat"或被后续消息覆盖的问题。改动涉及 方案评估结论:✅ 方案合理 方案正确解决了目标问题:将 auto-title 的来源从"当前发送的消息"改为"历史中的第一条用户消息",使标题确定性可复现。将 问题清单🔵 LOW — autoTitle.ts 中 filter + [0] 可用 find 替代文件: 问题代码: const lines = withoutThinkTags
.replace(/\r/g, '')
.split('\n')
.map((line) => line.trim())
.filter((line) => line && line !== '```');
const firstLine = lines[0] ?? '';问题说明:oxlint 修复建议: const firstLine = withoutThinkTags
.replace(/\r/g, '')
.split('\n')
.map((line) => line.trim())
.find((line) => line && line !== '```') ?? '';🔵 LOW — pageSize: 1000 获取全部消息仅为找第一条用户消息文件: 问题代码: const messages = await ipcBridge.database.getConversationMessages.invoke({
conversation_id: conversationId,
page: 0,
pageSize: 1000,
});问题说明:为了找到第一条用户消息,获取了最多 1000 条消息。对于大多数会话这不是问题,但对于长对话可能产生不必要的 IPC 开销。可考虑未来提供更精准的查询接口(如按 position 和 type 筛选),当前实现可接受。 汇总
结论✅ 批准合并 — 无阻塞性问题。方案设计合理,代码结构清晰,测试覆盖了核心逻辑(autoTitle 工具函数、useAutoTitle hook、conversation 页面联动)。两个 LOW 级别建议可在后续迭代中优化。 本报告由本地 |
|
✅ 已自动 review,无阻塞性问题,正在触发自动合并。 |
Summary
New Chatafter multiple turnsChanges
Why
Previously, auto-title updates were timing-sensitive:
New Chatbecause the rename path was missedThis PR makes the title source deterministic: use the first user prompt.
Tests
bun run vitest tests/unit/chat/autoTitle.test.ts tests/unit/chat/useAutoTitle.dom.test.tsx tests/unit/chat/conversationIndex.dom.test.tsx tests/unit/renderer/platformSendBoxes.dom.test.tsx tests/unit/renderer/useGeminiInitialMessage.dom.test.tsx tests/unit/RemoteSendBox.dom.test.tsxScope