on main help sign in
chore(chat): add some missing docs
95bae10Kujtim Hoxha
internal/ui/chat/messages.go+4
@@ -163,6 +163,10 @@ func GetMessageItems(sty *styles.Styles, msg *message.Message, toolResults map[s
163 return []MessageItem{}
163 return []MessageItem{}
164}
164}
165
165
166+// shouldRenderAssistantMessage determines if an assistant message should be rendered
167+//
168+// In some cases the assistant message only has tools so we do not want to render an
169+// empty message.
166func shouldRenderAssistantMessage(msg *message.Message) bool {
170func shouldRenderAssistantMessage(msg *message.Message) bool {
167 content := strings.TrimSpace(msg.Content().Text)
171 content := strings.TrimSpace(msg.Content().Text)
168 thinking := strings.TrimSpace(msg.ReasoningContent().Thinking)
172 thinking := strings.TrimSpace(msg.ReasoningContent().Thinking)
internal/ui/model/ui.go+3
@@ -384,6 +384,7 @@ func (m *UI) setSessionMessages(msgs []message.Message) tea.Cmd {
384 return tea.Batch(cmds...)
384 return tea.Batch(cmds...)
385}
385}
386
386
387+// appendSessionMessage appends a new message to the current session in the chat
387func (m *UI) appendSessionMessage(msg message.Message) tea.Cmd {
388func (m *UI) appendSessionMessage(msg message.Message) tea.Cmd {
388 items := chat.GetMessageItems(m.com.Styles, &msg, nil)
389 items := chat.GetMessageItems(m.com.Styles, &msg, nil)
389 var cmds []tea.Cmd
390 var cmds []tea.Cmd
@@ -399,6 +400,8 @@ func (m *UI) appendSessionMessage(msg message.Message) tea.Cmd {
399 return tea.Batch(cmds...)
400 return tea.Batch(cmds...)
400}
401}
401
402
403+// updateSessionMessage updates an existing message in the current session in the chat
404+// INFO: currently only updates the assistant when I add tools this will get a bit more complex
402func (m *UI) updateSessionMessage(msg message.Message) tea.Cmd {
405func (m *UI) updateSessionMessage(msg message.Message) tea.Cmd {
403 existingItem := m.chat.GetMessageItem(msg.ID)
406 existingItem := m.chat.GetMessageItem(msg.ID)
404 switch msg.Role {
407 switch msg.Role {