Skip to content

feat(cli): show a delivery progress bar in decdn fetch (#1118) - #1121

Merged
alpergundogdu merged 2 commits into
mainfrom
claude/silly-wilson-274a17
Jul 12, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
claude/silly-wilson-274a17

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1118.

Problem

decdn fetch printed nothing between channel setup and the final fetched N bytes -> <path> line. On a large or slow pull it looked hung — no bytes-received, no ETA, no sign it was alive.

Fix

The delivery already knew the total up front (StreamResponse.total_bytes → expected_wire) and counted bytes as they arrived in receive_and_pay, but nothing surfaced it. This PR threads an optional progress callback (wire_bytes_received, wire_bytes_expected) from receive_and_pay up through fetch_inner, exposed via a new stream_fetch_tracked_with_progress wrapper. The payment-critical stream_fetch_tracked becomes a thin delegate (… , None), so all its existing callers and tests — including the node_origin pull path — are unchanged.

decdn fetch renders the bar with indicatif:

  • TTY-aware: drawn to stderr, auto-hidden when stderr is piped/redirected, so scripted/CI output stays clean.
  • Steady tick during the pre-byte connect/handshake so the command never looks frozen.
  • Counts wire bytes (content + interleaved bao proof), so the bar total runs a hair above the final content-byte count — it tracks the transfer, not payload size.

bundle pull reuses fetch_blob and passes None (per-entry byte bars would interleave illegibly across concurrent pulls; it reports at entry granularity). Scope here is the single-blob fetch path; multi-entry progress for bundle pull is a possible follow-up.

Testing

  • New loopback test progress_callback_reports_monotonic_delivery drives a real 256 KiB pull over iroh and asserts the callback fires, the expected total stays constant, received bytes advance monotonically without overshoot, and the final observation reaches the full promised wire length.
  • cargo nextest run green for decdn-client-pull (35), decdn-node::client_loopback (29), decdn-cli (271).
  • cargo clippy (workspace, -D warnings), cargo fmt --check, and cargo deny check all pass; indicatif (MIT) clears the license allow-list.

Note: the byte bar is not exercised by an automated end-to-end decdn fetch run (that needs a live node + chain); the loopback test verifies the callback data path it consumes, and the indicatif glue is set_length/set_position.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a delivery progress bar to decdn fetch.
    • Progress updates reflect received data and display cleanly before completion or error messages.
    • Progress output is automatically suppressed when command output is redirected or piped.
  • Bug Fixes
    • Improved progress reporting for multi-chunk downloads, ensuring totals remain accurate and updates are consistent.

`decdn fetch` printed nothing between channel setup and the final
`fetched N bytes` line, so a large or slow pull looked hung. The receive
loop already tracked wire bytes against a known total but never surfaced
them.

Thread an optional progress callback `(wire_bytes_received,
wire_bytes_expected)` from `receive_and_pay` up through `fetch_inner`,
exposed via a new `stream_fetch_tracked_with_progress` wrapper so the
payment-critical `stream_fetch_tracked` and all its callers/tests stay
unchanged. `decdn fetch` renders a TTY-aware `indicatif` bar (silent when
stderr is piped/CI, steady tick during the pre-byte handshake); the
node-side `node_origin` pull and `bundle pull` pass `None` and are
unaffected.

Covered by a loopback test asserting the callback fires monotonically and
reaches the full promised wire length.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Copilot AI review requested due to automatic review settings July 12, 2026 13:39
@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@alpergundogdu, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 41 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: ab4f29b5-e04b-41ee-a40b-f6ab573c6d24

📥 Commits

Reviewing files that changed from the base of the PR and between a81fa43 and a26e16a.

📒 Files selected for processing (1)
  • crates/cli/src/commands/fetch.rs

Walkthrough

The pull kernel now emits optional wire-byte progress callbacks. The CLI renders these updates with an indicatif progress bar, disables bars for concurrent bundle pulls, and adds loopback coverage for monotonic delivery reporting.

Changes

Delivery Progress Reporting

Layer / File(s) Summary
Progress callback through the pull kernel
crates/client-pull/src/lib.rs
Adds optional callback plumbing through tracked pulls and reports cumulative and expected wire bytes after each received chunk; shared pulls pass no callback.
CLI progress bar integration
Cargo.toml, crates/cli/Cargo.toml, crates/cli/src/commands/fetch.rs, crates/cli/src/commands/bundle_pull.rs
Adds indicatif, creates a TTY-aware fetch progress bar, updates it from callback values, clears it before the final result, and keeps concurrent bundle pulls without per-entry bars.
Progress callback regression coverage
crates/node/tests/client_loopback.rs
Tests callback invocation, constant expected totals, monotonic received bytes, and completion at the expected wire length.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant fetch
  participant fetch_blob
  participant stream_fetch_tracked_with_progress
  participant receive_and_pay
  participant ProgressBar

  User->>fetch: start blob fetch
  fetch->>ProgressBar: create progress bar
  fetch->>fetch_blob: pass progress callback
  fetch_blob->>stream_fetch_tracked_with_progress: fetch with callback
  stream_fetch_tracked_with_progress->>receive_and_pay: receive paid chunks
  receive_and_pay-->>fetch: report cumulative and expected wire bytes
  fetch->>ProgressBar: update position and length
  fetch->>ProgressBar: clear before final outcome
Loading

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-actions

github-actions Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 88.71% (2452/2764 lines)
▲ +0.00pp vs base (88.71% → 88.71%)
Run: 29195386507

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces a delivery progress bar for the decdn fetch command using the indicatif crate. It adds a new stream_fetch_tracked_with_progress function in decdn-client-pull that accepts an optional progress callback, which is invoked as chunks are received. The fetch command utilizes this callback to update a TTY-aware progress bar on stderr. A new integration test is also added to verify the monotonic progress reporting. The feedback suggests optimizing the progress callback in fetch.rs by using an AtomicBool to avoid redundantly calling set_length on every chunk, which reduces lock contention in the hot receive loop.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread crates/cli/src/commands/fetch.rs Resolved

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.

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 80.34% (was 80.37%, ▼ 0.03%) — 44804/55770 lines

File Coverage Lines Δ
crates/cli/src/commands/bundle_pull.rs 28.61% 101/353 ▼ 0.33%
crates/cli/src/commands/fetch.rs 34.73% 174/501 ▼ 1.90%
crates/client-pull/src/lib.rs 88.22% 704/798 ▲ +0.52%
History
Commit Total Δ vs base
a81fa43 80.34% ▼ 0.02%
a26e16a (HEAD) 80.34% ▼ 0.03%

`expected` is constant across a pull and `ProgressBar::set_length` takes a
write lock, so calling it every chunk added needless contention in the hot
receive loop. Guard it with an `AtomicBool` so the length is set on the
first callback only. (review feedback, #1121)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@alpergundogdu
alpergundogdu merged commit 6ce282b into main Jul 12, 2026
25 checks passed
@alpergundogdu
alpergundogdu deleted the claude/silly-wilson-274a17 branch July 12, 2026 14:21
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.

decdn fetch shows no progress during blob delivery

2 participants