From b5a631ebd7e08ad9d85c1cd05a256c5629cbcb4c Mon Sep 17 00:00:00 2001 From: James Rich Date: Fri, 17 Apr 2026 09:17:48 -0500 Subject: [PATCH] fix(auto): only include unread messages in conversation notif MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The MIN_CONTEXT_MESSAGES fallback (pull 3 most recent history messages when unread < 3) was injecting already-read historical messages into the MessagingStyle. On Android Auto, Gearhead reads every message in the style aloud and shows them stacked on the HUN, so old context was announced alongside the new one. Just show the unread messages (up to MAX_HISTORY_MESSAGES). If nothing is unread, don't post at all — we only call this from paths that already check for fresh inbound content. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../core/service/MeshServiceNotificationsImpl.kt | 11 ++--------- 1 file changed, 2 insertions(+), 9 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 75ae47297..6d02f83be 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 @@ -119,7 +119,6 @@ class MeshServiceNotificationsImpl( const val MAX_BATTERY_LEVEL = 100 private val NOTIFICATION_LIGHT_COLOR = Color.BLUE private const val MAX_HISTORY_MESSAGES = 10 - private const val MIN_CONTEXT_MESSAGES = 3 private const val SNIPPET_LENGTH = 30 private const val GROUP_KEY_MESSAGES = "com.geeksville.mesh.GROUP_MESSAGES" private const val SUMMARY_ID = 1 @@ -426,14 +425,8 @@ class MeshServiceNotificationsImpl( .first() val unread = history.filter { !it.read } - val displayHistory = - if (unread.size < MIN_CONTEXT_MESSAGES) { - history.take(MIN_CONTEXT_MESSAGES).reversed() - } else { - unread.take(MAX_HISTORY_MESSAGES).reversed() - } - - if (displayHistory.isEmpty()) return + if (unread.isEmpty()) return + val displayHistory = unread.take(MAX_HISTORY_MESSAGES).reversed() val notification = createConversationNotification(