Notifications: agent notify reaches every device and clears everywhere

- 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>
This commit is contained in:
2026-12-02 19:43:55 +00:00
parent c441400f36
commit b91ef04ab0
32 changed files with 743 additions and 73 deletions
+27
View File
@@ -29,3 +29,30 @@ 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&timestamps=1&shown=1`, route `/chat/perf-chat-0`).