feat: serialize sub-activity activityType on WorkoutActivity#362
Open
TsSource wants to merge 2 commits into
Open
feat: serialize sub-activity activityType on WorkoutActivity#362TsSource wants to merge 2 commits into
TsSource wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: eb2f395 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
robertherber
approved these changes
Jul 17, 2026
commit: |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds serialization support for sub-activities’ activityType on WorkoutProxy.activities, so consumers can distinguish legs in multisport workouts (e.g., triathlon swim/bike/run) instead of receiving only timing/identity fields.
Changes:
- Added
activityType: WorkoutActivityTypeto theWorkoutActivityTypeScript interface. - Updated the iOS
WorkoutProxyserializer to include each sub-activity’sworkoutConfiguration.activityType. - Added a changeset bumping
@kingstinct/react-native-healthkitas a minor release for the additive field.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/react-native-healthkit/src/types/Workouts.ts | Extends WorkoutActivity to include the new activityType field. |
| packages/react-native-healthkit/ios/WorkoutProxy.swift | Serializes sub-activity activityType into WorkoutActivity objects returned to JS. |
| .changeset/serialize-workout-activity-type.md | Declares a minor release and documents the new serialized field. |
Comment on lines
+377
to
381
| duration: activity.duration, | ||
| activityType: WorkoutActivityType.init( | ||
| rawValue: Int32(activity.workoutConfiguration.activityType.rawValue) | ||
| ) ?? WorkoutActivityType.other | ||
| ) |
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
WorkoutProxy.activitiescurrently serializes eachHKWorkoutActivityas only{ startDate, endDate, uuid, duration }— the sub-activity'sactivityTypeis dropped at the bridge (ios/WorkoutProxy.swift). This PR adds it:WorkoutActivitygainsreadonly activityType: WorkoutActivityType(src/types/Workouts.ts)activity.workoutConfiguration.activityType.rawValue, with the same?? .otherfallback idiom the parentworkoutActivityTypegetter usesOne field, additive;
nitrogen/generatedis gitignored here so the diff is the two source files plus a changeset (minor).Why
Without it, multisport (
.swimBikeRun) workouts are opaque: consumers can see a triathlon has N sub-activities with time windows, but not which leg is the swim, the bike, or the run —duration/uuidalone can't type a leg, and ordering heuristics break for duathlons (run–bike–run). With the field, each leg can be typed directly offworkoutConfiguration, transitions (.transition) can be filtered by raw value, and per-leg stats can be assembled from sample queries over each leg's window.Verification
bun codegenregenerates the nitrogen output cleanly for the new field (standard enum-field codegen, same shape asWorkoutConfiguration.activityType);bun typecheck,bun lint, andbun run testall pass on this branch.14.0.2viapatch-package(TS interface + shipped d.ts + regeneratedWorkoutActivity.hpp/WorkoutActivity.swift+ theWorkoutProxy.swiftserializer). The app's typecheck and full Jest suite are green, including tests that consume the typed legs end-to-end (triathlon → per-leg typing by field, transition filtering by raw value, duathlon order-independence);pod installconsumes the patched pod source. We'd love to drop our patch in favor of an upstream release.Notes
WorkoutActivityType.otherfallback mirrors the existing parent-workout getter rather than force-unwrapping.