Commit Graph
1010 Commits
Author SHA1 Message Date
Lucas Berger d89eb47483 docs(03): add code review report 2026-06-09 10:19:01 -04:00
Lucas Berger a348bdd815 docs(04): add validation strategy 2026-06-09 10:03:12 -04:00
Lucas Berger bc45bddac9 docs(04): research phase — lists schema, SSE fan-out, fractional-indexing, dnd-kit, react-router 2026-06-09 10:01:47 -04:00
Lucas BergerandClaude Sonnet 4.6 492b85e9dc docs(04): UI design contract for shared lists + live sync
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 09:43:32 -04:00
Lucas Berger f695cc014d wip: Phase 4 paused — discuss complete, entry gate cleared, ready to plan 2026-06-07 21:53:23 -04:00
Lucas Berger 9ee59065f1 docs(quick-260607-u8o): record SSE-over-Pangolin smoke test PASS 2026-06-07 21:51:38 -04:00
Lucas Berger 1329e19803 chore: merge executor worktree (worktree-agent-a0352288acbf5055f) 2026-06-07 21:50:53 -04:00
Lucas Berger 26655cf859 docs(260607-u8o): mark Gate 2 Part C SSE row + summary PASS
- Part C row C1: PENDING -> PASS (2026-06-08) with verbatim evidence
- Summary Part-C row: DEFERRED -> PASS (Phase 4 entry gate D-14 cleared)
2026-06-07 21:49:55 -04:00
Lucas Berger dea6cb65a1 docs(260607-u8o): mark Phase 1 UAT item 4 (SSE smoke) PASS
- Record SSE-over-Pangolin smoke PASS (2026-06-08) with verbatim evidence
- Update Summary: passed 0->1, pending 4->3
2026-06-07 21:49:30 -04:00
Lucas Berger 92585d78db docs(260607-u8o): pre-dispatch plan for record SSE smoke PASS 2026-06-07 21:48:25 -04:00
Lucas Berger ecdb2317c8 docs(state): record phase 4 context session 2026-06-07 21:32:10 -04:00
Lucas Berger 05e1c9e556 docs(04): capture phase context 2026-06-07 21:32:09 -04:00
Lucas Berger 35871cd8cf roadmap(06): add Phase 6 — UX Polish
phase.add appended the entry after the 999.x backlog (the decimal backlog
convention confused the auto-placement). Moved it into Phase Details before
## Progress, added it to the top checklist + Progress table + execution order,
gave it goal/success-criteria/candidate-scope (promotes backlog 999.2/3/6/7/8/9),
renamed the dir to 06-ux-polish, and bumped STATE to 6 phases (50%).
2026-06-07 19:28:34 -04:00
Lucas Berger cca5205173 chore(03): close Phase 03 — transition to Phase 04
- 03-08-SUMMARY (Gate 2 record) written; phase marked complete (12/12)
- ROADMAP: Phase 3 [x] complete 2026-06-07; REQUIREMENTS updated
- STATE: advanced to Phase 4, focus + progress corrected (backlog 999.x were
  miscounted as milestone phases → reset total_phases to 5, 60%)
- PROJECT.md evolved: event CRUD / OIDC login / iOS PWA install moved to
  Validated (Phase 3); D-17 logged; Android install + onboarding-provider-setup
  kept Active
- removed stale .continue-here + one-shot HANDOFF.json

Carried forward: B5 (Android install), Phase 4 SSE entry gate (D-14), backlog 999.3-999.9.
2026-06-07 19:24:33 -04:00
Lucas Berger d71b15cd02 docs(03): Gate 2 complete for Phase 03 scope — D3 recurring write verified, recurring-series delete confirmed
Weekly recurring create writes valid RRULE and recurred in Fastmail; repeat-bound
+ per-occurrence-duration UX gaps backlogged (999.7/999.8). Deleting the recurring
series cleared master + all occurrences in one delete. Remaining deferred by
design: B5 (Android), C (SSE smoke — Phase 4 entry gate).
2026-06-07 19:19:57 -04:00
Lucas Berger cee7f0bad0 docs(backlog): add 999.6-999.9 (all-day visual, form end-tracking + all-day edit off-by-one, recurrence bound, recurring series edit)
Captured from Gate 2 live testing 2026-06-07:
- 999.6 all-day events need distinct visual treatment
- 999.7 event form: auto-advance end when start moves; + latent all-day EDIT
  off-by-one (edit grows the event by a day — write/display convert inclusive
  <-> exclusive but the edit form does not)
- 999.8 recurrence bound (repeat-until/count) so a recurring event isn't one
  giant multi-month event; verify daily-vs-weekly selection
- 999.9 edit a recurring series (whole-series edit; per-occurrence already v1.x)
2026-06-07 19:13:08 -04:00
Lucas Berger f656a41d1c docs(03): Gate 2 substantially complete — A/B/D verified; only D3 quick confirm left
A2 (transparent SSO), B2/B3/B4 (iOS standalone + load-bearing standalone login),
D2 (all-day, after off-by-one fix) all PASS. Remaining: D3 weekly recurring
(quick). Deferred: B5 Android, C SSE (Phase 4 entry gate).
2026-06-07 18:40:01 -04:00
Lucas Berger d4d5327fc4 fix(calendar): all-day off-by-one (exclusive DTEND) + member color too close to shared rose
All-day: a single-day all-day event displayed across two days. iCal all-day
DTEND is EXCLUSIVE (1-day event = DTSTART:24/DTEND:25) and the server occurrence
carries that exclusive end, but Schedule-X treats all-day end as INCLUSIVE.
hydrateEvents now subtracts one day (clamped to >= start) so a 1-day event shows
on one day and an N-day event spans N days. Write path was already correct
(verified against stored VEVENTs). +regression test.

Color: a member's coral (#E8734A) was mistaken for the shared-family rose
(#F25C7A). Reorder COLOR_PALETTE so warm near-rose hues (amber, coral) are
assigned LAST; early members get cool, clearly-distinct colors (blue/green/teal).
2026-06-07 18:37:56 -04:00
Lucas Berger 29b8c02715 docs(03): Gate 2 progress — A3 distinct colors + iOS install verified; backlog 999.5 (provider setup)
A3 PASS (distinct colors after collision fix), B1 PASS (wife installed + logged
in on iPhone). Added backlog 999.5: first-login provider-setup prompt to attach
each member's own Fastmail app password (per-member personal calendar, D-09).
Remaining Gate 2: A2, B2/B3/B4, D2, D3 (quick operator confirms); B5/C deferred.
2026-06-07 18:15:51 -04:00
Lucas Berger f700182674 fix(auth): assign first UNUSED palette color (AUTH-03 distinct colors)
Gate 2 A3 fail: a second member (amelia) got the same color as the first (luc),
both #E8734A. Color was assigned by COUNT(*) % palette; a deleted spike user
shifted the count so two live members landed on the same slot. Replace with
'first palette color not already in use by another user' (fall back to count
round-robin only once the palette is exhausted) — guarantees distinct, stable
colors for up to palette length members. +1 regression test (deletion frees a
slot → next member fills it, no collision).
2026-06-07 18:14:20 -04:00
Lucas Berger cdb097c5b3 docs(03): record Gate 2 live-verification results (2026-06-07)
A1 (OIDC login → app), D1/D4/D5 (create/edit/delete round-trips), D6 (412
conflict), and /health-over-tunnel verified live this session via operator
browser testing + outbox evidence. Remaining: A2/A3 + D2/D3 (desktop, quick),
B (iOS device, load-bearing), C (SSE — Phase 4 entry gate per D-14).
2026-06-07 18:02:53 -04:00
Lucas Berger 86069b89c1 docs(backlog): promote session-timeout + event-reminder todos to backlog (999.3/999.4) 2026-06-07 18:01:18 -04:00
Lucas Berger 2e10752a59 fix(pwa): stop calendar remount/flash on re-render (Bug B root cause)
The calendar flashed whenever the event popup/form closed or a post-write events
refetch landed. Root cause: CalendarContent was a function component DEFINED
INSIDE CalendarShell's render and used as <CalendarContent />. A nested component
has a new identity every render, so React unmounted+remounted its whole subtree
— including <ScheduleXCalendar> — on ANY CalendarShell re-render. The earlier
Bug B work only minimized re-renders (Zustand selectors) to dodge this; the
resync-before-done fix made the post-write ['events'] refetch deliver changed
data again, so the remount/flash returned.

Fix: render the content as a plain JSX element value (const calendarContent)
referenced at both layout sites instead of a nested component type. Element
values reconcile in place across re-renders — no remount, no flash.
2026-06-07 17:55:56 -04:00
Lucas Berger ae9fd9d790 docs(todo): redirect to sign-in on session timeout instead of hanging
Captured from Gate 2 live testing: when the OIDC session expires mid-use, the
app hangs the action and shows a generic 'couldn't load events' instead of
recognizing the signed-out state and redirecting to /api/login. Re-auth is
currently only wired to the initial /api/me failure (one-shot).
2026-06-07 17:49:20 -04:00
Lucas Berger 2c8f1a28af fix(auth): self-healing displayName; drop synthetic Member<sub> from storage
The legend showed 'Member 972be1a3' because Authelia does not emit
name/preferred_username/email in the ID TOKEN (only at the userinfo endpoint),
and @hono/oidc-auth reads ID-token claims only. The real fix is an Authelia
claims_policy adding those claims to id_token for the familysync client.

App-side robustness so it self-heals once Authelia is fixed (no DB surgery):
- deriveDisplayName now returns null (not a synthetic 'Member <sub>') when no
  real claim is present, so we never persist an ugly sub string; the UI degrades
  to a generic 'Member'.
- upsertUser now tracks the IdP name authoritatively: a non-null displayName that
  differs from the stored value updates the row (blank/stale 'Member …'/email →
  real name on next login). A null value never overwrites a good stored name.
2026-06-07 16:17:17 -04:00
Lucas Berger 98753d8e34 fix(broker): reconcile deletes into cache + resync before marking outbox done
Two write-path cache bugs surfaced during Gate 2 live testing:

P1 (delete didn't work / ghost event): syncCalendar only UPSERTED events
present on Fastmail and never removed cache rows for events that disappeared.
A successful CalDAV delete left the row in calendar_events forever, so
GET /api/events kept returning it and the UI showed a ghost that 'wouldn't
delete' (even after refresh). Add a prune step: delete calendar_events rows for
this calendar whose uid is absent from the server response (scoped to cal.id so
it never touches another calendar or the other member's rows — BUG B). Empty
server result prunes the whole calendar's cache.

P2 (edit needed a manual refresh): the outbox worker marked a row 'done' BEFORE
triggerTargetedResync refreshed the cache. The PWA's SyncStateToast invalidates
['events'] the instant sync-status flips to 'done', so it refetched stale cache.
Re-sync first, then mark done — 'done' now guarantees the cache reflects the write.

Tests: +2 prune regressions (present-subset prune, empty-server prune-all).
2026-06-07 16:12:43 -04:00
Lucas Berger bb61d21c83 fix(pwa): gate events query on auth to stop OIDC state-cookie churn
Internal Server Error after returning from Authelia: processOAuthCallback threw
OAUTH_INVALID_RESPONSE ("unexpected state parameter") because the OIDC state
cookie no longer matched the state returned to /callback.

Root cause: eventsQuery (fetchEvents, redirect:'follow', retry:2) ran
concurrently with fetchMe on load. While unauthenticated, every /api/* request
hits the OIDC guard, which 302-redirects to Authelia AND sets a fresh state
cookie. fetchEvents could not follow the cross-origin redirect, so React Query
retried it up to 3x over ~3s — each retry overwriting the state cookie mid-login,
racing the single /api/login navigation that owns the real flow.

Fix: enabled: meQuery.isSuccess. Only fetchMe (redirect:'manual', retry:false)
touches a guarded endpoint while unauthenticated, so the top-level /api/login
navigation owns the state cookie uncontested. Realizes the documented design
intent that only fetchMe drives the login redirect.
2026-06-07 15:57:17 -04:00
Lucas Berger 69bc57221b docs(quick-260607-l6l): summary, state, handoff update + reminder-options todo
- 260607-l6l SUMMARY (executor + orchestrator review follow-ups)
- STATE.md: quick-task row + session continuity (edit/delete blocker resolved)
- HANDOFF.json: 3 write-path code bugs marked done; remaining = operator rebuild + Gate 2 human/device checkpoints
- new backlog todo: event-creation reminder/VALARM options
2026-06-07 15:39:43 -04:00
Lucas Berger a99ef1daae refactor(260607-l6l): extract shared deriveDisplayName helper (BUG 2 DRY)
The displayName claim-preference logic (name → preferred_username → email →
sub fallback) was duplicated verbatim in me.ts and events.ts resolveUserId.
Extract it to auth/user.ts as deriveDisplayName and use it in both call sites,
so the rule has one definition. Update the events.test.ts user.js mock to keep
the real helper (spread importActual) while stubbing only upsertUser.
2026-06-07 15:37:18 -04:00
Lucas Berger 509f4b26e0 test(260607-l6l): make BUG 1 join regression test couple to the handler
The original toSQL() regression test hand-built the joined query inside the
test body and asserted the SQL contained a join — tautological: it never
exercised the handler, so removing .innerJoin from events.ts left it green.

Replace it with two tests that issue real PATCH/DELETE requests against the
mocked select-chain (from → innerJoin → where) and assert the handler returns
202 (not 503) AND invokes the innerJoin spy. Verified RED: removing the
edit+delete joins fails both tests; GREEN with the joins present.
2026-06-07 15:34:39 -04:00
Lucas Berger 8b5ec797cf chore: merge executor worktree (worktree-agent-a62cd2d02a9defd0a) 2026-06-07 15:31:31 -04:00
Lucas Berger 00a0454514 fix(260607-l6l): scope GET /api/events to current user + shared calendars
BUG 3: GET / had no ownership predicate — it returned all users' events.
Second household member would see other member's private events.

- Resolve currentUserId at top of GET handler (same resolveUserId helper
  as write endpoints); return 401 if unauthenticated.
- Add ownership predicate to WHERE: AND (calendars.userId = currentUserId
  OR calendars.isShared = true). Combined with and() around the existing
  date-window or() block. Mirrors the /writable-calendars idiom (D-03).
2026-06-07 15:28:54 -04:00
Lucas Berger 23c8bb3402 fix(260607-l6l): derive displayName from OIDC claims in me.ts + resolveUserId
BUG 2: Both me.ts and events.ts resolveUserId were passing email (often
absent) as displayName to upsertUser, resulting in blank legend names.
Also, upsertUser returned existing rows unchanged even when displayName
was null and a better value was now available.

- me.ts: derive displayName via name → preferred_username → email →
  "Member <sub-prefix>" fallback, checked defensively. Updated JSDoc.
- events.ts resolveUserId: same derivation so write-path upserts don't
  re-blank a correctly-set displayName.
- user.ts: when existing row has null displayName and caller supplies one,
  issue an UPDATE so already-existing blank rows are corrected on next login.

Authelia-side emission of name/preferred_username is an operator concern
(claim mappings / userinfo scope in authelia config) — out of scope here.
The code now reads whatever claims are present and falls back sensibly.
2026-06-07 15:27:40 -04:00
Lucas Berger 28704132d0 fix(260607-l6l): add missing innerJoin to PATCH+DELETE event lookups
BUG 1: PATCH /:uid/edit and DELETE /:uid selected calendars.url/userId
from .from(calendarEvents) with no join, causing Drizzle to throw at
toSQL() time → 503. Added .innerJoin(calendars, ...) to both lookups,
mirroring the working GET / join idiom.

- Updated PATCH + DELETE beforeEach mocks to route through innerJoin→where
- Updated CR-01 PATCH test mock similarly
- Added regression: edit/delete lookups join calendars describe block with
  toSQL() assertions using vi.importActual (real drizzle, no DB needed)
- All 21 tests pass; typecheck clean
2026-06-07 15:25:31 -04:00
Lucas Berger 4e174e5b44 docs(260607-l6l): pre-dispatch plan for write-path correctness bugs 2026-06-07 15:18:38 -04:00
Lucas Berger 3ae7724df1 wip: phase 03 Gate 2 paused — live bring-up working; edit/delete join fix is the next blocker 2026-06-06 22:42:06 -04:00
Lucas Berger bdbb9b8324 docs(debug): resolve write-path-event-bugs (timezone + calendar identity) 2026-06-06 22:32:10 -04:00
Lucas Berger a9d3de658e fix(03): correct event-write timezone + per-user calendar identity (Gate 2 Part D)
BUG A — timed events written 4h off: EventForm sent a naive local wall-clock
string with no offset; the UTC API container parsed it via new Date() as UTC, so
09:00 America/Toronto serialized to DTSTART:...090000Z. Fix: new
apps/pwa/src/lib/eventDateTime.ts serializes timed events to an unambiguous UTC
instant in the browser (where the operator's zone is known); all-day stays a DATE
string. No backend change.

BUG B — created events attached to the wrong user's calendar + duplicate calendar
rows per poll: calendars had no unique key on url, and poller/sync matched
calendars by url alone — so under the shared single Fastmail account (D-16) one
member's collection resolved to the other member's row. Fix: composite
unique(user_id, url); scope poller lookup + sync select to (userId, url); hand
migration 0001 (dedup + add key), applied to the live DB.

Regression tests fail against the buggy url-only predicate. API 98/98, PWA 140/140,
tsc clean both packages.
2026-06-06 22:32:10 -04:00
Lucas Berger 505f64ed93 docs: add backlog item 999.2 — slick unauthenticated-entry (no login flash) 2026-06-06 22:11:33 -04:00
Lucas Berger 431ab31fb8 fix(api): serve the full ./public tree, not just /assets/*
Root-level PWA files (manifest.webmanifest, sw.js, registerSW.js, workbox-*.js,
icon-*.png, apple-touch-icon.png) were falling through to the index.html
catch-all and returning HTML — breaking the manifest (syntax error) and
preventing the service worker from ever registering. serveStatic('/*') serves
any existing file and calls next() for SPA routes, so index.html stays the
fallback. Registered after /health, /api/*, /callback so those still win.
2026-06-06 21:57:42 -04:00
Lucas Berger 1adb460412 fix(pwa): fetchMe uses redirect:manual so unauthenticated /api/me can't hang
With the default redirect:follow, the browser follows the OIDC guard's 302 to
Authelia (cross-origin, credentialed) and the fetch HANGS — meQuery stays
'loading' so the SPA spins forever and the isError-driven login redirect never
fires. redirect:manual surfaces the 302 as an opaqueredirect (status 0) that we
detect as auth-required and throw, letting CalendarShell navigate to /api/login.
+4 fetchMe tests.
2026-06-06 21:57:42 -04:00
Lucas Berger 874f23de2f docs(quick-260606-tv8): sign-in redirect fix — summary + state 2026-06-06 21:42:58 -04:00
Lucas Berger 76db63458e chore: remove operator seed script + gitignore local verification artifacts
- git rm apps/api/scripts/seed-credential.mjs (operator-only, run out-of-band;
  the credential is already seeded in the running DB)
- gitignore .playwright-cli/, gate2-*.png, and the seed script path
2026-06-06 21:42:29 -04:00
Lucas Berger 7c6531f4d0 chore: merge executor worktree (worktree-agent-abd829a63c8f5dade) 2026-06-06 21:40:46 -04:00
Lucas Berger c2e0ab1b1f feat(260606-tv8-01): wire login redirect into CalendarShell meQuery handling
- Import maybeRedirectToLogin + clearLoginRedirect from loginRedirect.ts
- useEffect on meQuery.isError calls maybeRedirectToLogin() (one-shot, loop-guarded)
- useEffect on meQuery.isSuccess calls clearLoginRedirect() for future re-auth
- Existing 'Sign-in required' branch retained as fall-through for already-attempted case
2026-06-06 21:38:38 -04:00
Lucas Berger 6dc9ccd2e9 feat(260606-tv8-01): add one-shot login-redirect helper + tests; fix client.ts comment
- Add loginRedirect.ts: maybeRedirectToLogin (sessionStorage one-shot guard) and
  clearLoginRedirect; guards window/sessionStorage for SSR/test safety
- Add loginRedirect.test.ts: covers first-call redirect, one-shot no-op, clear+retry
- Update client.ts: remove false claim that fetch follows Authelia 302 automatically;
  note that XHR/fetch CORS-blocks cross-origin redirects, top-level nav required
2026-06-06 21:37:14 -04:00
Lucas Berger 237ec493aa feat(260606-tv8-01): add guarded GET /api/login route + tests
- Register app.get('/api/login', redirect to '/') in protected-routes block
- Route placed after OIDC guard so unauthenticated nav triggers auth flow
- Add login.test.ts covering bypass and OIDC-passthrough redirect paths
2026-06-06 21:35:52 -04:00
Lucas Berger b788ffc93e docs(260606-tv8): pre-dispatch plan for sign-in redirect fix 2026-06-06 21:33:35 -04:00
Lucas Berger b46b25b26b chore(03): Gate 2 stack bring-up — serve PWA from API image, prod env, credential seed
- Dockerfile: build apps/pwa into the production image's ./public so the API
  serves the PWA on a single port (:3000) for the Pangolin/newt tunnel
- docker-compose.yml: set NODE_ENV=production (mount OIDC unconditionally) and
  constrain OIDC_SCOPES=openid profile email offline_access (Authelia rejected
  the empty-default's full scopes_supported with invalid_scope)
- apps/api/scripts/seed-credential.mjs: operator tool to seed member_credentials
  (encrypted Fastmail app password) out-of-band — fills the documented gap
2026-06-06 21:30:58 -04:00
Lucas Berger ca87c023ef wip: phase 03 paused — gap-closure done, docker bring-up awaiting auth+PWA decisions 2026-06-05 21:48:17 -04:00