-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Add progress bar to concurrent downloads #21183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds visual progress bars to concurrent downloads in Homebrew, enhancing the user experience by providing real-time visual feedback on download progress. The implementation calculates the percentage of completion for each download and renders it as a Unicode box-drawing progress bar that occupies approximately 20% of the terminal width.
Key changes:
- Added progress bar rendering logic that displays download completion percentage using Unicode characters (━ for completed, ┈ for pending)
- Modified the progress string format to include the progress bar before the phase and size information
- Removed the square bracket notation from the progress display
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| percent = if (total_size = downloadable.total_size) | ||
| fetched_size.to_f / [1, total_size].max | ||
| else | ||
| 0.0 | ||
| end | ||
| bar_length = [4, available_width / 5].max | ||
| bar_used = (percent * bar_length).round |
Copilot
AI
Dec 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When total_size is 0 or very small, the percentage calculation can exceed 1.0, causing bar_used to be larger than bar_length. This would result in a negative count for bar_pending on line 308, causing an ArgumentError when attempting to multiply a string by a negative number.
Consider clamping the percent value:
percent = if (total_size = downloadable.total_size)
(fetched_size.to_f / [1, total_size].max).clamp(0.0, 1.0)
else
0.0
end
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great so far! Want to give this a better review and test but won't be until Monday. Maintainers: please don't merge until then, thanks!
brew lgtm(style, typechecking and tests) with your changes locally?I was looking over #20963 and enjoy the file size ratios (thanks!). I sometimes run on slow connections and would like some progress bars so I can look at quick glance on how the downloads are going. The prior PR's had no unit tests, and I tested this locally. Here is a video:
progress.mp4
I made sure the bar is 20% (1/5th) of the tty and that it is at least 4 characters long.
I used some unicode box drawing glyphs. I suppose we could use
=and-if we want full ASCII support, but the checkmark is already not ASCII, so we should be ok. I am open to feedback on the formatting, sizing, and appearance.