Created: 2025-12-22Documentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
Status: 📋 Recommendations
Related Specs: PF-10 (Notifications System), PF-36 (System Health Dashboard)
Executive Summary
Recommendations for push notification infrastructure and inbox/notification UI. The stack already covers in-app notifications, realtime updates, and basic push subscriptions; the items below target production readiness and UX gaps.Current State Assessment
✅ What’s Working Well
-
Core Infrastructure:
- Multi-channel notification system (in-app, email, SMS, push)
- Real-time notification updates via Supabase subscriptions
- Notification preferences per type and channel
- Template system with variable substitution
- Delivery tracking (pending, sent, delivered, read, failed)
- RLS policies for multi-tenant isolation
-
UI Components:
- NotificationCenter dropdown with unread count badge
- NotificationsPage with filtering, search, and bulk actions
- NotificationItem with read/unread states
- Category-based filtering (forms, tasks, automation, compliance, risk, system)
- Bulk selection and actions (mark as read, delete)
-
Push Infrastructure (Partial):
- Push subscription management (
usePushSubscriptionhook) - PushNotificationSettings component
- Database schema for push subscriptions
- Edge functions for save/remove subscription
- Push subscription management (
⚠️ Critical Gaps
-
Push Notifications Not Functional:
send-push-notificationedge function has TODO for web-push library- No service worker push event handler
- VAPID keys not fully integrated
- No push notification payload handling
-
Missing Features:
- No notification grouping/threading
- No quick actions from notifications
- No notification sounds/vibration
- No priority/urgency levels
- No notification scheduling
- Limited mobile optimization
- No notification badges on app icon
-
UX Improvements Needed:
- No notification preview/expand
- No notification history beyond current list
- No notification analytics
- Limited accessibility features
- No notification delivery retry logic
Priority Recommendations
🔴 P0: Critical for Production
1. Complete Push Notification Implementation
Current Issue: Push notifications are partially implemented but not functional. Recommendations:-
Integrate web-push library in edge function:
-
Add service worker push event handler:
-
Add notification click handler:
-
Fix multi-tenancy security issue:
- Change
pf_push_subscriptions.endpointfromUNIQUEtoUNIQUE (user_id, endpoint) - Add UPDATE RLS policy
- Update upsert to use composite conflict key
- Change
supabase/functions/send-push-notification/index.tssupabase/migrations/(new migration for schema fix)public/sw.jsor VitePWA service worker configsupabase/functions/save-push-subscription/index.ts
2. Notification Grouping and Threading
Problem: Related notifications (e.g., multiple form submissions) clutter the inbox. Recommendations:-
Add grouping logic:
-
Update UI to show grouped notifications:
- Show count badge on grouped items
- Expand/collapse to see individual notifications
- “Mark all as read” for group
src/platform/notifications/utils/notificationGrouping.tssrc/platform/notifications/components/NotificationGroup.tsxsrc/platform/notifications/NotificationItem.tsx(update to support groups)
3. Notification Quick Actions
Problem: Users must navigate to detail pages to take action on notifications. Recommendations:-
Add action buttons to notifications:
-
Implement action handlers:
- Call appropriate API endpoints
- Update notification status
- Show loading states
- Handle errors gracefully
-
Add action buttons to NotificationItem:
- Show actions on hover/click
- Mobile-friendly touch targets (44x44px)
src/platform/notifications/utils/notificationActions.tssrc/platform/notifications/hooks/useNotificationActions.tssrc/platform/notifications/NotificationItem.tsx
🟠 P1: High Priority Enhancements
4. Notification Priority and Urgency
Recommendations:-
Add priority levels to schema:
-
Visual indicators:
- Urgent: Red border, pulse animation
- High: Orange border
- Normal: Default styling
- Low: Muted styling
-
Push notification behavior:
- Urgent:
requireInteraction: true, sound, vibration - High: Sound, no vibration
- Normal: Silent (respect quiet hours)
- Low: Batched delivery
- Urgent:
supabase/migrations/(new migration)src/platform/notifications/NotificationItem.tsxsrc/platform/notifications/utils/notificationTypes.tssupabase/functions/send-push-notification/index.ts
5. Notification Sounds and Vibration
Recommendations:-
Add sound preferences:
-
Implement sound playback:
-
Add vibration API:
src/platform/notifications/utils/soundManager.tssrc/platform/notifications/NotificationToastProvider.tsxsrc/platform/notifications/NotificationCenter.tsx
6. Mobile Optimization
Recommendations:-
Bottom sheet for mobile:
- Replace dropdown with bottom sheet on mobile (<768px)
- Full-screen notification page on mobile
- Swipe gestures (swipe right to mark read, left to delete)
-
Touch targets:
- Ensure all interactive elements are 44x44px minimum
- Add haptic feedback on iOS
-
PWA badge updates:
src/platform/notifications/NotificationCenter.tsxsrc/platform/notifications/NotificationsPage.tsxsrc/platform/notifications/NotificationItem.tsxsrc/platform/notifications/useNotifications.ts
7. Notification Delivery Retry Logic
Recommendations:-
Implement exponential backoff:
-
Add retry queue:
- Store failed notifications in retry queue
- Process queue with exponential backoff
- Mark as permanently failed after max attempts
supabase/functions/send-pending-notifications/index.ts(enhance existing)supabase/migrations/(add retry tracking columns)
🟡 P2: Nice to Have
8. Notification Analytics
Recommendations:-
Track metrics:
- Delivery rates by channel
- Read rates by type
- Time to read
- Action rates (click-through)
- Unsubscribe rates
-
Add analytics table:
-
Dashboard view:
- Show analytics in notification preferences page
- Charts for delivery/read rates
- Export to CSV
supabase/migrations/(analytics table)src/platform/notifications/components/NotificationAnalytics.tsxsrc/platform/notifications/hooks/useNotificationAnalytics.ts
9. Notification Scheduling
Recommendations:-
Add scheduled delivery:
-
Respect quiet hours:
- Delay delivery during quiet hours
- Batch low-priority notifications
- Send urgent notifications immediately
-
Scheduled notification processor:
- Cron job to check for scheduled notifications
- Process in batches
- Handle timezone conversions
supabase/migrations/(add columns)supabase/functions/process-scheduled-notifications/index.tssrc/platform/notifications/utils/scheduling.ts
10. Notification History and Archive
Recommendations:-
Add archive functionality:
-
Archive view:
- Separate tab for archived notifications
- Auto-archive after 90 days
- Search archived notifications
-
Export functionality:
- Export to CSV
- Include read/delivery timestamps
- Filter by date range
supabase/migrations/(add columns)src/platform/notifications/NotificationsPage.tsxsrc/platform/notifications/hooks/useNotifications.ts
11. Notification Templates UI
Recommendations:-
Template management page:
- List all templates (platform + org)
- Create/edit templates
- Preview with sample data
- Test template rendering
-
Template variables:
- Show available variables per type
- Variable picker in editor
- Syntax highlighting for template syntax
src/platform/notifications/NotificationTemplatesPage.tsxsrc/platform/notifications/components/TemplateEditor.tsxsrc/platform/notifications/hooks/useNotificationTemplates.ts
12. Enhanced Accessibility
Recommendations:-
Screen reader support:
- Announce new notifications
- Describe notification content
- Announce actions taken
-
Keyboard navigation:
- Full keyboard support for notification center
- Keyboard shortcuts (e.g.,
Nfor notifications) - Focus management
-
High contrast mode:
- Support for high contrast themes
- Color-blind friendly indicators
- Text alternatives for icons
src/platform/notifications/NotificationCenter.tsxsrc/platform/notifications/NotificationItem.tsxsrc/platform/notifications/NotificationsPage.tsx
Implementation Roadmap
Phase 1: Critical Fixes (Week 1-2)
- ✅ Complete push notification implementation
- ✅ Fix multi-tenancy security issue
- ✅ Add service worker push handlers
- ✅ Notification grouping
Phase 2: Core Enhancements (Week 3-4)
- ✅ Quick actions
- ✅ Priority/urgency levels
- ✅ Sounds and vibration
- ✅ Mobile optimization
Phase 3: Reliability (Week 5)
- ✅ Retry logic
- ✅ Delivery tracking improvements
- ✅ Error handling
Phase 4: Advanced Features (Week 6-8)
- ✅ Analytics
- ✅ Scheduling
- ✅ Archive/history
- ✅ Template UI
Security Considerations
Critical Security Fixes
-
Push Subscription Multi-Tenancy:
- Issue:
endpointUNIQUE constraint allows cross-user hijacking - Fix: Change to
UNIQUE (user_id, endpoint)+ UPDATE RLS policy - Priority: P0 - Critical
- Issue:
-
VAPID Key Management:
- Store keys as Supabase secrets (not in code)
- Rotate keys periodically
- Use different keys per environment
-
Notification Data Validation:
- Sanitize notification content (prevent XSS)
- Validate action URLs (prevent open redirect)
- Rate limit notification creation
Performance Considerations
-
Real-time Subscription Optimization:
- Use Supabase filters to reduce payload size
- Debounce notification updates
- Batch UI updates
-
Notification List Virtualization:
- Use
react-windoworreact-virtuosofor long lists - Lazy load notification details
- Paginate notification history
- Use
-
Push Notification Batching:
- Batch multiple notifications per user
- Use notification groups
- Rate limit push delivery
Testing Recommendations
Unit Tests
- Notification grouping logic
- Priority/urgency calculations
- Sound/vibration preferences
- Action handlers
Integration Tests
- Push subscription flow
- Notification delivery
- Retry logic
- Multi-device sync
E2E Tests
- Complete notification flow (create → deliver → read)
- Push notification delivery
- Quick actions
- Mobile interactions
Metrics and Success Criteria
Key Metrics
- Push Notification Delivery Rate: >95%
- Notification Read Rate: >70% within 24 hours
- Action Rate: >30% (for actionable notifications)
- User Satisfaction: >4.0/5.0 (survey)
Success Criteria
- ✅ Push notifications work on all supported browsers
- ✅ Zero security vulnerabilities
- ✅ <2s notification delivery latency
- ✅ Mobile UX matches desktop quality
- ✅ 99.9% notification delivery reliability
References
- PF-10: Notifications System Spec
- PF-36: System Health Dashboard Spec
- Web Push Protocol
- Service Worker API
- Notification API
Last Updated: 2025-12-22
Next Review: After Phase 1 implementation