summaryrefslogtreecommitdiffhomepage
path: root/packages/tui/internal/components
diff options
context:
space:
mode:
authoradamdotdevin <[email protected]>2025-08-05 19:00:08 -0500
committeradamdotdevin <[email protected]>2025-08-05 19:05:44 -0500
commit6b25b7e95ea68321df73e22d62ad33e11154db85 (patch)
treed3d787f3ded38b9b359fb14897e35a8209b2022f /packages/tui/internal/components
parent030a3a7446f0f151fd2fc4d3699cc4c712dc1170 (diff)
downloadopencode-6b25b7e95ea68321df73e22d62ad33e11154db85.tar.gz
opencode-6b25b7e95ea68321df73e22d62ad33e11154db85.zip
feat: better assistant message visual
Diffstat (limited to 'packages/tui/internal/components')
-rw-r--r--packages/tui/internal/components/chat/message.go56
1 files changed, 32 insertions, 24 deletions
diff --git a/packages/tui/internal/components/chat/message.go b/packages/tui/internal/components/chat/message.go
index 8eb48c69f..ec908d5cf 100644
--- a/packages/tui/internal/components/chat/message.go
+++ b/packages/tui/internal/components/chat/message.go
@@ -23,17 +23,18 @@ import (
)
type blockRenderer struct {
- textColor compat.AdaptiveColor
- border bool
- borderColor *compat.AdaptiveColor
- borderLeft bool
- borderRight bool
- paddingTop int
- paddingBottom int
- paddingLeft int
- paddingRight int
- marginTop int
- marginBottom int
+ textColor compat.AdaptiveColor
+ backgroundColor compat.AdaptiveColor
+ border bool
+ borderColor *compat.AdaptiveColor
+ borderLeft bool
+ borderRight bool
+ paddingTop int
+ paddingBottom int
+ paddingLeft int
+ paddingRight int
+ marginTop int
+ marginBottom int
}
type renderingOption func(*blockRenderer)
@@ -44,6 +45,12 @@ func WithTextColor(color compat.AdaptiveColor) renderingOption {
}
}
+func WithBackgroundColor(color compat.AdaptiveColor) renderingOption {
+ return func(c *blockRenderer) {
+ c.backgroundColor = color
+ }
+}
+
func WithNoBorder() renderingOption {
return func(c *blockRenderer) {
c.border = false
@@ -132,14 +139,15 @@ func renderContentBlock(
) string {
t := theme.CurrentTheme()
renderer := &blockRenderer{
- textColor: t.TextMuted(),
- border: true,
- borderLeft: true,
- borderRight: false,
- paddingTop: 1,
- paddingBottom: 1,
- paddingLeft: 2,
- paddingRight: 2,
+ textColor: t.TextMuted(),
+ backgroundColor: t.BackgroundPanel(),
+ border: true,
+ borderLeft: true,
+ borderRight: false,
+ paddingTop: 1,
+ paddingBottom: 1,
+ paddingLeft: 2,
+ paddingRight: 2,
}
for _, option := range options {
option(renderer)
@@ -152,7 +160,7 @@ func renderContentBlock(
style := styles.NewStyle().
Foreground(renderer.textColor).
- Background(t.BackgroundPanel()).
+ Background(renderer.backgroundColor).
PaddingTop(renderer.paddingTop).
PaddingBottom(renderer.paddingBottom).
PaddingLeft(renderer.paddingLeft).
@@ -211,7 +219,7 @@ func renderText(
switch casted := message.(type) {
case opencode.AssistantMessage:
ts = time.UnixMilli(int64(casted.Time.Created))
- content = util.ToMarkdown(text, width, backgroundColor)
+ content = util.ToMarkdown(text, width+2, t.Background())
case opencode.UserMessage:
ts = time.UnixMilli(int64(casted.Time.Created))
base := styles.NewStyle().Foreground(t.Text()).Background(backgroundColor)
@@ -286,14 +294,14 @@ func renderText(
width,
WithTextColor(t.Text()),
WithBorderColor(t.Secondary()),
- WithBorderRight(),
)
case opencode.AssistantMessage:
return renderContentBlock(
app,
content,
- width,
- WithBorderColor(t.Accent()),
+ width+2,
+ WithNoBorder(),
+ WithBackgroundColor(t.Background()),
)
}
return ""