From 53e89057b6928a996acbbf42d3a5b92daeed641a Mon Sep 17 00:00:00 2001 From: OakChaser Date: Mon, 16 Nov 2026 02:18:33 +0800 Subject: [PATCH] fix(tasks): stop posting a notice for a cancelled task The cancel is the user's own click, so announcing it back is noise. The task still leaves the centre with a Cancelled outcome; only the notice kind is gone, along with its copy. --- app/src/ui/services/notifications.rs | 6 ++---- app/src/usecases/tasks.rs | 30 +++++++++++++++------------ crates/shared/src/notification.rs | 1 - tools/update-i18n.py | 2 ++ ui/globals/notifications.slint | 3 --- ui/i18n/de_DE/LC_MESSAGES/conic-ui.po | 5 ----- ui/i18n/en_US/LC_MESSAGES/conic-ui.po | 5 ----- ui/i18n/es_ES/LC_MESSAGES/conic-ui.po | 5 ----- ui/i18n/fr_FR/LC_MESSAGES/conic-ui.po | 5 ----- ui/i18n/ja_JP/LC_MESSAGES/conic-ui.po | 5 ----- ui/i18n/ko_KR/LC_MESSAGES/conic-ui.po | 5 ----- ui/i18n/pl_PL/LC_MESSAGES/conic-ui.po | 5 ----- ui/i18n/pt_BR/LC_MESSAGES/conic-ui.po | 5 ----- ui/i18n/ru_RU/LC_MESSAGES/conic-ui.po | 5 ----- ui/i18n/tr_TR/LC_MESSAGES/conic-ui.po | 5 ----- ui/i18n/zh_CN/LC_MESSAGES/conic-ui.po | 5 ----- ui/i18n/zh_TW/LC_MESSAGES/conic-ui.po | 5 ----- 17 files changed, 21 insertions(+), 81 deletions(-) diff --git a/app/src/ui/services/notifications.rs b/app/src/ui/services/notifications.rs index 2b5e1b60..3334ea5e 100644 --- a/app/src/ui/services/notifications.rs +++ b/app/src/ui/services/notifications.rs @@ -266,7 +266,6 @@ fn kind_key(kind: NoticeKind) -> &'static str { NoticeKind::UpdateApplied => "update-applied", NoticeKind::TaskFinished => "task-finished", NoticeKind::TaskFailed => "task-error", - NoticeKind::TaskCancelled => "task-cancelled", NoticeKind::GameCrashed => "game-crashed", NoticeKind::SetupSkipped => "setup-skipped", NoticeKind::MinecraftReleased => "minecraft-released", @@ -279,7 +278,6 @@ fn kind_icon(kind: NoticeKind) -> &'static str { NoticeKind::UpdateApplied => "checkmark-outline", NoticeKind::TaskFinished => "checkmark-outline", NoticeKind::TaskFailed => "warning", - NoticeKind::TaskCancelled => "ban", NoticeKind::GameCrashed => "warning", NoticeKind::SetupSkipped => "refresh", NoticeKind::MinecraftReleased => "minecraft", @@ -335,8 +333,8 @@ mod tests { #[test] fn new_notices_go_to_the_front_of_both_models() { let controller = NotificationController::new(); - controller.send(Notice::new(NoticeKind::TaskCancelled)); controller.send(Notice::new(NoticeKind::TaskFinished)); + controller.send(Notice::new(NoticeKind::TaskFailed)); let first = controller.notifications.row_data(0).expect("newest notice"); let preview = controller.toasts.row_data(0).expect("newest preview"); @@ -400,7 +398,7 @@ mod tests { #[test] fn a_plain_notice_is_not_actionable() { let controller = NotificationController::new(); - controller.send(Notice::new(NoticeKind::TaskCancelled)); + controller.send(Notice::new(NoticeKind::TaskFailed)); let item = controller.notifications.row_data(0).expect("one notice"); assert!(!item.has_action); diff --git a/app/src/usecases/tasks.rs b/app/src/usecases/tasks.rs index 6674fa13..df7a7f0b 100644 --- a/app/src/usecases/tasks.rs +++ b/app/src/usecases/tasks.rs @@ -4,12 +4,13 @@ //! The task centre: the application's scheduler of long-running work. //! -//! It owns the ids, the ordering, the cancellation policy and the completion -//! notices; a task is removed when it ends, because a finished task becomes a -//! notification. `submit` hands over the description and the work, and nothing -//! runs until the centre admits it — a task waits while its lane is full. A -//! launch is not scheduled here: [`TaskCenter::reserve_exclusive`] lets it wait -//! for the centre to go idle and then hold the exclusive lane itself. +//! It owns the ids, the ordering, the cancellation policy and the end-of-task +//! notices: a task that finishes or fails becomes a notification, while the +//! cancel the user just asked for does not. `submit` hands over the description +//! and the work, and nothing runs until the centre admits it — a task waits +//! while its lane is full. A launch is not scheduled here: +//! [`TaskCenter::reserve_exclusive`] lets it wait for the centre to go idle and +//! then hold the exclusive lane itself. use std::{ collections::{HashMap, VecDeque}, @@ -399,7 +400,9 @@ impl TaskCenter { id, outcome: outcome.clone(), }); - (self.notices)(notice_for(&spec, &outcome, &self.action)); + if let Some(notice) = notice_for(&spec, &outcome, &self.action) { + (self.notices)(notice); + } self.drain(); } @@ -436,17 +439,18 @@ fn instance_of(target: &TaskTarget) -> Option<&str> { } } -fn notice_for(spec: &TaskSpec, outcome: &TaskOutcome, action: &TaskNoticeAction) -> Notice { +fn notice_for(spec: &TaskSpec, outcome: &TaskOutcome, action: &TaskNoticeAction) -> Option { match outcome { TaskOutcome::Completed => { let mut notice = Notice::new(NoticeKind::TaskFinished) .with_arg(spec.subject.clone()) .with_arg(spec.kind.key()); notice.action = action(&spec.target); - notice + Some(notice) } - TaskOutcome::Failed(error) => Notice::new(NoticeKind::TaskFailed).with_arg(error), - TaskOutcome::Cancelled => Notice::new(NoticeKind::TaskCancelled).with_arg(&spec.subject), + TaskOutcome::Failed(error) => Some(Notice::new(NoticeKind::TaskFailed).with_arg(error)), + // The user did it; telling them what they just did is noise. + TaskOutcome::Cancelled => None, } } @@ -779,7 +783,7 @@ mod tests { } #[test] - fn a_short_task_cancels_immediately() { + fn a_short_task_cancels_immediately_without_a_notice() { let (center, events, notices) = centre(); let runs = Arc::new(AtomicUsize::new(0)); let cancelled = Arc::new(AtomicBool::new(false)); @@ -795,7 +799,7 @@ mod tests { .. }) )); - assert_eq!(lock(¬ices)[0].kind, NoticeKind::TaskCancelled); + assert!(lock(¬ices).is_empty()); } #[test] diff --git a/crates/shared/src/notification.rs b/crates/shared/src/notification.rs index d4a3fcb2..f75de241 100644 --- a/crates/shared/src/notification.rs +++ b/crates/shared/src/notification.rs @@ -16,7 +16,6 @@ pub enum NoticeKind { TaskFinished, /// `args[0]` is the failure detail. TaskFailed, - TaskCancelled, /// `args[0]` is the crashed instance's display name. GameCrashed, SetupSkipped, diff --git a/tools/update-i18n.py b/tools/update-i18n.py index 1aab74b2..0b9d5268 100644 --- a/tools/update-i18n.py +++ b/tools/update-i18n.py @@ -164,6 +164,8 @@ ("NotificationText", "Launcher update ready"), ("NotificationText", "Task failed"), ("NotificationText", "Task cancelled"), + # A cancel is the user's own click, so it posts no notice any more. + ("NotificationText", "The task was cancelled"), ("NotificationText", "Minecraft task finished"), ("NotificationText", "Notification"), ("NotificationText", "Setup skipped"), diff --git a/ui/globals/notifications.slint b/ui/globals/notifications.slint index 361e68d1..48478364 100644 --- a/ui/globals/notifications.slint +++ b/ui/globals/notifications.slint @@ -65,9 +65,6 @@ export global NotificationText { if item.kind == "task-error" { return @tr("NotificationText" => "{}", arg(item, 0)); } - if item.kind == "task-cancelled" { - return @tr("NotificationText" => "The task was cancelled"); - } if item.kind == "task-finished" { if arg(item, 1) == "content-download" || arg(item, 1) == "library-download" { return @tr("NotificationText" => "{} downloaded. Click here to view", arg(item, 0)); diff --git a/ui/i18n/de_DE/LC_MESSAGES/conic-ui.po b/ui/i18n/de_DE/LC_MESSAGES/conic-ui.po index 4616842b..e84b04f0 100644 --- a/ui/i18n/de_DE/LC_MESSAGES/conic-ui.po +++ b/ui/i18n/de_DE/LC_MESSAGES/conic-ui.po @@ -3183,11 +3183,6 @@ msgctxt "NotificationText" msgid "{}" msgstr "{}" -#: ui -msgctxt "NotificationText" -msgid "The task was cancelled" -msgstr "Die Aufgabe wurde abgebrochen" - #: ui msgctxt "NotificationText" msgid "The task finished" diff --git a/ui/i18n/en_US/LC_MESSAGES/conic-ui.po b/ui/i18n/en_US/LC_MESSAGES/conic-ui.po index 9c77e34f..1bf27861 100644 --- a/ui/i18n/en_US/LC_MESSAGES/conic-ui.po +++ b/ui/i18n/en_US/LC_MESSAGES/conic-ui.po @@ -3188,11 +3188,6 @@ msgctxt "NotificationText" msgid "{}" msgstr "{}" -#: ui -msgctxt "NotificationText" -msgid "The task was cancelled" -msgstr "The task was cancelled" - #: ui msgctxt "NotificationText" msgid "The task finished" diff --git a/ui/i18n/es_ES/LC_MESSAGES/conic-ui.po b/ui/i18n/es_ES/LC_MESSAGES/conic-ui.po index a482844b..63590c8e 100644 --- a/ui/i18n/es_ES/LC_MESSAGES/conic-ui.po +++ b/ui/i18n/es_ES/LC_MESSAGES/conic-ui.po @@ -3183,11 +3183,6 @@ msgctxt "NotificationText" msgid "{}" msgstr "{}" -#: ui -msgctxt "NotificationText" -msgid "The task was cancelled" -msgstr "La tarea fue cancelada" - #: ui msgctxt "NotificationText" msgid "The task finished" diff --git a/ui/i18n/fr_FR/LC_MESSAGES/conic-ui.po b/ui/i18n/fr_FR/LC_MESSAGES/conic-ui.po index fd0bbaf0..aad0bb1b 100644 --- a/ui/i18n/fr_FR/LC_MESSAGES/conic-ui.po +++ b/ui/i18n/fr_FR/LC_MESSAGES/conic-ui.po @@ -3183,11 +3183,6 @@ msgctxt "NotificationText" msgid "{}" msgstr "{}" -#: ui -msgctxt "NotificationText" -msgid "The task was cancelled" -msgstr "La tâche a été annulée" - #: ui msgctxt "NotificationText" msgid "The task finished" diff --git a/ui/i18n/ja_JP/LC_MESSAGES/conic-ui.po b/ui/i18n/ja_JP/LC_MESSAGES/conic-ui.po index 96d4cb56..6e23f40f 100644 --- a/ui/i18n/ja_JP/LC_MESSAGES/conic-ui.po +++ b/ui/i18n/ja_JP/LC_MESSAGES/conic-ui.po @@ -3183,11 +3183,6 @@ msgctxt "NotificationText" msgid "{}" msgstr "{}" -#: ui -msgctxt "NotificationText" -msgid "The task was cancelled" -msgstr "タスクはキャンセルされました" - #: ui msgctxt "NotificationText" msgid "The task finished" diff --git a/ui/i18n/ko_KR/LC_MESSAGES/conic-ui.po b/ui/i18n/ko_KR/LC_MESSAGES/conic-ui.po index 654117b9..422b3263 100644 --- a/ui/i18n/ko_KR/LC_MESSAGES/conic-ui.po +++ b/ui/i18n/ko_KR/LC_MESSAGES/conic-ui.po @@ -3183,11 +3183,6 @@ msgctxt "NotificationText" msgid "{}" msgstr "{}" -#: ui -msgctxt "NotificationText" -msgid "The task was cancelled" -msgstr "작업이 취소되었습니다" - #: ui msgctxt "NotificationText" msgid "The task finished" diff --git a/ui/i18n/pl_PL/LC_MESSAGES/conic-ui.po b/ui/i18n/pl_PL/LC_MESSAGES/conic-ui.po index add02681..e1a74e4c 100644 --- a/ui/i18n/pl_PL/LC_MESSAGES/conic-ui.po +++ b/ui/i18n/pl_PL/LC_MESSAGES/conic-ui.po @@ -3183,11 +3183,6 @@ msgctxt "NotificationText" msgid "{}" msgstr "{}" -#: ui -msgctxt "NotificationText" -msgid "The task was cancelled" -msgstr "Zadanie zostało anulowane" - #: ui msgctxt "NotificationText" msgid "The task finished" diff --git a/ui/i18n/pt_BR/LC_MESSAGES/conic-ui.po b/ui/i18n/pt_BR/LC_MESSAGES/conic-ui.po index 766a01c5..84b68084 100644 --- a/ui/i18n/pt_BR/LC_MESSAGES/conic-ui.po +++ b/ui/i18n/pt_BR/LC_MESSAGES/conic-ui.po @@ -3183,11 +3183,6 @@ msgctxt "NotificationText" msgid "{}" msgstr "{}" -#: ui -msgctxt "NotificationText" -msgid "The task was cancelled" -msgstr "A tarefa foi cancelada" - #: ui msgctxt "NotificationText" msgid "The task finished" diff --git a/ui/i18n/ru_RU/LC_MESSAGES/conic-ui.po b/ui/i18n/ru_RU/LC_MESSAGES/conic-ui.po index 3819843f..c0814e34 100644 --- a/ui/i18n/ru_RU/LC_MESSAGES/conic-ui.po +++ b/ui/i18n/ru_RU/LC_MESSAGES/conic-ui.po @@ -3183,11 +3183,6 @@ msgctxt "NotificationText" msgid "{}" msgstr "{}" -#: ui -msgctxt "NotificationText" -msgid "The task was cancelled" -msgstr "Задача была отменена" - #: ui msgctxt "NotificationText" msgid "The task finished" diff --git a/ui/i18n/tr_TR/LC_MESSAGES/conic-ui.po b/ui/i18n/tr_TR/LC_MESSAGES/conic-ui.po index a69adeca..87c1e946 100644 --- a/ui/i18n/tr_TR/LC_MESSAGES/conic-ui.po +++ b/ui/i18n/tr_TR/LC_MESSAGES/conic-ui.po @@ -3183,11 +3183,6 @@ msgctxt "NotificationText" msgid "{}" msgstr "{}" -#: ui -msgctxt "NotificationText" -msgid "The task was cancelled" -msgstr "Görev iptal edildi" - #: ui msgctxt "NotificationText" msgid "The task finished" diff --git a/ui/i18n/zh_CN/LC_MESSAGES/conic-ui.po b/ui/i18n/zh_CN/LC_MESSAGES/conic-ui.po index 92e6087a..cfec0371 100644 --- a/ui/i18n/zh_CN/LC_MESSAGES/conic-ui.po +++ b/ui/i18n/zh_CN/LC_MESSAGES/conic-ui.po @@ -3078,11 +3078,6 @@ msgctxt "NotificationText" msgid "{}" msgstr "{}" -#: ui -msgctxt "NotificationText" -msgid "The task was cancelled" -msgstr "任务已取消" - #: ui msgctxt "NotificationText" msgid "The task finished" diff --git a/ui/i18n/zh_TW/LC_MESSAGES/conic-ui.po b/ui/i18n/zh_TW/LC_MESSAGES/conic-ui.po index 913b5a4b..fa1c7e31 100644 --- a/ui/i18n/zh_TW/LC_MESSAGES/conic-ui.po +++ b/ui/i18n/zh_TW/LC_MESSAGES/conic-ui.po @@ -3183,11 +3183,6 @@ msgctxt "NotificationText" msgid "{}" msgstr "{}" -#: ui -msgctxt "NotificationText" -msgid "The task was cancelled" -msgstr "工作已取消" - #: ui msgctxt "NotificationText" msgid "The task finished"