From 47257c8a544bc7f86a215f446167282e4be4bd97 Mon Sep 17 00:00:00 2001 From: patriceckhart Date: Fri, 22 May 2026 17:12:06 +0200 Subject: [PATCH] Add separator before truncated tool footers --- internal/agent/tools/read.go | 3 +++ internal/tui/view.go | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/internal/agent/tools/read.go b/internal/agent/tools/read.go index a2be036..5bc3db9 100644 --- a/internal/agent/tools/read.go +++ b/internal/agent/tools/read.go @@ -131,6 +131,9 @@ func (t *ReadTool) Execute(ctx context.Context, raw json.RawMessage, progress fu sb.WriteString(line) sb.WriteByte('\n') } + if truncLines || truncBytes { + sb.WriteString("\n") + } if truncLines { sb.WriteString(fmt.Sprintf("... [truncated at %d lines]\n", maxReadLines)) } diff --git a/internal/tui/view.go b/internal/tui/view.go index b470a97..0ac73df 100644 --- a/internal/tui/view.go +++ b/internal/tui/view.go @@ -1113,7 +1113,9 @@ func (v *View) collapseToolBody(lines []string, hasImage bool) []string { total := len(lines) footer := fmt.Sprintf(" ... (%d more lines, %d total, ctrl+o to expand)", hidden, total) footer = v.Theme.FG256(v.Theme.Muted, footer) - return append(append([]string(nil), kept...), footer) + out := append([]string(nil), kept...) + out = append(out, "") + return append(out, footer) } // renderToolText renders a text block inside a tool result. If the @@ -1179,6 +1181,11 @@ func (v *View) renderToolText(text string, width, defaultColor int, sourcePath s out = append(out, " "+v.Theme.FG256(v.Theme.Muted, l)) continue } + if inDiff && strings.TrimSpace(l) == "..." { + out = append(out, "") + out = append(out, " "+v.Theme.FG256(v.Theme.Muted, "...")) + continue + } if inDiff && len(l) > 0 { switch l[0] { case '+': @@ -1716,7 +1723,9 @@ func (v *View) renderRawFile(text, sourcePath string, startLine int) []string { lines = lines[:n-1] } // Split code from trailing footer lines ("... [truncated ...]") - // so we don't number the footer. + // so we don't number the footer. A single blank separator line + // immediately before the footer is also pulled out so the + // gutter doesn't render a phantom number for it. codeEnd := len(lines) for i := len(lines) - 1; i >= 0; i-- { if strings.HasPrefix(lines[i], "...") { @@ -1725,6 +1734,9 @@ func (v *View) renderRawFile(text, sourcePath string, startLine int) []string { } break } + if codeEnd > 0 && codeEnd < len(lines) && lines[codeEnd-1] == "" { + codeEnd-- + } code := lines[:codeEnd] footer := lines[codeEnd:]