Files
pipelines/app/notes/notification-thread-grouping.md
T
alan fc7dbb0ac0 Remove ntfy: notifications go only through the app notification stream
Server: drop ntfy publishing (stage hooks, run outbox, chat attention, chat
tool notify, auto-switch and schedule notices), the chat push outbox (its
table is dropped at startup), ntfy status/endpoints and PIPELINES_NTFY_*.
The app_notifications stream, subscribe/clear and kinds are unchanged.
Notification settings keep run_finished/chat_needs_you/chat_reply_finished;
ntfy_enabled is accepted and ignored and its stored row is never read.

Stage type=ntfy is rejected: "ntfy stages were removed; notifications go to
the Pipelines apps — use the stage notify hook". The notify hook remains.

Installer: no ntfy build, accounts, config or supervisor child; manifest
gets top-level "mode" (legacy ntfy.mode still read). Reinstall retires an
old ntfy (safe PID-file stop, deletes binary, config, data dir, token, log,
with a note in logs/install.log); uninstall cleans leftovers.

App: ntfy settings section replaced by "Notification events"; texts updated.
Docs: docs/ntfy.md folded into docs/notifications.md; install, docker, cli,
author skill references updated; security review M1 marked resolved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 23:24:24 +00:00

4.0 KiB

Android notifications grouped per chat and run

What changed (native service only; Flutter unchanged)

  • android/.../notify/NotificationThreads.kt (new): ThreadEntry, ThreadHistory (bounded per-thread entries, bounded thread count, persisted through the ledger's LedgerStore under threads.history), and naming helpers. Threads are keyed by the server group (chat:<id> or run:<id>, per docs/notifications.md).
  • NotificationPresenter.kt: a grouped notification posts one conversation notification per thread with a stable id (thread:<group>), the latest 5 lines (sender = chat title, run title for runs), the unread count (setNumber), and a shared group per namespace (pipelines.chats, pipelines.runs). The group summary reads "N chats" / "N runs" and is removed when fewer than two are shown. Empty-group notifications keep the old standalone path. Channels and importance are unchanged (channelFor takes kind and priority, same rules).
  • cancel(ids) removes the cleared entries from history, drops a thread whose entries are all gone, and reposts a partially cleared thread with its new count. cancelAll() also clears the history.
  • NotificationDismissReceiver.kt: EXTRA_NOTIFICATION_ID may carry several newline-separated ids, so a tap or swipe on a thread clears every entry it shows.
  • NotificationService.kt, the ledger and the protocol are untouched, so run 405's reconnect/wakelock work is not affected.

Review fix (visit 2)

  • The thread notification now uses androidx.core.app.NotificationCompat.MessagingStyle with androidx.core.app.Person, built by NotificationCompat.Builder (the presenter's builder is compat throughout). Platform Notification.MessagingStyle and its API 28 BigTextStyle fallback are gone; the compat style renders on every supported API level.
  • app/android/app/build.gradle.kts adds implementation("androidx.core:core:1.15.0") (already in the offline Gradle cache).

Focused results

  • Gradle 9.1.0 (cached), --offline, JDK 17 (/opt/homebrew/opt/openjdk@17): :app:testDebugUnitTest --tests 'net.awan.pipelines_app.notify.*' → BUILD SUCCESSFUL. JUnit XML: ThreadHistoryTest 9 tests / 0 failures, DeliveryLedgerTest 8 / 0, NotificationProtocolTest 12 / 0.
  • tool/analyze.sh (run from app/, after the Kotlin tests): clean, exit 0.
  • No Flutter test was run: no Dart source changed.
  • JDK 27 fails the Android JDK image transform (jlink) in a plugin, so builds here need JDK 17 (environment issue, unrelated to this change).

Affected states

  • No Flutter UI changed. Native states not exercised on a device: a second chat appearing as a thread, a summary at 2 and 1 chats, tap/swipe on a multi-line thread, and the restart rebuild from persisted history.

Merge with main (land re-entry)

  • main moved NotificationPresenter.kt (sign-in notice, openApp() helper, SIGN_IN_ID, ACCOUNT_CHANNEL). Resolved by keeping both sides: the connection notification uses openApp(), and the sign-in block, constants and thread code all remain. The merge is staged with --no-commit; land concludes it.
  • Gradle, JDK 17, offline: :app:compileDebugUnitTestKotlin succeeds.
  • Gradle, JDK 17, offline: :app:testDebugUnitTest --tests 'net.awan.pipelines_app.notify.*' passes 37 of 37 (ConnectionLog 5, DeliveryLedger 8, NotificationProtocol 12, ReconnectPolicy 3, ThreadHistory 9).
  • No Dart changed in this stage, so no Flutter tests or analyze were run.

Limitations

  • Android posting (MessagingStyle, summary, PendingIntent extras) is not covered by JVM tests and has not been run on a device. Mobile behaviour is unverified.
  • The new androidx.core dependency is compiled offline but not run through a full APK build or on a device in this stage.
  • History is capped: 100 unread entries per thread (count is capped there) and 50 threads; the oldest thread is forgotten first when the cap is hit.
  • Swipe-dismissal of a thread clears its ids on the server, but the local history is trimmed only when the server confirms (notifications_cleared).