Notification inbox
Status: ✅ Implemented
Intent
Section titled “Intent”Toasts vanish; work does not. “Your export finished”, “an approval is waiting”, “the import had 3 errors” must survive the moment they happened and be findable later — with an unread count nudging the user. This is the inbox (events with read state), distinct from push toasts (transient) and task queues (work items).
Solution
Section titled “Solution”Implement NotificationsSupplier on the @UI app class:
@UI("")public class BackofficeApp implements NotificationsSupplier {
@Autowired NotificationStore notificationStore; // your inbox
@Override public List<AppNotification> notifications(HttpRequest httpRequest) { // per-user inbox: the user the host framework authenticated (the same identity // @EyesOnly authorization uses) var user = httpRequest.getUserPrincipal().getName(); return notificationStore.latest(user).stream() .map(n -> new AppNotification(n.id(), n.title(), n.text(), n.route(), n.unread(), n.relativeTime())) .toList(); }
@Override public void markNotificationsRead(List<String> ids, HttpRequest httpRequest) { notificationStore.markRead(httpRequest.getUserPrincipal().getName(), ids); }}- The shell shows a bell on the header (next to the theme toggle) with the unread count.
- The bell’s panel lists the entries — title, optional text, display time (
whenis already formatted by the server: it owns locale and relative-time rules). Clicking an entry with aroutenavigates there and marks it read; Mark all read clears the count. - The list is fetched per request through the app-level
_notifications-listaction (the same rail as the@AppContextpickers’ remote search), so it can be per-user and always current;_notifications-read(ids, or"all") marks read and answers the refreshed list. - Pair with long-running jobs: a
LongTaskwith.notifyWhenDone()posts its outcome to the inbox (“Import finished — 3 errors · View”).
Entries you act on 🧪
Section titled “Entries you act on 🧪”An entry can be more than a link. Give it a category (the panel groups by it), a variant
(severity), actions the user runs from the entry, and hasDetail when clicking it should open a
detail the server builds. States: unread → read → resolved (acted upon, still listed under
Resolved), or dismissed (gone).
AppNotification.builder() .id("expense-42") .title("Expense to approve") .text("Ana · 312,40 €") .unread(true) .when("5 min ago") .category("Approvals") .variant(NotificationVariant.warning) .actions(List.of( MessageAction.run("Approve", "approve").withStyle("primary"), MessageAction.run("Reject", "reject").withStyle("danger"))) .hasDetail(true) .build();The supplier’s optional methods answer them:
@Overridepublic Object onNotificationAction(String id, String actionId, HttpRequest httpRequest) { expenses.decide(id, actionId); // check the id is the caller's! inbox.resolve(httpRequest.getUserPrincipal().getName(), id); return Message.success("Expense " + actionId + "d");}
@Overridepublic void dismissNotifications(List<String> ids, HttpRequest httpRequest) { … }
@Overridepublic Object notificationDetail(String id, HttpRequest httpRequest) { return Drawer.builder().headerTitle("Expense 42").content(expenseView(id)).build();}They ride the app-level actions _notifications-act {id, actionId} (the answer + the refreshed
list), _notifications-dismiss {ids} and _notifications-open {id} (the detail, answered like any
action — a Drawer opens over the page). The panel filters Unread / All / Resolved, groups by
category, marks all read and dismisses per entry; all client-side over the list.
Pushed, not polled 🧪
Section titled “Pushed, not polled 🧪”With @App(liveUpdates = true) the bell updates as soon as something changes. Store the entry,
then publish it:
inbox.add(user, entry);LiveNotifications.publish(user, entry); // only the sessions of `user`LiveNotifications.publishToAll(announcement); // everyoneLiveNotifications.remove(user, "expense-42");LiveNotifications.refresh(user); // "fetch the list again"A change reaches only the sessions whose caller — the identity the host framework authenticated —
has that name. It travels as a NotificationsChanged command on the app’s live-updates stream; a
new unread entry also shows a toast. The same id replaces an entry (deduplication). In-process:
in a cluster, publish on every node.
The inbox a user sees is your list plus what this session added on its own — messages sent with
persistence inbox and pushed entries the list does not have yet — deduplicated by id.
Inbox messages are kept on the server 🧪
Section titled “Inbox messages are kept on the server 🧪”A Message sent with persistence inbox to a SIGNED-IN user is also stored for that user, so it
is still in the bell after a reload, in their other tabs and on their other devices:
return Message.success("Export ready") .withAction(MessageAction.open("Download", "/exports/7")) .withPersistence(MessagePersistence.inbox);The entry’s id is the message’s key (one is generated when it has none, and set on the message
the browser receives, so the toast’s own entry and the stored one are the same); its actions are
the message’s actions that open a ROUTE (an actionId belongs to the screen that sent it). It is
pushed to the user’s other sessions (apps with @App(liveUpdates = true); otherwise it shows at
the next list). An anonymous caller’s inbox messages stay in that tab: there is no one to keep them
for. The stored entries are listed after your NotificationsSupplier’s; reading and dismissing
them works the same.
Storage is yours — Mateu ships UI only. Out of the box an in-memory store is used (per process,
100 entries per user, lost on restart); implement InboxStore as a bean to keep them anywhere:
@Componentclass JdbcInbox implements InboxStore { public void add(String principal, AppNotification entry) { … } public List<AppNotification> list(String principal) { … } // newest first public void markRead(String principal, List<String> ids) { … } public void dismiss(String principal, List<String> ids) { … }}An app that does not implement NotificationsSupplier gets the bell — listing only the stored
entries — with @App(inbox = true). .NET: IInboxStore (register it as a service) and
[App(Inbox = true)]; Python: InboxStore (add_mateu(inbox_store=…)) and @app(inbox=True).
Operating-system notifications 🧪
Section titled “Operating-system notifications 🧪”With @App(osNotifications = true) (.NET [App(OsNotifications = true)], Python
@app(os_notifications=True)) a new unread entry — and a background task that finished — also
shows as a notification of the operating system while the app is not in front:
- browser: the Web Notifications API. The bell and the task center offer “Notify me on this device”; the browser asks the user only then, never on load. Shown while the tab is hidden; a click brings the tab back and opens the entry’s route.
- phone: a LOCAL notification, posted by the app while it is in the background; permission is asked from the inbox / task sheet. When your server also sends pushes, a REMOTE push reaches the phone while the app is suspended or closed. See what reaches the device below.
- IntelliJ / the desktop app: a system notification while the IDE is not active (it follows the IDE’s “Use system notifications” setting).
On a phone: what reaches the device while the app is away
Section titled “On a phone: what reaches the device while the app is away”A local notification can only be posted by the app itself, while its JavaScript runs. The OS suspends a backgrounded app soon after you leave it (within seconds on iOS; it varies on Android). To reach a suspended or closed app, the server sends a remote push. Mateu ships UI only, so delivery sits behind two interfaces you can implement yourself. Mateu also has an optional sender for Expo’s push service, which is the one the Mateu app uses:
# application.properties: Mateu's Expo sender (or register your own PushSender bean)mateu.push.expo.enabled=truemateu.push.expo.access-token=${EXPO_ACCESS_TOKEN} # optional: Expo's "enhanced security"Remote push is on when the app has @App(osNotifications = true) and a sender. The app shell then
carries pushNotifications: true. The phone asks the user for permission from “Notify me on this
device”, registers its push token with your server (the reserved _push-register action) and
removes it on sign-out, when the UI is removed from the phone’s list, or when the user turns
notifications off. From then on:
| Situation | What the user gets |
|---|---|
| App in front | The bell and a toast. A push arriving now is not shown by the OS, so the user is not told twice |
A task ends (or sends an inbox message) in the moments after leaving the app, while it still runs | An OS notification (local) |
An inbox message to a signed-in user, the app suspended or closed | A push. Tapping it opens that UI at the entry’s route |
PushNotifications.send(user, …) from your code | A push to that user’s phones |
A LiveNotifications push or a task ending while the app is away, without an inbox message | No OS notification (send it as an inbox message, or call PushNotifications.send) |
| Back in the app | The bell fetches its list at once, so the badge counts what arrived meanwhile |
Without a sender, or for an anonymous user’s inbox messages, only the local notifications and the inbox remain. The inbox is still the record: a push only points at it. The full set-up (FCM and APNs credentials, the token store, the .NET and Python options) is in Push notifications to phones.
In YAML
Section titled “In YAML”A data-authored shell feeds the bell from REST sources instead of a NotificationsSupplier class:
notifications: {source: …, markRead: …} on its type: AppShell — fetched by the browser (or
through the server when the source is proxy: true). See
App shell as data › Header extras.
AppDto.notificationsEnabled turns the bell on (AppDto.osNotifications the OS notifications,
AppDto.pushNotifications the remote push registration); the actions answer
Data{_notifications: [{id, title, text, route, unread, when, category, variant, resolved, actions, hasDetail}]} — same contract from the Java, .NET and Python servers. A push is the command
NotificationsChanged {notification, removedId} (both null = refetch).
On IntelliJ / the desktop app the entries are the platform’s own notifications (“Mateu” group, the Notifications tool window), with their actions, and the bell opens the app’s inbox panel with the same filters (All / Unread / Resolved) and category groups as the web; on the phone the bell lists them with the same filters.
Where it works
Section titled “Where it works”Every renderer. On Redwood the bell sits in the global header (badge with the unread count) and
opens an oj-popup holding JET’s oj-list-view; activating an entry marks it read and navigates to
its route. Demo: demo-vb-pms (PmsHome implements NotificationsSupplier). A data-authored
shell’s notifications.source works there too: the same bell lists it (a proxied source through
_appsource), and opening an entry or Mark all read calls markRead.
Related
Section titled “Related”- Push notifications — the transient sibling
- Task queue — when entries are work items with owners and states
See it live in the Explorer: Notification inbox & background work