Skip to content

Comments

Add partial Health Connect permissions + DB migration retry#241

Merged
fiddur merged 1 commit intodevelopfrom
feat/partial-permissions-migration-retry
Feb 22, 2026
Merged

Add partial Health Connect permissions + DB migration retry#241
fiddur merged 1 commit intodevelopfrom
feat/partial-permissions-migration-retry

Conversation

@fiddur
Copy link
Owner

@fiddur fiddur commented Feb 22, 2026

Summary

  • Android: Partial permissions support — Users can now sync whatever data types they've authorized instead of needing all 40+ permissions. The sync screen is redesigned from a debug record list to a clean card-based UI showing per-category permission status with individual grant buttons.
  • Backend: DB migration retry on schema errors — When a query hits a missing table/column (42P01/42703), it automatically runs migration and retries once. This fixes errors for long-lived sessions after deployments that add new schema.

Changes

Android

  • New HealthConnectPermissions.kt — 6 user-friendly data categories with pure helper functions
  • MainActivity.kt — Refactored from hasPermissions: Boolean to granular permission state; card-based sync UI replaces debug record list
  • HealthConnectSyncWorker.kt — Background sync works with partial permissions; filters aggregate metrics to granted types
  • Changes token invalidated when granted types change (forces safe re-fetch)

Backend

  • connection.ts — Added _isSchemaError, _runMigrationOnce (coalescing mutex), and retry logic in query()
  • connection.test.ts — 14 unit tests covering schema error detection, mutation coalescing, retry/no-retry paths

Test plan

  • Backend: All 692 unit tests pass
  • Android: Compiles cleanly, all unit tests pass (including new HealthConnectPermissionsTest)
  • Manual: Sara can test granting partial permissions on her phone

🤖 Generated with Claude Code

Android:
- Add HealthConnectPermissions.kt with 6 user-friendly data categories
  (Activity, Heart & Vitals, Body, Sleep, Nutrition, Reproductive)
- Refactor permission state from all-or-nothing boolean to granular
  grantedPermissions set with derived hasAny/hasAll/categoryStatuses
- Redesign sync screen with card-based UI: sync status card, per-category
  permission cards with individual Grant buttons, Sync Now button
- Remove debug-style raw record list
- Update background sync worker for partial permissions: filter
  aggregatable metrics to granted types, skip only if zero permissions
- Invalidate changes token when granted types change (forces re-fetch)

Backend:
- Add schema error detection (42P01 undefined_table, 42703 undefined_column)
- Add per-user migration mutex to coalesce concurrent migration attempts
- Add automatic migration retry in query() when called with username
  (not when called with Client directly, preventing infinite recursion)
- Login migration remains as eager/happy path; query retry is safety net

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
@codecov
Copy link

codecov bot commented Feb 22, 2026

Codecov Report

❌ Patch coverage is 26.55738% with 224 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.39%. Comparing base (965dc2e) to head (d7f5511).
⚠️ Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
...roid/app/src/main/java/net/aurboda/MainActivity.kt 0.00% 190 Missing ⚠️
...c/main/java/net/aurboda/HealthConnectSyncWorker.kt 0.00% 32 Missing ⚠️
.../main/java/net/aurboda/HealthConnectPermissions.kt 96.29% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #241      +/-   ##
===========================================
+ Coverage    27.20%   27.39%   +0.19%     
===========================================
  Files          175      176       +1     
  Lines        23517    23642     +125     
  Branches      2094     2104      +10     
===========================================
+ Hits          6397     6476      +79     
- Misses       17081    17127      +46     
  Partials        39       39              
Flag Coverage Δ
android 8.77% <18.84%> (+1.17%) ⬆️
backend 57.58% <100.00%> (+0.11%) ⬆️
web 3.02% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fiddur fiddur merged commit 4303272 into develop Feb 22, 2026
3 of 4 checks passed
@fiddur fiddur deleted the feat/partial-permissions-migration-retry branch February 22, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant