Skip to content

Commit d939d2a

Browse files
committed
Nicer rendering of tool calls
Signed-off-by: David Gageot <david.gageot@docker.com>
1 parent 5f4c405 commit d939d2a

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

internal/tui/components/tool/tool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (mv *toolModel) Render(width int) string {
130130
// Join the lines back and apply muted style
131131
trimmedContent := strings.Join(lines, "\n")
132132
if trimmedContent != "" {
133-
resultContent = "\n" + styles.MutedStyle.Render(trimmedContent)
133+
resultContent = "\n" + styles.ToolCallResultStyle.Render(trimmedContent)
134134
}
135135
}
136136

internal/tui/styles/styles.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,27 @@ func darken(c color.Color, percent float64) color.Color {
4545
}
4646
}
4747

48+
func lighten(c color.Color, percent float64) color.Color {
49+
r, g, b, a := c.RGBA()
50+
factor := percent / 100.0
51+
return color.RGBA{
52+
R: uint8(min(255, float64(r>>8)+255*factor)),
53+
G: uint8(min(255, float64(g>>8)+255*factor)),
54+
B: uint8(min(255, float64(b>>8)+255*factor)),
55+
A: uint8(a >> 8),
56+
}
57+
}
58+
4859
var (
4960
BaseStyle = lipgloss.NewStyle().Foreground(primary)
5061
AppStyle = BaseStyle.Padding(0, 1, 0, 1)
5162

5263
// Text styles
53-
HighlightStyle = BaseStyle.Foreground(highlight)
54-
MutedStyle = BaseStyle.Foreground(muted)
55-
SubtleStyle = BaseStyle.Foreground(subtle)
56-
SecondaryStyle = BaseStyle.Foreground(secondary)
64+
HighlightStyle = BaseStyle.Foreground(highlight)
65+
MutedStyle = BaseStyle.Foreground(muted)
66+
ToolCallResultStyle = BaseStyle.Foreground(muted).Margin(1, 0, 0, 0).Background(lighten(Background, 5)).Padding(1, 1)
67+
SubtleStyle = BaseStyle.Foreground(subtle)
68+
SecondaryStyle = BaseStyle.Foreground(secondary)
5769

5870
// Status styles
5971
SuccessStyle = BaseStyle.Foreground(success)

0 commit comments

Comments
 (0)