Skip to content

Commit b8a89da

Browse files
committed
fix: background color rendering issues
1 parent 7351e12 commit b8a89da

File tree

4 files changed

+36
-150
lines changed

4 files changed

+36
-150
lines changed

packages/tui/internal/components/chat/message.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,13 @@ func renderContentBlock(content string, options ...renderingOption) string {
180180
layout.Current.Container.Width,
181181
align,
182182
content,
183+
lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Background(t.Background())),
183184
)
184185
content = lipgloss.PlaceHorizontal(
185186
layout.Current.Viewport.Width,
186187
lipgloss.Center,
187188
content,
189+
lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Background(t.Background())),
188190
)
189191
return content
190192
}
@@ -373,6 +375,7 @@ func renderToolInvocation(
373375
lipgloss.Center,
374376
lipgloss.Top,
375377
body,
378+
lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Background(t.Background())),
376379
)
377380
}
378381
}
@@ -440,7 +443,12 @@ func renderToolInvocation(
440443
}
441444

442445
content := style.Render(title)
443-
content = lipgloss.PlaceHorizontal(layout.Current.Viewport.Width, lipgloss.Center, content)
446+
content = lipgloss.PlaceHorizontal(
447+
layout.Current.Viewport.Width,
448+
lipgloss.Center,
449+
content,
450+
lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Background(t.Background())),
451+
)
444452
if showResult && body != "" && error == "" {
445453
content += "\n" + body
446454
}

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,15 @@ func (m *messagesComponent) View() string {
275275
if m.rendering {
276276
return m.viewport.View()
277277
}
278+
t := theme.CurrentTheme()
278279
return lipgloss.JoinVertical(
279280
lipgloss.Left,
280-
lipgloss.PlaceHorizontal(m.width, lipgloss.Center, m.header()),
281+
lipgloss.PlaceHorizontal(
282+
m.width,
283+
lipgloss.Center,
284+
m.header(),
285+
lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Background(t.Background())),
286+
),
281287
m.viewport.View(),
282288
)
283289
}
@@ -346,13 +352,20 @@ func (m *messagesComponent) home() string {
346352
lines = append(lines, "")
347353
}
348354

349-
return lipgloss.Place(m.width, m.height, lipgloss.Center, lipgloss.Center,
355+
t := theme.CurrentTheme()
356+
return lipgloss.Place(
357+
m.width,
358+
m.height,
359+
lipgloss.Center,
360+
lipgloss.Center,
350361
baseStyle.Width(lipgloss.Width(logoAndVersion)).Render(
351362
lipgloss.JoinVertical(
352363
lipgloss.Top,
353364
lines...,
354365
),
355-
))
366+
),
367+
lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Background(t.Background())),
368+
)
356369
}
357370

358371
func (m *messagesComponent) SetSize(width, height int) tea.Cmd {

packages/tui/internal/components/dialog/quit.go

Lines changed: 0 additions & 139 deletions
This file was deleted.

packages/tui/internal/layout/flex.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package layout
33
import (
44
tea "github.com/charmbracelet/bubbletea/v2"
55
"github.com/charmbracelet/lipgloss/v2"
6+
"github.com/sst/opencode/internal/theme"
67
)
78

89
type FlexDirection int
@@ -76,6 +77,7 @@ func (f *flexLayout) View() string {
7677
return ""
7778
}
7879

80+
t := theme.CurrentTheme()
7981
views := make([]string, 0, len(f.panes))
8082
for i, pane := range f.panes {
8183
if pane == nil {
@@ -89,6 +91,7 @@ func (f *flexLayout) View() string {
8991
paneWidth,
9092
pane.Alignment(),
9193
pane.View(),
94+
lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Background(t.Background())),
9295
)
9396
views = append(views, view)
9497
} else {
@@ -99,6 +102,7 @@ func (f *flexLayout) View() string {
99102
lipgloss.Center,
100103
pane.Alignment(),
101104
pane.View(),
105+
lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Background(t.Background())),
102106
)
103107
views = append(views, view)
104108
}
@@ -160,14 +164,14 @@ func (f *flexLayout) SetSize(width, height int) tea.Cmd {
160164

161165
var cmds []tea.Cmd
162166
currentX, currentY := 0, 0
163-
167+
164168
for i, pane := range f.panes {
165169
if pane != nil {
166170
paneWidth, paneHeight := f.calculatePaneSize(i)
167-
171+
168172
// Calculate actual position based on alignment
169173
actualX, actualY := currentX, currentY
170-
174+
171175
if f.direction == FlexDirectionHorizontal {
172176
// In horizontal layout, vertical alignment affects Y position
173177
// (lipgloss.Center is used for vertical alignment in JoinHorizontal)
@@ -178,7 +182,7 @@ func (f *flexLayout) SetSize(width, height int) tea.Cmd {
178182
if pane.MaxWidth() > 0 && contentWidth > pane.MaxWidth() {
179183
contentWidth = pane.MaxWidth()
180184
}
181-
185+
182186
switch pane.Alignment() {
183187
case lipgloss.Center:
184188
actualX = (f.width - contentWidth) / 2
@@ -188,16 +192,16 @@ func (f *flexLayout) SetSize(width, height int) tea.Cmd {
188192
actualX = 0
189193
}
190194
}
191-
195+
192196
// Set position if the pane is a *container
193197
if c, ok := pane.(*container); ok {
194198
c.x = actualX
195199
c.y = actualY
196200
}
197-
201+
198202
cmd := pane.SetSize(paneWidth, paneHeight)
199203
cmds = append(cmds, cmd)
200-
204+
201205
// Update position for next pane
202206
if f.direction == FlexDirectionHorizontal {
203207
currentX += paneWidth

0 commit comments

Comments
 (0)