tui: collapse double-blank between adjacent tool boxes

Each tool result owns its own box, but the assistant message that
batched the originating tool_use blocks now renders to nothing (the
box edges moved to the tool result). Build() was still emitting an
inter-message blank for that empty render, which compounded with
the blank from the next real message and produced two blank rows
between adjacent tool boxes \u2014 visible whenever the model batched
multiple tool calls without prose between them.

Skip the inter-message blank when a message rendered to zero lines
so an empty assistant message no longer contributes a separator
row. Adjacent tool boxes now sit one blank row apart, matching the
spacing between every other pair of chat blocks.
This commit is contained in:
patriceckhart 2026-04-27 15:59:35 +02:00
parent 4b2bce3fb2
commit 955a9b703b

View file

@ -232,6 +232,15 @@ func (v *View) BuildWithAnchors(width int) ([]string, []MessageAnchor) {
for idx := range v.Messages {
anchors = append(anchors, MessageAnchor{MessageIdx: idx, Row: len(out)})
out = append(out, rendered[idx]...)
// Skip the inter-message blank for messages that rendered
// to nothing. An assistant message whose only content is
// ToolCallBlock(s) has no rendered output of its own (each
// tool result owns its box now), so emitting a blank for it
// would compound with the blank from the next real message
// and produce two blank rows between adjacent tool boxes.
if len(rendered[idx]) == 0 {
continue
}
out = append(out, "")
}
// Only render the streaming header/body when there's actual