feat(app): save Apple Watch heart rate per race like flight battery voltage#86
Draft
Saqoosha wants to merge 1 commit into
Draft
feat(app): save Apple Watch heart rate per race like flight battery voltage#86Saqoosha wants to merge 1 commit into
Saqoosha wants to merge 1 commit into
Conversation
…oltage Add an HDZapWatch watchOS companion target that runs an HKWorkoutSession + HKLiveWorkoutBuilder (the only way to get continuous ~1 Hz heart rate on watchOS) and streams bpm to the phone over WatchConnectivity. Race START/STOP on the phone is relayed to the watch so the workout follows the race automatically once the watch app is open; the on-watch button covers warm-up and manual recovery. On iOS, WatchHeartRateManager mirrors BluetoothManager's flight-battery telemetry surface (lastHeartRateBpm / lastHeartRateReceivedAt / heartRateNotifyRevision), and TimerView ingests samples into RaceHeartRateSample with the same tRace anchoring/clamping, dedupe, reset-site clearing, and chronological-sort-on-save conventions as RaceFlightBatterySample. RaceRecord persists heartRateSamples with decodeIfPresent back-compat and validator coverage, and RaceDetailView gains a heart-rate CSV share button next to the battery one. Requires 'cd app && xcodegen generate' to pick up the new target. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UWHtgSAWz9zLerpAj5C9Zh
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
What
Saves the pilot's Apple Watch heart rate into each race record, exactly like flight-battery voltage — no firmware/OSD involvement.
New watchOS companion (
app/HDZapWatch/)WatchWorkoutManagerruns anHKWorkoutSession+HKLiveWorkoutBuilder— the only supported way to get continuous ~1 Hz HR on watchOS (outside a workout the watch samples every few minutes) — and streams each bpm to the phone viaWCSession.sendMessage(["hr": …, "ts": …]). The workout also keeps the watch app alive wrist-down for the whole flight, and the flight is saved as a real workout in Activity on finish.["race": "start"|"stop"], so once the watch app is open the workout follows the race automatically.WatchContentViewshows live bpm plus a manual Start/Stop for warm-up (HR sensor lock-on takes a few seconds) and recovery.iOS
WatchHeartRateManagermirrorsBluetoothManager's flight-battery telemetry surface:lastHeartRateBpm/lastHeartRateReceivedAt(lockstep pair) /heartRateNotifyRevision, all mutated on the main actor.TimerViewingests via the same conventions asingestFlightBatteryTelemetry: race-start baseline capture,tRaceanchored to arrival time and clamped to ≥ 0, dedupe (on arrival time — steady bpm is real series data), cleared at both START and RESET sites, sorted chronologically on save.RaceRecordgainsheartRateSampleswithdecodeIfPresentback-compat (old JSON loads fine; old app versions ignore the new key) and validator coverage (finite/clampedtRace, bpm 1–300, chronological).RaceDetailViewgains a heart-rate CSV share button (t_race_s,received_at,bpm) next to the battery one;RaceRecord+HeartRatemirrorsRaceRecord+FlightBattery.Project config
project.yml: newHDZapWatchtarget (watchOS 11, bundle idsh.saqoo.HDZap.watchkitapp, HealthKit entitlement,workout-processingbackground mode, HealthKit usage strings), embedded via dependency from the iOS target.Not included (deliberately)
Testing needed (requires Mac + devices — couldn't be done in this environment)
cd app && xcodegen generate— required, the checked-in.xcodeprojpredates the new target/files.Known constraint:
sendMessagerequires the counterpart app to be reachable, so the auto start relay only lands when the watch app is frontmost (or already in a workout). The watch must be paired to the phone running HDZap — i.e. this targets the solo pilot-operator case.🤖 Generated with Claude Code
https://claude.ai/code/session_01UWHtgSAWz9zLerpAj5C9Zh
Generated by Claude Code