diff --git a/internal/ui/tool_renderers.go b/internal/ui/tool_renderers.go index 0a0fd4a7..b5f6f2dc 100644 --- a/internal/ui/tool_renderers.go +++ b/internal/ui/tool_renderers.go @@ -23,6 +23,7 @@ const ( maxCodeLines = 20 // lines for Read / code blocks maxWriteLines = 10 // lines for Write blocks maxBashLines = 20 // lines for Bash output (matches Read) + maxLsLines = 20 // lines for Ls directory listings ) // renderToolBody dispatches to tool-specific body renderers based on tool name. @@ -315,6 +316,13 @@ func renderLsBody(toolResult string, width int) string { lines := strings.Split(content, "\n") + // Truncate to maxLsLines for display + var hiddenCount int + if len(lines) > maxLsLines { + hiddenCount = len(lines) - maxLsLines + lines = lines[:maxLsLines] + } + const indent = " " codeWidth := max(width-len(indent), 20) @@ -329,6 +337,13 @@ func renderLsBody(toolResult string, width int) string { result = append(result, indent+styled) } + if hiddenCount > 0 { + hint := fmt.Sprintf("...(%d more entries)", hiddenCount) + hintContent := codeStyle.Width(codeWidth). + Foreground(theme.Muted).Italic(true).Render(hint) + result = append(result, indent+hintContent) + } + return strings.Join(result, "\n") }