Repository navigation
fix(cli): stop bundle-pull total bar tearing and fix its denominator - #1974
Conversation
Two defects in the `decdn bundle pull` multi-bar progress: The bars scrolled and re-printed instead of updating in place. Every bar enabled its steady tick before it joined the `MultiProgress`, so a detached bar painted an orphan line straight to stderr; the container then drew its own copy and tracked a line count that never included the orphans, so each redraw was offset and appended rather than overwriting. Enable the steady tick only after a bar is added/inserted (and drop the premature tick from the shared `labeled_delivery_bar`). The total bar's denominator only reflected files that had already started: it was metered in wire bytes, whose length is learned per pull from the first delivered chunk, so it grew as pulls began and never meant "of the whole download". The run knows the whole content size up front from the manifest, so the total is now content-byte metered with a fixed denominator (`total_content_bytes`: whole-file blobs deduped by hash, chunked files once each). Each pull folds its wire progress into the total scaled to its content size (`size * received / expected`) — monotonic, and exactly the pull's size at completion, so the total ends at 100%. Per-file bars stay wire-metered, since a single pull only knows its own wire length. A blob with no declared size contributes to neither numerator nor denominator; a manifest with no sizes omits the total bar. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The new manifest-derived total denominator can include entries/groups that end up fully skipped (already present), leaving the total bar under-filled and inconsistent on resumed or partially-present runs.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR fixes two regressions in the decdn bundle pull TTY progress UI: (1) multi-bar redraw “tearing” caused by starting steady ticks before bars are attached to an indicatif::MultiProgress, and (2) an incorrect/unstable total-bar denominator by switching the total bar to a fixed, manifest-derived content-bytes denominator while keeping per-file bars wire-bytes metered.
Changes:
- Move steady-tick enabling to after bars are inserted into
MultiProgress, and remove premature ticking from the sharedlabeled_delivery_bar(). - Rework the total bar to use a fixed content-size denominator (
total_content_bytes) and fold each pull’s wire progress into scaled content progress. - Thread manifest-declared
sizethrough chunked-file planning so chunked files can contribute to the total bar.
File summaries
| File | Description |
|---|---|
| crates/cli/src/commands/pull_progress.rs | Adds content-byte total bar logic, scaled folding helpers, and ensures steady ticks start only after bars join the MultiProgress. |
| crates/cli/src/commands/fetch.rs | Stops enabling steady ticks inside labeled_delivery_bar() so callers can attach first and avoid orphan redraw lines. |
| crates/cli/src/commands/bundle_pull.rs | Computes manifest-based total content bytes and threads it into PullProgress::new, plus propagates entry size into chunked-file progress. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The total bar's denominator is the whole manifest's content size, but a file whose destinations are all already on disk is skipped with no fetch and no delivery callback — so its content was counted in the denominator yet never in the numerator, leaving the total permanently short of 100% on resumed or already-present runs. Credit an all-skipped whole-file group and a skipped chunked file straight to the total the moment they resolve (a skip is instantaneous, so no per-file bar). A fetched or partially-present unit still reaches its full size through the delivery callback's scaled fold, and the two paths are mutually exclusive per unit, so nothing is double-counted. A sizeless skip is inert — it is absent from the denominator too. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Coverage reportTotal: 82.61% (was 82.63%, ▼ 0.02%) — 76138/92170 lines
History
|
What
Two defects in the
decdn bundle pullmulti-bar progress display (both introduced by #1969):1. Bars scrolled and re-printed instead of updating in place
Every bar enabled its steady tick before it joined the
MultiProgress. A detachedProgressBardraws straight to stderr, so the ticker painted an orphan line the container never accounted for;MultiProgressthen drew its own copy and tracked a line count that excluded the orphans, so each redraw was offset and appended rather than overwriting. This is what produced the duplicatedtotalline and repeated per-file bars.Fix: enable the steady tick only after a bar is added/inserted, and drop the premature tick from the shared
labeled_delivery_bar().2. Total bar denominator only reflected files that had already started
The total was metered in wire bytes, whose length is only learned per pull from its first delivered chunk — so the denominator grew as pulls began and never meant "of the whole download."
Fix: the run knows the whole content size up front from the manifest, so the total bar is now content-byte metered with a fixed denominator (
total_content_bytes: whole-file blobs deduped by hash, chunked files counted once each). Each pull folds its wire progress into the total scaled to its content size (size × received / expected) — monotonic, and exactly the pull's content size at completion, so the total ends at 100%. Per-file bars stay wire-metered (a single pull only knows its own wire length). A blob with no declared size contributes to neither numerator nor denominator; a manifest with no sizes omits the total bar entirely.Notes for reviewers
pull_progress.rsmodule docs.fetch_max) so a newly-starting chunk can't make the total regress, with a true-up to the file's size at completion.Known follow-up (not in this PR)
A resumed (partially-downloaded) file's bar shows 0 until its fetch actually starts delivering — the shared
client-pulldriver only reports progress once streaming begins. That fix belongs in the driver (affectsdecdn fetchand node-to-node pulls too) and involves a wire-vs-content unit decision, so it's tracked separately.Verification
cargo build,cargo clippy --all-targets --all-features -D warnings,cargo fmt --checkRUSTDOCFLAGS="-D warnings" cargo doc --no-deps --document-private-itemscargo nextest run -p decdn-cli— 612 pass (incl. 6 newpull_progresstests covering scaling, monotonicity, and true-up)🤖 Generated with Claude Code