【已审核】feat(agent): 会话标题自动跟随话题更新#1144
Open
climashscape wants to merge 1 commit into
Open
Conversation
climashscape
force-pushed
the
feat/progressive-title-update
branch
7 times, most recently
from
July 12, 2026 07:19
69d4cfb to
bfce0b2
Compare
climashscape
marked this pull request as ready for review
July 12, 2026 08:16
climashscape
force-pushed
the
feat/progressive-title-update
branch
from
July 12, 2026 08:43
4d8b35f to
5d0a872
Compare
实现渐进式会话标题更新:流完成后自动检测话题漂移并重新生成标题, 支持手动重生成(AgentHeader Sparkles 按钮),带节流/CAS锁/会话类型闸门。 核心功能: - maybeRefreshTitle:三道闸门(会话类型→设置开关→节流),completeRun 后 fire-and-forget - regenerateTitle:用户手动触发,专用 REGENERATE_TITLE_PROMPT 强制生成新标题 - titleManualOverride:用户手动编辑标题后跳过自动漂移,手动重生成后清除 - autoGenerateTitle:首条标题统一走 resolveTitleModel 模型解析路径 - sanitizeTitleOutput:黑名单滤除 prompt 指令回显,失败后静默重试极简 prompt - 设置页:渐进式开关 + 标题专用模型选择(ModelSelector) UX 改进: - 自动漂移更新 toast 低打扰通知(isAuto 标志) - 手动重生成 toast 带「撤销」按钮 - Pencil 编辑按钮不因 regenerating 锁定 - 设置描述去绝对化("始终"→"话题变化时")
climashscape
force-pushed
the
feat/progressive-title-update
branch
from
July 12, 2026 09:21
5d0a872 to
3961ac0
Compare
Contributor
Author
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

概述
让会话标题"活"起来——当你的对话悄悄换了话题,标题会自动跟上,不用手动改。
场景
你跟 Agent 聊着聊着,话题漂移了——从"怎么写这个 API"滑到了"数据库索引怎么优化"。再看侧边栏,标题还停在最初的"帮我写 API",已经和对话内容脱节了。
这个 PR 解决的问题就是:让标题自己去追对话。
怎么运作的
不是每轮都检测(那样太吵),而是设了四道闸门,过了才查:
防误判:标题比对前会
normalizeTitle— 全角半角统一、空白折叠、标点全删。比如「帮我写 API!」和「帮我写API」不会因为一个叹号和空格就被判成"漂移"。更新后的标题还会过一道sanitizeTitleOutput,防止弱模型把 prompt 指令(「只输出标题」「不要废话」之类)当标题吐出来。防竞态:LLM 调用期间如果你又发了新消息,旧的标题结果会自动作废(CAS 机制)——不会拿过期的标题覆盖你正在进行的新话题。
怎么用
自动模式(默认开启):什么也不用做。聊着聊着话题变了,标题自己更新,侧边栏会弹一个安静的 toast「标题已自动更新为:…」。
手动触发:顶栏 AgentHeader 右边多了个 ✨ 按钮。点一下就立即检测——如果标题已经准确,会告诉你「标题已反映当前话题」;如果需要更新,即刻重生成。重生成后还有撤销按钮,万一不满意一键回退。
个性化设置:
手动改标题的尊重:如果你自己点击标题编辑,系统会记住"这是用户亲手改的",不再自动覆盖——直到你主动点 ✨ 重生成,才算"重新交给系统"。
其他细节
改动
packages/shared/src/types/agent.tsAgentGenerateTitleInput扩展(messages / currentTitle / isManualRegen)、RegenerateTitleResult类型、lastTitleTurn/titleManualOverride元数据字段、REGENERATE_TITLE通道常量packages/shared/package.jsonapps/electron/src/main/lib/agent-orchestrator.tsapps/electron/src/main/lib/agent-service.tsregenerateAgentTitle导出;onTitleUpdated新增isAuto参数apps/electron/src/main/lib/agent-session-manager.tslastTitleTurn/titleManualOverrideapps/electron/src/main/lib/settings-service.tsprogressiveTitleUpdateEnabled默认 trueapps/electron/src/main/ipc.tsREGENERATE_TITLEhandler + 全窗口广播 +UPDATE_TITLE追加 manual override 标记apps/electron/src/preload/index.tsregenerateAgentTitle桥接;onAgentTitleUpdated签名扩展apps/electron/src/types/settings.tsapps/electron/src/renderer/atoms/ui-preferences.tsapps/electron/src/renderer/components/agent/AgentHeader.tsxapps/electron/src/renderer/components/settings/GeneralSettings.tsxapps/electron/src/renderer/hooks/useGlobalAgentListeners.tsapps/electron/src/renderer/main.tsxpackages/core/src/providers/anthropic-adapter.tsbody.thinking = { type: 'disabled' }),避免思维链污染标题测试
紧急度
常规
备注
Closes #1079