Commit Graph
853 Commits
Author SHA1 Message Date
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
Lucas Berger 5b1f3cefdc chore(graphify): rebuild knowledge graph at d521839 — 4090 nodes, 4249 edges, 427 communities
Captures the Phase 4 lists + live-sync subsystem. Rebuilt via graphify update
(AST re-extraction, 257 files).
2026-06-09 14:59:59 -04:00
Lucas Berger d521839a40 docs(intel): refresh codebase intelligence at 99f59c3 — capture Phase 4 lists + live-sync
Stale intel reflected commit 01f7456 (pre-Phase-4). Refresh adds the shared-lists
+ SSE subsystem: 21 API endpoints (was 10), lists/sse routes, listEmitter/listAccess/rank
libs, PWA lists surface, 7 new arch decisions, and Phase 4 deps (react-router, @dnd-kit,
fractional-indexing). Canonical filenames preserved; API-SURFACE.md + .last-refresh.json regenerated.
2026-06-09 14:57:27 -04:00
Lucas Berger 99f59c3999 test(04): complete UAT — 11 passed, 0 issues, 1 skipped (multi-user D-04, covered by route tests) 2026-06-09 14:48:53 -04:00
Lucas Berger fa71cf1a30 docs(04): re-verify phase 04 after gap-closure — 4/4 verified, 0 threats open
LIST-03 collation gap closed, T-04-05 + T-04-08 closed by plan 04-07.
Phase 04 sign-off complete.
2026-06-09 14:32:54 -04:00
Lucas Berger ae115c65ef chore(04-07): commit drizzle migration metadata for 0002 collation migration
The 0002_yielding_mattie_franklin.sql migration was committed but its
drizzle-kit journal entry and snapshot were left untracked. Without these,
drizzle-kit cannot track the migration as applied.
2026-06-09 14:26:52 -04:00
Lucas Berger ffaa44a9be docs(04-07): complete gap-closure plan — LIST-03 + T-04-08 closed, Phase 04 done
- 04-07-SUMMARY.md: documents rank-collation fix + owner-only guard, 184/184 tests
- STATE.md: Phase 04 marked complete (7/7 plans), progress 100%, decisions added
- ROADMAP.md: 04-07-PLAN.md checked off
2026-06-09 14:25:43 -04:00
Lucas Berger c0bd6d732d fix(04-07): add owner-only guard for isShared on PATCH /api/lists/:id (T-04-08)
- Immediately after access check, return 403 if patch.isShared !== undefined
  and !access.isOwner — blocks sharees from mutating list_shares
- Guard message: 'Only the list owner can change sharing settings'
- Sharees may still PATCH { name } (rename test stays green)
- Update stale comment: 'Reconcile list_shares on visibility change (owner only)'
- Closes T-04-08 (elevation of privilege) and T-04-05 (shared root cause)
2026-06-09 14:22:48 -04:00
Lucas Berger 931f767922 test(04-07): add failing sharee-403 tests for T-04-08 owner-only isShared guard
- T-04-08 test 1: sharee PATCH { isShared: false } must get 403 and
  list_shares row unchanged (currently 200 + shares wiped — bug)
- T-04-08 test 2: sharee PATCH { isShared: true } must get 403 and
  no new shares inserted (currently 200 + shares fan-out — bug)
- Both tests fail now; GREEN once owner-only guard added to lists.ts
2026-06-09 14:22:21 -04:00
Lucas Berger 9b860617c5 feat(04-07): migrate list_items.rank to COLLATE utf8mb4_bin (LIST-03)
- Add varcharBin customType helper emitting varchar(255) COLLATE utf8mb4_bin
- Replace listItems.rank varchar with varcharBin to carry explicit binary collation
- Generate migration 0002_yielding_mattie_franklin.sql: ALTER TABLE list_items
  MODIFY COLUMN rank varchar(255) COLLATE utf8mb4_bin NOT NULL (additive, no DROP)
- Apply migration via db:migrate (never db:push, per project memory constraint)
- utf8mb4_bin ensures uppercase-prefixed ranks (e.g. Zz) sort before lowercase
  ranks (e.g. a0) in DB ORDER BY, matching JS string order — closes LIST-03 gap
2026-06-09 14:21:42 -04:00
Lucas Berger ece663d1df test(04-07): add failing collation regression test (LIST-03)
- Seed items with ranks 'a0' and 'a1', drag second to top via rank 'Zz'
- Assert 'Zz' < 'a0' is true in JS (documents uppercase-before-lowercase intent)
- GET /api/lists/:id/items must return Zz-ranked item at index 0
- Fails now because MariaDB utf8mb4_uca1400_ai_ci sorts 'Zz' after 'a0'
- Will pass once rank column gets COLLATE utf8mb4_bin via migration
2026-06-09 14:19:27 -04:00
Lucas Berger 797338424d docs(04): gap-closure plan 04-07 (rank collation + isShared owner guard) 2026-06-09 14:07:14 -04:00
Lucas Berger 469c40f9b5 docs(phase-04): add security threat verification (13/14 closed, T-04-08 open) 2026-06-09 14:01:23 -04:00
Lucas Berger 0b736fea0c docs(04): add code review report 2026-06-09 13:56:45 -04:00
Lucas Berger be2078e21f docs(phase-04): verification — 3/4 verified, LIST-03 rank-collation gap deferred to gap-closure 2026-06-09 13:49:58 -04:00
Lucas Berger 690f0b95c0 refactor(04): move rank.test.ts into tests/ mirror dir (convention + dist hygiene)
src/lib/rank.test.ts was the last co-located API test. The API tsconfig excludes
tests/ from the build, so all test files belong there; a test in src/ gets compiled
into dist/ and vitest then runs the stale compiled copy (the source of phantom
'22 todo' and dist sourcemap warnings). Moving it to tests/lib/ matches convention
and leaves zero test files in src/, so the production build no longer emits test
artifacts. Updated rank.test.ts path refs in phase-04 plan docs.
2026-06-09 13:40:11 -04:00
Lucas Berger ca9e97879f docs(04-06): complete live-sync SSE vertical slice plan 2026-06-09 13:35:49 -04:00
Lucas Berger 1652a68c51 feat(04-06): implement live-sync SSE vertical slice (LIST-04, D-04/D-10/D-11/D-12)
- Wire publishListEvent fan-out in lists.ts after every write mutation (item:added/updated/deleted, list:updated/deleted)
- Add GET /api/sse/lists scoped endpoint in sse.ts: resolveUserId → 401 on null; getAccessibleListIds → subscribe only to accessible channels; 30s heartbeat; cleanup on disconnect (D-04/T-04-01/T-04-02)
- Create useListSSE.ts: bounded-backoff EventSource wrapper (250ms→500ms→1s→2s→4s→cap 8s); MAX_ATTEMPTS=6; withCredentials:true; close-before-retry prevents reconnect storm (Pitfall 3); invalidates ['list', listId] on open (D-10) and on each event; onStateChange('disconnected') after exhaustion (D-11)
- Create LiveSyncIndicator.tsx: connected=green dot; reconnecting=pulsing muted dot + label; disconnected=red dot + 'Updates paused' (role=alert); correct ARIA per UI-SPEC
- Wire useListSSE + LiveSyncIndicator into ListDetail header; retain refetchInterval:30000 polling fallback (D-12)
- All 8 useListSSE tests pass; all 54 API tests pass; both typechecks pass
- playwright-cli: live update confirmed (eggs item added via API appeared in browser without manual refresh)
2026-06-09 13:33:04 -04:00
Lucas Berger 5a8d1efe1c test(04-06): add failing RED tests for LIST-04 SSE fan-out + bounded backoff
- API: 5 failing fan-out spy tests (subscribeListEvents receives 0 events since publishListEvent seams commented out in lists.ts)
- API: 4 D-04 scoped subscription tests (green — listAccess primitives from 04-02 already proven)
- PWA: useListSSE.test.ts — all 7 tests fail (module-not-found; hook not yet created)
- Covers: item:added/updated/deleted, list:updated/deleted fan-out + D-11 bounded backoff exhaustion + D-10 reconnect invalidation
2026-06-09 13:25:39 -04:00
Lucas Berger f12093c910 docs(04-05): complete drag-to-reorder plan 2026-06-09 13:19:35 -04:00
Lucas Berger ef4b1157b3 test(04-05): server-side reorder ordering + rank precision tests (LIST-03, D-13)
- rank.test.ts: 100-iteration zipper mid-point insert precision test (Pitfall 2);
  rank-between-neighbors contract test; total 10 tests (was 8)
- lists.test.ts: 5 new LIST-03 ordering tests — PATCH position updates only rank
  and GET returns new ASC order; one-row write asserts other items unchanged;
  LWW (D-15): second PATCH overwrites first; T-04-07 two-field position PATCH → 400
- Note: tests use a0–a5 rank range (avoids uppercase ranks that sort differently
  under MariaDB utf8mb4_unicode_ci vs JS lexicographic order)
2026-06-09 13:17:35 -04:00
Lucas Berger d49c5f1c9c feat(04-05): dnd-kit drag-to-reorder active items (LIST-03, D-13/D-14/D-15)
- ItemRow: useSortable with drag listeners scoped to GripVertical handle only;
  CSS transform animation for remote reorders (D-14); grabbing cursor when dragging
- ListDetail: DndContext/SortableContext over active items; PointerSensor (immediate),
  TouchSensor (200ms delay + 5px tolerance — no accidental scroll drags),
  KeyboardSensor (accessibility fallback)
- onDragEnd: computes generateKeyBetween(prevRank, nextRank) at destination, fires
  optimistic setQueryData then PATCHes { position: newRank } — one-row write (D-13)
- Rollback on PATCH error restores previous order via onError (D-15 LWW convergence)
- Completed items receive no drag handle (not reorderable per UI-SPEC)
2026-06-09 13:13:11 -04:00
Lucas Berger 8ed105d467 docs(04-04): complete item-CRUD vertical slice plan 2026-06-09 13:04:48 -04:00
Lucas Berger 6da9c2ae7b feat(04-04): add ListDetail with active/completed split + ItemRow + AddItemInput (LIST-02)
- listsClient.ts: add fetchListItems, addItem, patchListItem, deleteItem + ListItemsResponse type
- ListDetail.tsx: replace placeholder with real implementation — useQuery(['list', listId])
  with 30s polling fallback (D-12); active/completed split (D-05); optimistic mutations (D-07);
  delete-wins no-rollback (D-09); per-field check PATCH (D-08)
- ItemRow.tsx: 44px touch target, checkbox (20px visual/44px touch, accent fill when checked),
  plain-text item text (T-04-06 XSS guard), GripVertical handle slot for Plan 05,
  hover Trash2 delete + swipe-left zone, transform 150ms ease-out animation slot (D-14)
- AddItemInput.tsx: sticky bottom input + Add button, disabled when empty, Enter key support
- ListDetail.test.tsx: 7 real tests replacing todo stubs — optimistic add/check/uncheck/delete,
  rollback on error, D-05 completed-sink split, D-09 delete-wins no-rollback
- Playwright browser check: add milk → sinks to Completed on check → vanishes on delete PASS
2026-06-09 13:01:49 -04:00
Lucas Berger 5e3151416c feat(04-04): implement item CRUD endpoints + fractional rank (LIST-02)
- Add rank.ts: rankForAppend/rankBetween wrapping fractional-indexing (D-13)
- Extend listsRouter: POST /:id/items (fractional rank at active-bottom),
  GET /:id/items (rank ASC, access-gated)
- Add listItemsRouter (mounted /api/list-items): PATCH /:itemId per-field LWW
  (exactly-one-field zod refine D-08/T-04-07), DELETE /:itemId delete-wins (D-09)
- Uncheck recomputes rank to active-bottom in same write (Open Question 2)
- All item handlers: access-gate via checkListAccess (T-04-05)
- Plan 06 SSE seam comments at each mutation handler
- All 48 tests green; typecheck passes
2026-06-09 12:55:32 -04:00
Lucas Berger b1dc9b8048 test(04-04): add failing tests for item CRUD endpoints + rank helpers
- Add rank.test.ts: unit tests for rankForAppend/rankBetween (RED - no impl yet)
- Extend lists.test.ts with item route tests: POST /:id/items, GET /:id/items,
  PATCH /list-items/:id (per-field LWW D-08), DELETE /list-items/:id (D-09)
- Import listItems from schema; add seedItem helper
- Tests cover: fractional rank assignment (D-13), exact-one-field refine (T-04-07),
  uncheck rank recompute, access gating T-04-05, delete-wins no resurrection D-09
2026-06-09 12:52:34 -04:00