Repository navigation
feat(cli): per-file and total progress bars on bundle pull - #1969
Conversation
`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]>
There was a problem hiding this comment.
🟡 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
PullProgressrenderer (multi-bar + bottom total bar) forbundle pull, including unit tests for total-mode selection and file labels. - Refactor
fetchprogress code by extractingbar_callbackand a reusablelabeled_delivery_barfor embedding in a sharedMultiProgress. - Thread progress callbacks through the
bundle pullfetch pipeline and restructure chunked pulls to be per-file concurrent while preserving fetch/pay-once semantics via a sharedOnceCellledger.
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.
Coverage reportTotal: 82.56% (was 82.72%, ▼ 0.16%) — 75544/91502 lines
History
|
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
What
decdn bundle pullfetched 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 waydecdn fetchshows its one blob.--jsonthe renderer is silent, so piped/scripted output is byte-for-byte unchanged.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
commands/pull_progress.rs— the multi-bar renderer:PullProgress(sharedMultiProgress+ bottom total bar),FileBar(whole-file),ChunkedFile(sums chunk pulls), plustotal_mode/file_labelwith unit tests. Per-file barsinsert_beforethe total so it stays pinned; each clears on completion.fetch.rs— extractedbar_callback(now optionally folds each byte delta into a total-bar sink) andlabeled_delivery_bar;delivery_progressreuses them, sofetchandbundle pullshare one bar style and rate/ETA engine.logging.rs—progress_container()hands bundle pull the process-globalMultiProgresswhen logging is on (bars and log lines coexist viasuspend) 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-overeprintln!s route throughMultiProgress::suspendso they don't tear the bars.Reviewer notes
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.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, andRUSTDOCFLAGS=-D warnings cargo doc— all clean.🤖 Generated with Claude Code