fix(tui): show spinner for indeterminate progress

This commit is contained in:
objz committed 2026-07-28 14:12:38 +02:00
1 parent b3c17b58c9
commit 6e898b8c45
2 files changed
+20 -2

No files matched your search

+2
View File
@@ -109,6 +109,7 @@ fn update_task_action(id: u64, text: String) {
if let Ok(mut state) = PROGRESS.lock() {
if let Some(task) = state.tasks.get_mut(&id) {
task.action = text;
task.progress = None;
}
refresh_visible(&mut state);
}
@@ -161,6 +162,7 @@ pub fn set_action(text: impl Into<String>) {
Ok(mut state) => {
state.legacy_active = true;
state.current_action = Some(text.clone());
state.progress = None;
super::request_redraw();
}
Err(e) => {
+18 -2
View File
@@ -23,7 +23,7 @@ fn newest_task_is_visible_and_drop_restores_previous_task() {
}
#[test]
fn changing_phase_keeps_the_existing_progress_visible() {
fn changing_phase_resets_progress_to_indeterminate() {
let _guard = TEST_LOCK.lock().unwrap();
clear();
let task = ProgressTask::start("inventory");
@@ -32,7 +32,7 @@ fn changing_phase_keeps_the_existing_progress_visible() {
let state = PROGRESS.lock().unwrap();
assert_eq!(state.current_action.as_deref(), Some("provider matching"));
assert_eq!(state.progress, Some((4, 10)));
assert_eq!(state.progress, None);
drop(state);
task.finish();
@@ -55,3 +55,19 @@ fn clearing_legacy_progress_keeps_owned_tasks() {
task.finish();
clear();
}
#[test]
fn a_new_legacy_action_does_not_reuse_the_previous_phase_progress() {
let _guard = TEST_LOCK.lock().unwrap();
clear();
set_action("Downloading installer");
set_progress(1, 1);
set_action("Running installer");
let state = PROGRESS.lock().unwrap();
assert_eq!(state.current_action.as_deref(), Some("Running installer"));
assert_eq!(state.progress, None);
drop(state);
clear();
}