From 47a6d0285724a7e078b4134a538cf90ebe765cac Mon Sep 17 00:00:00 2001 From: Benjamin Oldenburg Date: Sat, 20 Sep 2025 01:27:58 +0700 Subject: [PATCH] fix: session summarization dialog hanging indefinitely (#528) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The summarization dialog was getting stuck in "Generating..." state due to two issues: - Agent was formatting nil error values instead of actual response errors - Dialog only handled summarize events but not error events, leaving it in loading state 💖 Generated with Crush Co-authored-by: Crush --- internal/llm/agent/agent.go | 2 +- .../tui/components/dialogs/compact/compact.go | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/internal/llm/agent/agent.go b/internal/llm/agent/agent.go index 864188113168948c2e59a221c62c6cdad99f75ce..799cec2e67cc1cdc433903081da86db68ae31e99 100644 --- a/internal/llm/agent/agent.go +++ b/internal/llm/agent/agent.go @@ -832,7 +832,7 @@ func (a *agent) Summarize(ctx context.Context, sessionID string) error { if r.Error != nil { event = AgentEvent{ Type: AgentEventTypeError, - Error: fmt.Errorf("failed to summarize: %w", err), + Error: fmt.Errorf("failed to summarize: %w", r.Error), Done: true, } a.Publish(pubsub.CreatedEvent, event) diff --git a/internal/tui/components/dialogs/compact/compact.go b/internal/tui/components/dialogs/compact/compact.go index 86455e3139b4d0eb43baaf509b0fa0e039dd4939..ecde402fd8dfe1f31791834cd4e4bae13ec45e00 100644 --- a/internal/tui/components/dialogs/compact/compact.go +++ b/internal/tui/components/dialogs/compact/compact.go @@ -104,17 +104,24 @@ func (c *compactDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } case agent.AgentEvent: - if msg.Type == agent.AgentEventTypeSummarize { + switch msg.Type { + case agent.AgentEventTypeSummarize: if msg.Error != nil { c.state = stateError c.progress = "Error: " + msg.Error.Error() } else if msg.Done { - return c, util.CmdHandler( - dialogs.CloseDialogMsg{}, - ) + return c, util.CmdHandler(dialogs.CloseDialogMsg{}) } else { c.progress = msg.Progress } + case agent.AgentEventTypeError: + // Handle errors that occur during summarization but are sent as separate error events. + c.state = stateError + if msg.Error != nil { + c.progress = "Error: " + msg.Error.Error() + } else { + c.progress = "An unknown error occurred" + } } return c, nil }