tui: adjust message header styling

This commit is contained in:
Matt Low 2024-03-13 15:56:23 +00:00
parent 6cb8d03c5b
commit 51e6f6ebf6

View File

@ -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))