Skip to content

fix(cli): stop bundle-pull total bar tearing and fix its denominator - #1974

Merged
alpergundogdu merged 2 commits into
mainfrom
claude/decdn-duplicate-total-output-be1f1d
Sep 10, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
claude/decdn-duplicate-total-output-be1f1d

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

What

Two defects in the decdn bundle pull multi-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 detached ProgressBar draws straight to stderr, so the ticker painted an orphan line the container never accounted for; MultiProgress then 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 duplicated total line 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

  • The two rows now measure different units on purpose — documented in the pull_progress.rs module docs.
  • Chunked files use an upward-only fold (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-pull driver only reports progress once streaming begins. That fix belongs in the driver (affects decdn fetch and 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 --check
  • RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --document-private-items
  • cargo nextest run -p decdn-cli — 612 pass (incl. 6 new pull_progress tests covering scaling, monotonicity, and true-up)
  • Live visual (bars in a real terminal) not verified in this environment — needs a re-run against real nodes.

🤖 Generated with Claude Code

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]>
Copilot AI lite review requested due to automatic review settings September 10, 2026 15:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 shared labeled_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 size through 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.

Comment thread crates/cli/src/commands/bundle_pull.rs Resolved
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]>
@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 82.61% (was 82.63%, ▼ 0.02%) — 76138/92170 lines

File Coverage Lines Δ
crates/cli/src/commands/bundle_pull.rs 54.81% 980/1788 ▼ 0.82%
crates/cli/src/commands/fetch.rs 42.02% 927/2206 ▲ +0.02%
crates/cli/src/commands/pull_progress.rs 73.01% 238/326 ▲ +7.25%
History
Commit Total Δ vs base
8dffce1 82.60% ▼ 0.03%
d90e1fc (HEAD) 82.61% ▼ 0.02%

@alpergundogdu
alpergundogdu merged commit 30e05dc into main Sep 10, 2026
25 checks passed
@alpergundogdu
alpergundogdu deleted the claude/decdn-duplicate-total-output-be1f1d branch September 10, 2026 16:15
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