feat(notify): a push's buttons work from the browsers and the app, not only Home Assistant #22

Closed
gabrielvidal wants to merge 0 commits from push-buttons-everywhere into main
pull from: push-buttons-everywhere
Owner

Summary

On 2026-11-27 Gabriel tapped Merge & deploy on auto-ship's Merge & deploy 3 PRs? push and nothing happened. The buttons existed only on the Home Assistant notification, and the companion app sends a tap to ha.lab over the tailnet. The Pixel's Tailscale was off, so the tap never reached the lab, and nothing said so. The PWA's web push and the app showed the push without buttons. Now a push's buttons are also on the owner's browsers (web push) and in the app (the Waiting for feedback card and the bell). The first tap wins wherever it happens, and the push then leaves the other devices.

Companion PR: ai-agent-plugins auto-ship-waiting-card (auto-ship lists its open question with the push's id).

Key changes

  • backend/notifications/service.py _deliver: the owner's web push payload carries the push's button titles (actions). Guests' payloads don't: these pushes are the owner's, and /api/notify/{id}/action is owner only.
  • frontend/public/push-sw.js: draws a notify push's actions like an ask's options (up to maxActions), keeps it on screen (requireInteraction), and a tap POSTs /api/notify/{id}/action {index}. A failed answer opens the push's link, as an ask does.
  • backend/notifications/routes.py notify_action: the first tap wins. A second tap on an already-acted push returns it and dispatches nothing. A tap clears the push off the other devices (deliver.clear: web push + the HA channel), the way an answered ask is cleared.
  • backend/plugins/waiting.py: an inbox.waiting item may carry notifyId (ntf_ + 12 hex), owner only.
  • frontend: WaitingItem.notifyId, and actOnPush() (api.ts). In WaitingForFeedback and FeedbackBell, the options of such an item tap the push, not /api/ask/…. In sseBus, plugin-data also refetches the inbox, so the card leaves once the plugin's state says it's answered.
  • docs/plugins.md: the notify.action section explains how to put a push's buttons in the app.

Key decisions

  • The app card comes from the plugin (inbox.waiting), not from the hub's push log. Only the plugin knows whether its question is still open: auto-ship re-asks (supersedes) its push when a PR joins, and Later re-asks in 2 h. A card built from "pushes with buttons not tapped yet" would leave stale Merge & deploy buttons that do nothing, the very bug being fixed.
  • First tap wins, enforced in the hub. With buttons on three surfaces, double taps get likely. Auto-ship guards itself, but a scheduled conversation's Retry would retry twice. channels.py already documented "first answer wins", so this makes that documentation true.
  • Web push buttons don't help a PWA on ai-agent.lab while the phone is off the tailnet (the service worker can't reach the hub either; it falls back to opening the link). The app card does: it works from any open app, hub.gabvdl.xyz included.

Changelog

  • Added: a push's buttons (auto-ship's Merge & deploy / Later / Drop) on the browsers' web push notification, not only on the phone's Home Assistant notification
  • Added: auto-ship's open Merge & deploy N PRs? is answerable from the app's Waiting for feedback card and the bell
  • Fixed: tapping a push's button on a second device no longer runs its action twice, and the push leaves the other devices once answered

Test notes

  • Live, on the EVOX2: a local hub ran this branch under bwrap with auto-ship installed from the companion branch. With its queue seeded and ship asking, GET /api/inbox/waiting returned the card with notifyId, and screenshots show it on home and in the bell. A real click on Later (Puppeteer) sent POST /api/notify/ntf_…/action {"index":1}. The plugin moved the batch to later, requeued the PRs and called hub/changed, and the card left the page with no reload (screenshots below).
  • Backend: full suite, one module per process under bwrap: 161 modules, all green except test_typed_plugins.py::test_records_carry_kind, which fails identically on main. New tests: web push payload carries the titles (plain push doesn't), first tap wins, tap clears the other devices, notifyId passthrough (owner only, push ids only).
  • Frontend: tsc --noEmit is clean. vitest: 1077 pass. The 3 failures (useShareTarget ×2, CacheExpiredNotice) also fail on main, and reachability.test.ts is flaky (2 of 3 runs pass; file untouched). New tests: src/lib/pushSw.test.ts runs push-sw.js in a fake worker scope (buttons drawn, tap → /api/notify/{id}/action, ask unchanged, failure → link), and the bell's push tap.
  • Not tested: a real web push delivery to Android Chrome (needs the push service). The worker's logic is covered by pushSw.test.ts, the payload by the backend test.
  • Deploy from the Homelab after review (blue-green, ai-agent-deploy), never from the EVOX2. Reload auto-ship (companion PR) after this deploy. Before it, the card's buttons would call /api/ask/auto-ship:… and fail.

🤖 Generated with Claude Code

Screenshots

home-desktop.png
bell-card.png
after-later.png

## Summary On 2026-11-27 Gabriel tapped **Merge & deploy** on auto-ship's *Merge & deploy 3 PRs?* push and nothing happened. The buttons existed only on the Home Assistant notification, and the companion app sends a tap to `ha.lab` over the tailnet. The Pixel's Tailscale was off, so the tap never reached the lab, and nothing said so. The PWA's web push and the app showed the push without buttons. Now a push's buttons are also on the owner's browsers (web push) and in the app (the *Waiting for feedback* card and the bell). The first tap wins wherever it happens, and the push then leaves the other devices. Companion PR: ai-agent-plugins `auto-ship-waiting-card` (auto-ship lists its open question with the push's id). ## Key changes - `backend/notifications/service.py` `_deliver`: the owner's web push payload carries the push's button titles (`actions`). Guests' payloads don't: these pushes are the owner's, and `/api/notify/{id}/action` is owner only. - `frontend/public/push-sw.js`: draws a `notify` push's `actions` like an ask's options (up to `maxActions`), keeps it on screen (`requireInteraction`), and a tap POSTs `/api/notify/{id}/action {index}`. A failed answer opens the push's link, as an ask does. - `backend/notifications/routes.py` `notify_action`: the **first tap wins**. A second tap on an already-acted push returns it and dispatches nothing. A tap clears the push off the other devices (`deliver.clear`: web push + the HA channel), the way an answered ask is cleared. - `backend/plugins/waiting.py`: an `inbox.waiting` item may carry `notifyId` (`ntf_` + 12 hex), owner only. - `frontend`: `WaitingItem.notifyId`, and `actOnPush()` (`api.ts`). In `WaitingForFeedback` and `FeedbackBell`, the options of such an item tap the push, not `/api/ask/…`. In `sseBus`, `plugin-data` also refetches the inbox, so the card leaves once the plugin's state says it's answered. - `docs/plugins.md`: the `notify.action` section explains how to put a push's buttons in the app. ## Key decisions - **The app card comes from the plugin (`inbox.waiting`), not from the hub's push log.** Only the plugin knows whether its question is still open: auto-ship re-asks (supersedes) its push when a PR joins, and *Later* re-asks in 2 h. A card built from "pushes with buttons not tapped yet" would leave stale *Merge & deploy* buttons that do nothing, the very bug being fixed. - **First tap wins, enforced in the hub.** With buttons on three surfaces, double taps get likely. Auto-ship guards itself, but a scheduled conversation's *Retry* would retry twice. `channels.py` already documented "first answer wins", so this makes that documentation true. - **Web push buttons don't help a PWA on `ai-agent.lab` while the phone is off the tailnet** (the service worker can't reach the hub either; it falls back to opening the link). The app card does: it works from any open app, `hub.gabvdl.xyz` included. ## Changelog - Added: a push's buttons (auto-ship's *Merge & deploy / Later / Drop*) on the browsers' web push notification, not only on the phone's Home Assistant notification - Added: auto-ship's open *Merge & deploy N PRs?* is answerable from the app's *Waiting for feedback* card and the bell - Fixed: tapping a push's button on a second device no longer runs its action twice, and the push leaves the other devices once answered ## Test notes - **Live, on the EVOX2:** a local hub ran this branch under bwrap with auto-ship installed from the companion branch. With its queue seeded and `ship` asking, `GET /api/inbox/waiting` returned the card with `notifyId`, and screenshots show it on home and in the bell. A real click on **Later** (Puppeteer) sent `POST /api/notify/ntf_…/action {"index":1}`. The plugin moved the batch to `later`, requeued the PRs and called `hub/changed`, and the card left the page with no reload (screenshots below). - **Backend:** full suite, one module per process under bwrap: 161 modules, all green except `test_typed_plugins.py::test_records_carry_kind`, which fails identically on `main`. New tests: web push payload carries the titles (plain push doesn't), first tap wins, tap clears the other devices, `notifyId` passthrough (owner only, push ids only). - **Frontend:** `tsc --noEmit` is clean. vitest: 1077 pass. The 3 failures (`useShareTarget` ×2, `CacheExpiredNotice`) also fail on `main`, and `reachability.test.ts` is flaky (2 of 3 runs pass; file untouched). New tests: `src/lib/pushSw.test.ts` runs `push-sw.js` in a fake worker scope (buttons drawn, tap → `/api/notify/{id}/action`, ask unchanged, failure → link), and the bell's push tap. - **Not tested:** a real web push delivery to Android Chrome (needs the push service). The worker's logic is covered by `pushSw.test.ts`, the payload by the backend test. - **Deploy from the Homelab** after review (blue-green, `ai-agent-deploy`), never from the EVOX2. Reload auto-ship (companion PR) **after** this deploy. Before it, the card's buttons would call `/api/ask/auto-ship:…` and fail. 🤖 Generated with [Claude Code](https://claude.com/claude-code) ## Screenshots ![home-desktop.png](https://git.gabvdl.xyz/attachments/1ca9b4e0-18d5-4242-8a7a-4d928f28d8f6) ![bell-card.png](https://git.gabvdl.xyz/attachments/0e44ad05-6225-4438-854e-56fb3b64c323) ![after-later.png](https://git.gabvdl.xyz/attachments/3ff207e0-a4aa-42e6-86c4-c3a16baa64d2)
gabrielvidal self-assigned this 2026-11-27 10:24:04 +01:00
gabrielvidal added 1 commit 2026-11-27 10:24:04 +01:00
The auto-ship push 'Merge & deploy N PRs?' carried its buttons only on the
Home Assistant notification, whose taps reach the lab over the tailnet: with
the phone off the tailnet (2026-11-27), the tap went nowhere and nothing said so.

- web push: the owner's browsers get a push's button titles (`actions`);
  push-sw.js draws them and a tap answers POST /api/notify/{id}/action (a
  failure opens the push's link), like an ask's options
- /api/notify/{id}/action: the first tap wins (a second device's goes nowhere,
  the plugin hears it once) and the push is cleared off the other devices
- inbox.waiting items may name their push (`notifyId`, owner only): the
  Waiting for feedback card and the bell then tap that push's buttons
- a plugin's hub/changed also refetches the inbox (its card leaves once answered)
- tests: push-sw.js in a fake worker scope, the bell's push tap, the web push
  payload, first tap wins + clear, notifyId passthrough

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner
Merged into `main` as 75e069aa0095dc44e0e62e9e6a2823a256b9ff8a by the auto-ship batch https://ai-agent.lab.gabvdl.xyz/conversation/af7fc8c3-5bfc-4a65-bc7f-2eb0cb1ed0d6.
gabrielvidal closed this pull request 2026-11-27 11:23:18 +01:00

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: gabrielvidal/ai-agent#22