Skip to content

fix(alerts): keep pending alerts off a new webhook destination and keep a reachable link base - #2965

Merged
devswha merged 4 commits into
mainfrom
fix/alert-webhook-2943
Nov 5, 2026
Merged

devswha merged 4 commits into
mainfrom
fix/alert-webhook-2943

Conversation

@devswha

@devswha devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner

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.

…a reachable link base

An alert scheduled before the destination changed no longer goes to the
new one: push.ts records the destination's generation when it schedules
the alert, and the webhook drops it if the destination changed since.

A save from this PC's own loopback address no longer replaces a saved
base other devices can open. The view says whether messages carry such
a link, and the form tells the user when none is known yet.

Fixes #2943
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 30 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between de76154 and 8769a6d.

Files selected for processing: 11

  • changelog.d/alert-webhook-pending-and-link.md
  • scripts/alert-webhook-demo-regression.ts
  • server/alert-webhook.test.ts
  • server/alert-webhook.ts
  • server/push.ts
  • shared/alert-webhook.ts
  • site/demo/transport.ts
  • src/components/AlertWebhookGroup.tsx
  • src/lib/i18n/settings.ja.ts
  • src/lib/i18n/settings.ko.ts
  • src/lib/i18n/settings.zh.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Review round (omo + Codex Terra xhigh), resolved in this PR:

  • Codex MEDIUM (pre-PR): an IPv4-mapped loopback origin ([::ffff:127.0.0.1], normalized by URL to [::ffff:7f00:1]) counted as reachable and replaced a good link base. Fixed in 4f05206 with a test.
  • Codex LOW (pre-PR): the demo's loopback check differed from the server's (*.localhost). Fixed in the same commit.
  • Codex MEDIUM: a save from http://0.0.0.0:7317 or http://[::]:7317 replaced a good link base and reported it reachable. Fixed in 41a1b80; the test fails on the previous commit (http://[::]:7317/... instead of the saved base).
  • Codex LOW: the demo missed localhost. (DNS root dot). Fixed in 41a1b80.
  • omo review at 4f05206: CLEAR.

Validation at the head: bun run check fast pass after merging origin/main; bun test server/alert-webhook.test.ts 19 pass; bun scripts/alert-webhook-demo-regression.ts PASS at 390/1280 light/dark (before the last commit, which changed only the demo regex's extra cases). CodeRabbit has not been asked again for this fix round.

@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Local merge gate (owner-approved): bun run check fast passed at this head, omo CLEAR, Codex MEDIUMs fixed with failing-first tests, threads resolved, merges cleanly. Fixes #2943. Merged without waiting for GitHub CI.

@devswha
devswha merged commit 359db68 into main Nov 5, 2026
17 of 18 checks passed
@devswha
devswha deleted the fix/alert-webhook-2943 branch November 5, 2026 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alert webhooks: a pending alert can reach a newly set destination; a loopback save resets the link base

1 participant