Repository navigation
Mobile polish, phase 3: Web Push when a timer phase ends + app badge - #26
Merged
Merged
Conversation
- Push notifications when a focus countdown reaches its target or a pomodoro phase ends (break started / waiting, back to focus / next round waiting), to every device that opted in; nothing for stopwatches, pauses or phases the user ends by hand. - VAPID keys generated on first use and stored in the new single-row push_config table; push_subscriptions (one per device, deleted on revoke); migration 0007_web_push. No new required env var. - Hand-written WebCrypto VAPID (ES256) + RFC 8291 aes128gcm (matches the RFC example byte for byte); endpoint allowlist of known push services as SSRF guard; 404/410 removes a subscription, other failures are recorded and logged. - Scheduler: one setTimeout re-armed from every published timer snapshot; pomodoro rollovers publish their phase end after commit; one push per event key (DB compare-and-set), also across restarts. - API /api/push (GET/POST/DELETE) and /api/push/test; service worker push, notificationclick and pushsubscriptionchange handlers. - Settings → Notifications (install hint on iOS Safari, denied, off, on with Send test / Turn off; hidden in the desktop app); app icon badge = today's open tasks while notifications are on. - Tests: unit (allowlist, body validation, event planning, texts, crypto, settings state) and e2e push.spec.ts against a local fake push service. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Otherwise a device subscribing later got the stale event on the next timer change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
The timer runs on the server, but on the iPhone you only noticed a phase end while the app was open. Since iOS 16.4, home-screen web apps can receive Web Push. This PR adds:
How it works
push_config. There is no new required env var.ORIGIN).push_subscriptions, one per device. Re-subscribing replaces it, and it stores the device's language for theautosetting.revokeDevice()deletes the device's subscriptions.server/push-crypto.ts): VAPID ES256 and RFC 8291 aes128gcm, written with WebCrypto. No new dependency. It reproduces the RFC 8291 example byte for byte, and its output decrypts the same way asweb-push@3.6.7's.isAllowedPushEndpointin#lib/push.ts):web.push.apple.com,*.push.apple.com,fcm.googleapis.com,(*.)push.services.mozilla.com,*.notify.windows.com;LIBE_PUSH_TEST_ENDPOINT_ORIGINallows a loopback origin.server/push-scheduler.ts):setTimeout, re-armed from every timer snapshot the server broadcasts, so every change path is covered; it also re-arms from the DB on startup (inithook);Urgency: high,Topic: libe-timer. A 404/410 deletes the subscription; other failures are recorded and logged once, with no retries./focus. It also updates the badge from the payload and re-subscribes onpushsubscriptionchange. Caching rules are unchanged.openTodaycomes from the root layout load and is set only while this device has notifications on, because iOS ties badges to notification permission.Notification texts (body = the task title)
Migration:
0007_web_push.Screenshots
iPhone 390×844 (Chromium emulation). Headless Chromium has no push service, so the "off" and "on" states stub the permission and
PushManager; the section and the API are real.Desktop: after-settings-desktop.png
Tests
nextPushEvent(countdown and pomodoro sequences, pause shifts, idempotency keys), texts,notificationsState, and RFC 8291 encryption and VAPID.bun run testreports 453 pass.push.spec.ts, using a local fake push endpoint that decrypts each payload with the test's own keys:check0 errors / 0 warnings,lintclean,buildOK (also without.env).test:e2e92 passed, 6 skipped.test:e2e:mobile48 passed, 8 skipped.🤖 Generated with Claude Code