Skip to content

feat(cli): tab-bar progress and graceful Ctrl-C for fetch and bundle pull - #2153

Merged
alpergundogdu merged 4 commits into
mainfrom
claude/bundle-pull-progress-percentage-44adb5
Sep 25, 2026
Merged

alpergundogdu merged 4 commits into
mainfrom
claude/bundle-pull-progress-percentage-44adb5

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Tab-bar progress (OSC 9;4)

  • decdn bundle pull and decdn fetch drive the terminal's own progress indicator, so iTerm2, Ghostty, WezTerm, Windows Terminal, and others show the percent in the tab bar or dock, as they do for cargo build.
  • Support is detected with anstyle-progress (rust-cli, the crate Cargo uses, no dependencies of its own). Unsupported terminals, --json, and non-TTY stderr get no escape codes.
  • New commands/tab_progress.rs: forward-only, written only when the whole-number percent changes, removed on finish and on drop. A bundle pull with no declared sizes shows an indeterminate indicator.

Graceful Ctrl-C

  • New commands/interrupt.rs: the first Ctrl-C stops the command; a second exits at once. Both exit 130, and main prints interrupted; run the same command again to resume.
  • Stopping drops the in-flight drives. Each CLI drive site (single drive, striped drive, stdout Streamer, multi-source Downloader) now has a SettleOnDrop guard. On a drop it persists every lane's voucher watermark at PoolLedger::settlement() (the drop-path read the client crate provides for exactly this), so the next run's vouchers continue from what was paid. The single and striped sites also flush the ranged store's present-range record, so the resume does not re-fetch bytes that already landed.
  • In decdn-client, Downloader::fetch_to_paths_until arms a crate-private FlushOnDrop guard on its ClientRangedStore, so the multi-source path records its landed ranges on a drop too. The Streamer needs none: its store is a scratch dir discarded with the stream. Public API unchanged.
  • bundle pull lets its skip-cache flush finish, so every entry that settled before the Ctrl-C is recorded, then prints its summary and exits 130.
  • Every bar uses ProgressFinish::AndClear, so a bar dropped mid-transfer clears its line.

Test plan

  • cargo nextest run -p decdn-client -p decdn-cli (1213 pass). New tests cover tab-progress throttling, forward-only updates, capping at 100%, remove-once and remove-on-drop; TotalBar::inc driving the tab percent; SettleOnDrop firing only when dropped armed; Interrupt::wait re-polling safely after it fired; an interrupted bundle pull drive still flushing the entries that settled; and a Downloader dropped mid-fetch recording its landed prefix (fails with 0 bytes recorded when the guard is disarmed)
  • cargo clippy --workspace --all-targets --all-features -- -D warnings, cargo doc with -D warnings, cargo fmt --check, cargo deny check, crate-edge check, anvil-e2e compile gate
  • Manual: a decdn fetch hanging on an unreachable RPC, sent one SIGINT, prints the resume hint and exits 130
  • Manual: decdn bundle pull in iTerm2 3.6.6+ shows the percent in the tab
  • Manual: Ctrl-C mid-transfer on a live network, then a rerun resumes without a voucher rejection

🤖 Generated with Claude Code

`decdn bundle pull` mirrors its total bar's percent into the terminal's
own progress indicator (OSC 9;4), as `cargo build` does. Support is
detected with `anstyle-progress`, the crate Cargo uses (iTerm2 3.6.6+,
Ghostty, WezTerm, Windows Terminal, ConEmu, Konsole, Ptyxis); other
terminals get nothing. A run with no declared sizes shows an
indeterminate indicator. The percent only moves forward and is written
only when it changes; the indicator is removed at the end of the run or
when the renderer drops.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 25, 2026 11:06

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 review overview

🟡 Changes recommended

Early-exit cleanup of the OSC 9;4 indicator can be unreliable due to Arc cloning into callbacks, risking a stale tab/dock progress state without an explicit Drop-time clear on the renderer.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

This PR adds terminal tab/dock progress integration for decdn bundle pull by emitting OSC 9;4 progress sequences driven by the existing “total” progress bar, while remaining silent for --json and non-TTY stderr to avoid polluting scripted output.

Changes:

  • Add TabProgress to detect OSC 9;4 support and mirror total-bar percent to the terminal progress indicator, with tests for throttling/forward-only/cleanup behavior.
  • Wire TotalBar::inc to update the terminal indicator and ensure finish() removes it.
  • Add the anstyle-progress dependency (matching Cargo’s terminal support detection approach).
File Description
crates/​cli/​src/​commands/​pull_progress.rs Introduces TabProgress and connects total-bar percent updates to OSC 9;4 terminal progress, plus tests.
crates/​cli/​Cargo.toml Adds anstyle-progress dependency to the CLI crate.
Cargo.toml Adds anstyle-progress to workspace dependencies.
Cargo.lock Locks the new anstyle-progress crate version.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-code-quality

github-code-quality Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit ec8ebb3 in the claude/bundle-pull-p... branch remains at 85%, unchanged from commit 3ebf5f1 in the main branch.

Show a line coverage summary of the most impacted files.
File main 3ebf5f1 claude/bundle-pull-p... ec8ebb3 +/-
crates/cli/src/.../bundle_pull.rs 77% 77% 0%
crates/cache/src/engine.rs 94% 94% 0%
crates/cli/src/...mmands/fetch.rs 52% 52% 0%
crates/client/src/ledger.rs 99% 99% 0%
crates/client/s...c/downloader.rs 97% 97% 0%
crates/protocol/src/framing.rs 97% 97% 0%
crates/cli/src/...ull_progress.rs 78% 79% +1%
crates/cli/src/main.rs 81% 84% +3%
crates/cli/src/...ds/interrupt.rs 0% 73% +73%
crates/cli/src/...tab_progress.rs 0% 83% +83%

Updated September 25, 2026 11:58 UTC

The first Ctrl-C stops `decdn fetch` / `decdn bundle pull` mid-transfer
and exits 130 with a resume hint; a second Ctrl-C exits at once.

Stopping drops the in-flight drives, so every CLI drive site now carries
a `SettleOnDrop` guard that persists its lanes' voucher watermarks at
the armed settlement (`PoolLedger::settlement`, the drop-path read) and,
where the CLI owns the ranged store, flushes its present-range record.
The next run's vouchers continue from what was paid, and its resume
re-fetches nothing already recorded.

`bundle pull` still runs its skip-cache flush to completion, so every
entry that settled before the Ctrl-C is recorded, and prints its
summary. `decdn fetch` also mirrors its progress into the terminal tab
bar, sharing a `tab_progress` module with `bundle pull`. Bars clear
their line when dropped unfinished.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alpergundogdu alpergundogdu changed the title feat(cli): show bundle pull progress in the terminal tab bar feat(cli): tab-bar progress and graceful Ctrl-C for fetch and bundle pull Sep 25, 2026
alpergundogdu and others added 2 commits September 25, 2026 12:48
`Downloader::fetch_to_paths_until` arms a `FlushOnDrop` guard around
its multi-source fetch. A download future dropped mid-fetch (a caller's
Ctrl-C) never reaches the fetch's own final flush, so the guard writes
the present-range record synchronously on drop and a resume does not
fetch and pay for the landed ranges again. The guard is crate-private;
the public API is unchanged.

The `Streamer` needs no guard: its store lives in a scratch dir that is
discarded with the stream.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A per-file callback can outlive the renderer while holding the shared
TabProgress, so removal no longer waits for the last clone to drop.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alpergundogdu
alpergundogdu merged commit 49c13b9 into main Sep 25, 2026
32 checks passed
@alpergundogdu
alpergundogdu deleted the claude/bundle-pull-progress-percentage-44adb5 branch September 25, 2026 12: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