WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@yuzawa-san
Copy link

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example. see note
  • Have you successfully run 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.

Copilot AI review requested due to automatic review settings December 6, 2025 03:26
Copy link
Contributor

Copilot AI left a 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.

Comment on lines +300 to +306
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
Copy link

Copilot AI Dec 6, 2025

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

Copilot uses AI. Check for mistakes.
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants