From 51e6f6ebf6b91853b80e56e6346c8c3526723e6c Mon Sep 17 00:00:00 2001 From: Matt Low Date: Wed, 13 Mar 2024 15:56:23 +0000 Subject: [PATCH] tui: adjust message header styling --- pkg/tui/tui.go | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pkg/tui/tui.go b/pkg/tui/tui.go index af689eb..19aee27 100644 --- a/pkg/tui/tui.go +++ b/pkg/tui/tui.go @@ -72,8 +72,8 @@ type ( // styles var ( - userStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("10")) - assistantStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("12")) + userStyle = lipgloss.NewStyle().Faint(true).Bold(true).Foreground(lipgloss.Color("10")) + assistantStyle = lipgloss.NewStyle().Faint(true).Bold(true).Foreground(lipgloss.Color("12")) messageStyle = lipgloss.NewStyle().PaddingLeft(1) headerStyle = lipgloss.NewStyle(). PaddingLeft(1). @@ -326,14 +326,23 @@ func (m *model) updateContent() { sb := strings.Builder{} msgCnt := len(m.messages) for i, message := range m.messages { - var style lipgloss.Style - if message.Role == models.MessageRoleUser { + icon := "⚙️" + friendly := message.Role.FriendlyRole() + style := lipgloss.NewStyle().Bold(true).Faint(true) + + switch message.Role { + case models.MessageRoleUser: + icon = "" style = userStyle - } else { + case models.MessageRoleAssistant: + icon = "" style = assistantStyle + case models.MessageRoleToolCall: + case models.MessageRoleToolResult: + icon = "🔧" } - sb.WriteString(fmt.Sprintf("%s:\n\n", style.Render(string(message.Role.FriendlyRole())))) + sb.WriteString(fmt.Sprintf("%s\n\n", style.Render(icon + friendly))) highlighted, _ := m.ctx.Chroma.HighlightS(message.Content) sb.WriteString(messageStyle.Width(m.content.Width - 5).Render(highlighted))