Group summary left behind when a tagged notification is re-sent without a group

Closed Beginner friendly
#7,690 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

A pull request for this has already been merged.

  • #7744 by @Olaoluwa99 — merged

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
android, kotlin
Domain
mobile

Research direction

Read app/src/main/kotlin/io/homeassistant/companion/android/notifications/MessagingManager.kt around lines 1059–1064, then trace where the summary tag is posted and cancelGroupIfNeeded is called. Check the corresponding code in wear/.../MessagingManager.kt as the issue reports the same line there. Reproduce the grouped notification replacement from the issue and verify that both paths remove the empty summary while preserving notifications in groups that still have children.

Written by the indexing model from the issue text.

Description

bug notifications

Home Assistant Android app version(s): 2026.8.4-full (24228)

Android version(s): 14 (OxygenOS 14)

Device model(s): OnePlus 8T (KB2005)

Home Assistant version: 2026.10.4

Last working Home Assistant release (if known): unknown

Description of problem, include YAML if issue is related to notifications:

When a notification that was posted with a group is replaced (same tag) by a
notification without a group, the old group summary stays in the shade as an empty
entry — only "Home Assistant • ", no title or text.

Steps:

action: notify.mobile_app_kb2005
data:
  title: Test
  message: First, in a group
  data:
    tag: test-tag
    group: test-group

then

action: notify.mobile_app_kb2005
data:
  title: Test
  message: Second, same tag, no group
  data:
    tag: test-tag

Result: the second notification replaces the first one and leaves the group, but the
test-group summary remains, empty. Expected: the summary is removed, since the group no
longer has children.

The app already tries to handle exactly this case, but looks the summary up under the
wrong tag. In MessagingManager.kt
(L1059-L1064):

val notification = notificationManagerCompat.getActiveNotification(tag, messageId)
if (notification != null && notification.isGroup) {
    previousGroup = NotificationData.GROUP_PREFIX + notification.tag
    previousGroupId = previousGroup.hashCode()
}

notification.tag is the notification's own tag (test-tag), so previousGroup becomes
group_test-tag. The summary, however, is posted with tag group_test-group
(L1136),
so cancelGroupIfNeeded(previousGroup, previousGroupId)
(L1142)
finds no matching active notification and does nothing.

Suggested fix — take the group of the previous notification (it already carries the
group_ prefix, and is null for system auto-groups):

val notification = notificationManagerCompat.getActiveNotification(tag, messageId)
val previous = notification?.notification?.group
if (notification != null && notification.isGroup && !previous.isNullOrBlank()) {
    previousGroup = previous
    previousGroupId = previousGroup.hashCode()
}

With the right tag, cancelGroupIfNeeded should then remove the summary: by that point
the child has already been re-posted without the group, so the summary is the only
notification left in it.

Workarounds: keep the same group on the replacement, or send clear_notification with
tag: group_<group name> (that removes the orphaned summary).

Related: #4453 — a different case (same tag moved from group1 to group2), where the
app makes no attempt to clean up; here the cleanup code exists but uses the wrong key.

Companion App Logs:

Not collected — the cause is visible in the code above. Happy to provide them if needed.

Screenshot or video of problem:

Additional information:

The Wear OS app has the same line:
wear/.../MessagingManager.kt#L128.

Dominant language
Kotlin
Stars
4k
Forks
1.1k
Avg merge
2d 6h
Merged PRs (30d)
115

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from home-assistant/android

All issues in home-assistant/android

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.