From 80c90e6089a0b17a3f04cba294fc75bc586ff5c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=9D=E5=B0=98?= <237809796@qq.com> Date: Wed, 3 Jun 2026 22:15:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=20AI=20=E6=91=98=E8=A6=81?= =?UTF-8?q?=E6=97=A0=E9=99=90=E9=87=8D=E8=AF=95=E5=BE=AA=E7=8E=AF=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=20CPU=2035%=EF=BC=8C=E9=99=90=E5=88=B6=E6=AF=8F?= =?UTF-8?q?=E6=AC=A1=E6=9C=80=E5=A4=9A=E7=94=9F=E6=88=90=2020=20=E4=B8=AA?= =?UTF-8?q?=E6=91=98=E8=A6=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/app.go | 1 + internal/history.go | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/internal/app.go b/internal/app.go index 30ab527..2812734 100644 --- a/internal/app.go +++ b/internal/app.go @@ -29,6 +29,7 @@ type Model struct { allSessionsCache []*Session // "全部" tab 会话切片缓存 allSessionsDirty bool // 缓存是否需要重建 cacheDirty bool // session-cache.json 是否需要写盘 + summaryCount int // 本次会话已生成的摘要数 } func NewModel() *Model { diff --git a/internal/history.go b/internal/history.go index 047e1c4..9ce7244 100644 --- a/internal/history.go +++ b/internal/history.go @@ -736,28 +736,40 @@ func recordFork(targetID, sourceID string) { // --- AI 摘要与收藏操作 --- func (m *Model) applySummary(sessionID, summary string, completed, pending []string) { - if summary == "" { - return - } for _, pd := range m.history.Projects { for _, s := range pd.Sessions { if s.ID == sessionID { - s.AISummary = summary - s.Completed = completed - s.Pending = pending - updateSummaryInCache(m.history.Cache, sessionID, summary, completed, pending) + if summary == "" { + // 标记为已尝试,防止 nextSummaryCmd 无限重试 + // 用 FirstMsg 作为兜底显示,避免显示空白 + s.AISummary = s.FirstMsg + if s.AISummary == "" { + s.AISummary = s.ID[:8] + } + } else { + s.AISummary = summary + s.Completed = completed + s.Pending = pending + } + updateSummaryInCache(m.history.Cache, sessionID, s.AISummary, s.Completed, s.Pending) return } } } } +const maxSummaryPerSession = 20 // 每次启动最多生成 N 个摘要 + func (m *Model) nextSummaryCmd() tea.Cmd { + if m.summaryCount >= maxSummaryPerSession { + return nil + } for _, pd := range m.history.Projects { for _, s := range pd.Sessions { needSummary := s.AISummary == "" && s.FirstMsg != "" needDetail := s.AISummary != "" && len(s.Completed) == 0 && len(s.Pending) == 0 if (needSummary || needDetail) && s.FilePath != "" { + m.summaryCount++ return generateSummaryCmd(s.FilePath, s.ID) } }