b91ef04ab0
- Server: chat ntfy messages carry a sequence id derived from their app id; clearing a chat app notification also clears it in ntfy (PUT /<topic>/<seq>/clear, verified on ntfy v2.38.1). - Server: a turn that sent an agent notify does not also send chat_reply. - notify tool and MCP instructions: Pipelines already notifies at reply end and for questions/approvals; notify is for mid-turn or background news. - Shown notify items carry channels (apps/phone); the transcript row says where it went. - App: NotificationBridge.close(tag); web closes tracked Notifications and tells other tabs over a BroadcastChannel; native bridge cancels by tag and now supports macOS. AgentNotices closes on notifications_cleared and on resubscribe cleared ids, and a tap sends clear_notifications. - Docs: skill, chat reference, ntfy/notifications docs, app note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
59 lines
3.4 KiB
Markdown
59 lines
3.4 KiB
Markdown
# Agent notify reaches the web app
|
|
|
|
An agent's MCP `notify` call is recorded by the server as a `chat_notify` app
|
|
notification (id `chat:<session>:notify:<shown id>`, priority low 2 / default 3
|
|
/ high 4) on the existing notification stream (`subscribe_notifications`), so
|
|
every connected client receives it and a reconnecting client replays the ones
|
|
still active. ntfy delivery is unchanged.
|
|
|
|
The app (`lib/features/attention/notify/agent_notices.dart`) subscribes on every
|
|
connection through the send-only path and decides per notice
|
|
(`agent_notice.dart`, `agentNoticeDelivery`):
|
|
|
|
- focused page: an in-app toast with Open, nothing if that chat is in view;
|
|
- unfocused or hidden page with browser permission: a system notification
|
|
titled `<chat title>: <title>` (click focuses the tab and opens the chat) and a
|
|
`(n) ` count in the tab title until focus returns; low priority only posts
|
|
when the page is hidden, otherwise it waits as a toast;
|
|
- no permission or an insecure http page: toast, title count and, for default
|
|
and high priority live notices, a short Web Audio chime.
|
|
|
|
Replays older than one hour are recorded but not shown; at most five show. Shown
|
|
ids persist in the notification ledger (`agent` map, two days, 200 entries), so
|
|
reloads and reconnects never repeat one. Opening the chat clears the server copy
|
|
on every device (chat seen).
|
|
|
|
Captures (`tool/capture`, fixture `?ui-review=1&agentNotice=<ms>`): secure
|
|
focused toast, Open navigating to `/chat/ui-review`, no toast with the chat in
|
|
view, insecure unfocused toast with `document.title == "(1) Pipelines"` and back
|
|
to `Pipelines` on focus, and the Settings hints for secure and insecure pages.
|
|
Browser system notifications themselves were not captured (headless Chrome,
|
|
permission not granted); unit tests cover that path.
|
|
|
|
## Clearing everywhere
|
|
|
|
`AgentNotices` closes the system notification for every id in a
|
|
`notifications_cleared` frame (a push after a clear on another device or the
|
|
chat being opened, or the reply to this client's own clear) and for the cleared
|
|
ids a resubscribe reports. A tap sends `clear_notifications` for the notice
|
|
before opening the chat. `NotificationBridge.close(tag)` does the platform work:
|
|
the web bridge keeps the `Notification` objects it posted by tag, closes the one
|
|
for the tag and posts the tag on the `pipelines.notifications`
|
|
`BroadcastChannel` so the origin's other tabs and installed-app windows close
|
|
theirs; the native bridge (Android without the background service, iOS, and now
|
|
macOS) cancels the platform id it used for the tag. A browser `close` event is
|
|
deliberately not sent to the server: Chrome raises it for a notification
|
|
daemon's timeout and for a same-tag replacement by another tab, which would
|
|
clear the notice on every device seconds after it appeared. The transcript row
|
|
says where a notify went from the item's `channels` ("Notified your apps and
|
|
phone", "Notified your apps", "Notified your phone").
|
|
|
|
Browser check (headless Chromium, `tool/capture`, fixture
|
|
`?ui-review=1&agentNotice=6000[&agentNoticeClear=9000]`, notification
|
|
permission granted through CDP, `window.Notification` wrapped to record): the
|
|
notice posted `show chat:ui-review:notify:shown_capture`; a pushed
|
|
`notifications_cleared` then recorded `close` for that tag; without the clear,
|
|
a message on the `pipelines.notifications` BroadcastChannel (as another tab
|
|
sends) closed it. The transcript row reads "Notified your apps and phone:
|
|
Release ready" (`?chats=1×tamps=1&shown=1`, route `/chat/perf-chat-0`).
|