fix(packages-fetch): report download progress in staged_install - #1293
Conversation
Switch from download_file() to download_file_with_progress() so toolchain/framework downloads emit periodic progress updates (e.g. "arm-gcc: 50/150 MB (33%)") instead of repeating the same static "downloading" message. The DownloadProgress::format_message() already produces human-readable output with bytes and percentage; the progress callback publishes it via install_status so the daemon status stream (and CLI) show real download progress. Closes #1286 Co-Authored-By: Claude <noreply@anthropic.com>
📝 WalkthroughWalkthrough
ChangesPackage download progress
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/fbuild-packages-fetch/src/lib.rs`:
- Around line 374-380: Update the progress callback around
download_file_with_progress_timed so forwarded progress remains monotonic across
retries. Track the highest published progress and either adjust retry progress
to preserve it or suppress values lower than the previous value before calling
install_status::publish_install_status; retain normal progress updates when they
are not regressive.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 811cad71-a215-463d-9746-b90fa2f3872f
📒 Files selected for processing (1)
crates/fbuild-packages-fetch/src/lib.rs
| &mut |progress: &downloader::DownloadProgress| { | ||
| install_status::publish_install_status(install_status::status( | ||
| &name, | ||
| Some(&version), | ||
| InstallPhase::Downloading, | ||
| InstallRole::Installer, | ||
| progress.format_message(), |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Keep forwarded download progress monotonic across retries.
download_file_with_progress_timed resets downloaded and last_pct for each retry. If one attempt publishes 50/150 MB (33%) and then retries, this callback can publish a lower value such as 10/150 MB (6%). The daemon and CLI will show progress moving backward. Publish retry-aware progress or suppress lower values before forwarding them to install_status.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/fbuild-packages-fetch/src/lib.rs` around lines 374 - 380, Update the
progress callback around download_file_with_progress_timed so forwarded progress
remains monotonic across retries. Track the highest published progress and
either adjust retry progress to preserve it or suppress values lower than the
previous value before calling install_status::publish_install_status; retain
normal progress updates when they are not regressive.
…t objects PR #1293 introduced the download_file_with_progress() API with `&mut dyn FnMut(&DownloadProgress)` callbacks, but the async runtime requires these closures to be Send because they cross .await points. Add `+ Send` to all three trait-object sites. Co-Authored-By: Claude <noreply@anthropic.com>
Problem
Issue #1286: Toolchain downloads (e.g. arm-gcc) show the same static "downloading arm-gcc 15.2.Rel1" message repeatedly with no sense of progress. During large downloads, users see the same line ~17 times with no percentage, byte count, or ETA.
Fix
PackageBase::staged_install()was usingdownloader::download_file()(simple buffered download, no progress). Switched todownloader::download_file_with_progress(), which streams the response and fires a callback every 15 seconds or every 10% progress.The callback publishes progress via
install_status::publish_install_status(), which the daemon status stream surfaces to the CLI. TheDownloadProgress::format_message()produces output like"arm-gcc-15.2.Rel1.tar.gz: 50/150 MB (33%)"instead of the previous static message.Testing
soldr cargo check -p fbuild-packages-fetch— compiles cleansoldr cargo clippy -p fbuild-packages-fetch -- -D warnings— no new warningssoldr cargo test -p fbuild-packages-fetch— all 130 tests passCloses #1286
🤖 Generated with Claude Code
Summary by CodeRabbit