新增: skills 视图与标题编辑测试(未落库功能批量入库)

This commit is contained in:
lxy
2026-08-23 18:25:02 +08:00
parent 95f349bcd7
commit d54d0c4c63
12 changed files with 985 additions and 37 deletions
+50 -16
View File
@@ -11,22 +11,24 @@ import (
// Model 主模型
type Model struct {
activeGroup int
cursor int
selected map[int]bool
inputBuf string
width int
height int
launched string
history HistoryState
pendingCmd string
update UpdateState
wsFocus int // workspace 焦点列: 0=tabs 1=list
wsTabCur int // tabs 列光标 (0..len(Groups), 最后一个是历史入口)
forkMode bool // 分叉输入模式
forkBuf string // 分叉方向提示输入
editTitleMode bool // 编辑标题模式
editTitleBuf string // 标题编辑缓冲区
activeGroup int
cursor int
selected map[int]bool
inputBuf string
width int
height int
launched string
history HistoryState
pendingCmd string
update UpdateState
wsFocus int // workspace 焦点列: 0=tabs 1=list
wsTabCur int // tabs 列光标 (0..len(Groups), 最后一个是历史入口)
Skills SkillsState
forkMode bool // 分叉输入模式
forkBuf string // 分叉方向提示输入
editTitleMode bool // 编辑标题模式
editTitleBuf string // 标题编辑缓冲区
editTitleCursor int // 标题光标位置(rune 索引)
// 性能缓存
allSessionsCache []*Session // "全部" tab 会话切片缓存
@@ -60,8 +62,29 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.width = msg.Width
m.height = msg.Height
case ScanCompleteMsg:
// 保留尚未落盘的用户自定义标题:扫描从磁盘读缓存,若改名后 3s 内
// 触发扫描(切 tab/刷新),磁盘旧缓存会覆盖内存导致改名丢失。
savedTitles := map[string]string{}
for id, e := range m.history.Cache {
if e.UserTitle != "" {
savedTitles[id] = e.UserTitle
}
}
m.history.Projects = msg.Projects
m.history.Cache = msg.Cache
for id, title := range savedTitles {
if e, ok := m.history.Cache[id]; ok && e.UserTitle == "" {
e.UserTitle = title
m.cacheDirty = true
}
for _, pd := range m.history.Projects {
for _, s := range pd.Sessions {
if s.ID == id {
s.UserTitle = title
}
}
}
}
m.history.Loaded = true
m.history.Scanning = false
m.allSessionsDirty = true
@@ -93,6 +116,16 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.launched = fmt.Sprintf("refreshed: %d projects, %d sessions", len(msg.Projects), total)
// 无论本次是否有文件更新,都尝试补齐缺失的摘要
return m, m.nextSummaryCmd()
case ScanSkillsCompleteMsg:
m.Skills.Skills = msg.Skills
m.Skills.Loaded = true
m.Skills.Scanning = false
m.Skills.SkillCur = 0
m.Skills.FileCur = 0
m.Skills.FocusPanel = 0
m.Skills.Content = ""
m.Skills.ContentPath = ""
return m, nil
case SummaryResultMsg:
m.applySummary(msg.SessionID, msg.Summary, msg.Completed, msg.Pending)
m.cacheDirty = true
@@ -139,6 +172,7 @@ func (m *Model) confirmEditTitle() (*Model, tea.Cmd) {
title := strings.TrimSpace(m.editTitleBuf)
m.editTitleMode = false
m.editTitleBuf = ""
m.editTitleCursor = 0
if s == nil || title == "" {
return m, nil
}