Skip to content

【等待审核】feat(agent): 渐进式标题更新——话题漂移自动重生 + 专用模型配置#1144

Draft
climashscape wants to merge 1 commit into
proma-ai:mainfrom
climashscape:feat/progressive-title-update
Draft

【等待审核】feat(agent): 渐进式标题更新——话题漂移自动重生 + 专用模型配置#1144
climashscape wants to merge 1 commit into
proma-ai:mainfrom
climashscape:feat/progressive-title-update

Conversation

@climashscape

Copy link
Copy Markdown
Contributor

概述

实现渐进式会话标题更新:当对话话题显著偏离当前标题时,自动检测并重新生成标题,使侧边栏与顶栏始终反映最新对话主题。

核心机制

三道闸门节流:仅在普通主会话(排除子会话/定时会话)中生效,设置开关可控,距上次生成≥5轮才触发漂移检测,平衡"锚点稳定"与"及时更新"。

漂移判定:取最近6条消息做摘要,发往LLM比对当前标题——相同则只推进 lastTitleTurn 不修改标题,不同则写回新标题。normalizeTitle 归一化全角/半角标点空格差异避免假阳性漂移。

CAS 并发安全:LLM调用期间若用户推进了新轮次(lastTitleTurn 已变),放弃写回让新一轮完成后重新判断。

用户可操作

  • 设置页提供独立开关,可关闭渐进式更新
  • 可指定标题专用模型(渠道+模型),未设置则跟随当前会话模型
  • AgentHeader 提供 ✨ 手动重生成按钮,跳过节流立即触发漂移检测,按 reason 精�确提示(未漂移/无模型/无消息/不支持)

改动

文件 说明
packages/shared/src/types/agent.ts (+32) AgentGenerateTitleInput 扩展(messages/currentTitle)、RegenerateTitleResultlastTitleTurnREGENERATE_TITLE 通道常量
packages/shared/package.json 版本 0.1.41 → 0.1.42
apps/electron/src/main/lib/agent-orchestrator.ts (+403) 核心实现:漂移常量、normalizeTitle/isSameTitle、resolveTitleModel、requestTitle 提取、generateTitle 双模式、maybeRefreshTitle 三道闸门+CAS、regenerateTitle 手动重生成、autoGenerateTitle CAS防护
apps/electron/src/main/lib/agent-service.ts (+8) 新增 regenerateAgentTitle 导出
apps/electron/src/main/lib/agent-session-manager.ts (+2) updateAgentSessionMeta 的 Pick 追加 lastTitleTurn
apps/electron/src/main/lib/settings-service.ts (+3) progressiveTitleUpdateEnabled 默认值(true)
apps/electron/src/main/ipc.ts (+20) REGENERATE_TITLE handler + 全窗口广播 TITLE_UPDATED
apps/electron/src/preload/index.ts (+7) regenerateAgentTitle 桥接
apps/electron/src/types/settings.ts (+6) 3 个新设置字段类型
apps/electron/src/renderer/atoms/ui-preferences.ts (+44) 3 个 atom + 初始化/持久化函数
apps/electron/src/renderer/components/agent/AgentHeader.tsx (+68) ✨ 重生成按钮 + 6 种状态 toast + regenerating 期间禁用编辑
apps/electron/src/renderer/components/settings/GeneralSettings.tsx (+50) 开关 + ModelSelector 标题专用模型
apps/electron/src/renderer/main.tsx (+20) UiPreferencesInitializer 扩展

测试

  • TypeCheck 全包通过(6/6)
  • BDD 自审查通过(4 视角并行子会话审查:核心逻辑 / IPC 通道 / UI 状态管理 / 架构一致性)
  • 体验完整性审查通过(7 条旅程模拟:新会话、漂移、手动重生成、老会话升级、设置交互、并发竞态、多窗口同步)

紧急度

常规

备注

Closes #1079

@climashscape climashscape force-pushed the feat/progressive-title-update branch 2 times, most recently from b75a611 to 2976d3a Compare July 12, 2026 05:07
- 普通主会话累计轮次达阈值且检测到话题漂移时,自动基于最近消息重新生成标题

- 新增 REGENERATE_TITLE IPC 通道,支持手动触发重生成(走同一漂移检测逻辑)

- settings 新增 progressiveTitleUpdateEnabled / titleModelChannelId / titleModelId,标题生成可绑定独立模型

- AgentSessionMeta 新增 lastTitleTurn 节流字段,AgentGenerateTitleInput 支持 messages/currentTitle 二选一

- sendMessage 入口持久化 channelId/modelId 到 meta,resolveTitleModel 回退路径对老会话不再秒退

- AgentHeader 的 Sparkles 按钮仅普通主会话渲染,与后端会话类型闸门对齐

- REGENERATE_TITLE IPC 返回结构化 RegenerateTitleResult { ok, reason, title },前端按 reason 给准确提示,不再用 null 一刀切误报"未偏离"

- bump packages/shared 版本号
@climashscape climashscape force-pushed the feat/progressive-title-update branch from 2976d3a to 95eacc1 Compare July 12, 2026 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

会话标题应在对话推进中渐进式更新,而非仅首条消息生成一次

1 participant