summaryrefslogtreecommitdiffhomepage
path: root/packages/tui/internal/components/chat/message.go
diff options
context:
space:
mode:
authoradamdottv <[email protected]>2025-06-15 15:07:00 -0500
committeradamdottv <[email protected]>2025-06-15 15:07:05 -0500
commit77a6b3bdd6f68fe6ae5a69611b100b413e57473c (patch)
tree2b3ce77f3973189d281880c25b03c909152b65bf /packages/tui/internal/components/chat/message.go
parent7effff56c0305965ca9bea56c3165c5d02f5d2eb (diff)
downloadopencode-77a6b3bdd6f68fe6ae5a69611b100b413e57473c.tar.gz
opencode-77a6b3bdd6f68fe6ae5a69611b100b413e57473c.zip
fix: background color rendering issues
Diffstat (limited to 'packages/tui/internal/components/chat/message.go')
-rw-r--r--packages/tui/internal/components/chat/message.go33
1 files changed, 17 insertions, 16 deletions
diff --git a/packages/tui/internal/components/chat/message.go b/packages/tui/internal/components/chat/message.go
index 0a8bc0496..1f9f8ca59 100644
--- a/packages/tui/internal/components/chat/message.go
+++ b/packages/tui/internal/components/chat/message.go
@@ -2,7 +2,6 @@ package chat
import (
"fmt"
- "log/slog"
"path/filepath"
"slices"
"strings"
@@ -131,8 +130,8 @@ func renderContentBlock(content string, options ...renderingOption) string {
}
style := styles.BaseStyle().
- MarginTop(renderer.marginTop).
- MarginBottom(renderer.marginBottom).
+ // MarginTop(renderer.marginTop).
+ // MarginBottom(renderer.marginBottom).
PaddingTop(renderer.paddingTop).
PaddingBottom(renderer.paddingBottom).
PaddingLeft(renderer.paddingLeft).
@@ -188,6 +187,17 @@ func renderContentBlock(content string, options ...renderingOption) string {
content,
lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Background(t.Background())),
)
+ if renderer.marginTop > 0 {
+ for range renderer.marginTop {
+ content = "\n" + content
+ }
+ }
+ if renderer.marginBottom > 0 {
+ for range renderer.marginBottom {
+ content = content + "\n"
+ }
+ }
+
return content
}
@@ -210,18 +220,11 @@ func renderText(message client.MessageInfo, text string, author string) string {
}
info := fmt.Sprintf("%s (%s)", author, timestamp)
- align := lipgloss.Left
- switch message.Role {
- case client.User:
- align = lipgloss.Right
- case client.Assistant:
- align = lipgloss.Left
- }
-
textWidth := max(lipgloss.Width(text), lipgloss.Width(info))
markdownWidth := min(textWidth, width-padding-4) // -4 for the border and padding
content := toMarkdown(text, markdownWidth, t.BackgroundSubtle())
- content = lipgloss.JoinVertical(align, content, info)
+ content = strings.Join([]string{content, info}, "\n")
+ // content = lipgloss.JoinVertical(align, content, info)
switch message.Role {
case client.User:
@@ -270,6 +273,7 @@ func renderToolInvocation(
PaddingRight(2).
BorderLeft(true).
BorderRight(true).
+ BorderBackground(t.Background()).
BorderForeground(t.BackgroundSubtle()).
BorderStyle(lipgloss.ThickBorder())
@@ -294,10 +298,6 @@ func renderToolInvocation(
}
}
- if len(toolArgsMap) == 0 {
- slog.Debug("no args")
- }
-
body := ""
error := ""
finished := result != nil && *result != ""
@@ -358,6 +358,7 @@ func renderToolInvocation(
formattedDiff = strings.TrimSpace(formattedDiff)
formattedDiff = lipgloss.NewStyle().
BorderStyle(lipgloss.ThickBorder()).
+ BorderBackground(t.Background()).
BorderForeground(t.BackgroundSubtle()).
BorderLeft(true).
BorderRight(true).