Fix PWA push notifications and add Icelandic WOD support#136
Merged
Conversation
Fixes #134 ## Critical Bug Fixes ### 1. Subscription Data Structure Mismatch - Subscribe endpoint saves nested JSONB: `{ subscription: { endpoint, keys } }` - CRON jobs expected flat structure: `{ endpoint, p256dh_key, auth_key }` - Updated all CRON jobs to parse nested structure correctly ### 2. Supabase Client Scope Issues - Helper functions in CRON routes referenced `supabase` out of scope - Fixed by passing supabase client as parameter to helper functions ### 3. Missing Test Notification Endpoint - Created `/api/admin/test-push-notification` endpoint - Allows users to test push notifications from settings ### 4. Service Worker Missing Push Handlers - Added custom worker directory with push event handlers - Handles push, notificationclick, and pushsubscriptionchange events - Updated next.config.ts to use customWorkerDir ## New Features ### Icelandic Word of Day Support - Added Icelandic word list (27 words) - Added Icelandic content dictionary with real examples - Updated all WOD API routes to accept 'icelandic' language - Added Icelandic notification strings in CRON job ## Files Changed - app/api/cron/daily-notifications/route.ts - app/api/cron/welcome-notifications/route.ts - app/api/cron/daily-word-generation/route.ts - app/api/admin/test-push-notification/route.ts (NEW) - app/api/generate-word-of-day/route.ts - app/api/word-of-day/route.ts - app/api/word-of-day/fresh-sentences/route.ts - lib/mastra/tools/wordOfDay.ts - lib/mastra/workflows/wordOfDayGeneration.ts - next.config.ts - worker/index.js (NEW) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code expected ELEVEN_LABS_API_KEY but GCP secrets use ELEVENLABS_API_KEY. Updated to match deployed configuration. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add supabase client initialization to POST handler (was undefined) - Add comprehensive dark mode styling to word-of-day page 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add 🇮🇸 Íslenska button to language toggle - Add Icelandic header: "Orðið dagsins" - Add Icelandic section headers: Skilgreiningar, Dæmi - Support icelandic sentence display in examples 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update check constraint to allow 'icelandic' language for Word of Day. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Owner
Author
✅ UAT CompleteTests PerformedPWA Installation
Push Notifications (Partial)
Word of Day - Icelandic Support
Supabase Scope Fix
Fixes Cherry-Picked from UAT
Migrations Required
Notes
Ready to merge 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #134
Root Causes Fixed
1. Subscription Data Structure Mismatch (CRITICAL)
Subscribe endpoint saved nested JSONB
{ subscription: { endpoint, keys: { p256dh, auth } } }but CRON jobs expected flat structure{ endpoint, p256dh_key, auth_key }.2. Supabase Client Scope Issue
Helper functions in CRON jobs referenced
supabasevariable declared in outer GET handler scope.3. Missing Push Event Handlers
Service worker auto-generated by Workbox lacked push and notificationclick event handlers.
4. Missing Test Endpoint
NotificationSettings UI called non-existent
/api/admin/test-push-notification.Changes Made
app/api/cron/daily-notifications/route.tsapp/api/cron/welcome-notifications/route.tsapp/api/cron/daily-word-generation/route.tsapp/api/admin/test-push-notification/route.tsworker/index.jsnext.config.tscustomWorkerDir: 'worker'lib/mastra/tools/wordOfDay.tsapp/api/generate-word-of-day/route.tsapp/api/word-of-day/route.tsapp/api/word-of-day/fresh-sentences/route.tslib/mastra/workflows/wordOfDayGeneration.tsTest Plan
UAT: Push Notifications
TC1: Android Chrome
TC2: iOS Safari PWA
TC3: Desktop Browser
UAT: Icelandic WOD
TC4: Generate Icelandic Word
Expected: Returns Icelandic word with definitions
TC5: Fetch Icelandic Word
curl "https://staging.example.com/api/word-of-day?language=icelandic"Expected: Returns word data for Icelandic
Verification Checklist
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com