From 9c75f5a3f40c8427e918441df42a18f8ceb53ac5 Mon Sep 17 00:00:00 2001 From: James Rich Date: Fri, 17 Apr 2026 09:25:13 -0500 Subject: [PATCH] fix(auto): always cancel group summary when dismissing a conversation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reading notificationManager.activeNotifications immediately after cancel() races with NotificationManagerService, so the count of remaining children was unreliable and the summary could linger. Drop it unconditionally — the next inbound message rebuilds it via showGroupSummary(). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../core/service/MeshServiceNotificationsImpl.kt | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/core/service/src/androidMain/kotlin/org/meshtastic/core/service/MeshServiceNotificationsImpl.kt b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/MeshServiceNotificationsImpl.kt index 091d45ad2..3d1684cb6 100644 --- a/core/service/src/androidMain/kotlin/org/meshtastic/core/service/MeshServiceNotificationsImpl.kt +++ b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/MeshServiceNotificationsImpl.kt @@ -509,17 +509,10 @@ class MeshServiceNotificationsImpl( override fun cancelMessageNotification(contactKey: String) { notificationManager.cancel(contactKey.hashCode()) - // Refresh (or remove) the group summary so the notification shade / Auto HUN doesn't - // continue surfacing a stale summary after the last child is dismissed. - val remainingChildren = - notificationManager.activeNotifications.count { sbn -> - sbn.id != SUMMARY_ID && sbn.notification.group == GROUP_KEY_MESSAGES - } - if (remainingChildren == 0) { - notificationManager.cancel(SUMMARY_ID) - } else { - showGroupSummary() - } + // Always drop the group summary — reading notificationManager.activeNotifications right + // after cancel() races with NotificationManagerService, so we can't reliably count what's + // left. The next incoming message re-builds the summary via showGroupSummary(). + notificationManager.cancel(SUMMARY_ID) } override fun cancelLowBatteryNotification(node: Node) = notificationManager.cancel(node.num)