Skip to content

fix(aggregator): alerts push UX — permission flow, quiet-hours off, test button, primary nav - #3707

Merged
dezren39 merged 1 commit into
mainfrom
fix/alerts-push-ux
Nov 1, 2026
Merged

dezren39 merged 1 commit into
mainfrom
fix/alerts-push-ux

Conversation

@dezren39

@dezren39 dezren39 commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Fix build on #3676 from Drew's phone report (2026-11-01) — six defects:

  1. Unsupported browser was a dead-end line. The /alerts panel now shows plain steps, variant by UA: iPhone → open in Safari, Share → Add to Home Screen, open from the icon, enable push there; in-app/other browser → open the address in the real browser. (Installability itself verified: manifest display=standalone, 192/512 + maskable icons, apple-touch-icon + apple-mobile-web-app-capable already served.)
  2. 'notification permission: default' error: push-client threw notification permission: <raw value> and the page alert()ed it. The client now throws coded errors only (denied / dismissed / unsupported / subscribe-failed / save-failed); the page renders plain words per state. The permission request still runs inside the Enable tap, before subscribing.
  3. Quiet hours can be turned OFF — a checkbox stores enabled:false in the existing quiet jsonb (no migration); inQuietHours returns false when disabled; the time inputs disable while off.
  4. Plain-language controls: 'Incident alerts — a watchdog reports something down. Always delivered immediately.'; 'Quiet hours — pause non-urgent notifications overnight… Incident alerts always come through immediately, quiet hours or not.' The bare 'quiet' label is gone from the panel and the subscription rows ('quiet hours off' / 'quiet hours 23:00–07:00 …').
  5. Test button: 'Send a test alert' → POST /api/push/test sends a real Web Push (clearly a test) to all current subscriptions and records alerts.notification_sends rows with class test; the outcome is reported in plain words ('Test sent to N subscriptions' / 'No subscriptions yet — enable push first').
  6. Navigation: /alerts is primary-tier in the manifest (Drew's ruling supersedes the post-dashboard: clean up the page list (12 registered pages, overlaps to resolve) #1497 dropdown placement; curation test updated to record it) and /attention links to it.

Also: the alerts page opens with this browser's saved preferences applied to the controls, and push-client.js is cache-busted (?v=push-ux-2026-11-01) so phones pick up the fixed permission flow without waiting out the old 1h asset cache.

Tests: full aggregator suite 882 pass / 0 fail (new: quiet-off merge + inQuietHours-disabled, test-payload shape, sendTestPush sends-row recording incl. the zero-subscription case; curation table flipped).


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

…est button, primary nav (#3676)

Drew's phone report, six defects:
- unsupported-browser line was a dead end; now plain steps (iOS:
  Safari → Share → Add to Home Screen → open from the icon; in-app
  browser: open in the real browser), variant picked by UA.
- Enable threw 'notification permission: default' and the page
  alert()ed it. The client now throws coded errors only and the page
  renders plain words per state (blocked / prompt dismissed / ...);
  the request still runs inside the tap handler, before subscribing.
- quiet hours gain an OFF switch (quiet jsonb {enabled:false}, no
  migration); inQuietHours returns false when disabled and the time
  inputs disable with it.
- every control on the panel carries a one-line explanation in plain
  language; the bare 'quiet' label is gone.
- 'Send a test alert' button → POST /api/push/test sends a real push
  (class 'test') to all subscriptions and records notification_sends
  rows; the result is reported in plain words.
- /alerts promoted to the primary nav (Drew's ruling supersedes the
  post-#1497 dropdown placement) + a link from /attention.
@dezren39
dezren39 requested a review from a team as a code owner November 1, 2026 13:44
@coderabbitai

coderabbitai Bot commented Nov 1, 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 56 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 44eec03b-dbb6-4361-b2ed-401e21bb2b86
Commits

Reviewing files that changed from the base of the PR and between a9318ea and aaef868.

Files selected for processing: 7
  • pm-stack/aggregator/src/alerts.ts
  • pm-stack/aggregator/src/assets/push-client.js
  • pm-stack/aggregator/src/pages.ts
  • pm-stack/aggregator/src/render.ts
  • pm-stack/aggregator/src/server.ts
  • pm-stack/aggregator/test/alerts.test.ts
  • pm-stack/aggregator/test/curation-1497.test.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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T13:47:36.671888Z aaef868 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aaef86894f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<table><caption>Recent alert-ledger transitions</caption><tr><th scope="col">at</th><th scope="col">kind</th><th scope="col">incident</th><th scope="col">source · key</th></tr>${events}</table>`;
const script = `<script>
const VAPID = ${JSON.stringify(vapidPublicKey)};
const SUBS = ${JSON.stringify(view.subscriptions.map((s) => ({ endpoint: s.endpoint, classes: s.classes, quiet: s.quiet })))};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Escape subscription JSON before embedding it in the script

A subscription submitted through /api/push/subscriptions can contain a quiet.tz value such as </script><script>alert(document.domain)</script>: validateNewSubscription passes it through mergeQuiet, which accepts any nonempty string. Embedding that stored value here with only JSON.stringify lets the HTML parser terminate the script and execute attacker-controlled JavaScript whenever someone visits /alerts. Previously these values were HTML-escaped in subscription rows. Escape < in the serialized JSON before inserting it into the script.

Useful? React with 👍 / 👎.

Comment on lines +5654 to +5658
if (!window.pmPush || !window.pmPush.supported()) {
status.textContent = "Push isn't available in this browser yet — the steps below get it working.";
guide.hidden = false;
const pf = window.pmPush && window.pmPush.platform ? window.pmPush.platform() : { ios: false };
document.getElementById("push-guide-ios").hidden = !pf.ios;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Initialize the push panel after the deferred client loads

On a normal /alerts load, layout() places the deferred push-client.js before this non-deferred inline script, so the immediate refreshStatus() call runs before window.pmPush exists. This branch therefore always selects the generic unsupported-browser guide, even on iPhone, and returns without ever applying the newly added saved preferences. Nothing refreshes the panel when the client subsequently loads, so saved incident/quiet-hours choices remain displayed as checked defaults and can be overwritten by Save preferences. Run the initial refresh after the deferred client has executed, such as on DOMContentLoaded.

Useful? React with 👍 / 👎.

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.

1 participant