From 2bc6a0f9f6b71826b440de9d88c3d9ca71550769 Mon Sep 17 00:00:00 2001 From: Joe Prosser Date: Tue, 5 May 2026 16:26:15 +0100 Subject: [PATCH] fix(cli): correct package download progress bar math The IXP progress bar averaged three independent counters (comments, docs downloaded, docs written) and divided by three, then displayed that against the up-front comment count from dataset statistics. Because dataset statistics are approximate and not every comment maps 1:1 to a downloaded+written doc, the displayed numerator could exceed the total (e.g. "974 / 857"). - IXP bar now treats each comment as three units of work (fetch, doc-download, doc-write); total = total_comments * 3, position = sum of the three counters. - progress.rs grows the bar's length when the live position overtakes the initial total, so the displayed "current / total" never inverts even when the up-front estimate is wrong (this also covers the CM bar). Co-Authored-By: Claude Opus 4.7 (1M context) --- CHANGELOG.md | 1 + cli/src/commands/package/download.rs | 4 ++-- cli/src/progress.rs | 12 ++++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3967d02c..d24eeffb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Unreleased - Support `gpt_5_1_2025_11_13`, `gpt_5_4_2026_03_05`, `gemini_2_5_pro`, and `gemini_3_1_pro_preview` model versions - Fix downloaded packages placing extension-less documents at the package root instead of in the `documents/` folder +- Fix `re package download` progress bar showing more progress than the total when the dataset's comment count is approximate # v0.39.0 - Allow `re get comments --reviewed-only` to be combined with dataset filters diff --git a/cli/src/commands/package/download.rs b/cli/src/commands/package/download.rs index 1a9d8c0c..ed61e3f4 100644 --- a/cli/src/commands/package/download.rs +++ b/cli/src/commands/package/download.rs @@ -598,7 +598,7 @@ fn get_ixp_progress_bar(total_comments: u64, statistics: &Arc) -> Pr let num_annotations = statistics.num_annotations(); let num_docs_written = statistics.num_document_writes(); ( - ((num_comments + num_docs_downloaded + num_docs_written) / 3) as u64, + (num_comments + num_docs_downloaded + num_docs_written) as u64, format!( "{} {} {} {} {} {} {} {}", num_comments.to_string().bold(), @@ -613,7 +613,7 @@ fn get_ixp_progress_bar(total_comments: u64, statistics: &Arc) -> Pr ) }, statistics, - Some(total_comments), + Some(total_comments * 3), crate::progress::Options { bytes_units: false }, ) } diff --git a/cli/src/progress.rs b/cli/src/progress.rs index 735f1a78..12bf7f69 100644 --- a/cli/src/progress.rs +++ b/cli/src/progress.rs @@ -107,14 +107,22 @@ where let progress_fn = progress_fn; let statistics = Arc::clone(&statistics); let sleep_duration = Duration::from_millis(100); + let mut current_max = max_progress_value; while report_progress.load(Ordering::SeqCst) { thread::sleep(sleep_duration); let (progress_value, message) = progress_fn(&statistics); progress_bar.set_position(progress_value); progress_bar.set_prefix(message); - match max_progress_value { - Some(value) => progress_bar.set_message(format!("{progress_value} / {value}")), + match current_max { + Some(value) => { + let display_total = progress_value.max(value); + if display_total > value { + progress_bar.set_length(display_total); + current_max = Some(display_total); + } + progress_bar.set_message(format!("{progress_value} / {display_total}")); + } None => progress_bar.set_message(format!("{progress_value}")), }; }