新增: 历史会话标题自定义编辑与摘要质量修复

- 标题自定义编辑:HISTORY 详情按 e 编辑标题,UserTitle 持久化到缓存且最高优先级
- AI 摘要质量修复:困惑回复检测词表收紧,消息提取过滤噪音,修复 JSON 包裹困惑回复漏网
- 数据维护命令:--fix-titles 清理低质量摘要,--regen-summaries 并发生成
- 修复代码审查 9 个问题:退格 UTF-8 损坏、中文输入、flush 调度、误杀合法摘要、
  按键全局拦截、UserTitle 未同步窗口标题、wt 启动回落、cmd 注入防护、前缀误隐藏会话
- 启动链 wt.exe 回退与 cmd start 标题转义
- gofmt 规范化,新增 launch_test.go
This commit is contained in:
lxy
2026-07-31 21:22:17 +08:00
parent 043a7d9227
commit 95f349bcd7
10 changed files with 1465 additions and 126 deletions
+43
View File
@@ -5,6 +5,11 @@ import tea "charm.land/bubbletea/v2"
// --- 按键分发 ---
func (m *Model) handleKey(s string) (*Model, tea.Cmd) {
// 编辑标题时优先走输入处理,避免 q/1/2/u 等被全局拦截
if m.editTitleMode {
return m.handleHistoryKey(s)
}
switch s {
case "q", "ctrl+c":
return m, tea.Quit
@@ -17,6 +22,8 @@ func (m *Model) handleKey(s string) (*Model, tea.Cmd) {
// Tab 快捷切换: 1=工作空间 2=历史对话
if s == "1" {
m.editTitleMode = false
m.editTitleBuf = ""
if m.IsHistoryTab() {
m.activeGroup = 0
m.resetCursor()
@@ -117,6 +124,9 @@ func (m *Model) handleHistoryKey(s string) (*Model, tea.Cmd) {
if m.forkMode {
return m.handleForkInput(s)
}
if m.editTitleMode {
return m.handleEditTitleInput(s)
}
switch s {
case "up", "k":
@@ -159,6 +169,13 @@ func (m *Model) handleHistoryKey(s string) (*Model, tea.Cmd) {
}
case "f":
m.toggleFavorite()
case "e", "E":
if m.currentSession() != nil && !m.forkMode {
s := m.currentSession()
m.editTitleMode = true
m.editTitleBuf = s.DisplayTitle()
m.history.FocusPanel = 1 // 确保右栏可见
}
case "c":
if m.currentSession() != nil && m.history.FocusPanel == 1 {
m.forkMode = true
@@ -168,6 +185,32 @@ func (m *Model) handleHistoryKey(s string) (*Model, tea.Cmd) {
return m, nil
}
func (m *Model) handleEditTitleInput(s string) (*Model, tea.Cmd) {
switch s {
case "enter":
return m.confirmEditTitle()
case "esc":
m.editTitleMode = false
m.editTitleBuf = ""
case "backspace":
r := []rune(m.editTitleBuf)
if len(r) > 0 {
m.editTitleBuf = string(r[:len(r)-1])
}
default:
// 编辑状态下忽略导航/功能键,避免 up/down/tab 等被当作字符输入
switch s {
case "up", "down", "left", "right", "tab", "shift+tab":
// 不处理
default:
if s != "" && s[0] >= 32 {
m.editTitleBuf += s
}
}
}
return m, nil
}
func (m *Model) handleForkInput(s string) (*Model, tea.Cmd) {
switch s {
case "enter":