Skip to content

Commit d280e10

Browse files
committed
revert style
1 parent 7c3f6bd commit d280e10

File tree

3 files changed

+44
-46
lines changed

3 files changed

+44
-46
lines changed

crates/lib/src/deploy.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,13 @@ async fn handle_layer_progress_print(
162162
Some(ProgressFilter::TasksMatching(vec!["pulling".to_string()]))
163163
};
164164

165-
let mut aggregator = ProgressAggregatorBuilder::new()
166-
.with_json(prog.clone())
167-
.with_visual(visual_filter.unwrap_or(ProgressFilter::TasksMatching(vec![])))
168-
.build();
165+
let mut aggregator = {
166+
let mut builder = ProgressAggregatorBuilder::new().with_json(prog.clone());
167+
if let Some(filter) = visual_filter {
168+
builder = builder.with_visual(filter);
169+
}
170+
builder.build()
171+
};
169172

170173
let mut subtasks = vec![];
171174
let mut subtask: SubTaskBytes = Default::default();

crates/lib/src/progress_aggregator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ mod tests {
126126
async fn test_task_filtering() -> Result<()> {
127127
// Create an aggregator that only shows "pulling" tasks
128128
let mut aggregator = ProgressAggregatorBuilder::new()
129-
.for_tasks(vec!["pulling".to_string()])
129+
.with_visual(ProgressFilter::TasksMatching(vec!["pulling".to_string()]))
130130
.build();
131131

132132
// Send a pulling event (should be shown)

crates/lib/src/progress_renderer.rs

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ pub struct ProgressRenderer {
3434
filter: ProgressFilter,
3535

3636
// Style templates
37-
bytes_style: ProgressStyle,
3837
steps_style: ProgressStyle,
3938
subtask_style: ProgressStyle,
4039
}
@@ -43,20 +42,14 @@ impl ProgressRenderer {
4342
pub fn new(filter: ProgressFilter) -> Self {
4443
let multi = MultiProgress::new();
4544

46-
let bytes_style = ProgressStyle::with_template(
47-
"{spinner:.green} {msg} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {bytes}/{total_bytes} ({eta})"
48-
).unwrap()
49-
.with_key("eta", |state: &indicatif::ProgressState, w: &mut dyn std::fmt::Write| {
50-
write!(w, "{:.1}s", state.eta().as_secs_f64()).unwrap_or(());
51-
});
52-
5345
let steps_style = ProgressStyle::with_template(
54-
"{spinner:.green} {msg} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {pos}/{len}",
46+
"{prefix} {bar} {pos}/{len} {wide_msg}",
5547
)
5648
.unwrap();
5749

50+
// Match the old indicatif styling for byte progress with indentation
5851
let subtask_style = ProgressStyle::with_template(
59-
" {spinner:.yellow} {msg} [{wide_bar:.green/blue}] {bytes}/{total_bytes}",
52+
" └ {prefix} {bar} {binary_bytes}/{binary_total_bytes} ({binary_bytes_per_sec}) {wide_msg}",
6053
)
6154
.unwrap();
6255

@@ -67,7 +60,6 @@ impl ProgressRenderer {
6760
active_tasks: HashSet::new(),
6861
current_task_type: None,
6962
filter,
70-
bytes_style,
7163
steps_style,
7264
subtask_style,
7365
}
@@ -147,10 +139,10 @@ impl ProgressRenderer {
147139
fn update_bytes_progress(
148140
&mut self,
149141
task: &str,
150-
description: &str,
142+
_description: &str,
151143
id: &str,
152-
bytes: u64,
153-
bytes_total: u64,
144+
_bytes: u64,
145+
_bytes_total: u64,
154146
steps: u64,
155147
steps_total: u64,
156148
subtasks: &[SubTaskBytes<'_>],
@@ -160,37 +152,35 @@ impl ProgressRenderer {
160152
// Check if we need to create a new bar
161153
let needs_new_bar = !self.bars.contains_key(&bar_id);
162154
if needs_new_bar {
163-
let pb = self.multi.add(ProgressBar::new(bytes_total.max(1)));
164-
pb.set_style(self.bytes_style.clone());
165-
pb.set_message(format!("{} ({})", description, task));
155+
let pb = self.multi.add(ProgressBar::new(steps_total.max(1)));
156+
pb.set_style(self.steps_style.clone());
157+
// Match old format: set prefix to "Fetching layers" for pulling tasks
158+
if task == "pulling" {
159+
pb.set_prefix("Fetching layers");
160+
} else {
161+
pb.set_prefix(task.to_string());
162+
}
163+
pb.set_message("");
166164
self.active_tasks.insert(bar_id.clone());
167165
self.bars.insert(bar_id.clone(), pb);
168166
}
169167

170168
// Get the bar and update it
171169
let bar = self.bars.get(&bar_id).unwrap();
172170

173-
// Update main progress
174-
if bytes_total > 0 {
175-
bar.set_length(bytes_total);
176-
}
177-
bar.set_position(bytes);
178-
179-
// Show steps if available
171+
// Update main progress - use steps for the main bar
180172
if steps_total > 0 {
181-
bar.set_message(format!(
182-
"{} ({}) - Step {}/{}",
183-
description, task, steps, steps_total
184-
));
173+
bar.set_length(steps_total);
185174
}
175+
bar.set_position(steps);
186176

187177
// Update or create subtask bars
188178
self.update_subtask_bars(subtasks, &bar_id)?;
189179

190-
// Mark as complete if done
191-
if bytes_total > 0 && bytes >= bytes_total {
180+
// Mark as complete if done - match old behavior by finishing and clearing
181+
if steps >= steps_total {
192182
if let Some(bar) = self.bars.get(&bar_id) {
193-
bar.finish_with_message(format!("✓ {} completed", description));
183+
bar.finish_and_clear();
194184
}
195185
}
196186

@@ -245,10 +235,10 @@ impl ProgressRenderer {
245235
}
246236
}
247237

248-
// Mark as complete if done
238+
// Mark as complete if done - match old behavior by finishing and clearing
249239
if steps >= steps_total {
250240
if let Some(bar) = self.bars.get(&bar_id) {
251-
bar.finish_with_message(format!("✓ {} completed", description));
241+
bar.finish_and_clear();
252242
}
253243
}
254244

@@ -276,7 +266,9 @@ impl ProgressRenderer {
276266
self.multi.add(ProgressBar::new(subtask.bytes_total.max(1)))
277267
};
278268
pb.set_style(self.subtask_style.clone());
279-
pb.set_message(format!("{}: {}", subtask.description, subtask.id));
269+
// Match old format: set prefix to "Fetching" for byte progress
270+
pb.set_prefix("Fetching");
271+
pb.set_message(format!("{} {}", subtask.description, subtask.id));
280272
pb
281273
});
282274

@@ -286,10 +278,9 @@ impl ProgressRenderer {
286278
}
287279
subtask_bar.set_position(subtask.bytes);
288280

289-
// Mark as complete if done
281+
// Mark as complete if done - but don't show checkmarks, just clear like the old version
290282
if subtask.bytes_total > 0 && subtask.bytes >= subtask.bytes_total {
291-
subtask_bar
292-
.finish_with_message(format!(" ✓ {}: {}", subtask.description, subtask.id));
283+
subtask_bar.finish_and_clear();
293284
}
294285
}
295286

@@ -313,6 +304,10 @@ impl ProgressRenderer {
313304
/// Finish and clean up all progress bars
314305
pub fn finish(&mut self) {
315306
self.clear_all_bars();
307+
// Clear the multi-progress like the old version did
308+
if let Err(e) = self.multi.clear() {
309+
tracing::warn!("clearing progress bars: {e}");
310+
}
316311
}
317312
}
318313

@@ -324,7 +319,7 @@ mod tests {
324319

325320
#[test]
326321
fn test_filter_matching() {
327-
let mut renderer =
322+
let renderer =
328323
ProgressRenderer::new(ProgressFilter::TasksMatching(vec!["pulling".to_string()]));
329324

330325
// Should render pulling tasks
@@ -337,14 +332,14 @@ mod tests {
337332
}
338333

339334
#[test]
340-
fn test_last_task_only() {
341-
let mut renderer = ProgressRenderer::new(ProgressFilter::LastTaskOnly);
335+
fn test_all_tasks() {
336+
let mut renderer = ProgressRenderer::new(ProgressFilter::All);
342337

343338
// All tasks should be renderable
344339
assert!(renderer.should_render_task("pulling"));
345340
assert!(renderer.should_render_task("installing"));
346341

347-
// But ensure_clean_context should clear when task changes
342+
// But ensure_clean_context should track current task
348343
renderer.ensure_clean_context("pulling");
349344
assert_eq!(renderer.current_task_type, Some("pulling".to_string()));
350345

0 commit comments

Comments
 (0)