Title each grouped Android notification with its chat or run

Thread notifications lost their title and collapsed text when the
conversation style became a big-text preview, so inside a bundle each one
showed only the preview with no hint of which chat or run it came from.
This commit is contained in:
2026-11-13 15:06:09 +00:00
parent 9ad9874e7c
commit eeb07e5645
2 changed files with 11 additions and 0 deletions
@@ -146,6 +146,8 @@ class NotificationPresenter(private val context: Context) {
val ids = entries.map { it.id } val ids = entries.map { it.id }
val builder = builder(channel) val builder = builder(channel)
.setSmallIcon(R.drawable.ic_stat_pipelines) .setSmallIcon(R.drawable.ic_stat_pipelines)
.setContentTitle(threadTitle(latest))
.setContentText(latest.text)
.setNumber(entries.size) .setNumber(entries.size)
.setGroup(NotificationThreads.groupKey(NotificationThreads.namespaceOf(thread))) .setGroup(NotificationThreads.groupKey(NotificationThreads.namespaceOf(thread)))
.setAutoCancel(true) .setAutoCancel(true)
@@ -289,6 +291,13 @@ class NotificationPresenter(private val context: Context) {
fun runActionLabel(runClick: String): String? = fun runActionLabel(runClick: String): String? =
if (runClick.isEmpty()) null else "Open run" if (runClick.isEmpty()) null else "Open run"
/**
* A thread notification's title: the chat or run it belongs to, so
* each notification in a bundle says where it came from.
*/
fun threadTitle(entry: ThreadEntry): String =
entry.sender.trim().ifEmpty { kindLabel(entry.kind) }
/** The expanded text for a grouped notification, preferring artifact preview. */ /** The expanded text for a grouped notification, preferring artifact preview. */
fun threadPreview(entry: ThreadEntry): String = fun threadPreview(entry: ThreadEntry): String =
entry.preview.ifEmpty { entry.text } entry.preview.ifEmpty { entry.text }
@@ -61,6 +61,8 @@ class NotificationProtocolTest {
) )
assertEquals("Rendered artifact preview…", NotificationPresenter.threadPreview(entry)) assertEquals("Rendered artifact preview…", NotificationPresenter.threadPreview(entry))
assertEquals("Fallback message", NotificationPresenter.threadPreview(entry.copy(preview = ""))) assertEquals("Fallback message", NotificationPresenter.threadPreview(entry.copy(preview = "")))
assertEquals(entry.sender, NotificationPresenter.threadTitle(entry))
assertEquals("Chat question", NotificationPresenter.threadTitle(entry.copy(kind = "chat_question", sender = " ")))
} }
private val pushed = """ private val pushed = """