Skip to content

feat(ampup): TTY/CI progress reporting for download manager#6

Merged
mitchhs12 merged 4 commits intomainfrom
mitchhs12/ampup-progress-reporting
Mar 3, 2026
Merged

feat(ampup): TTY/CI progress reporting for download manager#6
mitchhs12 merged 4 commits intomainfrom
mitchhs12/ampup-progress-reporting

Conversation

@mitchhs12
Copy link
Contributor

@mitchhs12 mitchhs12 commented Mar 2, 2026

Summary

Implements progress reporting for the ampup install command as part of issue edgeandnode/amp#1762.

Before this PR, installs ran silently with no feedback. Now:

  • TTY: Each component shows a status line that updates in place — waiting...→ downloading...✓ downloaded
  • Non-TTY / CI: One line appended per completion — ✓ [1/2] Downloaded ampd

The reporter is auto-detected at runtime via Term::stderr().is_term().

Changes

progress.rs (new) — defines the ProgressReporter trait and its two implementations: TtyProgress for interactive terminals and CiProgress for CI/piped output. A create_reporter() factory picks the right one automatically.

github.rs — refactored download methods from show_progress: bool to progress_bar: ProgressBar. Callers now own the progress bar lifecycle; github.rs only updates position during streaming.

download_manager.rs — wires the reporter through the concurrent download pipeline. Tasks report started / completed / failed at the right points, including during fail-fast shutdown.

install.rs — creates the reporter and passes it into download_all.

updater.rs — self-update now creates its own styled ProgressBar for the single binary download it performs.

Introduce aggregate progress reporting so users see per-component status during parallel downloads, adapting output to the terminal environment.

- Add `ProgressReporter` trait with `TtyProgress` (in-place line updates) and `CiProgress` (append-only) implementations
- Auto-detect TTY via `console::Term::stderr().is_term()` in `create_reporter()` factory
- Thread reporter through `download_all` via `Arc<dyn ProgressReporter>` with lifecycle callbacks
- Add `download_error_artifact_name` helper to extract artifact name from any `DownloadError` variant
- Add `NoopReporter` test helper and 16 unit tests covering state transitions and formatting

Signed-off-by: Mitchell Spencer <mitchellhspencer@gmail.com>
…sBar

Decouple progress bar lifecycle from download logic by accepting a
ProgressBar parameter instead of a boolean toggle, enabling callers to
control styling and completion behavior.

- Replace `show_progress: bool` with `progress_bar: ProgressBar` across
  all download methods in `github.rs`
- Move progress bar creation and finish logic into `updater.rs` for
  self-update downloads
- Pass `ProgressBar::hidden()` in `download_manager.rs` to suppress
  per-file bars (aggregate reporting via `ProgressReporter`)
- Remove progress bar creation and styling code from `github.rs`

Signed-off-by: Mitchell Spencer <mitchellhspencer@gmail.com>
…ogress reporter

- Replace all Mutex::lock().expect() calls with unwrap_or_else(|e| e.into_inner())
  so a poisoned lock is recovered from rather than crashing the download
- Replace raw println!/eprintln! in CiProgress with crate::ui::success!/warn!
  macros to comply with the CLI output pattern
- Replace .expect() in updater.rs with .context()? for proper error propagation
- Improve test .expect() messages from "lock" to descriptive strings
The original issue only required per-component status labels (waiting/downloading/downloaded),
not byte-level bars. Remove indicatif to simplify the download path.

- Remove `indicatif` dependency from `Cargo.toml`
- Drop `progress_bar: ProgressBar` parameter from all download methods in `github.rs`
- Rename `download_with_progress` to `download_response` — no longer tracks bytes
- Remove `ProgressBar` spinner and byte-tracking from `updater.rs`
- Remove `ProgressBar::hidden()` plumbing from `download_manager.rs`

Signed-off-by: Mitchell Spencer <mitchellhspencer@gmail.com>
@LNSD LNSD self-requested a review March 3, 2026 08:03
Copy link
Contributor

@LNSD LNSD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✅

@mitchhs12 mitchhs12 merged commit 0c4a83f into main Mar 3, 2026
3 checks passed
@mitchhs12 mitchhs12 deleted the mitchhs12/ampup-progress-reporting branch March 3, 2026 14:07
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