Files
ollama_ollama/cmd/tui/chat/theme.go
T
ParthSareen 9b29453526 cmd/tui/chat: render bold emphasis consistently across markdown
Parse **...** / __...__ inline emphasis on the full source line before
wrapping, so bold stays intact across visual line breaks instead of
showing literal delimiters. Apply this path uniformly to assistant,
user, tool, heading, and table-cell output rather than only assistant
text.

- Add a parse-then-wrap inline renderer (wrapInlineRunes) shared by
  paragraphs, headings, and table cells
- Strip literal ** delimiters in headings and table cells; size table
  columns to rendered (delimiter-stripped) content
- Guard against misreading __ in bare URLs/identifiers as strong emphasis
- Add chatStrongStyle; update tests for the consistent bold behavior
2026-07-16 13:07:10 -07:00

130 lines
3.1 KiB
Go

package chat
import "github.com/charmbracelet/lipgloss"
const (
chatAnsiRed = "1"
chatAnsiGreen = "2"
chatAnsiYellow = "3"
chatAnsiBlue = "4"
chatAnsiCyan = "6"
chatAnsiBrightBlack = "8"
)
var (
chatHeaderStyle = lipgloss.NewStyle().
Bold(true)
chatMetaStyle = lipgloss.NewStyle().
Faint(true)
chatFooterStyle = lipgloss.NewStyle().
Faint(true)
chatInputBorderStyle = lipgloss.NewStyle().
Faint(true)
chatInputPlaceholderStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("8"))
chatCursorStyle = lipgloss.NewStyle().
Reverse(true)
chatBlankCursorStyle = lipgloss.NewStyle().
Faint(true)
chatNotificationStyle = chatMetaStyle
chatUserStyle = lipgloss.NewStyle()
chatUserBlockStyle = lipgloss.NewStyle().
Foreground(lipgloss.AdaptiveColor{Light: "#777777", Dark: "#8a8a8a"})
chatToolStyle = lipgloss.NewStyle()
chatInlineCodeStyle = lipgloss.NewStyle().
Bold(true)
chatStrongStyle = lipgloss.NewStyle().
Bold(true)
chatCodeBlockStyle = lipgloss.NewStyle()
chatTableBorderStyle = lipgloss.NewStyle().
Faint(true)
chatToolRunningStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color(chatAnsiYellow))
chatToolDoneStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color(chatAnsiGreen))
// chatToolMixedStyle marks a tool group with both succeeded and failed
// calls (partial success). Amber/orange is distinct from green (success),
// red (failure), and yellow (running).
chatToolMixedStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("208"))
chatToolOutputStyle = lipgloss.NewStyle().
Foreground(lipgloss.AdaptiveColor{Light: "#666666", Dark: "#a0a0a0"})
chatDiffMetaStyle = lipgloss.NewStyle().
Faint(true)
chatDiffFileStyle = lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color(chatAnsiCyan))
chatDiffHunkStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color(chatAnsiBlue))
chatDiffAddStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color(chatAnsiGreen))
chatDiffDeleteStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color(chatAnsiRed))
chatErrorStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color(chatAnsiRed))
chatFullAccessStyle = lipgloss.NewStyle().
Foreground(lipgloss.AdaptiveColor{Light: "#9f5f5f", Dark: "#b87373"})
chatCommandNameStyle = lipgloss.NewStyle()
chatPickerTextStyle = lipgloss.NewStyle()
chatPickerTitleStyle = lipgloss.NewStyle().
Bold(true)
chatPickerSelectedStyle = lipgloss.NewStyle().
Bold(true)
chatPickerMetaStyle = lipgloss.NewStyle().
Faint(true)
chatHistoryTitleStyle = lipgloss.NewStyle().
Bold(true)
chatHistorySystemRoleStyle = lipgloss.NewStyle().
Bold(true).
Faint(true)
chatHistoryUserRoleStyle = lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color(chatAnsiBlue))
chatHistoryAssistantRoleStyle = lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color(chatAnsiYellow))
chatHistoryToolRoleStyle = lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color(chatAnsiGreen))
chatHistoryLabelStyle = lipgloss.NewStyle().
Faint(true)
chatHistoryTextStyle = lipgloss.NewStyle()
)