Private
Public Access
1
0

tui: Error handling tweak

Moved errors to bottom of screen, fix infinite loop by typing errors
properly
This commit is contained in:
2024-09-23 03:37:01 +00:00
parent 172bfc57e1
commit 3ec2675632
7 changed files with 29 additions and 23 deletions

View File

@@ -19,11 +19,11 @@ func (m *Model) loadConversationMessages() tea.Cmd {
return func() tea.Msg {
messages, err := m.App.LoadConversationMessages()
if err != nil {
return shared.MsgError(err)
return shared.AsMsgError(err)
}
rootMessages, err := m.App.LoadConversationRootMessages()
if err != nil {
return shared.MsgError(err)
return shared.AsMsgError(err)
}
return msgConversationMessagesLoaded{
messages, rootMessages,
@@ -35,7 +35,7 @@ func (m *Model) generateConversationTitle() tea.Cmd {
return func() tea.Msg {
title, err := m.App.GenerateConversationTitle(m.App.Messages)
if err != nil {
return shared.MsgError(err)
return shared.AsMsgError(err)
}
return msgConversationTitleGenerated(title)
}
@@ -104,7 +104,7 @@ func (m *Model) persistConversation() tea.Cmd {
return func() tea.Msg {
conversation, messages, err := m.App.PersistConversation(m.App.Conversation, m.App.Messages)
if err != nil {
return shared.MsgError(err)
return shared.AsMsgError(err)
}
return msgConversationPersisted{conversation.ID == 0, conversation, messages}
}
@@ -114,7 +114,7 @@ func (m *Model) executeToolCalls(toolCalls []api.ToolCall) tea.Cmd {
return func() tea.Msg {
results, err := m.App.ExecuteToolCalls(toolCalls)
if err != nil {
return shared.MsgError(err)
return shared.AsMsgError(err)
}
return msgToolResults(results)
}
@@ -131,7 +131,7 @@ func (m *Model) promptLLM() tea.Cmd {
return func() tea.Msg {
resp, err := m.App.PromptLLM(m.App.Messages, m.chatReplyChunks, m.stopSignal)
if err != nil {
return msgChatResponseError(err)
return msgChatResponseError{ Err: err }
}
return msgChatResponse(resp)
}