新增: AI 摘要生成 (claude -p)

扫描完成后自动逐个调用 claude -p 生成会话标题,
摘要缓存到 ~/.u-tabs/session-cache.json, 下次免重复调用
This commit is contained in:
2026-05-16 23:33:06 +08:00
parent 3e81d4510f
commit e4ef8e02aa
2 changed files with 124 additions and 2 deletions

View File

@@ -56,7 +56,10 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.history.Projects = msg.Projects
m.history.Loaded = true
m.history.Scanning = false
return m, nil
return m, m.nextSummaryCmd()
case SummaryResultMsg:
m.applySummary(msg.SessionID, msg.Summary)
return m, m.nextSummaryCmd()
}
return m, nil
}
@@ -222,6 +225,34 @@ func (m *Model) resumeSelected() (*Model, tea.Cmd) {
return m, nil
}
// --- AI 摘要 ---
func (m *Model) applySummary(sessionID, summary string) {
if summary == "" {
return
}
for _, pd := range m.history.Projects {
for _, s := range pd.Sessions {
if s.ID == sessionID {
s.AISummary = summary
saveSummaryToCache(sessionID, summary)
return
}
}
}
}
func (m *Model) nextSummaryCmd() tea.Cmd {
for _, pd := range m.history.Projects {
for _, s := range pd.Sessions {
if s.AISummary == "" && s.FilePath != "" && s.FirstMsg != "" {
return generateSummaryCmd(s.FilePath, s.ID)
}
}
}
return nil
}
// --- Workspace 光标 ---
func (m *Model) moveCursor(dir int) {