Commit Graph

105 Commits

Author SHA1 Message Date
85b535f04a Add build info metric and diagnostic logging for Garmin sync
All checks were successful
Deploy / deploy (push) Successful in 1m44s
- Add phaseflow_build_info metric with version and commit labels
- Inject GIT_COMMIT env var at build time via next.config.ts
- Add logging to all Garmin fetch functions (HRV, body battery, intensity)
- Log API response status codes, actual data values, and errors

This enables verifying which build is deployed and diagnosing
silent failures where Garmin API returns errors but sync reports success.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 13:09:29 +00:00
7ed827f82c Fix body battery showing zeros on dashboard after Garmin sync
All checks were successful
Deploy / deploy (push) Successful in 2m29s
PocketBase coerces null number fields to 0 when reading. When Garmin
API returned no data (null), we stored null, which became 0 on
retrieval. The nullish coalescing (?? 100) in the API route didn't
catch this because 0 is not nullish.

Now store default value 100 when Garmin returns null, matching the
existing pattern used for decision engine calculations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 12:47:12 +00:00
3a06bff4d4 Fix Garmin sync to handle PocketBase date strings
All checks were successful
Deploy / deploy (push) Successful in 2m38s
PocketBase returns date fields as ISO strings, not Date objects.
The sync was failing with "e.getTime is not a function" because
the code expected Date objects.

- Export mapRecordToUser from pocketbase.ts
- Use mapRecordToUser in cron route to properly parse dates
- Add test for handling date fields as ISO strings

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 07:38:37 +00:00
4ba9f44cef Add PocketBase admin auth to garmin-sync cron job
All checks were successful
Deploy / deploy (push) Successful in 2m28s
The cron job needs to list all users, but the users collection
doesn't have a public listRule (for security). Added admin
authentication so the job can access user records.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 07:13:18 +00:00
0579ca2534 Add API rules setup to database initialization
All checks were successful
Deploy / deploy (push) Successful in 2m29s
The period_logs collection was returning 403 errors because API rules
were only configured in the e2e test harness, not in the production
setup script. This consolidates the setup logic so both prod and test
use the same setupApiRules() function.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 06:49:42 +00:00
4a874476c3 Enable 5 previously skipped e2e tests
All checks were successful
Deploy / deploy (push) Successful in 1m37s
- Fix OIDC tests with route interception for auth-methods API
- Add data-testid to DecisionCard for reliable test selection
- Fix /api/today to fetch fresh user data instead of stale cookie data
- Fix period logging test timing with proper API wait patterns
- Fix decision engine test with waitForResponse instead of timeout
- Simplify mobile viewport test locator

All 206 e2e tests now pass with 0 skipped.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 06:30:51 +00:00
ff3d8fad2c Add Playwright fixtures with 5 test user types for e2e tests
Creates test infrastructure to enable previously skipped e2e tests:
- Onboarding user (no period data) for setup flow tests
- Established user (period 14 days ago) for normal usage tests
- Calendar user (with calendarToken) for ICS feed tests
- Garmin user (valid tokens) for connected state tests
- Garmin expired user (expired tokens) for expiry warning tests

Also fixes ICS feed route to strip .ics suffix from Next.js dynamic
route param, adds calendarToken to /api/user response, and sets
viewRule on users collection for unauthenticated ICS access.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:54:49 +00:00
b221acee40 Implement automatic Garmin token refresh and fix expiry tracking
- Add OAuth1 to OAuth2 token exchange using Garmin's exchange endpoint
- Track refresh token expiry (~30 days) instead of access token expiry (~21 hours)
- Auto-refresh access tokens in cron sync before they expire
- Update Python script to output refresh_token_expires_at
- Add garminRefreshTokenExpiresAt field to User type and database schema
- Fix token input UX: show when warning active, not just when disconnected
- Add Cache-Control headers to /api/user and /api/garmin/status to prevent stale data
- Add oauth-1.0a package for OAuth1 signature generation

The system now automatically refreshes OAuth2 tokens using the stored OAuth1 token,
so users only need to re-run the Python auth script every ~30 days (when refresh
token expires) instead of every ~21 hours (when access token expires).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 20:33:10 +00:00
6df145d916 Fix Garmin token storage and flaky e2e test
1. Increase garminOauth1Token and garminOauth2Token max length from
   5000 to 20000 characters to accommodate encrypted OAuth tokens.
   Add logic to update existing field constraints in addUserFields().

2. Fix flaky pocketbase-harness e2e test by adding retry logic with
   exponential backoff to createAdminUser() and createTestUser().
   Handles SQLite database lock during PocketBase startup migrations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 12:52:01 +00:00
00b84d0b22 Fix E2E test reliability issues and stale data bugs
- Fix race conditions: Set workers: 1 since all tests share test user state
- Fix stale data: GET /api/user and /api/cycle/current now fetch fresh data
  from database instead of returning stale PocketBase auth store cache
- Fix timing: Replace waitForTimeout with retry-based Playwright assertions
- Fix mobile test: Use exact heading match to avoid strict mode violation
- Add test user setup: Include notificationTime and update rule for users

All 1014 unit tests and 190 E2E tests pass.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 20:23:32 +00:00
7dd08ab5ce Remove redundant notifications.spec.ts from enhancement list
All checks were successful
Deploy / deploy (push) Successful in 1m47s
The suggested notifications.spec.ts E2E tests for notification preferences
are already thoroughly covered by existing settings.spec.ts tests which
validate notification time and timezone input, validation, and persistence.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 19:08:35 +00:00
9709cf27ab Add 2 E2E tests for dark mode system preference detection
All checks were successful
Deploy / deploy (push) Successful in 2m36s
Verifies that the app correctly applies light/dark mode styling based on
the user's system preference (prefers-color-scheme). Tests cover both
light and dark modes using Playwright's emulateMedia API.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 19:03:11 +00:00
04a532bb01 Add 4 Garmin E2E tests for network error recovery
All checks were successful
Deploy / deploy (push) Successful in 2m28s
Add tests to verify error handling when network requests fail:
- Error toast when token save fails (500 response)
- Error toast when disconnect fails (500 response)
- Error state display when status fetch fails
- Retry succeeds after network failure

These tests improve resilience coverage for the Garmin connection flow.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 18:54:58 +00:00
b6f139883f Add 8 new E2E tests for accessibility and error recovery
All checks were successful
Deploy / deploy (push) Successful in 1m40s
- calendar.spec.ts: +4 accessibility tests (ARIA role, aria-labels, keyboard navigation, accessible nav buttons)
- settings.spec.ts: +1 error recovery test (retry after failed save)
- mobile.spec.ts: +3 calendar mobile tests (rendering, touch targets, navigation)

Total E2E tests: 190 → 198

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 18:48:58 +00:00
f3d7f8bd35 Add 4 new E2E tests for mobile viewport behavior
All checks were successful
Deploy / deploy (push) Successful in 2m28s
Tests mobile responsiveness including:
- Login page renders correctly on mobile viewport
- Dashboard displays correctly on mobile viewport
- Dashboard uses single-column layout on mobile (< 768px)
- Navigation elements are interactive on mobile

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 18:42:29 +00:00
e2a600700d Add 6 new E2E tests for OIDC flow and session persistence
All checks were successful
Deploy / deploy (push) Successful in 1m39s
New auth.spec.ts tests:
- OIDC button shows provider name when configured
- OIDC button shows loading state during authentication
- OIDC button is disabled when rate limited
- Session persists after page refresh
- Session persists when navigating between pages
- Logout clears session and redirects to login

E2E test count: 180 → 186 (auth.spec.ts: 14 → 20)
Total tests: 1194 → 1200

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 18:36:15 +00:00
c4d56f23e2 Add 5 new E2E tests for settings persistence
All checks were successful
Deploy / deploy (push) Successful in 2m28s
Tests added:
- notification time changes persist after page reload
- timezone changes persist after page reload
- multiple settings changes persist after page reload
- cycle length persistence verifies exact saved value
- settings form shows correct values after save without reload

Updated IMPLEMENTATION_PLAN.md with accurate E2E test counts (now 180 E2E tests).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 18:31:39 +00:00
79414b813a Add 5 new E2E tests for period logging modal and edit/delete flows
All checks were successful
Deploy / deploy (push) Successful in 2m38s
New tests cover:
- Period date modal opens from dashboard onboarding banner
- Period date input restricts future dates via max attribute
- Logging period from modal updates dashboard cycle info
- Edit period modal flow changes date successfully
- Delete period confirmation flow removes entry

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 18:26:03 +00:00
5bfe51d630 Add 5 new Garmin E2E tests for expiry warnings and lifecycle
All checks were successful
Deploy / deploy (push) Successful in 1m39s
New tests:
- Yellow warning banner when token expires in 10 days (warning level)
- Red critical banner when token expires in 5 days (critical level)
- Expired token state shows token input for re-entry
- Connection persists after page reload
- Can reconnect after disconnecting

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 18:20:42 +00:00
b3c711b9af Condense IMPLEMENTATION_PLAN.md after feature completion
All checks were successful
Deploy / deploy (push) Successful in 2m28s
Reduced the implementation plan from 1514 lines to 156 lines (90% reduction)
by consolidating completed items into compact summary tables. The project is
feature complete with 1014 unit tests and 165 E2E tests passing.

Key changes:
- Removed detailed task descriptions for completed P0-P5 items
- Consolidated library, API, page, component, and E2E test summaries
- Preserved critical business rules and architecture notes
- Kept E2E enhancement opportunities for future reference

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 18:14:35 +00:00
f6b05a0765 Add 14 new E2E tests for ICS content validation and settings form
All checks were successful
Deploy / deploy (push) Successful in 2m27s
Calendar ICS content validation tests (7):
- VCALENDAR structure validation
- VEVENT entries verification
- Phase events with emojis (🩸🌱🌸🌙🌑)
- CATEGORIES for calendar color coding
- 90-day span coverage
- Warning events inclusion
- Content-type header validation

Settings form validation tests (7):
- Notification time HH:MM format acceptance
- Cycle length minimum (21) boundary validation
- Cycle length maximum (45) boundary validation
- Timezone field editability
- Current cycle length value display
- Settings persistence after page reload
- Save button loading state

Total E2E test count: 165 tests across 12 files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 18:09:37 +00:00
78c658822e Add 16 new dashboard E2E tests for comprehensive UI coverage
All checks were successful
Deploy / deploy (push) Successful in 1m57s
- Decision Card tests: GENTLE/LIGHT/REDUCED status display, icon rendering
- Override behavior tests: stress forces REST, PMS forces GENTLE, persistence after refresh
- Mini Calendar tests: current month display, today highlight, phase colors, navigation
- Onboarding Banner tests: setup prompts, Garmin link, period date prompt
- Loading state tests: skeleton loaders, performance validation

Total dashboard E2E coverage now 42 tests. Overall E2E count: 129 tests across 12 files.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 18:00:41 +00:00
2558930507 Add 13 new E2E tests for period logging flow and calendar display
All checks were successful
Deploy / deploy (push) Successful in 2m28s
Period logging tests (5 new):
- Future date validation
- Cycle length display between periods
- Prediction accuracy display
- Delete period log from history
- Edit period log from history

Calendar tests (8 new):
- Today highlight in calendar view
- Phase colors in calendar days
- Phase legend display
- Today button for quick navigation
- Multi-month navigation with return to today
- Calendar URL generation
- URL format validation
- Copy to clipboard functionality

Total E2E tests: 113 (was 100)
Total unit tests: 1014 (51 test files)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 17:51:23 +00:00
f4a3f7d9fd Add 14 new dashboard E2E tests for data panel, nutrition, and accessibility
All checks were successful
Deploy / deploy (push) Successful in 2m39s
- Added 8 data panel tests: HRV status, Body Battery, cycle day format,
  current phase, intensity minutes, phase limit, remaining minutes
- Added 4 nutrition panel tests: seed cycling, carb range, keto guidance,
  nutrition section header
- Added 4 accessibility tests: main landmark, skip navigation link,
  keyboard accessible overrides, focus indicators

Total dashboard E2E coverage: 24 tests (up from 10)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 17:43:56 +00:00
54b57d5160 Add 36 new E2E tests across 5 test files
All checks were successful
Deploy / deploy (push) Successful in 1m41s
New E2E test files:
- e2e/health.spec.ts: 3 tests for health/observability endpoints
- e2e/history.spec.ts: 7 tests for history page
- e2e/plan.spec.ts: 7 tests for exercise plan page
- e2e/decision-engine.spec.ts: 8 tests for decision display and overrides
- e2e/cycle.spec.ts: 11 tests for cycle tracking, settings, and period logging

Total E2E tests: 100 (up from 64)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 17:37:34 +00:00
2ade07e12a More E2E tests. 2026-01-13 17:29:41 +00:00
27f084f950 Fix Garmin token connection not persisting after save
All checks were successful
Deploy / deploy (push) Successful in 1m38s
Root cause: The setup-db script was missing user field definitions
(garminConnected, tokens, etc.). Production PocketBase had no such
fields, so updates silently failed to persist.

Changes:
- Add user custom fields to setup-db.ts (matches e2e harness)
- Fix status route to use strict boolean check (=== true)
- Add verification in tokens route with helpful error message
- Add ENCRYPTION_KEY to playwright config for e2e tests
- Add comprehensive e2e tests for Garmin connection flow

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 13:20:50 +00:00
3b9e023736 Remove CI workflow. 2026-01-13 09:41:39 +00:00
8c59b3bd67 Add self-contained e2e test harness with ephemeral PocketBase
Some checks failed
CI / quality (push) Failing after 29s
Deploy / deploy (push) Successful in 2m37s
Previously, 15 e2e tests were skipped because TEST_USER_EMAIL and
TEST_USER_PASSWORD env vars weren't set. Now the test harness:

- Starts a fresh PocketBase instance in /tmp on port 8091
- Creates admin user, collections, and API rules automatically
- Seeds test user with period data for authenticated tests
- Cleans up temp directory after tests complete

Also fixes:
- Override toggle tests now use checkbox role (not button)
- Adds proper wait for OVERRIDES section before testing toggles
- Suppresses document.cookie lint warning with explanation

Test results: 64 e2e tests pass, 1014 unit tests pass

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 09:38:24 +00:00
eeeece17bf Add spec compliance improvements: seed switch alert, calendar emojis, period indicator, IP logging
Some checks failed
CI / quality (push) Failing after 28s
Deploy / deploy (push) Successful in 2m38s
- NutritionPanel: Display seed switch alert on day 15 per dashboard spec
- MonthView: Add phase emojis to legend (🩸🌱🌸🌙🌑) per calendar spec
- DayCell: Show period indicator (🩸) for days 1-3 per calendar spec
- Auth middleware: Log client IP from x-forwarded-for/x-real-ip per observability spec
- Updated NutritionGuidance type to include seedSwitchAlert field
- /api/today now returns seedSwitchAlert in nutrition response

Test coverage: 1005 tests (15 new tests added)
- nutrition-panel.test.tsx: +4 tests
- month-view.test.tsx: +1 test
- day-cell.test.tsx: +5 tests
- auth-middleware.test.ts: +3 tests
- today/route.test.ts: +2 tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 23:33:14 +00:00
d613417e47 Fix spec compliance gaps in email and dashboard
Some checks failed
CI / quality (push) Failing after 28s
Deploy / deploy (push) Successful in 2m39s
- Email subject now follows spec format: PhaseFlow: [STATUS] - Day [cycleDay] ([phase])
- Daily email includes seed switch alert on day 15 (using getSeedSwitchAlert)
- Data panel HRV status now color-coded: green=Balanced, red=Unbalanced, gray=Unknown
- Data panel shows progress bar for week intensity vs phase limit with color thresholds

Adds 13 new tests (990 total).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 23:20:18 +00:00
0ea8e2f2b5 Fix decision-engine override behavior: sleep/pms return GENTLE per spec
Some checks failed
CI / quality (push) Failing after 28s
Deploy / deploy (push) Successful in 1m40s
The spec (decision-engine.md lines 93-94) clearly states:
- sleep override -> GENTLE
- pms override -> GENTLE

But the implementation was returning REST for all overrides. This fix:
- Updates decision-engine.ts to use OVERRIDE_DECISIONS with correct status/reason/icon per override type
- Updates tests to expect GENTLE for sleep and pms overrides
- Aligns implementation with specification

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 23:11:47 +00:00
262c28d9bd Fix P3.10 documentation inconsistency
Some checks failed
CI / quality (push) Failing after 29s
Deploy / deploy (push) Successful in 2m39s
Update gap analysis note to reflect current test counts (977 unit tests across
50 files + 64 E2E tests) and complete status of all P0-P5 items.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 23:08:04 +00:00
aeb87355ed Fix P3.10 documentation inconsistency
Some checks failed
CI / quality (push) Failing after 28s
Deploy / deploy (push) Has been cancelled
- Mark P3.10 E2E Test Suite as COMPLETE (was showing unchecked)
- Update file path from tests/e2e/ to e2e/ (actual location)
- Add reference to P5.4 which has full implementation details

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 23:06:04 +00:00
e971fe683f Add toast notification system with sonner library
- Create Toaster component wrapping sonner at bottom-right position
- Add showToast utility with success/error/info methods
- Error toasts persist until dismissed, others auto-dismiss after 5s
- Migrate error handling to toasts across all pages:
  - Dashboard (override toggle errors)
  - Settings (save/load success/error)
  - Garmin settings (connection success/error)
  - Calendar (load errors)
  - Period History (load/delete errors)
- Add dark mode support for toast styling
- Add Toaster provider to root layout
- 27 new tests (23 toaster component + 4 integration)
- Total: 977 unit tests passing

P5.2 COMPLETE - All P0-P5 items now complete.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 23:04:27 +00:00
38bea1ffd7 Add comprehensive E2E test suite for all user flows
Some checks failed
CI / quality (push) Failing after 28s
Deploy / deploy (push) Successful in 2m28s
- Add e2e/auth.spec.ts (14 tests): Login page UI, form validation, error
  handling, protected route redirects, public routes
- Add e2e/dashboard.spec.ts (10 tests): Dashboard display, decision card,
  override toggles, navigation
- Add e2e/settings.spec.ts (15 tests): Settings form, Garmin settings,
  logout flow
- Add e2e/period-logging.spec.ts (9 tests): Period history page, API auth
- Add e2e/calendar.spec.ts (13 tests): Calendar view, navigation, ICS
  subscription, token endpoints

Total: 64 E2E tests (28 pass without auth, 36 skip when TEST_USER_EMAIL/
TEST_USER_PASSWORD not set)

Authenticated tests use test credentials via environment variables, allowing
full E2E coverage when PocketBase test user is available.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 22:44:57 +00:00
cd103ac1cc Add CI pipeline with lint, typecheck, and unit tests
Some checks failed
CI / quality (push) Failing after 2m47s
Deploy / deploy (push) Successful in 1m41s
Creates Gitea Actions workflow that runs on pull requests and pushes
to main. Enforces quality gates (lint, typecheck, unit tests) in CI,
complementing the local Lefthook pre-commit hooks.

Features:
- Node.js 24 with pnpm 10 setup
- pnpm dependency caching for faster runs
- Linting with biome
- TypeScript type checking
- 950 unit tests via vitest

Completes P5.3 from the implementation plan.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 22:36:17 +00:00
07577dbdbb Add period history UI with CRUD operations
All checks were successful
Deploy / deploy (push) Successful in 2m27s
- Add GET /api/period-history route with pagination, cycle length
  calculation, and prediction accuracy tracking
- Add PATCH/DELETE /api/period-logs/[id] routes for editing and
  deleting period entries with ownership validation
- Add /period-history page with table view, edit/delete modals,
  and pagination controls
- Include 61 new tests covering all functionality

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 22:33:36 +00:00
6e391a46be E2E tests. 2026-01-12 22:19:58 +00:00
dbf0c32588 Fix garmin status showing stale connection state
All checks were successful
Deploy / deploy (push) Successful in 1m37s
Fetch fresh user data from database in status endpoint instead of
relying on auth store cookie, which may be stale after token save.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 21:45:35 +00:00
6bd5eb663b Add Playwright E2E testing infrastructure
- Add playwright-web-flake to flake.nix for NixOS browser support
- Pin @playwright/test@1.56.1 to match nixpkgs version
- Create playwright.config.ts with Chromium-only, auto-start dev server
- Add e2e/smoke.spec.ts with initial smoke tests
- Add .mcp.json for Claude browser control via MCP
- Update .gitignore for playwright artifacts
- Remove E2E test skip from spec.md Known Limitations
- Update specs/testing.md to require three-tier testing approach

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 21:43:24 +00:00
30c5955a61 Fix garmin token expires_at format for PocketBase compatibility
Output expires_at as ISO 8601 date string instead of Unix timestamp.
PocketBase date fields expect ISO format, and the integer was causing
token saves to fail silently.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 21:25:38 +00:00
ce80fb1ede Add database setup script and fix dark mode visibility
- Add scripts/setup-db.ts to programmatically create missing PocketBase
  collections (period_logs, dailyLogs) with proper relation fields
- Fix dark mode visibility across settings, login, calendar, and dashboard
  components by using semantic CSS tokens and dark: variants
- Add db:setup npm script and document usage in AGENTS.md
- Update vitest config to include scripts directory tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 21:23:20 +00:00
ca35b36efa Fix garth token serialization using TypeAdapter for Pydantic dataclasses
Garth's OAuth1Token and OAuth2Token are Pydantic dataclasses, not BaseModel
subclasses, so they require TypeAdapter for serialization instead of model_dump().
Also adds user-friendly error handling for authentication failures.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 17:45:01 +00:00
c8a738d0c4 Fix garth token serialization using Pydantic v2 API
All checks were successful
Deploy / deploy (push) Successful in 1m36s
The garth library uses Pydantic dataclasses for OAuth tokens which don't
have a serialize() method. Use model_dump() instead, and fix expires_at
handling since it's an integer timestamp not a datetime object.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 16:49:16 +00:00
2408839b8b Fix 404 error when saving user preferences
Routes using withAuth were creating new unauthenticated PocketBase
clients, causing 404 errors when trying to update records. Modified
withAuth to pass the authenticated pb client to handlers so they can
use it for database operations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 16:45:55 +00:00
df2f52ad50 Install deps for python script. 2026-01-12 15:00:31 +00:00
0e585e6bb4 Add period date setup modal for new users
All checks were successful
Deploy / deploy (push) Successful in 2m27s
Users without a lastPeriodDate can now set it via a modal opened from
the onboarding banner. The dashboard now fetches user data independently
so the banner shows even when /api/today fails due to missing period date.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 14:28:49 +00:00
72706bb91b Fix Invalid Date error in auth middleware
All checks were successful
Deploy / deploy (push) Successful in 2m28s
Add parseDate helper that safely returns null for empty/invalid date
strings from PocketBase. This prevents RangeError when pino logger
tries to serialize Invalid Date objects via toISOString().

- Make garminTokenExpiresAt and lastPeriodDate nullable in User type
- Filter garmin-sync cron to skip users without required dates
- Add test assertions for null date handling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 14:13:02 +00:00
63023550fd Symlink to agents.md 2026-01-12 14:01:02 +00:00