fix(web): notifications dismiss integrity and feed-consistent badge #3

Merged
pregno merged 2 commits from fix/notifications-integrity into main 2026-06-11 23:57:36 +02:00
Owner

Fixes two Important findings from the repo-wide review:

  1. Dismiss failures are no longer silent. dismissAlert/dismissMarketAlert now throw on !res.ok (matching the rest of client.ts); Clear all uses Promise.allSettled and re-throws so react-query reports failures, while onSettled invalidation still reconciles the UI to server truth; mutation errors render in the Notifications card using the same pattern as Trading.

  2. Clear-all and the nav badge now agree. Previously Clear all dismissed only the collapsed (latest-per-symbol) feed items, leaving older same-symbol alerts new on the server, while the badge counted all new signal alerts and ignored market alerts — yielding an empty feed under a stuck badge. Now:

    • New bulk endpoints POST /api/alerts/dismiss-all and POST /api/market-alerts/dismiss-all (optional zod-validated { before }), backed by parameterized Drizzle updates.
    • Clear all calls the two bulk endpoints instead of N per-item dismisses.
    • buildFeed/collapseBySymbol extracted to src/lib/notifications.ts; the badge derives from the same buildFeed over both alert types, so it counts exactly what the feed shows.

Note: badge semantics change from raw ackStatus === "new" count to feed length (collapsed, both kinds) — equivalent in practice since nothing sets acknowledged.

New tests: 6 server route tests (bulk dismiss, before boundary, bad body), client tests for throw-on-error and bulk paths, container tests for Clear all via FakeEventSource + fetch stub, badge-consistency test. Full repo 307 tests green; typecheck clean.

Fixes two Important findings from the repo-wide review: 1. **Dismiss failures are no longer silent.** `dismissAlert`/`dismissMarketAlert` now throw on `!res.ok` (matching the rest of client.ts); Clear all uses `Promise.allSettled` and re-throws so react-query reports failures, while `onSettled` invalidation still reconciles the UI to server truth; mutation errors render in the Notifications card using the same pattern as Trading. 2. **Clear-all and the nav badge now agree.** Previously Clear all dismissed only the collapsed (latest-per-symbol) feed items, leaving older same-symbol alerts `new` on the server, while the badge counted all new signal alerts and ignored market alerts — yielding an empty feed under a stuck badge. Now: - New bulk endpoints `POST /api/alerts/dismiss-all` and `POST /api/market-alerts/dismiss-all` (optional zod-validated `{ before }`), backed by parameterized Drizzle updates. - Clear all calls the two bulk endpoints instead of N per-item dismisses. - `buildFeed`/`collapseBySymbol` extracted to `src/lib/notifications.ts`; the badge derives from the same `buildFeed` over both alert types, so it counts exactly what the feed shows. Note: badge semantics change from raw `ackStatus === "new"` count to feed length (collapsed, both kinds) — equivalent in practice since nothing sets `acknowledged`. New tests: 6 server route tests (bulk dismiss, `before` boundary, bad body), client tests for throw-on-error and bulk paths, container tests for Clear all via FakeEventSource + fetch stub, badge-consistency test. Full repo 307 tests green; typecheck clean.
POST /api/alerts/dismiss-all and /api/market-alerts/dismiss-all with an
optional zod-validated { before } body (dismiss everything with ts <= before).
Backed by Repositories.dismissAllAlerts/dismissAllMarketAlerts.
- dismissAlert/dismissMarketAlert now throw on non-ok responses, matching the
  rest of client.ts (failures were silently swallowed and the UI looked cleared)
- Clear all uses the new bulk dismiss-all endpoints instead of N per-item
  dismisses, so server-side older same-symbol alerts can no longer stay 'new'
- clear mutations invalidate on settled (not just success) so the UI
  reconciles to server truth after a failure; errors render in the card the
  same way Trading surfaces its mutation errors
- buildFeed/collapseBySymbol extracted to lib/notifications; the nav badge now
  derives from buildFeed over both alert types, counting exactly what the
  Notifications feed shows (market alerts previously never badged)
pregno force-pushed fix/notifications-integrity from d1d6ced63f to cd50808d04 2026-06-11 18:36:03 +02:00 Compare
pregno force-pushed fix/notifications-integrity from cd50808d04 to 512ef3211a 2026-06-11 18:46:58 +02:00 Compare
pregno merged commit 7b754b4a34 into main 2026-06-11 23:57:36 +02:00
pregno deleted branch fix/notifications-integrity 2026-06-11 23:57:36 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pregno/polymarket-screener!3
No description provided.