mirror of
https://github.com/jarrodwatts/claude-hud.git
synced 2026-05-21 07:22:44 +00:00
* fix: scale progress bars based on terminal width Resolves #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) * fix: also check COLUMNS env var as fallback for bar width For cross-platform compatibility (zsh, macOS, Windows), getBarWidth() now also checks process.env.COLUMNS when process.stdout.columns is unavailable (non-TTY, piped output). * refactor: extract getAdaptiveBarWidth to shared utility - 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) * test: add unit tests for getAdaptiveBarWidth 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) * style: simplify JSDoc to match project comment style --------- Co-authored-by: Anna Terek <wabalabudabdab@users.noreply.github.com>