TestFlight diagnostic build: HealthKit logging + permission fixes - #30
Draft
gsbernstein wants to merge 4 commits into
Draft
TestFlight diagnostic build: HealthKit logging + permission fixes#30gsbernstein wants to merge 4 commits into
gsbernstein wants to merge 4 commits into
Conversation
- DiagnosticLogger records HealthKit bootstrap, queries, and state changes. - Settings Diagnostics section: share/copy logs, retry HealthKit, live state. - Grant Access always calls requestAuthorization and shows loading/errors. - Bootstrap tries silent data load first; only prompts when zero samples. - Await HK queries, recover from SwiftData store failures, fix preferences seeding. Co-authored-by: Greg <gsbernstein@users.noreply.github.com>
Make log() nonisolated so it can be called from BedtimeApp's static ModelContainer initializer. Move UI-published mutations to @mainactor record() and remove init-time logging that referenced shared during init. Co-authored-by: Greg <gsbernstein@users.noreply.github.com>
Co-authored-by: Greg <gsbernstein@users.noreply.github.com>
Present UIActivityViewController from the topmost view controller instead of nesting a SwiftUI sheet inside the Settings sheet. Co-authored-by: Greg <gsbernstein@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
TestFlight diagnostic build for a tester who cannot load HealthKit sleep data. Adds local logging with a share/copy flow in Settings — no third-party analytics.
Also fixes several issues found while investigating:
requestAuthorization()returned early when state was alreadyhasRequestedfrom a silent init attempt, so the button had no effect. Grant now always callsrequestAuthorization, shows a spinner, and surfaces errors.DiagnosticLogger.log()was MainActor-isolated but called fromBedtimeApp's nonisolated staticModelContainerinitializer. Fixed by makinglog()nonisolated.For the tester
The logs include: HealthKit availability, authorization calls, sample counts, discovered sources, permission state transitions, and ModelContainer status.
What to look for in logs
Silent load returned 0 samples+requestAuthorization returned+ still 0 samples → likely read access denied (check Settings → Health → Data Access & Devices → Bedger → Sleep)Display query error→ HealthKit query failure with messageDiscovered N sourceswith N > 0 but 0 sessions → source filtering or sleep stage parsing issue