Default weight profile - #1227
Merged
Merged
Conversation
# Conflicts: # lib/features/routines/providers/routines_notifier.dart # lib/features/routines/providers/routines_notifier.g.dart # test/features/exercises/providers/exercise_filters_notifier_test.mocks.dart # test/features/routines/helpers/routine_form_test_overrides.dart # test/features/routines/models/log_test.dart # test/features/routines/providers/routines_notifier_test.dart # test/features/routines/providers/routines_notifier_test.mocks.dart # test/features/routines/widgets/forms/routine_form_test.dart
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates routines/gym-mode logic to derive the default weight unit (kg/lb) from the user’s profile rather than hard-coding kg, and adjusts hydration/logging and tests so routines and ad-hoc set configs behave correctly when weight_unit is not explicitly provided.
Changes:
- Derive and apply a profile-based default weight unit during routine hydration and when creating ad-hoc set configs in gym mode.
- Make
weightUnitIdnullable in routine models and update log creation to fall back to the resolvedWeightUnitobject when no explicit ID exists. - Update form wiring and tests/mocks to set/stub weight/repetition units and the user profile repository/provider.
Reviewed changes
Copilot reviewed 19 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/features/routines/widgets/forms/slot_entry_form_test.dart | Updates widget test to explicitly select weight/repetition units before submit and assert persisted IDs. |
| test/features/routines/widgets/forms/routine_form_test.mocks.dart | Regenerated Mockito mocks to include UserProfileRepository. |
| test/features/routines/widgets/forms/routine_form_test.dart | Stubs/overrides userProfileRepositoryProvider to avoid real DB access during tests. |
| test/features/routines/screens/gym_mode_test.mocks.dart | Regenerated Mockito mocks to include UserProfileRepository. |
| test/features/routines/screens/gym_mode_test.dart | Stubs/overrides userProfileRepositoryProvider for gym mode tests. |
| test/features/routines/providers/routines_notifier_test.dart | Adds coverage for default-weight-unit resolution from profile and re-hydration on profile changes. |
| test/features/routines/providers/gym_state_test.dart | Adds test ensuring ad-hoc set configs get the profile default weight unit. |
| test/features/routines/models/slot_entry_model_test.dart | Verifies SlotEntry.withData leaves weight unit unset so profile default can apply. |
| test/features/routines/models/log_test.dart | Adds test ensuring log derives weightUnitId from resolved unit object when ID is missing. |
| test/features/routines/helpers/routine_form_test_overrides.mocks.dart | Regenerated mocks to include UserProfileRepository. |
| test/features/routines/helpers/routine_form_test_overrides.dart | Extends override helpers to stub UserProfileRepository in routine-form-related tests. |
| test/core/helpers_test.dart | Formatting-only update to expected log message assertion. |
| lib/features/routines/widgets/forms/slot_entry.dart | Fixes form callbacks to set unit IDs/objects via model setters when user changes units. |
| lib/features/routines/providers/routines_notifier.g.dart | Regenerated Riverpod code for routines notifier. |
| lib/features/routines/providers/routines_notifier.dart | Rehydrates routines based on profile default unit and waits for profile stream before full fetch hydration. |
| lib/features/routines/providers/gym_state_notifier.g.dart | Regenerated Riverpod code for gym state notifier. |
| lib/features/routines/providers/gym_state_notifier.dart | Applies profile default weight unit to newly inserted ad-hoc set configs. |
| lib/features/routines/models/slot_entry.dart | Changes slot-entry weightUnitId semantics to allow null for “profile default applies”. |
| lib/features/routines/models/set_config_data.g.dart | Stops defaulting weightUnitId to kg during JSON parsing. |
| lib/features/routines/models/set_config_data.dart | Makes weightUnitId nullable in model construction. |
| lib/features/routines/models/log.dart | Updates log creation to fall back to resolved WeightUnit object when ID is absent. |
| lib/features/account/models/user_profile.dart | Adds defaultWeightUnitId derived from profile metric preference. |
Files not reviewed (3)
- lib/features/routines/models/set_config_data.g.dart: Generated file
- lib/features/routines/providers/gym_state_notifier.g.dart: Generated file
- lib/features/routines/providers/routines_notifier.g.dart: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Proposed Changes
This is #1207 with master merged in (couldn't push because of screenshots, which are in LFS and need an extra permission, "allow maintainers to push to branch" is not enough)
Closes #1180