fix: scale progress bars based on terminal width#237
Open
wabalabudabdab wants to merge 5 commits intojarrodwatts:mainfrom
Open
fix: scale progress bars based on terminal width#237wabalabudabdab wants to merge 5 commits intojarrodwatts:mainfrom
wabalabudabdab wants to merge 5 commits intojarrodwatts:mainfrom
Conversation
Resolves jarrodwatts#231 Progress bars (coloredBar/quotaBar) were hardcoded to width 10, causing line wrapping in narrow terminals. Now bars scale dynamically based on process.stdout.columns: - Wide terminal (>=100 cols): width 10 (default) - Medium terminal (60-99 cols): width 6 - Narrow terminal (<60 cols): width 4 Affected files: - src/render/session-line.ts (context bar + usage bars) - src/render/lines/identity.ts (context bar in expanded layout) - src/render/lines/usage.ts (quota bars in expanded layout)
For cross-platform compatibility (zsh, macOS, Windows), getBarWidth() now also checks process.env.COLUMNS when process.stdout.columns is unavailable (non-TTY, piped output).
- Remove duplicated getBarWidth() from 3 render files - Add src/utils/terminal.ts with exported getAdaptiveBarWidth() - Add Math.floor() for consistency with getTerminalWidth() - All 3 render files now import from shared utility (DRY)
Tests cover: - Narrow terminal (<60 cols) → 4 - Medium terminal (60-99 cols) → 6 - Wide terminal (>=100 cols) → 10 - Boundary values (59, 60, 99, 100) - Non-TTY/piped output (undefined columns) → 10 (default) - Fallback to COLUMNS env var - No terminal info at all → 10 (default)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Progress bars (
coloredBar/quotaBar) were hardcoded towidth: 10insession-line.ts,lines/identity.ts, andlines/usage.ts, causing line wrapping and broken layout in narrow terminals.Closes #231
Solution
Added a
getBarWidth()helper that readsprocess.stdout.columnsand returns an appropriate width:Changes
src/render/session-line.ts— context bar + usage quota barssrc/render/lines/identity.ts— context bar in expanded layoutsrc/render/lines/usage.ts— quota bars in expanded layoutBuild passes with
npm run build✅