on main help sign in
fix: session summarization dialog hanging indefinitely (#528)
47a6d02Benjamin Oldenburg
internal/llm/agent/agent.go+1−1
@@ -832,7 +832,7 @@ func (a *agent) Summarize(ctx context.Context, sessionID string) error {
832 if r.Error != nil {
832 if r.Error != nil {
833 event = AgentEvent{
833 event = AgentEvent{
834 Type: AgentEventTypeError,
834 Type: AgentEventTypeError,
835− Error: fmt.Errorf("failed to summarize: %w", err),
835+ Error: fmt.Errorf("failed to summarize: %w", r.Error),
836 Done: true,
836 Done: true,
837 }
837 }
838 a.Publish(pubsub.CreatedEvent, event)
838 a.Publish(pubsub.CreatedEvent, event)
internal/tui/components/dialogs/compact/compact.go+11−4
@@ -104,17 +104,24 @@ func (c *compactDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
104 }
104 }
105
105
106 case agent.AgentEvent:
106 case agent.AgentEvent:
107+ switch msg.Type {
107− if msg.Type == agent.AgentEventTypeSummarize {
108+ case agent.AgentEventTypeSummarize:
108 if msg.Error != nil {
109 if msg.Error != nil {
109 c.state = stateError
110 c.state = stateError
110 c.progress = "Error: " + msg.Error.Error()
111 c.progress = "Error: " + msg.Error.Error()
111 } else if msg.Done {
112 } else if msg.Done {
112− return c, util.CmdHandler(
113+ return c, util.CmdHandler(dialogs.CloseDialogMsg{})
113− dialogs.CloseDialogMsg{},
114− )
115 } else {
114 } else {
116 c.progress = msg.Progress
115 c.progress = msg.Progress
117 }
116 }
117+ case agent.AgentEventTypeError:
118+ // Handle errors that occur during summarization but are sent as separate error events.
119+ c.state = stateError
120+ if msg.Error != nil {
121+ c.progress = "Error: " + msg.Error.Error()
122+ } else {
123+ c.progress = "An unknown error occurred"
124+ }
118 }
125 }
119 return c, nil
126 return c, nil
120 }
127 }