Skip to content

Implement Reliability Epic: Reminders v2 - Web Push + Service Worker + Offline Sync#28

Open
Copilot wants to merge 5 commits intomasterfrom
copilot/reliable-reminders-web-push-sync
Open

Implement Reliability Epic: Reminders v2 - Web Push + Service Worker + Offline Sync#28
Copilot wants to merge 5 commits intomasterfrom
copilot/reliable-reminders-web-push-sync

Conversation

Copy link

Copilot AI commented Sep 9, 2025

This PR delivers a comprehensive push notification and offline synchronization system for SymptomSync, transforming basic reminders into a reliable, production-ready notification platform that works even when the app is closed.

🔔 Key Features

Reliable Push Notifications

  • OS-level notifications using Web Push API with VAPID authentication
  • Works even when all browser tabs are closed
  • Action buttons for quick responses (Mark Taken, Snooze, Dismiss)
  • Multi-device support with automatic subscription management

Offline-First Architecture

  • Complete offline functionality for creating/editing medications and appointments
  • Background sync with automatic retry until success
  • IndexedDB-based queue system for pending changes
  • Real-time sync status indicators in the UI

Smart Scheduling

  • Timezone-aware reminder processing with DST handling
  • Do-Not-Disturb windows (e.g., 22:00–07:00) with overnight period support
  • Configurable snooze presets (10min, 30min, 2hr by default)
  • Per-notification-type controls (medications, appointments, logs)

🏗️ Technical Implementation

Database Schema

  • user_push_subscriptions: Stores Web Push subscription data with device identification
  • notification_events: Tracks notification delivery status and user interactions
  • user_settings: Extended with timezone, DND preferences, and snooze configuration
  • Row-level security policies for data protection

Service Worker (public/sw.js)

  • Push notification handling with rich action buttons
  • Background sync for offline queue processing
  • IndexedDB management for persistent storage
  • Message passing with main thread for real-time updates

Backend APIs

  • /api/notifications/subscribe|unsubscribe: Manage push subscriptions
  • /api/notifications/action: Handle notification interactions (taken/snooze/dismiss)
  • /api/cron/process-reminders: Scheduled reminder dispatch system
  • /api/admin/test-notification: Development testing endpoint

Frontend Components

  • NotificationSettings: Comprehensive settings UI with device management
  • NotificationStatus: Real-time status indicator for navigation
  • useNotifications: React hook for app-wide notification state
  • Settings page with tabbed interface for user preferences

🔧 Setup & Configuration

VAPID Keys Generation

node scripts/generate-vapid-keys.js

Environment Variables

  • NEXT_PUBLIC_VAPID_PUBLIC_KEY: Public VAPID key for client-side use
  • VAPID_PRIVATE_KEY: Private key for server-side push sending
  • VAPID_EMAIL: Contact email for push service
  • CRON_API_KEY: Security token for cron endpoint access

Cron Job Integration
The system includes built-in support for various deployment platforms:

  • Vercel Cron configuration
  • External webhook support
  • API key authentication for security

🛡️ Security & Privacy

  • JWT token authentication for all API endpoints
  • Row-level security policies restricting access to user's own data
  • Encrypted push subscriptions with P256DH/Auth keys
  • Rate limiting and input validation on all endpoints
  • Minimal data exposure in notification payloads

📱 Browser Support

  • Chrome/Edge: Full support
  • Firefox: Full support
  • Safari: iOS 16.4+ required for push notifications
  • Mobile: Enhanced experience with "Add to Home Screen"

🧪 Testing

Includes comprehensive test coverage with:

  • Unit tests for core notification utilities
  • Mocked IndexedDB and Service Worker APIs
  • Admin testing endpoints for development
  • Proper error handling and edge case coverage

The system transforms SymptomSync from a basic reminder app into a truly reliable health companion that ensures users never miss their medication or appointments, regardless of connectivity or device status.

Fixes #27.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fonts.googleapis.com
    • Triggering command: /usr/local/bin/node /home/REDACTED/work/SymptomSync-Health-App/SymptomSync-Health-App/web/node_modules/next/dist/compiled/jest-worker/processChild.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link

vercel bot commented Sep 9, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
symptomsync-health-app Error Error Sep 9, 2025 1:24pm

Co-authored-by: hoangsonww <124531104+hoangsonww@users.noreply.github.com>
…on utilities

Co-authored-by: hoangsonww <124531104+hoangsonww@users.noreply.github.com>
@hoangsonww hoangsonww requested review from Copilot and hoangsonww and removed request for hoangsonww September 9, 2025 13:11
@hoangsonww hoangsonww added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers question Further information is requested labels Sep 9, 2025
@hoangsonww hoangsonww moved this from Backlog to In progress in SymptomSync App Project Board Sep 9, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements Phase 3 of the Reminders v2 implementation, focusing on Web Push notifications, Service Worker functionality, and offline synchronization capabilities. It establishes the foundational infrastructure for reliable reminder delivery with offline support.

  • Database schema creation with migrations for push subscriptions, notification events, and user settings
  • Complete API infrastructure for subscription management and notification actions
  • Full service worker implementation with push handling and background sync
  • Comprehensive notification utilities library with IndexedDB support for offline functionality

Reviewed Changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
web/scripts/generate-vapid-keys.js VAPID key generation script for Web Push setup
web/public/sw.js Service worker with push notification handling and offline queue management
web/pages/api/notifications/*.ts API routes for subscription management and notification actions
web/package.json Dependencies for web-push, IndexedDB, and TypeScript support
web/lib/notifications.ts Notification utilities and service worker integration functions
web/.env.example Environment variable configuration for VAPID keys and settings
supabase/*.sql Database schema files for notifications infrastructure
supabase/migrations/*.sql Migration file consolidating all notification-related tables
Files not reviewed (1)
  • web/package-lock.json: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}

function generateId(): string {
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

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

The substr method is deprecated. Use substring instead for better compatibility.

Suggested change
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
return `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;

Copilot uses AI. Check for mistakes.

// Generate unique ID
function generateId() {
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

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

The substr method is deprecated. Use substring instead for better compatibility.

Suggested change
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
return `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;

Copilot uses AI. Check for mistakes.
Co-authored-by: hoangsonww <124531104+hoangsonww@users.noreply.github.com>
… documentation

Co-authored-by: hoangsonww <124531104+hoangsonww@users.noreply.github.com>
Copilot AI changed the title [WIP] Reliability Epic: Reminders v2 - Web Push + Service Worker + Offline Sync Implement Reliability Epic: Reminders v2 - Web Push + Service Worker + Offline Sync Sep 9, 2025
Copilot AI requested a review from hoangsonww September 9, 2025 13:25
@hoangsonww hoangsonww marked this pull request as ready for review October 23, 2025 13:55
@hoangsonww hoangsonww moved this from In progress to Ready in SymptomSync App Project Board Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested

Projects

Status: Ready

Development

Successfully merging this pull request may close these issues.

Reliability Epic: Reminders v2 - Web Push + Service Worker + Offline Sync

3 participants