Skip to content

feat: claim status notifications with permission UX, polling backoff, and SSE - #256

Merged
jhayniffy merged 2 commits into
InsurNiffy:mainfrom
darcszn:feat/claim-status-notifications
Mar 28, 2026
Merged

feat: claim status notifications with permission UX, polling backoff, and SSE#256
jhayniffy merged 2 commits into
InsurNiffy:mainfrom
darcszn:feat/claim-status-notifications

Conversation

@darcszn

@darcszn darcszn commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

Closes #94


Summary

Implements optional browser notifications and in-app toasts for claim status changes on watched claims.

Changes

Frontend

File Change
useNotificationPermission.ts One-time permission request helper — localStorage flag prevents re-prompting after denial or dismissal
useClaimWatcher.ts Polls /api/claims/status with exponential backoff (base 15 s, cap 60 s); pauses when tab is hidden (Page Visibility API); resumes immediately on tab focus
useNotifications.ts Privacy-safe lock-screen copy; in-app toast fallback when permission not granted; per-claim mute() / snooze() controls; new useClaimStatusNotifications hook
NotificationPermissionBanner.tsx One-time banner with clear value explanation; ClaimNotificationsToggle for full feature disable
ClaimsBoard.tsx Wires banner, toggle, watcher, and status-change notifications

Backend

File Change
claims.controller.ts GET /api/claims/status (polling, throttled 30 req/min); GET /api/claims/status/stream (SSE with 25 s heartbeat, throttled 5 conn/min)
claims.service.ts getClaimStatuses(), subscribeToStatusChanges(), publishStatusChange() (static, call from indexer/queue)

Docs

  • docs/claim-notification-latency.md — latency budget table, agreed SLO, battery impact, indexer lag, multi-instance note

Acceptance Criteria

  • Users who deny permission are not re-prompted on subsequent visits
  • Status changes surface within agreed max delay (SLO: 2 min, see latency doc)
  • Feature can be fully disabled via ClaimNotificationsToggle
  • Notification copy does not leak sensitive details on shared/locked screens
  • Polling pauses when tab is hidden (battery impact considered)
  • Exponential backoff prevents tight retry loops on failure

Notes

  • The SSE pub/sub uses an in-process listener registry. For multi-instance deployments, replace ClaimsService.statusListeners with a Redis pub/sub channel (noted in code and docs).
  • ClaimsService.publishStatusChange() is the integration point for the indexer — call it whenever a claim status changes in the DB.

… and SSE

- Add useNotificationPermission: one-time prompt, localStorage denial memory,
  no nag loops across sessions
- Add useClaimWatcher: polls /api/claims/status with exponential backoff
  (base 15s, cap 60s), pauses on Page Visibility hidden, battery-conscious
- Update useNotifications: privacy-safe lock-screen copy, in-app toast
  fallback, per-claim mute/snooze controls, useClaimStatusNotifications hook
- Add NotificationPermissionBanner: value-prop explanation, single ask,
  ClaimNotificationsToggle for full feature disable via settings
- Wire ClaimsBoard to banner, toggle, watcher, and status-change notifications
- Backend: GET /api/claims/status (polling) and GET /api/claims/status/stream
  (SSE with heartbeat) endpoints; in-process pub/sub with Redis note
- Add docs/claim-notification-latency.md: latency budget, SLO (2 min),
  battery impact, indexer lag, multi-instance deployment guidance
@drips-wave

drips-wave Bot commented Mar 28, 2026

Copy link
Copy Markdown

@darcszn Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@jhayniffy
jhayniffy merged commit 7456124 into InsurNiffy:main Mar 28, 2026
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.

Frontend — Notifications UX: polling/SSE, permission prompts, respectful backoff

2 participants