Skip to content

Commit a8c071e

Browse files
committed
Better wrapping of tool calls
Signed-off-by: David Gageot <[email protected]>
1 parent a55c0b0 commit a8c071e

File tree

1 file changed

+6
-3
lines changed
  • internal/tui/components/tool

1 file changed

+6
-3
lines changed

internal/tui/components/tool/tool.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,11 @@ func (mv *toolModel) Render(width int) string {
115115
// Add tool result content if available (for completed tools with content)
116116
var resultContent string
117117
if (msg.ToolStatus == types.ToolStatusCompleted || msg.ToolStatus == types.ToolStatusError) && msg.Content != "" {
118+
style := styles.ToolCallResultStyle
119+
118120
// Calculate available width for content (accounting for padding)
119-
availableWidth := max(width-2, 10) // Minimum readable width
121+
padding := style.Padding().GetHorizontalPadding()
122+
availableWidth := max(width-2-padding, 10) // Minimum readable width
120123

121124
// Wrap long lines to fit the component width
122125
lines := wrapLines(msg.Content, availableWidth)
@@ -125,13 +128,13 @@ func (mv *toolModel) Render(width int) string {
125128
if len(lines) > 10 {
126129
lines = lines[:10]
127130
// Add indicator that content was truncated
128-
lines = append(lines, "... (output truncated)")
131+
lines = append(lines, wrapLines("... (output truncated)", availableWidth)...)
129132
}
130133

131134
// Join the lines back and apply muted style
132135
trimmedContent := strings.Join(lines, "\n")
133136
if trimmedContent != "" {
134-
resultContent = "\n" + styles.ToolCallResultStyle.Render(trimmedContent)
137+
resultContent = "\n" + style.Render(trimmedContent)
135138
}
136139
}
137140

0 commit comments

Comments
 (0)