LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Issue #345: review fixes for the activity stack
Andrey Vyrodov8c3c586b8031
diff --git a/crates/engine/src/tests_face_recognize.rs b/crates/engine/src/tests_face_recognize.rsindex 8d14d3c61..aabcb03c3 100644--- a/crates/engine/src/tests_face_recognize.rs+++ b/crates/engine/src/tests_face_recognize.rs@@ -492,7 +492,11 @@ fn every_scanned_face_is_shown_by_the_same_kind_of_box() {fn face_scan_row_follows_pending_photos() {let d = temp("activity");let (mut s, _) = setup(&d, 64);- let (a, b) = two_photos(&s);+ // the last two demo photos, not the first two the other scan tests use: two sessions scanning the same demo scene+ // at once can deadlock (issue #630), and this test is about the row, not that+ let mut ids = s.catalog.photos().map(|p| p.id).collect::<Vec<_>>();+ ids.sort();+ let (a, b) = (ids[ids.len() - 2], ids[ids.len() - 1]);set_regions(&mut s, a, vec![region(0.1, None), region(0.5, None)]);set_regions(&mut s, b, vec![region(0.3, None)]);let faces_rows = |s: &Session| s.activity.list().into_iter().filter(|t| t.kind == "faces").collect::<Vec<_>>();diff --git a/crates/ui-egui/src/panels/activity.rs b/crates/ui-egui/src/panels/activity.rsindex 8a41a04ff..7b0d449c6 100644--- a/crates/ui-egui/src/panels/activity.rs+++ b/crates/ui-egui/src/panels/activity.rs@@ -102,14 +102,19 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {});});if let Some(id) = cancel {- // the task may have just finished: nothing to tell the user then- let _ = app.run("activity.cancel", json!({"id": id}));+ self::cancel(app, id);}if toggle {app.activity_expanded = !app.activity_expanded;}}+/// ✕ on task `id`'s row. The task may have just finished or stopped being cancellable: nothing to tell the user then,+/// so the command goes to the engine directly (`LightcraftApp::run` would put its error in the status bar).+pub(crate) fn cancel(app: &mut LightcraftApp, id: u64) {+ let _ = app.session.execute("activity.cancel", &json!({"id": id}));+}+/// One task: name and ✕, the bar, the detail line. True when ✕ was clicked.fn row(ui: &mut egui::Ui, t: &Tokens, task: &TaskInfo, width: f32) -> bool {let mut clicked = false;diff --git a/crates/ui-egui/src/tests_activity.rs b/crates/ui-egui/src/tests_activity.rsindex f54c12463..ca2a6de7e 100644--- a/crates/ui-egui/src/tests_activity.rs+++ b/crates/ui-egui/src/tests_activity.rs@@ -130,6 +130,12 @@ fn stale_cancel_is_harmless() {assert_eq!(r["ok"], false, "an error result, not a panic: {r}");h.step();assert!(h.app.ui.toast.is_none(), "{:?}", h.app.ui.toast);+ // the same through the row's ✕ (clicked in the frame the task ended): no message in the status bar either+ h.app.ui.status = "Ready".into();+ crate::panels::activity::cancel(&mut h.app, id);+ h.step();+ assert_eq!(h.app.ui.status, "Ready");+ assert!(h.app.ui.toast.is_none(), "{:?}", h.app.ui.toast);}#[test]