Skip to content

feat(cli): per-file and total progress bars on bundle pull - #1969

Merged
alpergundogdu merged 4 commits into
mainfrom
claude/bundle-pull-per-file-progress-2940ee
Sep 10, 2026
Merged

alpergundogdu merged 4 commits into
mainfrom
claude/bundle-pull-per-file-progress-2940ee

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

What

decdn bundle pull fetched many blobs silently — only a final summary and occasional fail-over notices. It now renders one delivery bar per active pull (bounded by --jobs; a finished file's bar clears) above a single total bar pinned at the bottom — the way decdn fetch shows its one blob.

  • Off a terminal or under --json the renderer is silent, so piped/scripted output is byte-for-byte unchanged.
  • Total bar (adaptive): delivered content bytes when every kept entry declares a size (denominator dedups by hash to match fetch-once grouping), else completed files count (a chunk blob carries no size).
  • Chunked entries show as one bar per file, summed across their chunks.

Why

This supersedes the earlier decision to keep bundle pull bar-free (#1118). That call was about the unbounded wall of bars a whole manifest would produce; showing one bar per active pull caps the count at --jobs, which is legible.

How

  • New commands/pull_progress.rs — the multi-bar renderer: PullProgress (shared MultiProgress + bottom total bar), FileBar (whole-file), ChunkedFile (sums chunk pulls), plus total_mode/file_label with unit tests. Per-file bars insert_before the total so it stays pinned; each clears on completion.
  • fetch.rs — extracted bar_callback (now optionally folds each byte delta into a total-bar sink) and labeled_delivery_bar; delivery_progress reuses them, so fetch and bundle pull share one bar style and rate/ETA engine.
  • logging.rs — progress_container() hands bundle pull the process-global MultiProgress when logging is on (bars and log lines coexist via suspend) or a standalone one otherwise.
  • bundle_pull.rs — threaded the delivery callback through the fetch chain; the whole-file path shows one bar per hash group. The chunked path is restructured to per-file concurrency with a shared fetch-once ledger (ChunkCell): a chunk shared across files is still fetched and paid for exactly once (first file fetches, others await the same cell and reuse the staged blob) while each file gets its own summed bar. Fail-over eprintln!s route through MultiProgress::suspend so they don't tear the bars.

Reviewer notes

  • Payment-once invariant: the chunked restructure changes scheduling in a payment-sensitive path. The ChunkCell (tokio::sync::OnceCell) caches each chunk's result (Ok or Err), so a shared chunk is fetched once and a shared failure fails dependents without a re-fetch — preserving prior semantics. Worth a close look.
  • Byte-total under-fill: when chunks are shared across files, actual downloaded bytes < summed entry sizes, so the byte total can finish slightly short; it's cleared at end of run, so no stuck bar shows.
  • Not visually verified in CI: bars are TTY-gated and need a live node + chain to drive bytes, so on-screen rendering (stacking/clearing, total pinned) wasn't observed here. Logic is unit-tested; visual polish is worth a manual pull.

Verification

cargo build, cargo clippy --all-targets --all-features -D warnings, cargo nextest run -p decdn-cli (607 passed, incl. 6 new), cargo fmt --check, and RUSTDOCFLAGS=-D warnings cargo doc — all clean.

🤖 Generated with Claude Code

`decdn bundle pull` fetched many blobs silently — only a final summary and
occasional fail-over notices. It now renders one delivery bar per active
pull (bounded by `--jobs`, finished files' bars clear) above a single total
bar, the way `decdn fetch` shows its one blob. Off a terminal or under
`--json` the renderer is silent, so piped and scripted output is unchanged.

This supersedes the earlier decision to keep bundle pull bar-free (#1118):
the wall-of-bars problem was the unbounded count, and per active pull caps
it at `--jobs`.

- New `commands/pull_progress.rs`: the multi-bar renderer. `PullProgress`
  owns the shared `MultiProgress` and the bottom total bar; per-file bars
  insert before it so it stays pinned. The total counts delivered content
  bytes when every kept entry declares a size (denominator dedups by hash to
  match fetch-once grouping) and completed files otherwise (a chunk blob
  carries no size).
- `fetch.rs`: extract `bar_callback` (now optionally folds each byte delta
  into a total-bar sink) and `labeled_delivery_bar`; `delivery_progress`
  reuses them, so both commands share one bar style and rate/ETA engine.
- `logging.rs`: `progress_container()` hands bundle pull the process-global
  `MultiProgress` when logging is on (bars and log lines coexist) or a
  standalone one otherwise.
- `bundle_pull.rs`: thread the delivery callback through the fetch chain; the
  whole-file path shows one bar per hash group. The chunked path is
  restructured to per-file concurrency with a shared fetch-once ledger
  (`ChunkCell`), so a chunk shared across files is fetched — and paid for —
  exactly once while each file still gets its own summed bar. Fail-over
  notices route through `MultiProgress::suspend` so they never tear the bars.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 10, 2026 14:18

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

Byte-based progress rendering currently mixes manifest “content bytes” with a progress callback defined in “bao wire bytes”, which can make per-file and total bars over/under-fill and misreport totals/ETAs unless the units are made consistent.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adds TTY-gated multi-progress rendering to decdn bundle pull, showing one progress bar per active file pull (bounded by --jobs) plus a pinned total bar, and refactors the existing decdn fetch progress-bar machinery so both commands share a consistent bar style and callback plumbing.

Changes:

  • Add a new PullProgress renderer (multi-bar + bottom total bar) for bundle pull, including unit tests for total-mode selection and file labels.
  • Refactor fetch progress code by extracting bar_callback and a reusable labeled_delivery_bar for embedding in a shared MultiProgress.
  • Thread progress callbacks through the bundle pull fetch pipeline and restructure chunked pulls to be per-file concurrent while preserving fetch/pay-once semantics via a shared OnceCell ledger.
File summaries
File Description
crates/cli/src/logging.rs Add progress_container() to provide either the process-global MultiProgress (when logging is enabled) or a standalone one.
crates/cli/src/commands/pull_progress.rs New multi-bar progress renderer for bundle pull (per-file bars + bottom total bar), plus unit tests.
crates/cli/src/commands/mod.rs Export the new pull_progress module.
crates/cli/src/commands/fetch.rs Extract reusable progress-bar pieces (bar_callback, labeled_delivery_bar) so fetch and bundle pull share rendering logic.
crates/cli/src/commands/bundle_pull.rs Wire in progress callbacks and restructure chunked pulls for per-file concurrency with a fetch-once ChunkCell ledger and MultiProgress::suspend for failover notices.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • 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/fetch.rs Resolved
@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 82.56% (was 82.72%, ▼ 0.16%) — 75544/91502 lines

File Coverage Lines Δ
crates/cli/src/commands/bundle_pull.rs 55.62% 979/1760 ▼ 3.17%
crates/cli/src/commands/fetch.rs 42.00% 927/2207 ▼ 0.54%
crates/cli/src/commands/pull_progress.rs 65.76% 121/184 new
crates/cli/src/logging.rs 55.26% 42/76 ▼ 3.89%
History
Commit Total Δ vs base
6b3590b 82.43% ▼ 0.25%
15afff6 (HEAD) 82.56% ▼ 0.16%

alpergundogdu and others added 3 commits September 10, 2026 15:41
The delivery `ProgressCallback` reports **wire** bytes (bao content plus
interleaved proof nodes), but the total bar keyed its denominator to manifest
`size` values, which are content bytes. Wire bytes exceed content bytes by the
proof overhead, so a byte-mode total could climb past 100% and misreport ETAs —
and chunked per-file bars with a content-size length overshot the same way.

Make the whole renderer wire-consistent:

- The total bar no longer uses a content-size denominator (a blob's wire length
  is not known before its `StreamResponse`, so it cannot be precomputed). It is
  one wire-byte bar whose length grows as each pull's wire size is learned and
  whose position climbs the same deltas, so it ends at exactly 100% for both
  whole-file and chunked pulls. The adaptive byte-vs-files `TotalMode` and
  `total_mode`/`advance_files` machinery are gone.
- `bar_callback` folds `(received_delta, expected_delta)` into the total (length
  by expected, position by received); a chunked file grows its own length and
  position together, so a reused chunk (counted by content size, not streamed)
  still reads as complete without unbalancing the bar.
- Corrected the `fetch` progress docs (`new_progress_bar`, `SpeedState`,
  `bar_callback`) that described the bar as content bytes; it has always been
  fed wire bytes.

Addresses Copilot review feedback on #1969.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Unit-test the fold that the earlier content-vs-wire bug broke: the total sink
grows length by expected and position by received (ending at exactly 100%, no
overshoot), a chunked file sums its chunks and folds the same wire deltas into
the total, and a reused chunk completes its own bar without double-counting in
the total. Plus the disabled-renderer no-callback paths.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…-file-progress-2940ee

# Conflicts:
#	crates/cli/src/commands/bundle_pull.rs
@alpergundogdu
alpergundogdu merged commit 9b236f2 into main Sep 10, 2026
25 checks passed
@alpergundogdu
alpergundogdu deleted the claude/bundle-pull-per-file-progress-2940ee branch September 10, 2026 15:02
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