Skip to content
This repository was archived by the owner on Sep 18, 2025. It is now read-only.

Commit dfd2378

Browse files
committed
more theme cleanup
1 parent 4a74863 commit dfd2378

18 files changed

Lines changed: 134 additions & 1184 deletions

File tree

cspell.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"words":["opencode","charmbracelet","lipgloss","bubbletea","textinput","Focusable","lsps"],"version":"0.2","language":"en","flagWords":[]}
1+
{"words":["opencode","charmbracelet","lipgloss","bubbletea","textinput","Focusable","lsps","Sourcegraph"],"version":"0.2","language":"en","flagWords":[]}

internal/tui/components/chat/chat.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/opencode-ai/opencode/internal/session"
1515
"github.com/opencode-ai/opencode/internal/tui/components/chat/messages"
1616
"github.com/opencode-ai/opencode/internal/tui/components/core/list"
17-
"github.com/opencode-ai/opencode/internal/tui/components/dialog"
1817
"github.com/opencode-ai/opencode/internal/tui/layout"
1918
"github.com/opencode-ai/opencode/internal/tui/util"
2019
)
@@ -87,9 +86,6 @@ func (m *messageListCmp) Init() tea.Cmd {
8786
// Update handles incoming messages and updates the component state.
8887
func (m *messageListCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
8988
switch msg := msg.(type) {
90-
case dialog.ThemeChangedMsg:
91-
m.listCmp.ResetView()
92-
return m, nil
9389
case SessionSelectedMsg:
9490
if msg.ID != m.session.ID {
9591
cmd := m.SetSession(msg)

internal/tui/components/chat/editor/editor.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"github.com/opencode-ai/opencode/internal/tui/components/dialog"
2323
"github.com/opencode-ai/opencode/internal/tui/layout"
2424
"github.com/opencode-ai/opencode/internal/tui/styles"
25-
"github.com/opencode-ai/opencode/internal/tui/theme"
2625
"github.com/opencode-ai/opencode/internal/tui/util"
2726
)
2827

@@ -138,9 +137,6 @@ func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
138137
var cmd tea.Cmd
139138
var cmds []tea.Cmd
140139
switch msg := msg.(type) {
141-
case dialog.ThemeChangedMsg:
142-
m.textarea = CreateTextArea(&m.textarea)
143-
return m, cmd
144140
case chat.SessionSelectedMsg:
145141
if msg.ID != m.session.ID {
146142
m.session = msg
@@ -300,11 +296,11 @@ func (m *editorCmp) GetSize() (int, int) {
300296

301297
func (m *editorCmp) attachmentsContent() string {
302298
var styledAttachments []string
303-
t := theme.CurrentTheme()
304-
attachmentStyles := styles.BaseStyle().
299+
t := styles.CurrentTheme()
300+
attachmentStyles := t.S().Base.
305301
MarginLeft(1).
306-
Background(t.TextMuted()).
307-
Foreground(t.Text())
302+
Background(t.FgMuted).
303+
Foreground(t.FgBase)
308304
for i, attachment := range m.attachments {
309305
var filename string
310306
if len(attachment.FileName) > 10 {

internal/tui/components/chat/messages/messages.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"github.com/opencode-ai/opencode/internal/tui/components/anim"
1717
"github.com/opencode-ai/opencode/internal/tui/layout"
1818
"github.com/opencode-ai/opencode/internal/tui/styles"
19-
"github.com/opencode-ai/opencode/internal/tui/theme"
2019
"github.com/opencode-ai/opencode/internal/tui/util"
2120
)
2221

@@ -124,7 +123,7 @@ func (m *messageCmp) textWidth() int {
124123
// style returns the lipgloss style for the message component.
125124
// Applies different border colors and styles based on message role and focus state.
126125
func (msg *messageCmp) style() lipgloss.Style {
127-
t := theme.CurrentTheme()
126+
t := styles.CurrentTheme()
128127
var borderColor color.Color
129128
borderStyle := lipgloss.NormalBorder()
130129
if msg.focused {
@@ -133,17 +132,16 @@ func (msg *messageCmp) style() lipgloss.Style {
133132

134133
switch msg.message.Role {
135134
case message.User:
136-
borderColor = t.Secondary()
135+
borderColor = t.Secondary
137136
case message.Assistant:
138-
borderColor = t.Primary()
137+
borderColor = t.Primary
139138
default:
140139
// Tool call
141-
borderColor = t.TextMuted()
140+
borderColor = t.BgSubtle
142141
}
143142

144-
return styles.BaseStyle().
143+
return t.S().Muted.
145144
BorderLeft(true).
146-
Foreground(t.TextMuted()).
147145
BorderForeground(borderColor).
148146
BorderStyle(borderStyle)
149147
}
@@ -182,14 +180,13 @@ func (m *messageCmp) renderAssistantMessage() string {
182180
// renderUserMessage renders user messages with file attachments.
183181
// Displays message content and any attached files with appropriate icons.
184182
func (m *messageCmp) renderUserMessage() string {
185-
t := theme.CurrentTheme()
183+
t := styles.CurrentTheme()
186184
parts := []string{
187185
m.markdownContent(),
188186
}
189-
attachmentStyles := styles.BaseStyle().
187+
attachmentStyles := t.S().Text.
190188
MarginLeft(1).
191-
Background(t.BackgroundSecondary()).
192-
Foreground(t.Text())
189+
Background(t.BgSubtle)
193190
attachments := []string{}
194191
for _, attachment := range m.message.BinaryContent() {
195192
file := filepath.Base(attachment.Path)

internal/tui/components/chat/messages/renderer.go

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"github.com/opencode-ai/opencode/internal/llm/agent"
1616
"github.com/opencode-ai/opencode/internal/llm/tools"
1717
"github.com/opencode-ai/opencode/internal/tui/styles"
18-
"github.com/opencode-ai/opencode/internal/tui/theme"
1918
)
2019

2120
// responseContextHeight limits the number of lines displayed in tool output
@@ -107,7 +106,7 @@ func (br baseRenderer) renderWithParams(v *toolCallCmp, toolName string, args []
107106
return joinHeaderBody(header, body)
108107
}
109108

110-
// unmarshalParams safely unmarshals JSON parameters
109+
// unmarshalParams safely unmarshal JSON parameters
111110
func (br baseRenderer) unmarshalParams(input string, target any) error {
112111
return json.Unmarshal([]byte(input), target)
113112
}
@@ -593,7 +592,7 @@ func joinHeaderBody(header, body string) string {
593592
}
594593

595594
func renderPlainContent(v *toolCallCmp, content string) string {
596-
t := theme.CurrentTheme()
595+
t := styles.CurrentTheme()
597596
content = strings.TrimSpace(content)
598597
lines := strings.Split(content, "\n")
599598

@@ -606,58 +605,55 @@ func renderPlainContent(v *toolCallCmp, content string) string {
606605
if len(ln) > v.textWidth() {
607606
ln = v.fit(ln, v.textWidth())
608607
}
609-
out = append(out, lipgloss.NewStyle().
608+
out = append(out, t.S().Muted.
610609
Width(v.textWidth()).
611-
Background(t.BackgroundSecondary()).
612-
Foreground(t.TextMuted()).
610+
Background(t.BgSubtle).
613611
Render(ln))
614612
}
615613

616614
if len(lines) > responseContextHeight {
617-
out = append(out, lipgloss.NewStyle().
618-
Background(t.BackgroundSecondary()).
619-
Foreground(t.TextMuted()).
615+
out = append(out, t.S().Muted.
616+
Background(t.BgSubtle).
620617
Render(fmt.Sprintf("... (%d lines)", len(lines)-responseContextHeight)))
621618
}
622619
return strings.Join(out, "\n")
623620
}
624621

625622
func renderCodeContent(v *toolCallCmp, path, content string, offset int) string {
626-
t := theme.CurrentTheme()
623+
t := styles.CurrentTheme()
627624
truncated := truncateHeight(content, responseContextHeight)
628625

629-
highlighted, _ := highlight.SyntaxHighlight(truncated, path, t.BackgroundSecondary())
626+
highlighted, _ := highlight.SyntaxHighlight(truncated, path, t.BgSubtle)
630627
lines := strings.Split(highlighted, "\n")
631628

632629
if len(strings.Split(content, "\n")) > responseContextHeight {
633-
lines = append(lines, lipgloss.NewStyle().
634-
Background(t.BackgroundSecondary()).
635-
Foreground(t.TextMuted()).
630+
lines = append(lines, t.S().Muted.
631+
Background(t.BgSubtle).
636632
Render(fmt.Sprintf("... (%d lines)", len(strings.Split(content, "\n"))-responseContextHeight)))
637633
}
638634

639635
for i, ln := range lines {
640-
num := lipgloss.NewStyle().
641-
PaddingLeft(4).PaddingRight(2).
642-
Background(t.BackgroundSecondary()).
643-
Foreground(t.TextMuted()).
636+
num := t.S().Muted.
637+
Background(t.BgSubtle).
638+
PaddingLeft(4).
639+
PaddingRight(2).
644640
Render(fmt.Sprintf("%d", i+1+offset))
645641
w := v.textWidth() - lipgloss.Width(num)
646642
lines[i] = lipgloss.JoinHorizontal(lipgloss.Left,
647643
num,
648-
lipgloss.NewStyle().
644+
t.S().Base.
649645
Width(w).
650-
Background(t.BackgroundSecondary()).
646+
Background(t.BgSubtle).
651647
Render(v.fit(ln, w)))
652648
}
653649
return lipgloss.JoinVertical(lipgloss.Left, lines...)
654650
}
655651

656652
func (v *toolCallCmp) renderToolError() string {
657-
t := theme.CurrentTheme()
653+
t := styles.CurrentTheme()
658654
err := strings.ReplaceAll(v.result.Content, "\n", " ")
659655
err = fmt.Sprintf("Error: %s", err)
660-
return styles.BaseStyle().Foreground(t.Error()).Render(v.fit(err, v.textWidth()))
656+
return t.S().Base.Foreground(t.Error).Render(v.fit(err, v.textWidth()))
661657
}
662658

663659
func removeWorkingDirPrefix(path string) string {

internal/tui/components/chat/messages/tool.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/opencode-ai/opencode/internal/tui/components/anim"
1212
"github.com/opencode-ai/opencode/internal/tui/layout"
1313
"github.com/opencode-ai/opencode/internal/tui/styles"
14-
"github.com/opencode-ai/opencode/internal/tui/theme"
1514
"github.com/opencode-ai/opencode/internal/tui/util"
1615
)
1716

@@ -216,19 +215,17 @@ func (m *toolCallCmp) renderPending() string {
216215
// style returns the lipgloss style for the tool call component.
217216
// Applies muted colors and focus-dependent border styles.
218217
func (m *toolCallCmp) style() lipgloss.Style {
219-
t := theme.CurrentTheme()
218+
t := styles.CurrentTheme()
220219
if m.isNested {
221-
return styles.BaseStyle().
222-
Foreground(t.TextMuted())
220+
return t.S().Muted
223221
}
224222
borderStyle := lipgloss.NormalBorder()
225223
if m.focused {
226224
borderStyle = lipgloss.DoubleBorder()
227225
}
228-
return styles.BaseStyle().
226+
return t.S().Muted.
229227
BorderLeft(true).
230-
Foreground(t.TextMuted()).
231-
BorderForeground(t.TextMuted()).
228+
BorderForeground(t.Border).
232229
BorderStyle(borderStyle)
233230
}
234231

@@ -240,8 +237,8 @@ func (m *toolCallCmp) textWidth() int {
240237

241238
// fit truncates content to fit within the specified width with ellipsis
242239
func (m *toolCallCmp) fit(content string, width int) string {
243-
t := theme.CurrentTheme()
244-
lineStyle := lipgloss.NewStyle().Background(t.BackgroundSecondary()).Foreground(t.TextMuted())
240+
t := styles.CurrentTheme()
241+
lineStyle := t.S().Muted.Background(t.BgSubtle)
245242
dots := lineStyle.Render("...")
246243
return ansi.Truncate(content, width, dots)
247244
}

internal/tui/components/completions/completions.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"github.com/charmbracelet/lipgloss/v2"
77
"github.com/opencode-ai/opencode/internal/tui/components/core/list"
88
"github.com/opencode-ai/opencode/internal/tui/styles"
9-
"github.com/opencode-ai/opencode/internal/tui/theme"
109
"github.com/opencode-ai/opencode/internal/tui/util"
1110
)
1211

@@ -172,11 +171,11 @@ func (c *completionsCmp) View() tea.View {
172171
}
173172

174173
func (c *completionsCmp) style() lipgloss.Style {
175-
t := theme.CurrentTheme()
176-
return styles.BaseStyle().
174+
t := styles.CurrentTheme()
175+
return t.S().Base.
177176
Width(c.width).
178177
Height(c.height).
179-
Background(t.BackgroundSecondary())
178+
Background(t.BgSubtle)
180179
}
181180

182181
func (c *completionsCmp) Open() bool {

internal/tui/components/dialog/filepicker.go

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/opencode-ai/opencode/internal/message"
2020
"github.com/opencode-ai/opencode/internal/tui/image"
2121
"github.com/opencode-ai/opencode/internal/tui/styles"
22-
"github.com/opencode-ai/opencode/internal/tui/theme"
2322
"github.com/opencode-ai/opencode/internal/tui/util"
2423
)
2524

@@ -258,7 +257,8 @@ func (f *filepickerCmp) addAttachmentToMessage() (tea.Model, tea.Cmd) {
258257
}
259258

260259
func (f *filepickerCmp) View() tea.View {
261-
t := theme.CurrentTheme()
260+
t := styles.CurrentTheme()
261+
baseStyle := t.S().Base
262262
const maxVisibleDirs = 20
263263
const maxWidth = 80
264264

@@ -286,12 +286,11 @@ func (f *filepickerCmp) View() tea.View {
286286

287287
for i := startIdx; i < endIdx; i++ {
288288
file := f.dirs[i]
289-
itemStyle := styles.BaseStyle().Width(adjustedWidth)
289+
itemStyle := t.S().Text.Width(adjustedWidth)
290290

291291
if i == f.cursor {
292292
itemStyle = itemStyle.
293-
Background(t.Primary()).
294-
Foreground(t.Background()).
293+
Background(t.Primary).
295294
Bold(true)
296295
}
297296
filename := file.Name()
@@ -309,20 +308,18 @@ func (f *filepickerCmp) View() tea.View {
309308

310309
// Pad to always show exactly 21 lines
311310
for len(files) < maxVisibleDirs {
312-
files = append(files, styles.BaseStyle().Width(adjustedWidth).Render(""))
311+
files = append(files, baseStyle.Width(adjustedWidth).Render(""))
313312
}
314313

315-
currentPath := styles.BaseStyle().
314+
currentPath := baseStyle.
316315
Height(1).
317316
Width(adjustedWidth).
318317
Render(f.cwd.View())
319318

320-
viewportstyle := lipgloss.NewStyle().
319+
viewportstyle := baseStyle.
321320
Width(f.viewport.Width()).
322-
Background(t.Background()).
323321
Border(lipgloss.RoundedBorder()).
324-
BorderForeground(t.TextMuted()).
325-
BorderBackground(t.Background()).
322+
BorderForeground(t.BorderFocus).
326323
Padding(2).
327324
Render(f.viewport.View())
328325
var insertExitText string
@@ -335,17 +332,16 @@ func (f *filepickerCmp) View() tea.View {
335332
content := lipgloss.JoinVertical(
336333
lipgloss.Left,
337334
currentPath,
338-
styles.BaseStyle().Width(adjustedWidth).Render(""),
339-
styles.BaseStyle().Width(adjustedWidth).Render(lipgloss.JoinVertical(lipgloss.Left, files...)),
340-
styles.BaseStyle().Width(adjustedWidth).Render(""),
341-
styles.BaseStyle().Foreground(t.TextMuted()).Width(adjustedWidth).Render(insertExitText),
335+
baseStyle.Width(adjustedWidth).Render(""),
336+
baseStyle.Width(adjustedWidth).Render(lipgloss.JoinVertical(lipgloss.Left, files...)),
337+
baseStyle.Width(adjustedWidth).Render(""),
338+
t.S().Muted.Width(adjustedWidth).Render(insertExitText),
342339
)
343340

344341
f.cwd.SetValue(f.cwd.Value())
345-
contentStyle := styles.BaseStyle().Padding(1, 2).
342+
contentStyle := baseStyle.Padding(1, 2).
346343
Border(lipgloss.RoundedBorder()).
347-
BorderBackground(t.Background()).
348-
BorderForeground(t.TextMuted()).
344+
BorderForeground(t.BorderFocus).
349345
Width(lipgloss.Width(content) + 4)
350346

351347
return tea.NewView(

0 commit comments

Comments
 (0)