feat(bar): make progress bar fill full terminal width #2

Merged
fuzzy merged 9 commits from feat/full-width-progress-bar into main 2026-07-15 19:17:07 +00:00
Owner

What

Make the progress bar extend across the entire console width by dynamically calculating bar width based on terminal size and actual non-bar content.

Why

Previously, GetTerminalSize() was a stub (always returned 80 cols) and calcBarWidth hardcoded cols - 40, leaving the bar narrow regardless of terminal width.

Changes

  • util.GetTerminalSize(): properly parse COLUMNS/LINES env vars (was reading but discarding with _ = w)
  • calcNonBarWidth() (new): measures visible width of template content excluding the bar, so bar can fill remaining space
  • calcBarWidth(nonBarWidth): accepts non-bar width; formula is cols - 1 (margin) - ends_width - non_bar_width
  • String(): compute non-bar width before bar width for dynamic sizing
  • Tests: updated TestCalcBarWidth for new signature, added TestCalcNonBarWidth and TestGetTerminalSizeEnvVars

Testing

  • go test ./... passes
  • go vet ./... clean
  • Pre-commit hooks pass (go fmt, golangci-lint, go-unit-tests, go-build, etc.)

Breaking Changes

None. API backwards compatible — calcBarWidth is unexported.

Closes #(no issue tracks this)

## What Make the progress bar extend across the entire console width by dynamically calculating bar width based on terminal size and actual non-bar content. ## Why Previously, `GetTerminalSize()` was a stub (always returned 80 cols) and `calcBarWidth` hardcoded `cols - 40`, leaving the bar narrow regardless of terminal width. ## Changes - **`util.GetTerminalSize()`**: properly parse `COLUMNS`/`LINES` env vars (was reading but discarding with `_ = w`) - **`calcNonBarWidth()`** (new): measures visible width of template content excluding the bar, so bar can fill remaining space - **`calcBarWidth(nonBarWidth)`**: accepts non-bar width; formula is `cols - 1 (margin) - ends_width - non_bar_width` - **`String()`**: compute non-bar width before bar width for dynamic sizing - Tests: updated `TestCalcBarWidth` for new signature, added `TestCalcNonBarWidth` and `TestGetTerminalSizeEnvVars` ## Testing - [x] `go test ./...` passes - [x] `go vet ./...` clean - [x] Pre-commit hooks pass (go fmt, golangci-lint, go-unit-tests, go-build, etc.) ## Breaking Changes None. API backwards compatible — `calcBarWidth` is unexported. Closes #(no issue tracks this)
feat(bar): make progress bar fill full terminal width
All checks were successful
CI / Go Mod Tidy (pull_request) Successful in 30s
CI / Build (pull_request) Successful in 34s
CI / Test (pull_request) Successful in 1m43s
CI / Lint (pull_request) Successful in 2m36s
0e154ddeba
Fix util.GetTerminalSize() to parse COLUMNS/LINES env vars.
Replace hardcoded cols-40 bar width with dynamic calculation:
bar width = terminal_width - 1 (margin) - ends_width - non_bar_width.

Use fixed estimate strings ("100MB", "5m30s") for non-bar width
calculation instead of per-frame formatted values, ensuring the bar
width is stable across frames and identical across bars with the same
template.

- calcNonBarWidth(): new method measures stable non-bar content width
- calcBarWidth(nonBarWidth): accounts for ends and non-bar content
- GetTerminalSize(): properly parses COLUMNS/LINES env vars
fix(bar): use actual formatted values for non-bar width calc
All checks were successful
CI / Go Mod Tidy (pull_request) Successful in 37s
CI / Test (pull_request) Successful in 55s
CI / Build (pull_request) Successful in 1m18s
CI / Lint (pull_request) Successful in 2m30s
db6267d79c
calcNonBarWidth was using fixed estimate strings ("100MB",
"5m30s") that were too pessimistic, leaving the bar 5-7 chars
narrower than optimal. Also, cleanEmptySections' final strings.Trim
stripped the leading space separator between bar and first metadata
element, causing a 1-char mismatch in the total line width.

Fix: use actual formatted placeholder values and strip empty
sections without the final Trim. This ensures:
- Total rendered line = cols - 1 (fills terminal width exactly)
- Non-bar width is accurate per-frame
- Leading space between bar and metadata is preserved
fix(util): use golang.org/x/term for real terminal size detection
Some checks failed
CI / Go Mod Tidy (pull_request) Successful in 1m27s
CI / Build (pull_request) Successful in 1m8s
CI / Test (pull_request) Failing after 1m14s
CI / Lint (pull_request) Failing after 8m8s
bde83b66c0
IsTerminal and GetTerminalSize were both stubs that never actually
queried the terminal. IsTerminal did a basic char-device check that
fails in many environments. GetTerminalSize always returned 24x80
(COLUMNS/LINES env vars were read but discarded).

Replace both with golang.org/x/term which uses IOCTL/TIOCGWINSZ on
Unix and GetConsoleScreenBufferInfo on Windows — the correct way.
GetTerminalSize now gets the real terminal dimensions; bars finally
span the full terminal width.
fix: downgrade golang.org/x/term to v0.18.0 for Go 1.24 compat
Some checks failed
CI / Go Mod Tidy (pull_request) Successful in 32s
CI / Test (pull_request) Successful in 1m21s
CI / Build (pull_request) Successful in 1m33s
CI / Lint (pull_request) Failing after 2m44s
3fe3ebf612
v0.45.0 requires go 1.25 but CI targets 1.24.11. Pin both term and
sys to v0.18.0 which work with Go 1.24.
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-07-15 19:10:19 +00:00
the.auditor left a comment

Suggestions

  1. bar/bar.go:250-258calcNonBarWidth() duplicates empty-section filtering from cleanEmptySections(). Refactor to reuse shared helper. Filed as #3.

Verdict

Code is correct, well-tested, and solves the stated problem. No blocking issues.

## Suggestions 1. `bar/bar.go:250-258` – `calcNonBarWidth()` duplicates empty-section filtering from `cleanEmptySections()`. Refactor to reuse shared helper. Filed as #3. ## Verdict Code is correct, well-tested, and solves the stated problem. No blocking issues.
the.auditor approved these changes 2026-07-15 19:11:57 +00:00
Dismissed
the.auditor left a comment

Approved. One non-blocking suggestion filed as #3 (duplicated empty-section filtering logic).

Approved. One non-blocking suggestion filed as #3 (duplicated empty-section filtering logic).
fix: suppress gosec G115 false positive on fd conversion
All checks were successful
CI / Go Mod Tidy (pull_request) Successful in 42s
CI / Test (pull_request) Successful in 38s
CI / Build (pull_request) Successful in 1m5s
CI / Lint (pull_request) Successful in 3m15s
3e928577a8
os.Stdout.Fd() returns uintptr, term.IsTerminal/GetSize take int.
Conversion is safe (fd values 0-2), suppress gosec warning.
fuzzy dismissed the.auditor's review 2026-07-15 19:13:03 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

the.auditor left a comment

Changes since last review: only //nolint:gosec annotations added to util.go:35,43. No new issues. Still approved.

Changes since last review: only `//nolint:gosec` annotations added to `util.go:35,43`. No new issues. Still approved.
fuzzy merged commit 3e928577a8 into main 2026-07-15 19:17:07 +00:00
fuzzy deleted branch feat/full-width-progress-bar 2026-07-15 19:17:07 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/konsoru!2
No description provided.