Skip to content

Make line wrapping adapt to the terminal width - #2

Merged
gurnben merged 1 commit into
mainfrom
fix/terminal-width-adaptation
Oct 20, 2026
Merged

gurnben merged 1 commit into
mainfrom
fix/terminal-width-adaptation

Conversation

@gurnben

@gurnben gurnben commented Oct 20, 2026

Copy link
Copy Markdown
Member

Summary

Width was handled in three broken ways, all fixed:

  • Monitor transcript: lines were truncated to whatever the width was when they arrived and never re-flowed on resize. Lines now wrap (ANSI-aware) instead of truncating, and every retained line re-wraps when the terminal resizes.
  • Header / status bar: overflowed on narrow terminals (the model name + elapsed + status easily exceeds 60 columns). Both now clip to one line at the current width; the budget bar yields its cells first.
  • Report browser: table columns and the glamour markdown word wrap were computed once from a hardcoded 100-column startup fallback. Both are now derived from the current width and rebuilt on every resize (cursor preserved, rows re-truncated to the new column widths).
  • Plain output (pipes, --no-monitor, summaries): clipped at a fixed 200 characters. Now wraps to the measured terminal width (120-col fallback when not a TTY), including the kv summary lines that previously overflowed with long journal paths.

Verification

  • 6 new regression tests: re-wrap on resize, one-line header invariant across 40-200 columns, adaptive report table columns, ANSI-preserving wrap/truncate with correct cell counts (40 total, race detector on, vet/staticcheck clean).
  • Verified live in a 50-column PTY: transcript, status bar, and summary all fit; the monitor exits cleanly on q after completion.

💘 Generated with Crush

Width was handled in three broken ways: monitor transcript lines were
truncated to whatever the width was when they arrived (and never
re-flowed on resize), the report browser computed its table columns and
markdown word wrap once from a hardcoded 100-column startup fallback,
and plain output clipped at a fixed 200 characters regardless of the
terminal.

Transcript lines now wrap ANSI-aware instead of truncating, and every
retained line re-wraps when the terminal resizes, so the transcript
stays complete and readable at any width. The monitor header and status
bar clip to one line at the current width (the budget bar yields cells
first), the report browser rebuilds its columns and re-renders its
markdown on resize while preserving the cursor, and plain output plus
the run summary wrap to the measured terminal width.

Regression tests pin the behaviors: re-wrap on resize, one-line header
invariant from 40 to 200 columns, adaptive report columns, ANSI-preserving
wrap/truncate. Verified live in a 50-column PTY: transcript, status bar
and summary all fit.

💘 Generated with Crush

Assisted-by: Crush:rits/zai-org/glm-5-3
@gurnben
gurnben requested a review from a team as a code owner October 20, 2026 19:26
@gurnben
gurnben merged commit 62c924b into main Oct 20, 2026
2 checks passed
@gurnben
gurnben deleted the fix/terminal-width-adaptation branch October 20, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant