diff options
| author | Adam <[email protected]> | 2025-06-26 10:16:07 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-26 10:16:07 -0500 |
| commit | 7d13baadc84d7377a352c6d58ed9deeea2c918be (patch) | |
| tree | 575b6897431e390ae8bf4b9ccde2803446c6c67a /packages/tui/internal/components | |
| parent | db24bf87c01d3fff2a9594e55e9fab0d9ef52cfe (diff) | |
| download | opencode-7d13baadc84d7377a352c6d58ed9deeea2c918be.tar.gz opencode-7d13baadc84d7377a352c6d58ed9deeea2c918be.zip | |
feat: default system theme (#419)
Co-authored-by: adamdottv <[email protected]>
Diffstat (limited to 'packages/tui/internal/components')
| -rw-r--r-- | packages/tui/internal/components/chat/editor.go | 65 | ||||
| -rw-r--r-- | packages/tui/internal/components/chat/message.go | 31 | ||||
| -rw-r--r-- | packages/tui/internal/components/chat/messages.go | 26 | ||||
| -rw-r--r-- | packages/tui/internal/components/commands/commands.go | 19 | ||||
| -rw-r--r-- | packages/tui/internal/components/dialog/complete.go | 4 | ||||
| -rw-r--r-- | packages/tui/internal/components/dialog/init.go | 2 | ||||
| -rw-r--r-- | packages/tui/internal/components/dialog/models.go | 2 | ||||
| -rw-r--r-- | packages/tui/internal/components/dialog/permission.go | 5 | ||||
| -rw-r--r-- | packages/tui/internal/components/dialog/session.go | 11 | ||||
| -rw-r--r-- | packages/tui/internal/components/dialog/theme.go | 2 | ||||
| -rw-r--r-- | packages/tui/internal/components/diff/diff.go | 249 | ||||
| -rw-r--r-- | packages/tui/internal/components/list/list.go | 6 | ||||
| -rw-r--r-- | packages/tui/internal/components/modal/modal.go | 6 | ||||
| -rw-r--r-- | packages/tui/internal/components/qr/qr.go | 6 | ||||
| -rw-r--r-- | packages/tui/internal/components/status/status.go | 21 | ||||
| -rw-r--r-- | packages/tui/internal/components/toast/toast.go | 9 |
16 files changed, 250 insertions, 214 deletions
diff --git a/packages/tui/internal/components/chat/editor.go b/packages/tui/internal/components/chat/editor.go index b5d1cc034..79b80cf69 100644 --- a/packages/tui/internal/components/chat/editor.go +++ b/packages/tui/internal/components/chat/editor.go @@ -26,6 +26,9 @@ type EditorComponent interface { Content() string Lines() int Value() string + Focused() bool + Focus() (tea.Model, tea.Cmd) + Blur() Submit() (tea.Model, tea.Cmd) Clear() (tea.Model, tea.Cmd) Paste() (tea.Model, tea.Cmd) @@ -48,7 +51,7 @@ type editorComponent struct { } func (m *editorComponent) Init() tea.Cmd { - return tea.Batch(textarea.Blink, m.spinner.Tick, tea.EnableReportFocus) + return tea.Batch(m.textarea.Focus(), m.spinner.Tick, tea.EnableReportFocus) } func (m *editorComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) { @@ -69,7 +72,7 @@ func (m *editorComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case dialog.ThemeSelectedMsg: m.textarea = createTextArea(&m.textarea) m.spinner = createSpinner() - return m, tea.Batch(m.spinner.Tick, textarea.Blink) + return m, tea.Batch(m.spinner.Tick, m.textarea.Focus()) case dialog.CompletionSelectedMsg: if msg.IsCommand { commandName := strings.TrimPrefix(msg.CompletionValue, "/") @@ -104,12 +107,11 @@ func (m *editorComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (m *editorComponent) Content() string { t := theme.CurrentTheme() - base := styles.BaseStyle().Background(t.Background()).Render - muted := styles.Muted().Background(t.Background()).Render - promptStyle := lipgloss.NewStyle(). + base := styles.NewStyle().Foreground(t.Text()).Background(t.Background()).Render + muted := styles.NewStyle().Foreground(t.TextMuted()).Background(t.Background()).Render + promptStyle := styles.NewStyle().Foreground(t.Primary()). Padding(0, 0, 0, 1). - Bold(true). - Foreground(t.Primary()) + Bold(true) prompt := promptStyle.Render(">") textarea := lipgloss.JoinHorizontal( @@ -117,11 +119,11 @@ func (m *editorComponent) Content() string { prompt, m.textarea.View(), ) - textarea = styles.BaseStyle(). + textarea = styles.NewStyle(). + Background(t.BackgroundElement()). Width(m.width). PaddingTop(1). PaddingBottom(1). - Background(t.BackgroundElement()). Render(textarea) hint := base(m.getSubmitKeyText()) + muted(" send ") @@ -140,10 +142,10 @@ func (m *editorComponent) Content() string { } space := m.width - 2 - lipgloss.Width(model) - lipgloss.Width(hint) - spacer := lipgloss.NewStyle().Background(t.Background()).Width(space).Render("") + spacer := styles.NewStyle().Background(t.Background()).Width(space).Render("") info := hint + spacer + model - info = styles.Padded().Background(t.Background()).Render(info) + info = styles.NewStyle().Background(t.Background()).Padding(0, 1).Render(info) content := strings.Join([]string{"", textarea, info}, "\n") return content @@ -156,6 +158,18 @@ func (m *editorComponent) View() string { return m.Content() } +func (m *editorComponent) Focused() bool { + return m.textarea.Focused() +} + +func (m *editorComponent) Focus() (tea.Model, tea.Cmd) { + return m, m.textarea.Focus() +} + +func (m *editorComponent) Blur() { + m.textarea.Blur() +} + func (m *editorComponent) GetSize() (width, height int) { return m.width, m.height } @@ -297,14 +311,14 @@ func createTextArea(existing *textarea.Model) textarea.Model { ta := textarea.New() - ta.Styles.Blurred.Base = lipgloss.NewStyle().Background(bgColor).Foreground(textColor) - ta.Styles.Blurred.CursorLine = lipgloss.NewStyle().Background(bgColor) - ta.Styles.Blurred.Placeholder = lipgloss.NewStyle().Background(bgColor).Foreground(textMutedColor) - ta.Styles.Blurred.Text = lipgloss.NewStyle().Background(bgColor).Foreground(textColor) - ta.Styles.Focused.Base = lipgloss.NewStyle().Background(bgColor).Foreground(textColor) - ta.Styles.Focused.CursorLine = lipgloss.NewStyle().Background(bgColor) - ta.Styles.Focused.Placeholder = lipgloss.NewStyle().Background(bgColor).Foreground(textMutedColor) - ta.Styles.Focused.Text = lipgloss.NewStyle().Background(bgColor).Foreground(textColor) + ta.Styles.Blurred.Base = styles.NewStyle().Foreground(textColor).Background(bgColor).Lipgloss() + ta.Styles.Blurred.CursorLine = styles.NewStyle().Background(bgColor).Lipgloss() + ta.Styles.Blurred.Placeholder = styles.NewStyle().Foreground(textMutedColor).Background(bgColor).Lipgloss() + ta.Styles.Blurred.Text = styles.NewStyle().Foreground(textColor).Background(bgColor).Lipgloss() + ta.Styles.Focused.Base = styles.NewStyle().Foreground(textColor).Background(bgColor).Lipgloss() + ta.Styles.Focused.CursorLine = styles.NewStyle().Background(bgColor).Lipgloss() + ta.Styles.Focused.Placeholder = styles.NewStyle().Foreground(textMutedColor).Background(bgColor).Lipgloss() + ta.Styles.Focused.Text = styles.NewStyle().Foreground(textColor).Background(bgColor).Lipgloss() ta.Styles.Cursor.Color = t.Primary() ta.Prompt = " " @@ -317,18 +331,21 @@ func createTextArea(existing *textarea.Model) textarea.Model { ta.SetHeight(existing.Height()) } - ta.Focus() + // ta.Focus() return ta } func createSpinner() spinner.Model { + t := theme.CurrentTheme() return spinner.New( spinner.WithSpinner(spinner.Ellipsis), spinner.WithStyle( - styles. - Muted(). - Background(theme.CurrentTheme().Background()). - Width(3)), + styles.NewStyle(). + Foreground(t.Background()). + Foreground(t.TextMuted()). + Width(3). + Lipgloss(), + ), ) } diff --git a/packages/tui/internal/components/chat/message.go b/packages/tui/internal/components/chat/message.go index c20bf6447..4f0293de5 100644 --- a/packages/tui/internal/components/chat/message.go +++ b/packages/tui/internal/components/chat/message.go @@ -129,15 +129,13 @@ func renderContentBlock(content string, options ...renderingOption) string { option(renderer) } - style := styles.BaseStyle(). + style := styles.NewStyle().Foreground(t.TextMuted()).Background(t.BackgroundPanel()). // MarginTop(renderer.marginTop). // MarginBottom(renderer.marginBottom). PaddingTop(renderer.paddingTop). PaddingBottom(renderer.paddingBottom). PaddingLeft(renderer.paddingLeft). PaddingRight(renderer.paddingRight). - Background(t.BackgroundPanel()). - Foreground(t.TextMuted()). BorderStyle(lipgloss.ThickBorder()) align := lipgloss.Left @@ -179,13 +177,13 @@ func renderContentBlock(content string, options ...renderingOption) string { layout.Current.Container.Width, align, content, - lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Background(t.Background())), + styles.WhitespaceStyle(t.Background()), ) content = lipgloss.PlaceHorizontal( layout.Current.Viewport.Width, lipgloss.Center, content, - lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Background(t.Background())), + styles.WhitespaceStyle(t.Background()), ) if renderer.marginTop > 0 { for range renderer.marginTop { @@ -226,7 +224,7 @@ func renderText(message client.MessageInfo, text string, author string) string { textWidth := max(lipgloss.Width(text), lipgloss.Width(info)) markdownWidth := min(textWidth, width-padding-4) // -4 for the border and padding if message.Role == client.Assistant { - markdownWidth = width - padding - 4 - 2 + markdownWidth = width - padding - 4 - 3 } if message.Role == client.User { text = strings.ReplaceAll(text, "<", "\\<") @@ -275,9 +273,10 @@ func renderToolInvocation( } t := theme.CurrentTheme() - style := styles.Muted(). - Width(outerWidth). + style := styles.NewStyle(). + Foreground(t.TextMuted()). Background(t.BackgroundPanel()). + Width(outerWidth). PaddingTop(paddingTop). PaddingBottom(paddingBottom). PaddingLeft(2). @@ -293,7 +292,9 @@ func renderToolInvocation( if !showDetails { title = "∟ " + title padding := calculatePadding() - style := lipgloss.NewStyle().Width(outerWidth - padding - 4).Background(t.BackgroundPanel()) + style := styles.NewStyle(). + Background(t.BackgroundPanel()). + Width(outerWidth - padding - 4 - 3) return renderContentBlock(style.Render(title), WithAlign(lipgloss.Left), WithBorderColor(t.Accent()), @@ -334,9 +335,9 @@ func renderToolInvocation( if e, ok := metadata.Get("error"); ok && e.(bool) == true { if m, ok := metadata.Get("message"); ok { style = style.BorderLeftForeground(t.Error()) - error = styles.BaseStyle(). - Background(t.BackgroundPanel()). + error = styles.NewStyle(). Foreground(t.Error()). + Background(t.BackgroundPanel()). Render(m.(string)) error = renderContentBlock( error, @@ -374,7 +375,7 @@ func renderToolInvocation( formattedDiff, _ = diff.FormatDiff(filename, patch, diff.WithTotalWidth(diffWidth)) } formattedDiff = strings.TrimSpace(formattedDiff) - formattedDiff = lipgloss.NewStyle(). + formattedDiff = styles.NewStyle(). BorderStyle(lipgloss.ThickBorder()). BorderBackground(t.Background()). BorderForeground(t.BackgroundPanel()). @@ -394,7 +395,7 @@ func renderToolInvocation( lipgloss.Center, lipgloss.Top, body, - lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Background(t.Background())), + styles.WhitespaceStyle(t.Background()), ) } } @@ -506,7 +507,7 @@ func renderToolInvocation( if !showDetails { title = "∟ " + title padding := calculatePadding() - style := lipgloss.NewStyle().Width(outerWidth - padding - 4).Background(t.BackgroundPanel()) + style := styles.NewStyle().Background(t.BackgroundPanel()).Width(outerWidth - padding - 4 - 3) paddingBottom := 0 if isLast { paddingBottom = 1 @@ -530,7 +531,7 @@ func renderToolInvocation( layout.Current.Viewport.Width, lipgloss.Center, content, - lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Background(t.Background())), + styles.WhitespaceStyle(t.Background()), ) if showDetails && body != "" && error == "" { content += "\n" + body diff --git a/packages/tui/internal/components/chat/messages.go b/packages/tui/internal/components/chat/messages.go index bdb6a6f82..da45545c9 100644 --- a/packages/tui/internal/components/chat/messages.go +++ b/packages/tui/internal/components/chat/messages.go @@ -245,7 +245,7 @@ func (m *messagesComponent) renderView() { m.width, lipgloss.Center, block, - lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Background(t.Background())), + styles.WhitespaceStyle(t.Background()), )) } @@ -260,8 +260,8 @@ func (m *messagesComponent) header() string { t := theme.CurrentTheme() width := layout.Current.Container.Width - base := styles.BaseStyle().Background(t.Background()).Render - muted := styles.Muted().Background(t.Background()).Render + base := styles.NewStyle().Foreground(t.Text()).Background(t.Background()).Render + muted := styles.NewStyle().Foreground(t.TextMuted()).Background(t.Background()).Render headerLines := []string{} headerLines = append(headerLines, toMarkdown("# "+m.app.Session.Title, width-6, t.Background())) if m.app.Session.Share != nil && m.app.Session.Share.Url != "" { @@ -271,11 +271,11 @@ func (m *messagesComponent) header() string { } header := strings.Join(headerLines, "\n") - header = styles.BaseStyle(). + header = styles.NewStyle(). + Background(t.Background()). Width(width). PaddingLeft(2). PaddingRight(2). - Background(t.Background()). BorderLeft(true). BorderRight(true). BorderBackground(t.Background()). @@ -306,7 +306,7 @@ func (m *messagesComponent) View() string { m.width, lipgloss.Center, m.header(), - lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Background(t.Background())), + styles.WhitespaceStyle(t.Background()), ), m.viewport.View(), ) @@ -314,9 +314,9 @@ func (m *messagesComponent) View() string { func (m *messagesComponent) home() string { t := theme.CurrentTheme() - baseStyle := styles.BaseStyle().Background(t.Background()) + baseStyle := styles.NewStyle().Background(t.Background()) base := baseStyle.Render - muted := styles.Muted().Background(t.Background()).Render + muted := styles.NewStyle().Foreground(t.TextMuted()).Background(t.Background()).Render open := ` █▀▀█ █▀▀█ █▀▀ █▀▀▄ @@ -335,9 +335,9 @@ func (m *messagesComponent) home() string { // cwd := app.Info.Path.Cwd // config := app.Info.Path.Config - versionStyle := lipgloss.NewStyle(). - Background(t.Background()). + versionStyle := styles.NewStyle(). Foreground(t.TextMuted()). + Background(t.Background()). Width(lipgloss.Width(logo)). Align(lipgloss.Right) version := versionStyle.Render(m.app.Version) @@ -347,14 +347,14 @@ func (m *messagesComponent) home() string { m.width, lipgloss.Center, logoAndVersion, - lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Background(t.Background())), + styles.WhitespaceStyle(t.Background()), ) m.commands.SetBackgroundColor(t.Background()) commands := lipgloss.PlaceHorizontal( m.width, lipgloss.Center, m.commands.View(), - lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Background(t.Background())), + styles.WhitespaceStyle(t.Background()), ) lines := []string{} @@ -372,7 +372,7 @@ func (m *messagesComponent) home() string { lipgloss.Center, lipgloss.Center, baseStyle.Render(strings.Join(lines, "\n")), - lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Background(t.Background())), + styles.WhitespaceStyle(t.Background()), ) } diff --git a/packages/tui/internal/components/commands/commands.go b/packages/tui/internal/components/commands/commands.go index 8031e5351..d7f334c35 100644 --- a/packages/tui/internal/components/commands/commands.go +++ b/packages/tui/internal/components/commands/commands.go @@ -60,15 +60,9 @@ func (c *commandsComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (c *commandsComponent) View() string { t := theme.CurrentTheme() - triggerStyle := lipgloss.NewStyle(). - Foreground(t.Primary()). - Bold(true) - - descriptionStyle := lipgloss.NewStyle(). - Foreground(t.Text()) - - keybindStyle := lipgloss.NewStyle(). - Foreground(t.TextMuted()) + triggerStyle := styles.NewStyle().Foreground(t.Primary()).Bold(true) + descriptionStyle := styles.NewStyle().Foreground(t.Text()) + keybindStyle := styles.NewStyle().Foreground(t.TextMuted()) if c.background != nil { triggerStyle = triggerStyle.Background(*c.background) @@ -99,10 +93,11 @@ func (c *commandsComponent) View() string { } if len(commandsToShow) == 0 { + muted := styles.NewStyle().Foreground(theme.CurrentTheme().TextMuted()) if c.showAll { - return styles.Muted().Render("No commands available") + return muted.Render("No commands available") } - return styles.Muted().Render("No commands with triggers available") + return muted.Render("No commands with triggers available") } // Calculate column widths @@ -188,7 +183,7 @@ func (c *commandsComponent) View() string { // Remove trailing newline result := strings.TrimSuffix(output.String(), "\n") if c.background != nil { - result = lipgloss.NewStyle().Background(c.background).Width(maxWidth).Render(result) + result = styles.NewStyle().Background(*c.background).Width(maxWidth).Render(result) } return result diff --git a/packages/tui/internal/components/dialog/complete.go b/packages/tui/internal/components/dialog/complete.go index 4924885f9..f2ed30fff 100644 --- a/packages/tui/internal/components/dialog/complete.go +++ b/packages/tui/internal/components/dialog/complete.go @@ -26,7 +26,7 @@ type CompletionItemI interface { func (ci *CompletionItem) Render(selected bool, width int) string { t := theme.CurrentTheme() - baseStyle := styles.BaseStyle() + baseStyle := styles.NewStyle().Foreground(t.Text()) itemStyle := baseStyle. Background(t.BackgroundElement()). @@ -185,7 +185,7 @@ func (c *completionDialogComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (c *completionDialogComponent) View() string { t := theme.CurrentTheme() - baseStyle := styles.BaseStyle() + baseStyle := styles.NewStyle().Foreground(t.Text()) maxWidth := 40 completions := c.list.GetItems() diff --git a/packages/tui/internal/components/dialog/init.go b/packages/tui/internal/components/dialog/init.go index 339e31ca4..cf81e5a07 100644 --- a/packages/tui/internal/components/dialog/init.go +++ b/packages/tui/internal/components/dialog/init.go @@ -94,7 +94,7 @@ func (m InitDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // View implements tea.Model. func (m InitDialogCmp) View() string { t := theme.CurrentTheme() - baseStyle := styles.BaseStyle() + baseStyle := styles.NewStyle().Foreground(t.Text()) // Calculate width needed for content maxWidth := 60 // Width for explanation text diff --git a/packages/tui/internal/components/dialog/models.go b/packages/tui/internal/components/dialog/models.go index 5da3c9eef..52ece493f 100644 --- a/packages/tui/internal/components/dialog/models.go +++ b/packages/tui/internal/components/dialog/models.go @@ -158,7 +158,7 @@ func (m *modelDialog) getScrollIndicators(maxWidth int) string { } t := theme.CurrentTheme() - return styles.BaseStyle(). + return styles.NewStyle(). Foreground(t.TextMuted()). Width(maxWidth). Align(lipgloss.Right). diff --git a/packages/tui/internal/components/dialog/permission.go b/packages/tui/internal/components/dialog/permission.go index 1f573e59d..5bc40624b 100644 --- a/packages/tui/internal/components/dialog/permission.go +++ b/packages/tui/internal/components/dialog/permission.go @@ -145,7 +145,7 @@ func (p *permissionDialogComponent) selectCurrentOption() tea.Cmd { func (p *permissionDialogComponent) renderButtons() string { t := theme.CurrentTheme() - baseStyle := styles.BaseStyle() + baseStyle := styles.NewStyle().Foreground(t.Text()) allowStyle := baseStyle allowSessionStyle := baseStyle @@ -355,8 +355,7 @@ func (p *permissionDialogComponent) renderDefaultContent() string { func (p *permissionDialogComponent) styleViewport() string { t := theme.CurrentTheme() - contentStyle := lipgloss.NewStyle(). - Background(t.Background()) + contentStyle := styles.NewStyle().Background(t.Background()) return contentStyle.Render(p.contentViewPort.View()) } diff --git a/packages/tui/internal/components/dialog/session.go b/packages/tui/internal/components/dialog/session.go index 71f3f2e9e..6ee8d1cce 100644 --- a/packages/tui/internal/components/dialog/session.go +++ b/packages/tui/internal/components/dialog/session.go @@ -7,7 +7,6 @@ import ( "slices" tea "github.com/charmbracelet/bubbletea/v2" - "github.com/charmbracelet/lipgloss/v2" "github.com/muesli/reflow/truncate" "github.com/sst/opencode/internal/app" "github.com/sst/opencode/internal/components/list" @@ -33,7 +32,7 @@ type sessionItem struct { func (s sessionItem) Render(selected bool, width int) string { t := theme.CurrentTheme() - baseStyle := styles.BaseStyle() + baseStyle := styles.NewStyle() var text string if s.isDeleteConfirming { @@ -44,7 +43,7 @@ func (s sessionItem) Render(selected bool, width int) string { truncatedStr := truncate.StringWithTail(text, uint(width-1), "...") - var itemStyle lipgloss.Style + var itemStyle styles.Style if selected { if s.isDeleteConfirming { // Red background for delete confirmation @@ -151,9 +150,9 @@ func (s *sessionDialog) Render(background string) string { listView := s.list.View() t := theme.CurrentTheme() - helpStyle := styles.BaseStyle().PaddingLeft(1).PaddingTop(1) - helpText := styles.BaseStyle().Foreground(t.Text()).Render("x/del") - helpText = helpText + styles.BaseStyle().Background(t.BackgroundElement()).Foreground(t.TextMuted()).Render(" delete session") + helpStyle := styles.NewStyle().PaddingLeft(1).PaddingTop(1) + helpText := styles.NewStyle().Foreground(t.Text()).Render("x/del") + helpText = helpText + styles.NewStyle().Background(t.BackgroundElement()).Foreground(t.TextMuted()).Render(" delete session") helpText = helpStyle.Render(helpText) content := strings.Join([]string{listView, helpText}, "\n") diff --git a/packages/tui/internal/components/dialog/theme.go b/packages/tui/internal/components/dialog/theme.go index eea3e74e7..b6e970617 100644 --- a/packages/tui/internal/components/dialog/theme.go +++ b/packages/tui/internal/components/dialog/theme.go @@ -103,7 +103,7 @@ func NewThemeDialog() ThemeDialog { // Set the initial selection to the current theme list.SetSelectedIndex(selectedIdx) - + // Set the max width for the list to match the modal width list.SetMaxWidth(36) // 40 (modal max width) - 4 (modal padding) diff --git a/packages/tui/internal/components/diff/diff.go b/packages/tui/internal/components/diff/diff.go index 13f0f562f..9475c1f19 100644 --- a/packages/tui/internal/components/diff/diff.go +++ b/packages/tui/internal/components/diff/diff.go @@ -441,84 +441,84 @@ func SyntaxHighlight(w io.Writer, source, fileName, formatter string, bg color.C <entry type="TextWhitespace" style="%s"/> </style> `, - getColor(t.BackgroundPanel()), // Background - getColor(t.Text()), // Text - getColor(t.Text()), // Other - getColor(t.Error()), // Error - - getColor(t.SyntaxKeyword()), // Keyword - getColor(t.SyntaxKeyword()), // KeywordConstant - getColor(t.SyntaxKeyword()), // KeywordDeclaration - getColor(t.SyntaxKeyword()), // KeywordNamespace - getColor(t.SyntaxKeyword()), // KeywordPseudo - getColor(t.SyntaxKeyword()), // KeywordReserved - getColor(t.SyntaxType()), // KeywordType - - getColor(t.Text()), // Name - getColor(t.SyntaxVariable()), // NameAttribute - getColor(t.SyntaxType()), // NameBuiltin - getColor(t.SyntaxVariable()), // NameBuiltinPseudo - getColor(t.SyntaxType()), // NameClass - getColor(t.SyntaxVariable()), // NameConstant - getColor(t.SyntaxFunction()), // NameDecorator - getColor(t.SyntaxVariable()), // NameEntity - getColor(t.SyntaxType()), // NameException - getColor(t.SyntaxFunction()), // NameFunction - getColor(t.Text()), // NameLabel - getColor(t.SyntaxType()), // NameNamespace - getColor(t.SyntaxVariable()), // NameOther - getColor(t.SyntaxKeyword()), // NameTag - getColor(t.SyntaxVariable()), // NameVariable - getColor(t.SyntaxVariable()), // NameVariableClass - getColor(t.SyntaxVariable()), // NameVariableGlobal - getColor(t.SyntaxVariable()), // NameVariableInstance - - getColor(t.SyntaxString()), // Literal - getColor(t.SyntaxString()), // LiteralDate - getColor(t.SyntaxString()), // LiteralString - getColor(t.SyntaxString()), // LiteralStringBacktick - getColor(t.SyntaxString()), // LiteralStringChar - getColor(t.SyntaxString()), // LiteralStringDoc - getColor(t.SyntaxString()), // LiteralStringDouble - getColor(t.SyntaxString()), // LiteralStringEscape - getColor(t.SyntaxString()), // LiteralStringHeredoc - getColor(t.SyntaxString()), // LiteralStringInterpol - getColor(t.SyntaxString()), // LiteralStringOther - getColor(t.SyntaxString()), // LiteralStringRegex - getColor(t.SyntaxString()), // LiteralStringSingle - getColor(t.SyntaxString()), // LiteralStringSymbol - - getColor(t.SyntaxNumber()), // LiteralNumber - getColor(t.SyntaxNumber()), // LiteralNumberBin - getColor(t.SyntaxNumber()), // LiteralNumberFloat - getColor(t.SyntaxNumber()), // LiteralNumberHex - getColor(t.SyntaxNumber()), // LiteralNumberInteger - getColor(t.SyntaxNumber()), // LiteralNumberIntegerLong - getColor(t.SyntaxNumber()), // LiteralNumberOct - - getColor(t.SyntaxOperator()), // Operator - getColor(t.SyntaxKeyword()), // OperatorWord - getColor(t.SyntaxPunctuation()), // Punctuation - - getColor(t.SyntaxComment()), // Comment - getColor(t.SyntaxComment()), // CommentHashbang - getColor(t.SyntaxComment()), // CommentMultiline - getColor(t.SyntaxComment()), // CommentSingle - getColor(t.SyntaxComment()), // CommentSpecial - getColor(t.SyntaxKeyword()), // CommentPreproc - - getColor(t.Text()), // Generic - getColor(t.Error()), // GenericDeleted - getColor(t.Text()), // GenericEmph - getColor(t.Error()), // GenericError - getColor(t.Text()), // GenericHeading - getColor(t.Success()), // GenericInserted - getColor(t.TextMuted()), // GenericOutput - getColor(t.Text()), // GenericPrompt - getColor(t.Text()), // GenericStrong - getColor(t.Text()), // GenericSubheading - getColor(t.Error()), // GenericTraceback - getColor(t.Text()), // TextWhitespace + getChromaColor(t.BackgroundPanel()), // Background + getChromaColor(t.Text()), // Text + getChromaColor(t.Text()), // Other + getChromaColor(t.Error()), // Error + + getChromaColor(t.SyntaxKeyword()), // Keyword + getChromaColor(t.SyntaxKeyword()), // KeywordConstant + getChromaColor(t.SyntaxKeyword()), // KeywordDeclaration + getChromaColor(t.SyntaxKeyword()), // KeywordNamespace + getChromaColor(t.SyntaxKeyword()), // KeywordPseudo + getChromaColor(t.SyntaxKeyword()), // KeywordReserved + getChromaColor(t.SyntaxType()), // KeywordType + + getChromaColor(t.Text()), // Name + getChromaColor(t.SyntaxVariable()), // NameAttribute + getChromaColor(t.SyntaxType()), // NameBuiltin + getChromaColor(t.SyntaxVariable()), // NameBuiltinPseudo + getChromaColor(t.SyntaxType()), // NameClass + getChromaColor(t.SyntaxVariable()), // NameConstant + getChromaColor(t.SyntaxFunction()), // NameDecorator + getChromaColor(t.SyntaxVariable()), // NameEntity + getChromaColor(t.SyntaxType()), // NameException + getChromaColor(t.SyntaxFunction()), // NameFunction + getChromaColor(t.Text()), // NameLabel + getChromaColor(t.SyntaxType()), // NameNamespace + getChromaColor(t.SyntaxVariable()), // NameOther + getChromaColor(t.SyntaxKeyword()), // NameTag + getChromaColor(t.SyntaxVariable()), // NameVariable + getChromaColor(t.SyntaxVariable()), // NameVariableClass + getChromaColor(t.SyntaxVariable()), // NameVariableGlobal + getChromaColor(t.SyntaxVariable()), // NameVariableInstance + + getChromaColor(t.SyntaxString()), // Literal + getChromaColor(t.SyntaxString()), // LiteralDate + getChromaColor(t.SyntaxString()), // LiteralString + getChromaColor(t.SyntaxString()), // LiteralStringBacktick + getChromaColor(t.SyntaxString()), // LiteralStringChar + getChromaColor(t.SyntaxString()), // LiteralStringDoc + getChromaColor(t.SyntaxString()), // LiteralStringDouble + getChromaColor(t.SyntaxString()), // LiteralStringEscape + getChromaColor(t.SyntaxString()), // LiteralStringHeredoc + getChromaColor(t.SyntaxString()), // LiteralStringInterpol + getChromaColor(t.SyntaxString()), // LiteralStringOther + getChromaColor(t.SyntaxString()), // LiteralStringRegex + getChromaColor(t.SyntaxString()), // LiteralStringSingle + getChromaColor(t.SyntaxString()), // LiteralStringSymbol + + getChromaColor(t.SyntaxNumber()), // LiteralNumber + getChromaColor(t.SyntaxNumber()), // LiteralNumberBin + getChromaColor(t.SyntaxNumber()), // LiteralNumberFloat + getChromaColor(t.SyntaxNumber()), // LiteralNumberHex + getChromaColor(t.SyntaxNumber()), // LiteralNumberInteger + getChromaColor(t.SyntaxNumber()), // LiteralNumberIntegerLong + getChromaColor(t.SyntaxNumber()), // LiteralNumberOct + + getChromaColor(t.SyntaxOperator()), // Operator + getChromaColor(t.SyntaxKeyword()), // OperatorWord + getChromaColor(t.SyntaxPunctuation()), // Punctuation + + getChromaColor(t.SyntaxComment()), // Comment + getChromaColor(t.SyntaxComment()), // CommentHashbang + getChromaColor(t.SyntaxComment()), // CommentMultiline + getChromaColor(t.SyntaxComment()), // CommentSingle + getChromaColor(t.SyntaxComment()), // CommentSpecial + getChromaColor(t.SyntaxKeyword()), // CommentPreproc + + getChromaColor(t.Text()), // Generic + getChromaColor(t.Error()), // GenericDeleted + getChromaColor(t.Text()), // GenericEmph + getChromaColor(t.Error()), // GenericError + getChromaColor(t.Text()), // GenericHeading + getChromaColor(t.Success()), // GenericInserted + getChromaColor(t.TextMuted()), // GenericOutput + getChromaColor(t.Text()), // GenericPrompt + getChromaColor(t.Text()), // GenericStrong + getChromaColor(t.Text()), // GenericSubheading + getChromaColor(t.Error()), // GenericTraceback + getChromaColor(t.Text()), // TextWhitespace ) r := strings.NewReader(syntaxThemeXml) @@ -527,6 +527,9 @@ func SyntaxHighlight(w io.Writer, source, fileName, formatter string, bg color.C // Modify the style to use the provided background s, err := style.Builder().Transform( func(t chroma.StyleEntry) chroma.StyleEntry { + if _, ok := bg.(lipgloss.NoColor); ok { + return t + } r, g, b, _ := bg.RGBA() t.Background = chroma.NewColour(uint8(r>>8), uint8(g>>8), uint8(b>>8)) return t @@ -546,10 +549,18 @@ func SyntaxHighlight(w io.Writer, source, fileName, formatter string, bg color.C } // getColor returns the appropriate hex color string based on terminal background -func getColor(adaptiveColor compat.AdaptiveColor) string { +func getColor(adaptiveColor compat.AdaptiveColor) *string { return stylesi.AdaptiveColorToString(adaptiveColor) } +func getChromaColor(adaptiveColor compat.AdaptiveColor) string { + color := stylesi.AdaptiveColorToString(adaptiveColor) + if color == nil { + return "" + } + return *color +} + // highlightLine applies syntax highlighting to a single line func highlightLine(fileName string, line string, bg color.Color) string { var buf bytes.Buffer @@ -561,11 +572,11 @@ func highlightLine(fileName string, line string, bg color.Color) string { } // createStyles generates the lipgloss styles needed for rendering diffs -func createStyles(t theme.Theme) (removedLineStyle, addedLineStyle, contextLineStyle, lineNumberStyle lipgloss.Style) { - removedLineStyle = lipgloss.NewStyle().Background(t.DiffRemovedBg()) - addedLineStyle = lipgloss.NewStyle().Background(t.DiffAddedBg()) - contextLineStyle = lipgloss.NewStyle().Background(t.DiffContextBg()) - lineNumberStyle = lipgloss.NewStyle().Background(t.DiffLineNumber()).Foreground(t.TextMuted()) +func createStyles(t theme.Theme) (removedLineStyle, addedLineStyle, contextLineStyle, lineNumberStyle stylesi.Style) { + removedLineStyle = stylesi.NewStyle().Background(t.DiffRemovedBg()) + addedLineStyle = stylesi.NewStyle().Background(t.DiffAddedBg()) + contextLineStyle = stylesi.NewStyle().Background(t.DiffContextBg()) + lineNumberStyle = stylesi.NewStyle().Foreground(t.TextMuted()).Background(t.DiffLineNumber()) return } @@ -613,9 +624,17 @@ func applyHighlighting(content string, segments []Segment, segmentType LineType, currentPos := 0 // Get the appropriate color based on terminal background - bgColor := lipgloss.Color(getColor(highlightBg)) - fgColor := lipgloss.Color(getColor(theme.CurrentTheme().BackgroundPanel())) + bg := getColor(highlightBg) + fg := getColor(theme.CurrentTheme().BackgroundPanel()) + var bgColor color.Color + var fgColor color.Color + if bg != nil { + bgColor = lipgloss.Color(*bg) + } + if fg != nil { + fgColor = lipgloss.Color(*fg) + } for i := 0; i < len(content); { // Check if we're at an ANSI sequence isAnsi := false @@ -651,12 +670,20 @@ func applyHighlighting(content string, segments []Segment, segmentType LineType, currentStyle := ansiSequences[currentPos] // Apply foreground and background highlight - sb.WriteString("\x1b[38;2;") - r, g, b, _ := fgColor.RGBA() - sb.WriteString(fmt.Sprintf("%d;%d;%dm", r>>8, g>>8, b>>8)) - sb.WriteString("\x1b[48;2;") - r, g, b, _ = bgColor.RGBA() - sb.WriteString(fmt.Sprintf("%d;%d;%dm", r>>8, g>>8, b>>8)) + if fgColor != nil { + sb.WriteString("\x1b[38;2;") + r, g, b, _ := fgColor.RGBA() + sb.WriteString(fmt.Sprintf("%d;%d;%dm", r>>8, g>>8, b>>8)) + } else { + sb.WriteString("\x1b[49m") + } + if bgColor != nil { + sb.WriteString("\x1b[48;2;") + r, g, b, _ := bgColor.RGBA() + sb.WriteString(fmt.Sprintf("%d;%d;%dm", r>>8, g>>8, b>>8)) + } else { + sb.WriteString("\x1b[39m") + } sb.WriteString(char) // Full reset of all attributes to ensure clean state @@ -677,16 +704,16 @@ func applyHighlighting(content string, segments []Segment, segmentType LineType, } // renderLinePrefix renders the line number and marker prefix for a diff line -func renderLinePrefix(dl DiffLine, lineNum string, marker string, lineNumberStyle lipgloss.Style, t theme.Theme) string { +func renderLinePrefix(dl DiffLine, lineNum string, marker string, lineNumberStyle stylesi.Style, t theme.Theme) string { // Style the marker based on line type var styledMarker string switch dl.Kind { case LineRemoved: - styledMarker = lipgloss.NewStyle().Background(t.DiffRemovedBg()).Foreground(t.DiffRemoved()).Render(marker) + styledMarker = stylesi.NewStyle().Foreground(t.DiffRemoved()).Background(t.DiffRemovedBg()).Render(marker) case LineAdded: - styledMarker = lipgloss.NewStyle().Background(t.DiffAddedBg()).Foreground(t.DiffAdded()).Render(marker) + styledMarker = stylesi.NewStyle().Foreground(t.DiffAdded()).Background(t.DiffAddedBg()).Render(marker) case LineContext: - styledMarker = lipgloss.NewStyle().Background(t.DiffContextBg()).Foreground(t.TextMuted()).Render(marker) + styledMarker = stylesi.NewStyle().Foreground(t.TextMuted()).Background(t.DiffContextBg()).Render(marker) default: styledMarker = marker } @@ -695,7 +722,7 @@ func renderLinePrefix(dl DiffLine, lineNum string, marker string, lineNumberStyl } // renderLineContent renders the content of a diff line with syntax and intra-line highlighting -func renderLineContent(fileName string, dl DiffLine, bgStyle lipgloss.Style, highlightColor compat.AdaptiveColor, width int, t theme.Theme) string { +func renderLineContent(fileName string, dl DiffLine, bgStyle stylesi.Style, highlightColor compat.AdaptiveColor, width int) string { // Apply syntax highlighting content := highlightLine(fileName, dl.Content, bgStyle.GetBackground()) @@ -714,7 +741,9 @@ func renderLineContent(fileName string, dl DiffLine, bgStyle lipgloss.Style, hig ansi.Truncate( content, width, - lipgloss.NewStyle().Background(bgStyle.GetBackground()).Foreground(t.TextMuted()).Render("..."), + "...", + // stylesi.NewStyleWithColors(t.TextMuted(), bgStyle.GetBackground()).Render("..."), + // stylesi.WithForeground(stylesi.NewStyle().Background(bgStyle.GetBackground()), t.TextMuted()).Render("..."), ), ) } @@ -725,7 +754,7 @@ func renderUnifiedLine(fileName string, dl DiffLine, width int, t theme.Theme) s // Determine line style and marker based on line type var marker string - var bgStyle lipgloss.Style + var bgStyle stylesi.Style var lineNum string var highlightColor compat.AdaptiveColor @@ -733,8 +762,8 @@ func renderUnifiedLine(fileName string, dl DiffLine, width int, t theme.Theme) s case LineRemoved: marker = "-" bgStyle = removedLineStyle - lineNumberStyle = lineNumberStyle.Foreground(t.DiffRemoved()).Background(t.DiffRemovedLineNumberBg()) - highlightColor = t.DiffHighlightRemoved() + lineNumberStyle = lineNumberStyle.Background(t.DiffRemovedLineNumberBg()).Foreground(t.DiffRemoved()) + highlightColor = t.DiffHighlightRemoved() // TODO: handle "none" if dl.OldLineNo > 0 { lineNum = fmt.Sprintf("%6d ", dl.OldLineNo) } else { @@ -743,8 +772,8 @@ func renderUnifiedLine(fileName string, dl DiffLine, width int, t theme.Theme) s case LineAdded: marker = "+" bgStyle = addedLineStyle - lineNumberStyle = lineNumberStyle.Foreground(t.DiffAdded()).Background(t.DiffAddedLineNumberBg()) - highlightColor = t.DiffHighlightAdded() + lineNumberStyle = lineNumberStyle.Background(t.DiffAddedLineNumberBg()).Foreground(t.DiffAdded()) + highlightColor = t.DiffHighlightAdded() // TODO: handle "none" if dl.NewLineNo > 0 { lineNum = fmt.Sprintf(" %7d", dl.NewLineNo) } else { @@ -766,7 +795,7 @@ func renderUnifiedLine(fileName string, dl DiffLine, width int, t theme.Theme) s // Render the content prefixWidth := ansi.StringWidth(prefix) contentWidth := width - prefixWidth - content := renderLineContent(fileName, dl, bgStyle, highlightColor, contentWidth, t) + content := renderLineContent(fileName, dl, bgStyle, highlightColor, contentWidth) return prefix + content } @@ -780,7 +809,7 @@ func renderDiffColumnLine( t theme.Theme, ) string { if dl == nil { - contextLineStyle := lipgloss.NewStyle().Background(t.DiffContextBg()) + contextLineStyle := stylesi.NewStyle().Background(t.DiffContextBg()) return contextLineStyle.Width(colWidth).Render("") } @@ -788,7 +817,7 @@ func renderDiffColumnLine( // Determine line style based on line type and column var marker string - var bgStyle lipgloss.Style + var bgStyle stylesi.Style var lineNum string var highlightColor compat.AdaptiveColor @@ -798,8 +827,8 @@ func renderDiffColumnLine( case LineRemoved: marker = "-" bgStyle = removedLineStyle - lineNumberStyle = lineNumberStyle.Foreground(t.DiffRemoved()).Background(t.DiffRemovedLineNumberBg()) - highlightColor = t.DiffHighlightRemoved() + lineNumberStyle = lineNumberStyle.Background(t.DiffRemovedLineNumberBg()).Foreground(t.DiffRemoved()) + highlightColor = t.DiffHighlightRemoved() // TODO: handle "none" case LineAdded: marker = "?" bgStyle = contextLineStyle @@ -818,7 +847,7 @@ func renderDiffColumnLine( case LineAdded: marker = "+" bgStyle = addedLineStyle - lineNumberStyle = lineNumberStyle.Foreground(t.DiffAdded()).Background(t.DiffAddedLineNumberBg()) + lineNumberStyle = lineNumberStyle.Background(t.DiffAddedLineNumberBg()).Foreground(t.DiffAdded()) highlightColor = t.DiffHighlightAdded() case LineRemoved: marker = "?" @@ -849,7 +878,7 @@ func renderDiffColumnLine( // Render the content prefixWidth := ansi.StringWidth(prefix) contentWidth := colWidth - prefixWidth - content := renderLineContent(fileName, *dl, bgStyle, highlightColor, contentWidth, t) + content := renderLineContent(fileName, *dl, bgStyle, highlightColor, contentWidth) return prefix + content } diff --git a/packages/tui/internal/components/list/list.go b/packages/tui/internal/components/list/list.go index d5cc4b4f9..fe03f5c28 100644 --- a/packages/tui/internal/components/list/list.go +++ b/packages/tui/internal/components/list/list.go @@ -5,7 +5,6 @@ import ( "github.com/charmbracelet/bubbles/v2/key" tea "github.com/charmbracelet/bubbletea/v2" - "github.com/charmbracelet/lipgloss/v2" "github.com/muesli/reflow/truncate" "github.com/sst/opencode/internal/styles" "github.com/sst/opencode/internal/theme" @@ -174,11 +173,11 @@ type StringItem string func (s StringItem) Render(selected bool, width int) string { t := theme.CurrentTheme() - baseStyle := styles.BaseStyle() + baseStyle := styles.NewStyle() truncatedStr := truncate.StringWithTail(string(s), uint(width-1), "...") - var itemStyle lipgloss.Style + var itemStyle styles.Style if selected { itemStyle = baseStyle. Background(t.Primary()). @@ -187,6 +186,7 @@ func (s StringItem) Render(selected bool, width int) string { PaddingLeft(1) } else { itemStyle = baseStyle. + Foreground(t.TextMuted()). PaddingLeft(1) } diff --git a/packages/tui/internal/components/modal/modal.go b/packages/tui/internal/components/modal/modal.go index 62cafe843..6bce64247 100644 --- a/packages/tui/internal/components/modal/modal.go +++ b/packages/tui/internal/components/modal/modal.go @@ -90,12 +90,8 @@ func (m *Modal) Render(contentView string, background string) string { innerWidth := outerWidth - 4 - // Base style for the modal - baseStyle := styles.BaseStyle(). - Background(t.BackgroundElement()). - Foreground(t.TextMuted()) + baseStyle := styles.NewStyle().Foreground(t.TextMuted()).Background(t.BackgroundElement()) - // Add title if provided var finalContent string if m.title != "" { titleStyle := baseStyle. diff --git a/packages/tui/internal/components/qr/qr.go b/packages/tui/internal/components/qr/qr.go index 82d597a3f..ccf28200b 100644 --- a/packages/tui/internal/components/qr/qr.go +++ b/packages/tui/internal/components/qr/qr.go @@ -3,7 +3,7 @@ package qr import ( "strings" - "github.com/charmbracelet/lipgloss/v2" + "github.com/sst/opencode/internal/styles" "github.com/sst/opencode/internal/theme" "rsc.io/qr" ) @@ -23,9 +23,7 @@ func Generate(text string) (string, int, error) { } // Create lipgloss style for QR code with theme colors - qrStyle := lipgloss.NewStyle(). - Foreground(t.Text()). - Background(t.Background()) + qrStyle := styles.NewStyleWithColors(t.Text(), t.Background()) var result strings.Builder diff --git a/packages/tui/internal/components/status/status.go b/packages/tui/internal/components/status/status.go index 62d207088..fb5ff8ced 100644 --- a/packages/tui/internal/components/status/status.go +++ b/packages/tui/internal/components/status/status.go @@ -36,14 +36,15 @@ func (m statusComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (m statusComponent) logo() string { t := theme.CurrentTheme() - base := lipgloss.NewStyle().Background(t.BackgroundElement()).Foreground(t.TextMuted()).Render - emphasis := lipgloss.NewStyle().Bold(true).Background(t.BackgroundElement()).Foreground(t.Text()).Render + base := styles.NewStyle().Foreground(t.TextMuted()).Background(t.BackgroundElement()).Render + emphasis := styles.NewStyle().Foreground(t.Text()).Background(t.BackgroundElement()).Bold(true).Render open := base("open") code := emphasis("code ") version := base(m.app.Version) - return styles.Padded(). + return styles.NewStyle(). Background(t.BackgroundElement()). + Padding(0, 1). Render(open + code + version) } @@ -77,7 +78,7 @@ func formatTokensAndCost(tokens float32, contextWindow float32, cost float32) st func (m statusComponent) View() string { t := theme.CurrentTheme() if m.app.Session.Id == "" { - return styles.BaseStyle(). + return styles.NewStyle(). Background(t.Background()). Width(m.width). Height(2). @@ -86,9 +87,10 @@ func (m statusComponent) View() string { logo := m.logo() - cwd := styles.Padded(). + cwd := styles.NewStyle(). Foreground(t.TextMuted()). Background(t.BackgroundPanel()). + Padding(0, 1). Render(m.app.Info.Path.Cwd) sessionInfo := "" @@ -111,9 +113,10 @@ func (m statusComponent) View() string { } } - sessionInfo = styles.Padded(). - Background(t.BackgroundElement()). + sessionInfo = styles.NewStyle(). Foreground(t.TextMuted()). + Background(t.BackgroundElement()). + Padding(0, 1). Render(formatTokensAndCost(tokens, contextWindow, cost)) } @@ -123,11 +126,11 @@ func (m statusComponent) View() string { 0, m.width-lipgloss.Width(logo)-lipgloss.Width(cwd)-lipgloss.Width(sessionInfo), ) - spacer := lipgloss.NewStyle().Background(t.BackgroundPanel()).Width(space).Render("") + spacer := styles.NewStyle().Background(t.BackgroundPanel()).Width(space).Render("") status := logo + cwd + spacer + sessionInfo - blank := styles.BaseStyle().Background(t.Background()).Width(m.width).Render("") + blank := styles.NewStyle().Background(t.Background()).Width(m.width).Render("") return blank + "\n" + status } diff --git a/packages/tui/internal/components/toast/toast.go b/packages/tui/internal/components/toast/toast.go index 09b3c6288..2de6bf619 100644 --- a/packages/tui/internal/components/toast/toast.go +++ b/packages/tui/internal/components/toast/toast.go @@ -90,9 +90,9 @@ func (tm *ToastManager) Update(msg tea.Msg) (*ToastManager, tea.Cmd) { func (tm *ToastManager) renderSingleToast(toast Toast) string { t := theme.CurrentTheme() - baseStyle := styles.BaseStyle(). - Background(t.BackgroundElement()). + baseStyle := styles.NewStyle(). Foreground(t.Text()). + Background(t.BackgroundElement()). Padding(1, 2) maxWidth := max(40, layout.Current.Viewport.Width/3) @@ -101,15 +101,14 @@ func (tm *ToastManager) renderSingleToast(toast Toast) string { // Build content with wrapping var content strings.Builder if toast.Title != nil { - titleStyle := lipgloss.NewStyle(). - Foreground(toast.Color). + titleStyle := styles.NewStyle().Foreground(toast.Color). Bold(true) content.WriteString(titleStyle.Render(*toast.Title)) content.WriteString("\n") } // Wrap message text - messageStyle := lipgloss.NewStyle() + messageStyle := styles.NewStyle() contentWidth := lipgloss.Width(toast.Message) if contentWidth > contentMaxWidth { messageStyle = messageStyle.Width(contentMaxWidth) |
