Repository navigation
feat(cli): tab-bar progress and graceful Ctrl-C for fetch and bundle pull - #2153
Conversation
`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]>
There was a problem hiding this comment.
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
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
TabProgressto 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::incto update the terminal indicator and ensurefinish()removes it. - Add the
anstyle-progressdependency (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.
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit ec8ebb3 in the Show a line coverage summary of the most impacted files.
Updated |
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]>
`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]>

Summary
Tab-bar progress (OSC 9;4)
decdn bundle pullanddecdn fetchdrive 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 forcargo build.anstyle-progress(rust-cli, the crate Cargo uses, no dependencies of its own). Unsupported terminals,--json, and non-TTY stderr get no escape codes.commands/tab_progress.rs: forward-only, written only when the whole-number percent changes, removed on finish and on drop. Abundle pullwith no declared sizes shows an indeterminate indicator.Graceful Ctrl-C
commands/interrupt.rs: the first Ctrl-C stops the command; a second exits at once. Both exit 130, andmainprintsinterrupted; run the same command again to resume.Streamer, multi-sourceDownloader) now has aSettleOnDropguard. On a drop it persists every lane's voucher watermark atPoolLedger::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.decdn-client,Downloader::fetch_to_paths_untilarms a crate-privateFlushOnDropguard on itsClientRangedStore, so the multi-source path records its landed ranges on a drop too. TheStreamerneeds none: its store is a scratch dir discarded with the stream. Public API unchanged.bundle pulllets its skip-cache flush finish, so every entry that settled before the Ctrl-C is recorded, then prints its summary and exits 130.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::incdriving the tab percent;SettleOnDropfiring only when dropped armed;Interrupt::waitre-polling safely after it fired; an interruptedbundle pulldrive still flushing the entries that settled; and aDownloaderdropped 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 docwith-D warnings,cargo fmt --check,cargo deny check, crate-edge check, anvil-e2e compile gatedecdn fetchhanging on an unreachable RPC, sent one SIGINT, prints the resume hint and exits 130decdn bundle pullin iTerm2 3.6.6+ shows the percent in the tab🤖 Generated with Claude Code