-
Notifications
You must be signed in to change notification settings - Fork 293
feat: add progress bars for time-consuming operations #1249
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
Closes dora-rs#1229 This PR implements visual progress feedback for all time-consuming Dora CLI operations using the indicatif crate. Changes: - Created shared progress bar component library (progress.rs) - Added progress to build, up, start, and run commands - Unified cyan/blue styling with success/failure indicators - Smart TTY detection (auto-hides in CI environments) - Multi-progress support for parallel operations All operations >2s now have visual feedback with consistent behavior. Testing: - cargo check: passed - cargo fmt: passed - cargo clippy: passed
phil-opp
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.
Thanks for the PR!
This commit addresses the remaining review feedback from PR dora-rs#1249: 1. Replace `atty` with `std::io::IsTerminal`: - Removed deprecated `atty` crate dependency - Use `std::io::stderr().is_terminal()` for TTY detection 2. Rewrite progress bar documentation: - Simplified module docs to focus on behavior and usage - Added progress bar example (not just spinners) - Clarified behavior in non-TTY environments - Removed marketing terms 3. Add progress bar example: - Added example showing progress bar with known steps 4. Remove unused code: - Removed `should_show_progress()` function - Removed `ProgressBarBuilder` struct and tests 5. Refactor to reduce duplication: - Created `new_inner()` helper method - Both `new()` and `new_bytes()` now use shared implementation 6. Fix MultiProgress in try_clone(): - Store MultiProgress reference in LocalBuildLogger - Use multi.add_spinner() in try_clone() to properly add to MultiProgress 7. Keep log messages visible: - Always print log messages to stdout for scrollback - Also update progress bar message for live feedback - Users can now scroll up to see warnings/errors
|
Hi @phil-opp, Thank you for the detailed review! I've addressed all the feedback points:
|
phil-opp
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.
Thanks for the updates!
Addresses review feedback about try_clone() implementation: 1. Fixed bug where cloning a progress bar without MultiProgress would result in None instead of preserving the progress bar 2. Now preserves the original progress bar's message instead of hardcoding a new message format 3. Handles three cases properly: - With MultiProgress: adds new spinner to multi with same message - Without MultiProgress: creates standalone spinner with same message - No progress bar: returns None The try_clone() method is used at libraries/core/src/build/mod.rs:125 when spawning tokio tasks to log stdout from build commands.
| let progress_bar = match (&self.progress_bar, &self.multi) { | ||
| (Some(pb), Some(multi)) => { | ||
| // Clone the progress bar by creating a new one with the same message | ||
| // and adding it to the MultiProgress | ||
| let message = pb.inner().message(); | ||
| Some(multi.add_spinner(message)) | ||
| } | ||
| (Some(pb), None) => { | ||
| // No MultiProgress, create a standalone progress bar with the same message | ||
| let message = pb.inner().message(); | ||
| Some(ProgressBar::new_spinner(message)) | ||
| } | ||
| _ => None, | ||
| }; | ||
|
|
||
| Ok(LocalBuildLogger { | ||
| node_id: self.node_id.clone(), | ||
| progress_bar, | ||
| multi: self.multi.clone(), |
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.
I'm still not sure about this implementation. It's still always a spinner, but I guess that's ok since we don't create progress bars in LocalBuildLogger. The bigger issue is that creating a new ProgressBar displays another bar, doesn't it?
Why not store the bar as an Arc<ProgressBar>? Then we could cheaply clone it without duplicating the bar.
This addresses the PR feedback by wrapping ProgressBar in Arc instead of creating new progress bars in try_clone(). This approach: - Avoids displaying duplicate progress bars when cloning - Provides cheap clones through Arc's reference counting - Simplifies the try_clone() implementation significantly The previous implementation created new progress bars on each clone, which would result in multiple visual indicators for the same task.
|
PTAL @phil-opp, I have implemented the changes that you mentioned. Thank you for the guidance. |
phil-opp
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.
Thanks for the updates!
The code looks good to me now, but the output format still needs improvement imo.
For me, the dora build output looks like this currently:
So the percentage is printed a lot and makes the output quite messy. I would prefer if we could "pin" the progress bar and the spinners to the bottom so that they aren't part of the messages that scroll up. So basically a region at the bottom where we display progress and another region above where we print the log/stdout messages.
For example, here is how cargo does it:
The Building progress marker at the bottom stays there and does not interfere with the "Compiling" lines above.
|
Hi @phil-opp, Thanks for the feedback! |
|
It looks like pinning the progress bar is indicatif's default behavior, but you have to use the |
This addresses phil-opp's feedback about output readability by using indicatif's MultiProgress::println instead of regular println!. Changes: - Added MultiProgress::println method with fallback for non-TTY - Updated log_message to use MultiProgress::println - Progress bars now stay pinned at bottom while logs scroll above - Non-terminal outputs (CI/logs) still work via println! fallback This matches cargo's behavior where progress indicators stay at the bottom and don't interfere with scrolling log messages.
|
Hi @phil-opp, I have implemented the changes. |
|
@phil-opp |
Setting the message before adding it to `MultiProgress` draws the progress bar directly, which messes up the rendering of the multi progress bar. This leads to duplicated progress bars in the output.
|
@Deepak-negi11 Thanks for checking! I pushed eb1fdf0 to hopefully fix this issue. Could you try again? |
phil-opp
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.
Thanks for the updates!
phil-opp
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.




This PR implements visual progress feedback for all time-consuming Dora CLI operations using the indicatif crate.
Changes:
All operations >2s now have visual feedback with consistent behavior.
Testing:
Closes #1229