Commit Graph
842 Commits
Author SHA1 Message Date
Lucas Berger 79ea94f4b9 docs(18): mark WR-01/WR-02 resolved in review
- WR-01: resolved (first-run save enabled — AdminPage.tsx + unit tests)
- WR-02: resolved (seed endpoint idempotent — admin.ts + integration tests)
- WR-03: accepted/not-fixing (redundant GET SELECT, low priority)
- Info items remain as-is (no action required)
2026-06-14 22:57:05 -04:00
Lucas Berger bda31a33bd fix(18): make timezone seed idempotent under concurrent race (WR-02)
- Import sql from drizzle-orm in admin.ts
- Add onDuplicateKeyUpdate({ set: { value: sql\`value\` } }) to the
  conditional INSERT in POST /config/timezone/seed so a concurrent seed
  (or seed racing a PUT) cannot 500 on the app_config.key PK constraint
- Existing value is preserved per D-03 no-overwrite (no-op ODKU)
- seeded flag still reflects the pre-flight SELECT (winner: true, loser: false)
- Add tests: 403 access control, seeded:true on first seed, seeded:false
  on second seed without throw (WR-02 idempotent race)
2026-06-14 22:56:18 -04:00
Lucas Berger 173e06ea77 fix(18): enable first-run timezone save when not explicitly set (WR-01)
- Derive isExplicit from timezoneQuery.data?.isExplicitlySet
- Apply the input===stored no-op guard only when isExplicit is true
- Keep pending and empty-input guards unconditional
- Add unit tests (AdminPage.timezone.test.ts) verifying first-run Save is
  enabled when isExplicitlySet:false and input matches stored fallback value
2026-06-14 22:53:44 -04:00
Lucas Berger 9481544a58 docs(18-04): complete admin timezone UI plan 2026-06-14 22:46:21 -04:00
Lucas Berger 3013b53b19 test(18-04): playwright-cli timezone round-trip e2e spec
- 6 desktop tests covering the full 18-04 acceptance criteria:
  timezone section visible, combobox pre-filled, save disabled when
  unchanged, save enables on change, persists across reload, use-detected
  affordance sets browser zone
- All 6 pass against the real 18-02 API endpoints
2026-06-14 22:44:44 -04:00
Lucas Berger 43d6689167 feat(18-04): add Timezone section (searchable IANA picker + save) to AdminPage
- Import fetchAdminTimezone + setAdminTimezone from api/client.js
- timezoneQuery: useQuery(['admin','timezone'], fetchAdminTimezone, retry:false, staleTime:60s)
- timezoneMutation: useMutation(setAdminTimezone) with invalidateQueries on success
- Timezone <section aria-label="Timezone"> after Shared Calendar (with marginBottom on preceding section)
- Searchable <input type=text list=iana-zones> + <datalist> from Intl.supportedValuesOf (guarded)
- 'Use detected: <zone>' affordance for D-02 one-tap seed
- 'Using system default' note when isExplicitlySet === false (D-06)
- Save button disabled while pending or when input equals stored value
- No touch to eventDateTime.ts / hydrateEvents.ts / other sections (D-07)
2026-06-14 22:37:21 -04:00
Lucas Berger 57424e6770 feat(18-04): add fetchAdminTimezone + setAdminTimezone to PWA API client
- Export AdminTimezoneResponse interface (timezone: string, isExplicitlySet: boolean)
- fetchAdminTimezone(): GET /api/admin/config/timezone with credentials/redirect pattern
- setAdminTimezone(timezone): PUT /api/admin/config/timezone with JSON body
- Both wrappers call handleAuthResponse (same auth handling as sibling admin calls)
2026-06-14 22:35:19 -04:00
Lucas Berger 9798d795a7 docs(18-03): complete broker rewire plan 2026-06-14 22:33:39 -04:00
Lucas Berger c80845cdba feat(18-03): route all-day reminder TZ through stored household_timezone
- reminderScheduler.ts: add import { getHouseholdTimezone } from '../lib/householdTimezone.js'
  and replace bare process.env.TZ ?? Intl... at line 247 with await getHouseholdTimezone(db)
- outboxWorker.ts: add same import and replace BOTH bare tz lookups at the update-branch
  (~line 501) and create-branch (~line 607) with await getHouseholdTimezone(db)
- D-05 satisfied: all three all-day sites now read from the single stored accessor
- D-06 satisfied: getHouseholdTimezone falls back to process.env.TZ → Intl when unset;
  existing process.env.TZ-pinned tests pass unchanged
- D-07 satisfied: eventDateTime.ts and hydrateEvents.ts are not modified
- outboxWorker.test.ts: update wireMockChain() to handle app_config table with where().limit()
  chain returning empty rows (D-06 fallback), so existing CAL-13 all-day test stays green
- reminderScheduler.test.ts: update mockTwoQueries to mock the new third db.select() call
  (getHouseholdTimezone) returning no row (D-06 fallback), keeping all 37 existing tests green
- All 76 broker tests pass; tsc --noEmit clean
2026-06-14 22:31:37 -04:00
Lucas Berger 94daca3c7a test(18-03): add failing stored-TZ all-day tests for scheduler + outbox
- reminderScheduler: new describe block with mockThreeQueries helper that
  extends mockTwoQueries to mock getHouseholdTimezone app_config SELECT
  (select({value}).from(appConfig).where(...).limit(1) chain)
- reminderScheduler: D-05 test expects dispatch at 14:00 UTC (Chicago CDT)
  when stored zone is America/Chicago; fails RED (code still reads process.env.TZ=America/New_York)
- reminderScheduler: D-05 NOT-fire test expects no dispatch at 13:00 UTC (NY time)
  when stored zone overrides to Chicago; fails RED (code fires at NY time)
- outboxWorker: new describe block with wireMockChainWithTz that extends
  mockFromFn to handle app_config table via where().limit() chain
- outboxWorker: D-05 create-branch test expects VALARM TRIGGER 20260619T140000Z
  (Chicago CDT); fails RED (code emits 20260619T130000Z using UTC fallback)
- outboxWorker: D-05 update-branch test same assertion, also fails RED
- Existing process.env.TZ-pinned all-day tests untouched; all 72 pass
2026-06-14 22:24:25 -04:00
Lucas Berger 08c39165bf docs(18-02): complete admin timezone endpoints plan 2026-06-14 22:13:53 -04:00
Lucas Berger 3bd6a5d97e feat(18-02): admin timezone GET/PUT/seed endpoints
- Add appConfig + getHouseholdTimezone/isValidIanaTimezone imports to admin.ts
- Add timezoneSchema: z.object({ timezone: z.string().min(1).max(64).refine(isValidIanaTimezone) })
  No noEchoHook — timezone strings are non-sensitive (T-18-06)
- GET /api/admin/config/timezone: returns { timezone, isExplicitlySet } using D-06 fallback
- PUT /api/admin/config/timezone: validates via timezoneSchema + upserts via onDuplicateKeyUpdate
- POST /api/admin/config/timezone/seed: SELECT-then-INSERT (no onDuplicateKeyUpdate) to enforce D-03 no-overwrite
- All three routes appended AFTER existing routes so line-41 requireAdmin covers them (T-18-03)
- All 25 admin.test.ts tests pass; 366/366 full API suite green; tsc --noEmit clean
2026-06-14 22:12:35 -04:00
Lucas Berger f109b3cf38 test(18-02): add failing integration tests for admin timezone endpoints
- describe('admin timezone config') covers 8 cases:
  - GET and PUT 403 for non-admin authenticated user (T-18-03)
  - GET with no stored row returns 200 with isExplicitlySet: false
  - PUT America/Chicago then GET round-trip with isExplicitlySet: true
  - PUT UTC returns 200 (Pitfall 2)
  - PUT Not/AZone returns 400 and does not write to app_config (T-18-04)
  - POST seed when unset stores the value (D-02)
  - POST seed when already set does NOT overwrite (D-03)
- appConfig imported from db/schema for per-test cleanup
- afterEach removes household_timezone row to prevent test bleed
- 6 new cases FAIL (404 — endpoints not yet implemented); 19 existing pass
2026-06-14 22:11:05 -04:00
Lucas Berger ac60161726 docs(18-01): complete household timezone accessor + IANA validator plan 2026-06-14 22:08:37 -04:00
Lucas Berger eaceff0295 feat(18-01): implement household timezone accessor + IANA validator
- getHouseholdTimezone(db): selects household_timezone from app_config
- D-06 fallback chain: stored value → process.env.TZ → Intl.DateTimeFormat().resolvedOptions().timeZone
- isValidIanaTimezone: try/catch Intl.DateTimeFormat (no Intl.supportedValuesOf per RESEARCH Pitfall 2)
- Exports match D-05 single-accessor contract for reminderScheduler + outboxWorker
- All 11 unit tests pass; 358/358 total suite green; tsc --noEmit clean
2026-06-14 22:07:16 -04:00
Lucas Berger db0077c3c3 test(18-01): add failing tests for household timezone accessor + IANA validator
- RED gate: tests for getHouseholdTimezone fallback chain (stored → TZ env → Intl)
- Tests for null row value falling through to TZ env branch
- Tests for isValidIanaTimezone (UTC, Etc/UTC, America/Chicago, Europe/London pass; garbage fails)
- Mock Drizzle select chain follows requireAdmin.test.ts pattern
- Saves/restores process.env.TZ in beforeEach/afterEach to prevent env state leaks
2026-06-14 22:05:58 -04:00
Lucas Berger 6cdc1ed22e docs(18): create phase plan 2026-06-14 21:53:38 -04:00
Lucas Berger 68a315e164 docs(18): create phase plan (4 plans, 3 waves) 2026-06-14 21:51:13 -04:00
Lucas Berger efae7159a4 docs(18): add validation strategy 2026-06-14 21:41:06 -04:00
Lucas Berger 12fb5d2adb docs(18): research phase domain 2026-06-14 21:39:56 -04:00
Lucas Berger 79111232b6 docs(state): record phase 18 context session 2026-06-14 21:25:46 -04:00
Lucas Berger 5d961b7c37 docs(18): capture phase context 2026-06-14 21:25:40 -04:00
Lucas BergerandClaude Sonnet 4.6 8be2b533d2 docs(phase-12): UI design contract for Initial Setup Wizard
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-14 21:16:23 -04:00
luckberg 6d50f7f41c Merge pull request 'chore(dev): make the dev stack reachable through the Pangolin tunnel' (#20) from chore/dev-stack-config into main
Publish / publish (push) Successful in 21s
Reviewed-on: #20
2026-06-14 21:09:26 -04:00
Lucas BergerandClaude Opus 4.8 cc875de0eb chore(dev): allow tunnel host + all interfaces in Vite dev server
CI / changes (pull_request) Successful in 1s
CI / fast-checks (pull_request) Successful in 1m26s
CI / api (pull_request) Successful in 1m5s
CI / harness (pull_request) Successful in 4m16s
CI / security (pull_request) Successful in 39s
CI / gate (pull_request) Successful in 1s
Reaching the dev PWA through the Pangolin/newt tunnel failed: Vite's default
host check 403s any non-localhost Host header ('Blocked request'), which the
tunnel health checks on / and /health read as unhealthy. Add allowedHosts:true
and host:true so the dev server accepts the tunnel hostname and listens on all
interfaces. Dev-only config; the production image serves the built PWA itself.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14 19:03:38 -04:00
Lucas BergerandClaude Opus 4.8 a2ad5bdbd3 chore(dev): enable DEV_AUTH_BYPASS in the dev compose stack
The api service in docker-compose.dev.yml ran with NODE_ENV=development but
without DEV_AUTH_BYPASS, so the dockerized dev stack enforced OIDC even though
no Authelia is reachable on the dev box. Set DEV_AUTH_BYPASS=true on the dev
override only; guarded by NODE_ENV!='production' and the production image bakes
NODE_ENV=production, so it can never reach a shipped image.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14 19:03:38 -04:00
luckberg e907b69145 Merge pull request 'Phase 11: Per-Event Reminders (CAL-13/14, NOTIF-04/05/06)' (#19) from gsd/phase-11-per-event-reminders into main
Publish / publish (push) Successful in 33s
Reviewed-on: #19
2026-06-14 14:06:43 -04:00
Lucas BergerandClaude Opus 4.8 eff9b13c66 fix(11): make CI green — pin TZ in all-day scheduler tests, drop redundant casts
CI / changes (pull_request) Successful in 2s
CI / fast-checks (pull_request) Successful in 1m25s
CI / api (pull_request) Successful in 1m3s
CI / harness (pull_request) Successful in 4m14s
CI / security (pull_request) Successful in 41s
CI / gate (pull_request) Successful in 1s
fast-checks failed on 3 no-unnecessary-type-assertion ESLint errors (reminderIsCustom is now a real CalendarOccurrence field). api failed on 4 all-day 9 AM-local tests that assumed a UTC-4 host; CI runs UTC. Pin process.env.TZ=America/New_York in the all-day describe (production code reads TZ at call time, D-04).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-14 11:22:04 -04:00
Lucas BergerandClaude Opus 4.8 156bdf057b docs(phase-11): evolve PROJECT.md — per-event reminders validated
CI / changes (pull_request) Successful in 3s
CI / fast-checks (pull_request) Failing after 50s
CI / api (pull_request) Failing after 1m3s
CI / harness (pull_request) Successful in 4m12s
CI / security (pull_request) Successful in 40s
CI / gate (pull_request) Failing after 1s
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-14 08:32:23 -04:00
Lucas BergerandClaude Opus 4.8 ff06a8479b docs(phase-11): complete phase execution (5/5 plans, CAL-13/14 + NOTIF-04/05/06)
One deferred human check: live Fastmail VALARM round-trip + push (untestable in dev, backlog 999.19).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-14 08:31:31 -04:00
Lucas BergerandClaude Opus 4.8 c86020ac21 docs(phase-11): mark gap-closure plan 11-05 complete; post-merge gate green (typecheck, API 347, PWA 206)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-14 08:30:51 -04:00
Lucas Berger 9bc6c7274c docs(11-05): complete gap-closure plan — SUMMARY 2026-06-14 08:28:24 -04:00
Lucas Berger a3aec2d21d style(11-05): prettier format EventForm.test.tsx WR-03 additions 2026-06-14 08:26:00 -04:00
Lucas Berger a04c76b823 fix(11-05): WR-03 gate helper text on active preset set only
- helper text condition now uses (allDay ? ALLDAY_REMINDER_PRESETS : TIMED_REMINDER_PRESETS)
- previously checked !TIMED && !ALLDAY: a timed event with 10080 (in ALLDAY set) was
  incorrectly treated as 'in presets' and suppressed the helper text
- synthetic option gating for each allDay/timed branch was already correct
2026-06-14 08:24:24 -04:00
Lucas Berger 401591374a test(11-05): RED — WR-03 helper text suppressed for timed off-list 10080
- timed event with reminderLeadMinutes=10080 must show 'Custom reminder kept' helper
- currently suppressed: helper text checks !TIMED && !ALLDAY, but 10080 is in ALLDAY
- fix: gate helper text on active preset set only (allDay ? ALLDAY : TIMED)
2026-06-14 08:24:01 -04:00
Lucas Berger 7d94afb2d8 fix(11-05): WR-02 add .max(10080) to reminderLeadMinutes in both Zod schemas
- eventFieldsSchema (events.ts): rejects reminderLeadMinutes > 10080 with 400
- outboxPayloadSchema (outboxWorker.ts): hard-fails row when value exceeds 1-week cap
- 10080 = 1 week in minutes; matches UI select maximum
2026-06-14 08:22:13 -04:00
Lucas Berger 30b8c9643a test(11-05): RED — WR-02 reminderLeadMinutes max(10080) in both Zod schemas
- outboxPayloadSchema: 10081 must hard-fail the row (currently dispatches)
- eventFieldsSchema: POST /create with 10081 must 400 (currently 202)
- boundary 10080 and null pass (already correct, no test fails expected)
2026-06-14 08:21:44 -04:00
Lucas Berger bc605e6a42 fix(11-05): WR-01 positive-duration TRIGGER classifies as custom (no Math.abs)
classifyValarms: check sign of dur.toSeconds() before preset lookup.
Positive value = alarm fires after event (RFC 5545 TRIGGER:+PT15M or
TRIGGER;RELATED=END:PTNm) → return {kind:'custom'} for preserve path.
Compute leadMinutes as -seconds/60 (was Math.abs) for negative triggers.

Prevents alarm direction inversion: +PT15M was being stored as 15-min-before
lead and re-fired at dtstartUtc-15min — the opposite of the original intent.
2026-06-14 08:15:31 -04:00
Lucas Berger d18aba7816 test(11-05): RED — WR-01 positive-duration TRIGGER classifies as custom
4 new tests in classifyValarms suite asserting TRIGGER:+PT15M and TRIGGER:PT30M
(positive/no-sign = fires after event) classify as {kind:'custom'}, not as
preset/offlist. Negative triggers regression guards also present.
2 tests FAIL (RED): Math.abs() discards the sign, misclassifies as preset.
2026-06-14 08:15:06 -04:00
Lucas Berger 16ac235476 fix(11-05): CR-02 all-day-aware push body (no "Starts in 0 min")
- humanizeLeadMinutes: add isAllDay=false param; all-day branch returns
  "Today" (lead=0), "Tomorrow" (1440), "In 1 week" (10080), "In N days" (other)
- byKey map: store isAllDay flag (false for timed, true for all-day)
- dispatch loop: pass event.isAllDay to humanizeLeadMinutes

All-day same-day reminder push now reads "Today" instead of "Starts in 0 min".
Timed event wording unchanged (isAllDay defaults to false).
2026-06-14 08:14:08 -04:00
Lucas Berger 1caa2e36d2 test(11-05): RED — CR-02 all-day-aware humanizeLeadMinutes
5 new tests asserting isAllDay=true branch: lead=0→"Today", 1440→"Tomorrow",
2880→"In 2 days", 10080→"In 1 week"; timed (isAllDay=false) behavior unchanged.
All 5 FAIL (RED): humanizeLeadMinutes only accepts one argument.
2026-06-14 08:12:56 -04:00
Lucas Berger f6b47ebf1e fix(11-05): CR-01 surface reminderIsCustom to preserve custom VALARMs on edit
- expand.ts: add reminderIsCustom:boolean to CalendarOccurrence interface;
  derived from classifyValarms kind==='custom'; propagated to both
  non-recurring and recurring occurrence branches
- client.ts: mirror reminderIsCustom on CalendarOccurrence (atomic mirror)
- EventForm.tsx: extend deriveReminderValue to accept isCustom flag;
  returns '__custom__' when true, making the existing D-08 preserve branch
  live — editing a custom-alarm event now omits reminderLeadMinutes from
  the payload so outboxWorker extractValarms keeps the original VALARM
- Fix existing test fixtures (EventForm.test.tsx, EventDetailPopover.test.tsx)
  to include reminderIsCustom:false on all CalendarOccurrence literals

Fixes CAL-14 Pitfall 1: Apple Calendar absolute DATE-TIME / multi-VALARM
alarms no longer silently stripped on any edit round-trip from the PWA.
2026-06-14 08:11:46 -04:00
Lucas Berger 5d6cb47191 test(11-05): RED — CR-01 custom alarm round-trip
- expand.test.ts: 3 new tests asserting reminderIsCustom:true for
  absolute DATE-TIME trigger and multi-VALARM, false for relative preset
- EventForm.test.tsx: 3 new tests asserting __custom__ picker init,
  'Custom (kept)' option visibility, and payload omits reminderLeadMinutes
- Fixtures: absolute-alarm.ics (DATE-TIME VALARM), multi-alarm.ics (2 VALARMs)
- All 6 new tests FAIL (RED): reminderIsCustom field not yet on interface
2026-06-14 08:08:24 -04:00
Lucas BergerandClaude Opus 4.8 6cdf9d22f9 docs(11): gap-closure plan 11-05 — fix CR-01/CR-02 blockers + WR-01/02/03 from code review
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-14 08:03:44 -04:00
Lucas BergerandClaude Opus 4.8 89132be3be docs(11): code review (2 blockers, 3 warnings) + goal verification (5/5, 1 live-check deferred)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-14 08:02:08 -04:00
Lucas BergerandClaude Opus 4.8 213f2547cf docs: backlog 999.19 — dev user full app functionality without real-calendar sync
Captured during Phase 11 UAT: dev-bypass user has no calendar provider, blocking hands-on event/reminder testing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-14 06:59:35 -04:00
Lucas Berger 8cd4c0e2c2 docs(11-04): complete reminder picker plan — SUMMARY, STATE, ROADMAP, REQUIREMENTS
- 11-04-SUMMARY.md: allDay-aware select, edit pre-population, Custom-kept limitation, playwright smoke results
- STATE.md: advance plan counter, add key decisions, record session
- ROADMAP.md: phase 11 now Complete (4/4 summaries)
- REQUIREMENTS.md: CAL-13 + CAL-14 marked complete
2026-06-14 06:58:18 -04:00
Lucas Berger b9b3191b5b style(11-04): apply prettier to phase-11 modified files
- apps/pwa/src/components/EventForm.tsx (Task 2)
- apps/api/src/broker/{expand,reminderScheduler,sync,vevent}.ts (Plans 11-01/11-03)
- apps/api/tests/broker/{reminderScheduler,sync}.test.ts (Plans 11-01/11-03)
2026-06-14 06:54:11 -04:00
Lucas Berger fe549ef2b0 feat(11-04): add reminder picker to EventForm (allDay swap, edit pre-population, payload mapping)
- TIMED_REMINDER_PRESETS + ALLDAY_REMINDER_PRESETS sets for preset classification
- humanizeReminderLead() + deriveReminderValue() helpers for off-list synthetic options
- reminderValue state (__none__ / numeric string / __custom__ sentinels)
- allDay toggle resets reminderValue to __none__ (D-03 — no carry-over)
- Reset effect derives reminderValue from occurrence.reminderLeadMinutes on mount/cache update
- Reminder <select id=event-reminder> after Recurrence picker: allDay-conditional option swap (D-02), timed presets when !allDay, day-granularity presets when allDay; synthetic off-list option; Custom (kept) read-only disabled option
- Helper text under select in edit mode for off-list/custom states (D-07)
- executeSubmit payload: __none__ → null, numeric → integer, __custom__ → field omitted (D-08)
- 10 new Phase 11 reminder picker tests (create/allDay-swap/edit-pre-pop/payload-mapping); fix pre-existing None-ambiguity test
- pwa vitest 201/201 pass; tsc --noEmit clean
2026-06-13 22:36:31 -04:00
Lucas Berger 2c30afe8ff feat(11-04): add reminderLeadMinutes to CreateEventPayload + CalendarOccurrence
- CalendarOccurrence: required reminderLeadMinutes: number | null (atomic mirror of expand.ts, Plan 11-03)
- CreateEventPayload: optional reminderLeadMinutes?: number | null with absent/null/0/positive contract (D-08)
- Update CalendarOccurrence fixtures in EventForm.test.tsx + EventDetailPopover.test.tsx to include the new required field (reminderLeadMinutes: null)
- pwa tsc --noEmit exits 0
2026-06-13 22:33:06 -04:00