From 136763181b9dfd80db914e3581d4f084cc3daccc Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Sat, 15 Aug 2026 17:51:38 +0200 Subject: [PATCH] fix(display): clip the header line to the terminal width like every other row The "[+] op N/M" header was the one line bypassing renderSegs, so on a very narrow terminal it could wrap and desync the cursor arithmetic the rest of the design guarantees against. Route it through the same clip and cover degenerate widths (8, 12 cells) in the invariant test. Co-Authored-By: Claude Fable 5 Signed-off-by: Nicolas De Loof --- cmd/display/tty_layout.go | 3 ++- cmd/display/tty_test.go | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/display/tty_layout.go b/cmd/display/tty_layout.go index 08da3df36..9f6622611 100644 --- a/cmd/display/tty_layout.go +++ b/cmd/display/tty_layout.go @@ -65,7 +65,8 @@ const ( // layoutFrame renders the whole progress block, one string per terminal row. func layoutFrame(t *taskTree, operation string, o layoutOpts) []string { done, total := t.counts() - lines := []string{fmt.Sprintf("[+] %s %d/%d", operation, done, total)} + header := fmt.Sprintf("[+] %s %d/%d", operation, done, total) + lines := []string{renderSegs([]seg{{text: header}}, o.width)} rows := buildRows(t, o) maxRows := max(o.height-2, 1) diff --git a/cmd/display/tty_test.go b/cmd/display/tty_test.go index 49b3c081b..0945ee8e6 100644 --- a/cmd/display/tty_test.go +++ b/cmd/display/tty_test.go @@ -116,7 +116,9 @@ func adversarialEvents() []api.Resource { } func TestTerm_NoLineEverExceedsTerminalWidth(t *testing.T) { - for _, width := range []int{20, 30, 40, 60, 80, 120} { + // 8 and 12 exercise the degenerate widths where even the "[+] op N/M" + // header must be clipped rather than allowed to wrap + for _, width := range []int{8, 12, 20, 30, 40, 60, 80, 120} { t.Run(fmt.Sprintf("width=%d", width), func(t *testing.T) { w, buf, _ := newTermWriter(width, 40) feed(w, adversarialEvents()...)