Repository navigation
fix(renderer): keep half the terminal when the flex reserve would take more - #702
eric-engberg wants to merge 1 commit into
Conversation
…e more Full minus 40, and Full until compact past its threshold, reserve 40 columns for Claude Code's auto-compact message; Full reserves 6. On a narrow terminal, such as a phone's or a split pane, that left almost nothing: 41 columns truncated the line to a single ".", 60 columns left 20, and since the zero-width fix 40 columns or fewer rendered an empty line. Before that fix the line printed at full length and wrapped instead. Cap the reserve at half the terminal width. From 80 columns the full 40 still applies, so wide terminals are unchanged; below that the status line keeps half the width: 40 columns now leave 20, 60 leave 30. Full's 6-column reserve is only capped under 12 columns. The TUI preview uses the same widths, so it still matches what Claude Code receives.
|
I'm considering removing these settings entirely as the newer claude code builds keep the statusline full-width, and in theory set the COLUMNS env var when invoking it now. I haven't had time to test in depth or on other OSs, but in theory it should negate the need for these settings. Thoughts @eric-engberg ? |
|
Makes sense to me. I checked what Claude Code 2.1.310 does: the status line command runs through the same runner as hooks, which sets On dropping the reserve modes: if the line no longer shares its row with the auto-compact indicator, "full" is all that's left to choose, so the Terminal Width menu and I can put up the |
|
@eric-engberg Sure, if you want to put up the COLUMNS change and the full removal of the terminal width options I'm good with it. I think there might be another PR with the columns change, but I've gotten so many lately I'm still working my way through. |
Relates to #498.
What
The width a flex mode reserves to the right of the status line now never takes more than half the terminal. Full width minus 40, and Full width until compact past its threshold, still reserve 40 columns from 80 columns up, so wide terminals are unchanged. On narrower terminals the status line keeps half the width:
.)Full width always reserves 6 columns, so it only changes below 12 columns.
Why
#498 asks for a status line that works on a phone (the Moshi iOS app), where the terminal is about 40 columns wide. With the 40-column reserve that left almost nothing:
., and at 60 to one widget.The reserve is there for Claude Code's auto-compact message, which can't fit beside anything on a terminal that narrow anyway, so giving it all of the width only costs the status line.
How
resolveEffectiveTerminalWidthinrenderer.tsreservesmin(reserve, floor(width / 2))columns instead of the full reserve, for every flex mode, in the piped render and the TUI preview alike, so the preview still matches what Claude Code receives. The line can no longer get a width of 0 from a detected width, so a stale comment about that went too.docs/USAGE.mdsays how Full width minus 40 behaves below 80 columns.This doesn't make layouts responsive, which the issue also asks about (for example dropping widgets on narrow terminals). It fixes the empty line and keeps half the width.
Demo
The same line piped with Full width minus 40 at 120 down to 30 columns, each render wrapped in
[ ]so an empty one shows.Powerline: before
Powerline: after
Plain: before
Plain: after
Testing
renderer-flex-width.test.ts:bun test: 3112 pass, 0 fail.bun run lintpasses.mainat 120 and 80 columns, and matching the table above at the narrower widths.runtime-check.shagainstmainwith the baseline configs: same output, and the TUI opens and exits cleanly under both.