Skip to content

feat(agents): add desktop notifications via VAPID web push#22454

Merged
kylecarbs merged 4 commits intomainfrom
feat/agents-desktop-notifications
Mar 1, 2026
Merged

feat(agents): add desktop notifications via VAPID web push#22454
kylecarbs merged 4 commits intomainfrom
feat/agents-desktop-notifications

Conversation

@kylecarbs
Copy link
Copy Markdown
Member

Summary

Wire VAPID web push notifications into the Agents (chat) system so users get desktop notifications when an agent finishes running.

Backend

  • Add webpush.Dispatcher to chatd.Server and pass it through from coderd.Options.WebPushDispatcher
  • In processChat()'s deferred cleanup, dispatch a web push notification when the chat reaches a terminal state:
    • waiting (success): "Agent has finished running."
    • error (failure): the error message, or "Agent encountered an error."
  • Sub-agent chats (ParentChatID.Valid) are skipped to avoid notification spam from internal delegation
  • Gracefully no-ops when the dispatcher is nil (web push disabled)

Frontend

  • New WebPushButton component — a bell icon that uses the existing useWebpushNotifications hook
    • Returns null when the web-push experiment is off
    • Three states: loading spinner, green bell (subscribed), muted bell-off (unsubscribed)
    • Tooltip + toast feedback on toggle
  • Added to both the Agents page empty state top bar and the AgentDetail top bar
  • The Agents page has its own layout (no standard Navbar), so it needs its own subscribe button

End-to-end flow

  1. User clicks the bell icon on /agents → browser subscribes via VAPID
  2. User starts an agent chat → chat enters running status
  3. Agent finishes → processChat defer sets status to waiting/error → dispatches web push
  4. Browser service worker shows a desktop notification with the chat title and status

Wire the existing webpush.Dispatcher into the chatd Server so that
when an agent chat finishes processing (status transitions to waiting
or error), a web push notification is dispatched to the chat owner.

Sub-agent chats are skipped to avoid notification spam from internal
delegation.

On the frontend, add a WebPushButton bell icon to the Agents page
top bar (both the empty state and agent detail views) so users can
subscribe/unsubscribe to push notifications directly from /agents,
which has its own layout and doesn't use the standard Navbar.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 1, 2026


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


Coder seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@coder-tasks
Copy link
Copy Markdown
Contributor

coder-tasks bot commented Mar 1, 2026

Documentation Check

Updates Needed

  • docs/admin/monitoring/notifications/index.md - The Delivery Methods section lists SMTP, webhook, and dashboard inbox, but doesn't mention browser push notifications. Now that the web-push experiment surfaces a bell icon on the Agents page, it would be helpful to at least acknowledge this experimental delivery method here (e.g., a note that web push browser notifications are available as an early-access experiment).

Note: Since web-push is an experimental feature and the bell button returns null when the experiment is disabled, this documentation is optional for this PR but would be useful before the feature reaches GA.


Automated review via Coder Tasks

Coder added 2 commits March 1, 2026 04:26
…ribe

- Check PublicKey() != "" before dispatching so NoopWebpusher
  (used when web-push experiment is off) doesn't cause noisy
  warning logs on every chat completion.
- Fix pre-existing bug in useWebpushNotifications: unsubscribe()
  now calls API.deleteWebPushSubscription before browser-side
  unsubscribe so the server removes the stale endpoint.
@kylecarbs kylecarbs merged commit c9ed1e1 into main Mar 1, 2026
27 of 28 checks passed
@kylecarbs kylecarbs deleted the feat/agents-desktop-notifications branch March 1, 2026 04:40
@github-actions github-actions bot locked and limited conversation to collaborators Mar 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant