feat(bar): make progress bar fill full terminal width #2
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/konsoru!2
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/full-width-progress-bar"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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) andcalcBarWidthhardcodedcols - 40, leaving the bar narrow regardless of terminal width.Changes
util.GetTerminalSize(): properly parseCOLUMNS/LINESenv vars (was reading but discarding with_ = w)calcNonBarWidth()(new): measures visible width of template content excluding the bar, so bar can fill remaining spacecalcBarWidth(nonBarWidth): accepts non-bar width; formula iscols - 1 (margin) - ends_width - non_bar_widthString(): compute non-bar width before bar width for dynamic sizingTestCalcBarWidthfor new signature, addedTestCalcNonBarWidthandTestGetTerminalSizeEnvVarsTesting
go test ./...passesgo vet ./...cleanBreaking Changes
None. API backwards compatible —
calcBarWidthis unexported.Closes #(no issue tracks this)
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 varscalcNonBarWidth 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 preservedSuggestions
bar/bar.go:250-258–calcNonBarWidth()duplicates empty-section filtering fromcleanEmptySections(). Refactor to reuse shared helper. Filed as #3.Verdict
Code is correct, well-tested, and solves the stated problem. No blocking issues.
Approved. One non-blocking suggestion filed as #3 (duplicated empty-section filtering logic).
New commits pushed, approval review dismissed automatically according to repository settings
Changes since last review: only
//nolint:gosecannotations added toutil.go:35,43. No new issues. Still approved.