Add separator before truncated tool footers

This commit is contained in:
patriceckhart 2026-05-22 17:12:06 +02:00
parent 14ffdb65b0
commit 47257c8a54
2 changed files with 17 additions and 2 deletions

View file

@ -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))
}

View file

@ -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:]