Skip to content

Default weight profile - #1227

Merged
rolandgeider merged 8 commits into
masterfrom
default-weight-profile
Jul 30, 2026
Merged

Default weight profile#1227
rolandgeider merged 8 commits into
masterfrom
default-weight-profile

Conversation

@rolandgeider

@rolandgeider rolandgeider commented Jun 19, 2026

Copy link
Copy Markdown
Member

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

jmccaull and others added 8 commits May 28, 2026 15:22
# 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 weightUnitId nullable in routine models and update log creation to fall back to the resolved WeightUnit object 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.

Comment thread lib/features/routines/models/slot_entry.dart
Comment thread lib/features/routines/models/set_config_data.dart
Comment thread lib/features/routines/providers/gym_state_notifier.dart
@rolandgeider
rolandgeider merged commit e3affdd into master Jul 30, 2026
21 checks passed
@rolandgeider rolandgeider mentioned this pull request Jul 30, 2026
2 tasks
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.

Use plate selection to imply default weight unit

3 participants