Commit Graph
428 Commits
Author SHA1 Message Date
Lucas Berger 1044de57ae test(05-review): add CR-01/WR-01 reminder pruning tests and IN-01 actor-name tests 2026-06-09 22:30:03 -04:00
Lucas Berger 50da9b3bca fix(05-review): IN-01 resolve actor display name in eventChangeDispatcher for D-02/D-03 2026-06-09 22:25:32 -04:00
Lucas Berger 8cecbab7ab fix(05-review): CR-02 change endpoint/p256dh to varchar to prevent InnoDB prefix-index truncation 2026-06-09 22:24:23 -04:00
Lucas Berger 82eccc9017 fix(05-review): CR-04 pre-fetch VAPID key into state; no await before pushManager.subscribe 2026-06-09 22:24:00 -04:00
Lucas Berger e5f7b1ab7c fix(05-review): CR-03 notificationclick uses matchAll+focus+navigate for deep-link URLs 2026-06-09 22:22:27 -04:00
Lucas Berger 7702f7e19a fix(05-review): CR-01+WR-01 prune sentReminders after each scan and mark-sent after dispatch 2026-06-09 22:22:04 -04:00
Lucas Berger f058aefb88 fix(05-review): WR-04 collect delete changes after db.delete to avoid race in sync fan-out 2026-06-09 22:21:37 -04:00
Lucas Berger 814d29dbdd fix(05-review): WR-05 re-confirm push subscription server-side on health-check mount 2026-06-09 22:21:16 -04:00
Lucas Berger 76e0fb9588 fix(05-review): IN-03 use useId() instead of Math.random() for headingId in PushPermissionPrompt 2026-06-09 22:21:05 -04:00
Lucas Berger bf64a0a0e1 fix(05-review): IN-02 add empty-string fallbacks for VAPID env vars in docker-compose 2026-06-09 22:20:50 -04:00
Lucas Berger c69bd30aaa fix(05-review): WR-03 log error.message not raw error in push route catch blocks 2026-06-09 22:20:43 -04:00
Lucas Berger b666b1d114 fix(05-review): WR-02 remove unused 'and' import from listChangeDispatcher 2026-06-09 22:20:30 -04:00
Lucas Berger e496b5e00a docs(05-07): complete eventChangeDispatcher + syncCalendar diff plan 2026-06-09 22:06:14 -04:00
Lucas Berger 30e9de13f9 feat(05-07): implement eventChangeDispatcher + syncCalendar diff/title/onChanges
- Create eventChangeDispatcher.ts: dispatchEventChange + isMeaningfulChange
- D-04: description-only edits are silent; meaningful fields = title/dtstartUtc/dtstartDate/allDay/location
- D-03: actor excluded via ne() + application-level filter; all subs filtered by userId != actorUserId
- D-13: reads only push_subscriptions from MariaDB — no tsdav/Fastmail I/O
- syncCalendar: add optional onChanges callback; populate title from VEVENT SUMMARY on every upsert
- syncCalendar: pre-upsert SELECT to detect add vs update; track changedFields; prune emits deletes
- poller: pass onChanges with actor=cred.userId (external changes from other member)
- outboxWorker.triggerTargetedResync: pass onChanges with actor=userId (this-member writes)
- All 4 eventChangeDispatcher tests + 14 sync tests GREEN
2026-06-09 22:03:52 -04:00
Lucas Berger 4ef6333201 docs(05-08): complete opt-out + reliability surface plan 2026-06-09 21:53:33 -04:00
Lucas Berger 010a69c047 feat(05-08): PermissionDeniedBanner + App mount + CalendarShell onOpenSettings wiring
- Create PermissionDeniedBanner.tsx: role=alert banner shown only when
  permission=denied AND notificationsEnabled=1 (OS-revoked case, D-10)
  with AlertCircle icon, 'Notifications blocked' heading, inline 'How to enable'
  button that opens OS-specific instruction sheet (iOS 4-step / Android 4-step)
- Mount PermissionDeniedBanner and SettingsSheet in App.tsx; wire onOpenSettings
  state from avatar tap through CalendarShell → AppNav → PhoneNav/DesktopNav
- CalendarShell accepts optional onOpenSettings prop, threads to both AppNav usages
- playwright-cli verified: banner renders with exact UI-SPEC copy when
  permission=denied+was-enabled; banner absent when permission=granted;
  'How to enable' opens instruction sheet with correct Android steps;
  SettingsSheet opens from avatar click with toggle + permission-denied hint
2026-06-09 21:50:48 -04:00
Lucas Berger 1de4aa5a3e feat(05-08): SettingsSheet (master toggle D-09) + AppNav avatar promoted to button
- Create SettingsSheet.tsx: bottom sheet (role=dialog, z:301, Escape+backdrop-close)
  with FamilySync Notifications toggle (role=switch, aria-checked, 44px target)
  wired to usePushSubscription setEnabled + permission state
  and inline permission-denied hint (AlertCircle + 'How to enable') when denied
- Promote PhoneNav avatar div to button with onOpenSettings onClick + aria-label
- Add onOpenSettings prop to DesktopNav; add avatar button at sidebar bottom
- Thread onOpenSettings through AppNavProps
- Add @keyframes spin to tokens.css (fixes missing keyframe used by SettingsSheet + SyncStateToast)
2026-06-09 21:45:59 -04:00
Lucas Berger 458d6e4fef feat(05-08): extend usePushSubscription with isSubscribed, setEnabled, permission state (D-10)
- Add isSubscribed state (true when pushManager has active subscription)
- Add setEnabled(on) master toggle: off=unsubscribe, on+granted=silent subscribe, on+default/denied=no-op
- Health-check now respects readNotificationsDisabled() — skip re-subscribe if user explicitly disabled
- Export readNotificationsEnabled for PermissionDeniedBanner/SettingsSheet initial state
- Remove dead readNotificationsEnabled local-only usage (was unused in returned interface)
- persistNotificationsEnabled(false) now writes '0' instead of removing key for explicit off state
2026-06-09 21:43:31 -04:00
Lucas Berger 8e741cf528 docs(05-06): complete reminderScheduler plan 2026-06-09 21:40:22 -04:00
Lucas Berger b95f671485 feat(05-06): implement reminderScheduler — shared timed 15-min reminder scan
- Create apps/api/src/broker/reminderScheduler.ts:
  - runReminderCheck(now): queries isShared=true + allDay=false events
    with dtstartUtc in [now+14min, now+16min] via calendarEvents→calendars→
    pushSubscriptions cross-join (2 innerJoins; fans out to all subscribers)
  - In-memory sentReminders Set keyed uid:minuteBucket prevents double-fire
    at window boundary (D-06, T-05-18)
  - Per-event and per-subscription try/catch for error isolation (T-05-19)
  - Null title fallback (event.title ?? uid) — handles rows before Plan 05-07
  - Empty shared-calendar set produces zero sends and no crash (D-16)
  - startReminderScheduler(): node-cron 1-min schedule wrapping runReminderCheck
- Wire startReminderScheduler() into index.ts isMainModule() guard after
  startOutboxWorker() and VAPID setVapidDetails (NOTIF-01)
- Tests: 3/3 GREEN (all-day excluded, non-shared excluded, dedup)
2026-06-09 21:38:32 -04:00
Lucas Berger 9b04528fd6 docs(05-05): complete list-change push plan 2026-06-09 21:29:09 -04:00
Lucas Berger d2ce4e08c7 feat(05-05): hook notifyListChange into list/item mutations (reorder excluded)
- POST /:id/items (item added) → notifyListChange
- PATCH /list-items/:itemId checked/text → notifyListChange; position-only → silent (D-01)
- DELETE /list-items/:itemId → notifyListChange
- PATCH /:id (list rename/share toggle) → notifyListChange
- DELETE /:id (list delete) → notifyListChange
- POST / (list create) → no notification (empty list, D-01 spirit)
- lists.test.ts: 2 new tests prove reorder-silent (position) and check-notifies (NOTIF-02)
- All 59 lists.test.ts assertions GREEN
2026-06-09 21:26:29 -04:00
Lucas Berger 69231043e4 feat(05-05): implement listChangeDispatcher — access-scoped, self-suppressed, coalesced push (NOTIF-02)
- notifyListChange(listId, actorId, windowMs?) wraps coalesceListPush with a
  dispatch closure that resolves actor name + list name from DB, builds
  audience as owner ∪ list_shares MINUS actorId (D-03), and calls
  dispatchPush per accessible subscriber subscription
- D-02 generic copy: '{Actor} made {N} changes to {ListName}' — no item text
- D-03 self-suppression: actorId filtered from audience before subscription load
- T-05-14: audience strictly scoped to list access (owner + list_shares only)
- T-05-15: no item text in notification body
- Empty audience and missing subscriptions are silent no-ops
- Tests: 5/5 GREEN (burst→1 push, self-suppress, access scope, empty audience)
2026-06-09 21:24:48 -04:00
Lucas Berger 97f7026095 test(05-05): add failing tests for listChangeDispatcher — RED gate
- burst coalescing: N calls → 1 dispatchPush to non-actor with count=N
- D-03 self-suppression: actor's own subscription never dispatched
- T-05-14 access scoping: unrelated user (no owner/share) excluded
- empty audience (no other members): no dispatch, no crash
- empty audience (other member has no subscription): no dispatch, no crash
2026-06-09 21:20:34 -04:00
Lucas Berger 60c247d8ed docs(05-04): complete push vertical slice plan 2026-06-09 21:16:23 -04:00
Lucas Berger d816f79271 fix(05-04): wrap setVapidDetails in try/catch to prevent startup crash on bad VAPID key
- Bad/truncated VAPID_PRIVATE_KEY logs a warning instead of crashing the server
- API still starts and serves all other routes; push dispatch fails with a log message
2026-06-09 21:13:58 -04:00
Lucas Berger bf8f63b47c feat(05-04): usePushSubscription hook + PushPermissionPrompt + App mount
- Create apps/pwa/src/hooks/usePushSubscription.ts: subscribe (in tap handler, VAPID key cached), unsubscribe, permission; health-check on mount (D-10); urlBase64ToUint8Array helper; prefetchVapidKey export
- Create apps/pwa/src/components/PushPermissionPrompt.tsx: WalkthroughSheet-style bottom sheet, Bell icon, 'Stay in the loop' heading, 48px Enable CTA (var(--color-member-0)), 44px Not-now ghost, no backdrop-dismiss, pushPermissionDismissed key, Loader2 spinner while awaiting
- Mount PushPermissionPrompt in App.tsx (for installed-PWA path) and InstallPrompt.tsx (for post-Android-install justInstalled path)
- Build green; tsc clean
2026-06-09 21:09:41 -04:00
Lucas Berger e5953ebb31 feat(05-04): SW migration to injectManifest with push + notificationclick + denylist
- Migrate vite.config.ts from generateSW to injectManifest (strategies, srcDir, filename)
- Add rolldownOptions.output.format=iife to produce sw.js (not sw.mjs) matching registerSW.js
- Create apps/pwa/src/sw.ts: skipWaiting+clientsClaim (autoUpdate), precacheAndRoute, NavigationRoute denylist (/callback,/api/,/health)
- Push handler: dual-format payload parsing (iOS 18.4+ declarative + legacy), ALWAYS event.waitUntil(showNotification) — never silent (D-11)
- notificationclick: close notification, focus existing window or openWindow to deep-link URL (D-14)
- Build verified: dist/sw.js contains showNotification, waitUntil, callback denylist, notificationclick
2026-06-09 21:06:32 -04:00
Lucas Berger f6f1374904 feat(05-04): push subscription API + VAPID startup wiring
- Create apps/api/src/routes/push.ts: GET /vapid-public-key, POST /subscription (upsert), DELETE /subscription (user-scoped)
- Wire pushRouter at /api/push in index.ts
- Call webpush.setVapidDetails() in isMainModule() guard before serve()
- Fix broken vi.getMockImplementation scaffold bug in push.test.ts (Rule 1)
- push.test.ts: all 4 tests GREEN
2026-06-09 21:04:16 -04:00
Lucas Berger f07c85d0c9 docs(05-03): complete pushCoalescer TDD plan 2026-06-09 21:00:22 -04:00
Lucas Berger c1758de05e feat(05-03): implement pushCoalescer — per-(list,actor) sliding debounce (D-01/D-03)
- module-level Map<string, {count, timer}> keyed by ${listId}:${actorId}
- sliding window: each call within window resets timer and increments count
- fires dispatch(listId, actorId, count) once on timer expiry; map entry self-deletes
- actorId passed as second arg so caller can apply excludeUserId=actorId (D-03)
- default windowMs=45000; injected dispatch keeps module pure and testable
2026-06-09 20:58:42 -04:00
Lucas Berger 7af827a9b9 test(05-03): add actorId assertion in burst test — fix unused var lint warning 2026-06-09 20:58:01 -04:00
Lucas Berger fc6f534f0a docs(05-02): complete pushDispatcher TDD plan 2026-06-09 20:56:13 -04:00
Lucas Berger e4170b3823 feat(05-02): implement pushDispatcher — VAPID send + 410/404 prune
- buildPushBody: dual-format payload (iOS 18.4+ declarative + legacy)
- dispatchPush: calls webpush.sendNotification with TTL=300, urgency=normal
- Prunes push_subscriptions row on 410/404 from push service (D-11)
- Logs transient errors with [pushDispatcher] prefix; never throws to caller
- Default import for web-push (CommonJS — Pitfall 7)
2026-06-09 20:54:47 -04:00
Lucas Berger 4e0b06d3fd docs(05-01): mark NOTIF requirements complete in traceability 2026-06-09 20:52:35 -04:00
Lucas Berger 1cc08f1bf1 docs(05-01): complete Wave-0 foundation plan 2026-06-09 20:52:23 -04:00
Lucas Berger ef558b65be test(05-01): add Wave-0 RED scaffolds + VAPID fixture + setup truncation
- tests/fixtures/vapid.ts: static TEST_VAPID keypair for offline unit tests
- tests/lib/pushDispatcher.test.ts: RED — 410/404 prune + 201/5xx no-delete
- tests/lib/pushCoalescer.test.ts: RED — burst coalesce fires once with count=N; excludeUserId
- tests/broker/reminderScheduler.test.ts: RED — shared+timed filter; dedup by (uid,minuteBucket)
- tests/lib/eventChangeDispatcher.test.ts: RED — create/meaningful-update fires; description-only silent; actor excluded
- tests/routes/push.test.ts: RED — POST 201/401; DELETE removes rows; GET vapid-public-key
- test/setup.ts: import pushSubscriptions + add db.delete(pushSubscriptions) in afterEach
- all 5 RED files fail on missing-module (correct; implementations in Plans 05-02..05-06)
2026-06-09 20:50:35 -04:00
Lucas Berger 2cae72e9dd docs: capture todo - Gitea CI regression + Docker build/publish 2026-06-09 20:49:07 -04:00
Lucas Berger 73fcdaf075 feat(05-01): add push_subscriptions table + calendar_events.title column; VAPID env wiring
- schema.ts: new pushSubscriptions mysqlTable (user_id FK cascade, endpoint unique, p256dh, auth)
- schema.ts: add nullable title varchar(500) to calendarEvents after rawVevent (D-02/NOTIF-01)
- 0003_same_xavin.sql: CREATE TABLE push_subscriptions + ALTER calendar_events ADD title
- migration applied to dev DB via db:generate + db:migrate (NOT db:push per anti-pattern)
- docker-compose.yml: inject VAPID_PUBLIC_KEY/PRIVATE_KEY/SUBJECT into api environment block
- .env.example: document all three VAPID vars with placeholders + generation instructions
2026-06-09 20:47:44 -04:00
Lucas Berger 80bbdc1735 chore(05-01): install web-push and workbox push dependencies
- apps/api: add web-push@^3.6.7 (prod) + @types/web-push@^3.6.4 (dev)
- apps/pwa: add workbox-core, workbox-precaching, workbox-routing@^7.4.1 (dev)
- pnpm-lock.yaml updated for all three workspace packages
2026-06-09 20:47:35 -04:00
Lucas Berger ddc84f1ffc docs(05): finalize plan 05-07 (D-13 boundary) + add patterns doc 2026-06-09 20:34:15 -04:00
Lucas Berger 36fb929a40 docs(05): create phase plan 2026-06-09 18:44:55 -04:00
Lucas Berger dbf370b18c docs(05): mark research open questions resolved 2026-06-09 18:43:43 -04:00
Lucas Berger 1ecca03f53 docs(05): create phase 5 web-push plan (8 plans, 6 waves) 2026-06-09 18:39:05 -04:00
Lucas Berger 6a8b6e994c docs(phase-5): add validation strategy 2026-06-09 18:21:39 -04:00
Lucas Berger 7264a9880f docs(05): research phase web-push-notifications 2026-06-09 18:20:36 -04:00
Lucas Berger 3723286e9e docs(05): UI design contract for web-push-notifications phase
Specifies three new surfaces (permission prompt, settings sheet,
permission-denied banner) and notification copy templates for
NOTIF-01/02/03, all built from the existing Phase 2 token system.
2026-06-09 18:03:18 -04:00
Lucas Berger d136099dd8 wip: phase 5 web-push paused after discuss (ready to plan) 2026-06-09 15:15:18 -04:00
Lucas Berger 3bbfbbc383 docs(state): record phase 5 context session 2026-06-09 15:13:07 -04:00
Lucas Berger e74f24debf docs(05): capture phase context 2026-06-09 15:13:01 -04:00