Repository navigation
feat(alerts): also send alerts to ntfy, Slack, Discord, Telegram or a JSON webhook - #2940
Conversation
… JSON webhook Settings -> Alerts -> Also send to: one destination this PC also posts its pane alerts to, with its own alert choices, the same waits and holds as a device, a test button and the last error. The URL or token is stored owner-only in the state dir and only ever answered masked. One post at a time and at most one waiting, retried with backoff on network/429/5xx failures. Fixes #2920
… the retry backoff as a fixed wait
|
Caution Review failedThe pull request is closed. Summary
Merge Risk:
|
- Mask a destination as its host only: an ntfy topic or a short path was readable from the last four characters. - Drop a retry once the alert is no longer news (pane changed, muted, a window in use, kind turned off). - A save or removal ends the old destination's backoff, so a new destination is not held behind it. - One test post at a time; a test of a removed or replaced destination records nothing. - Keep the saved link base on a relay request, whose origin opens nothing. - Refuse webhook changes to a Portal visitor, as push subscriptions are (standing access). - Settings: one preference save at a time.
The destination records who saved it, as a push subscription records its device (a paired device, null for a local/token sign-in, absent for the open LAN), and every try asks the same canDeliver push uses: a revoked device's or a closed open LAN's destination gets nothing, also after a restart.
- push.ts bumps a per-pane epoch wherever it calls off an alert (a change, an end, a resync) and when a pane is muted; a webhook retry goes out only under the epoch it was sent in, so an ended terminal, a status that came back, or a mute undone resurrects nothing. - A test of a new destination is its own, not the one still out for the old. - Settings and the guide say the pane goes by its terminal title. - Finished's choice waits while a save is out, like the switches. - The tests wait for the fake destination's posts, not a polling loop.
|
Review status at 0d79cea: omo CLEAR. Codex (Terra, xhigh) found no HIGH. Its two reproduced MEDIUMs are in the follow-up issue #2943. The LOWs below are left as they are:
CodeRabbit did not review this PR (review limit reached). |
|
Local merge gate (owner-approved): |
…ep a reachable link base (#2965) Fixes #2943 Two edge cases of the alert webhooks (#2940), both reproduced first by a test that fails on main. ### 1. A pending alert no longer reaches a destination set after it arose `server/push.ts` now records the destination's generation (`AlertWebhook.generation()`, bumped by a save that changes the URL/token/chat or by a removal) when it schedules a status or error alert, and passes it with the alert. `send()` drops an alert whose generation no longer matches. A save that only flips alert choices keeps the generation, so it does not drop anything. Device push timers are unchanged. ### 2. A loopback save keeps a reachable link base `save()` keeps a saved base that another device can open when the save comes from this PC's loopback address (relay saves already kept it). A loopback base is still stored when nothing better is known. `AlertWebhookView` gains `reachable_link`, and Settings → Alerts → Also send to shows a hint when messages have no link a phone can open yet (for example after a first save over the relay or from localhost). The demo transport does the same check, so the existing demo regression now asserts the hint. ### Validation - `bun test server/alert-webhook.test.ts src/lib/i18n.test.ts server/push.test.ts`: 124 pass (the two new tests fail on main: one alert reached the new destination; `reachable_link` was missing and the link pointed at 127.0.0.1). - `bun scripts/alert-webhook-demo-regression.ts` with screenshots: PASS at 390 and 1280, light and dark. - `bun run check fast` at the head: pass (11953 unit tests, typecheck, build). - Not run locally: integration/browser lanes beyond the alert-webhook demo regression, Windows. A pre-PR Codex review found that an IPv4-mapped loopback origin (`[::ffff:127.0.0.1]`, which `URL` writes as `[::ffff:7f00:1]`) still counted as reachable, and that the demo's loopback check differed from the server's; both are fixed in the second commit with a test.
Fixes #2920
What
Settings → Alerts → Also send to: one destination this PC also posts its pane alerts to.
?pane=…&view=chat,machine=for another PC). The link base is the origin of the browser that saved the destination.alert-webhook.jsonin the state dir throughwritePrivateState(0600). It is never answered back; the view shows only its host (discord.com/…). The secret field is an uncontrolled password input (src/AGENTS.md).mutating && !ownPreferencesrule). A Portal visitor cannot set one either: the routes are standing access, like push subscriptions.Routes (shared/alert-webhook.ts):
GET/PUT/DELETE /api/alerts/webhook,POST /api/alerts/webhook/test.Out of scope: an inbound bot (answering from Slack or Telegram), as the issue says. Including the question or answer text is left out entirely rather than added as an opt-in: push alerts do not carry that text today, so there is nothing to opt into yet.
Design: none of the reference apps (Codex, Claude, Paseo, T3 Code, Zed, Warp, Conductor) has outbound chat alerts. The form follows the app's own write-only secret pattern from Settings → Voice input → OpenAI API key (password field, Save, masked state), with Alerts' existing per-event controls reused.
Screenshots
390 and 1280, light and dark, captured from the demo by
scripts/alert-webhook-demo-regression.ts(UI_EVIDENCE_DIR); the script also runs in the browser lane (scripts/ci-browser.sh).Validation
bun test server/alert-webhook.test.ts server/open-access.test.ts server/dispatch.test.ts server/push.test.ts: 116 pass (alert-webhook: 17 now). Covers the format of each preset, masking and 0600, refused URLs and tokens, retry with a single waiting slot, no retry on 4xx, the routes, and push → webhook timing, choices and the in-use hold. The push integration test failed before the push.ts change.bun test server/push.test.ts server/push-health.contract.test.ts server/conversation-push.contract.test.ts server/core/status.test.ts: 156 pass.bun test src/lib/i18n.test.ts src/conventions.test.ts: pass.bun run typecheck: pass.bun scripts/alert-webhook-demo-regression.ts: PASS at 390/1280, light/dark.bun run check fast: pass at the head (11892 unit tests, 0 fail).check fulland the Windows/Mac jobs (left to CI).Review round
omo and Codex (Terra, xhigh) reviewed 1a682b1. The fixes are in the next commit, each with a test that failed first:
canDeliverbefore every try, also after a restart.CodeRabbit hit its review limit on this PR.