Skip to content

Enhance user feedback and improve exercise log retrieval - #37

Merged
Devasy merged 3 commits into
mainfrom
feat/app-flow-corrected
Apr 25, 2026
Merged

Enhance user feedback and improve exercise log retrieval#37
Devasy merged 3 commits into
mainfrom
feat/app-flow-corrected

Conversation

@Devasy

@Devasy Devasy commented Apr 25, 2026

Copy link
Copy Markdown
Owner

Improve user feedback mechanisms and streamline the retrieval of exercise logs in the settings and workout provider. Adjustments ensure that date ranges are handled correctly, and new utility functions simplify the process of finding the most recent exercise logs. Additionally, tests validate the functionality of these enhancements.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Fixed date range filtering to handle reversed date inputs correctly.
  • Refactor

    • Improved consistency of success/error feedback messages in settings.
    • Refined exercise recommendation logic to use most recent workout data.
    • Adjusted profile screen spacing for better visual balance.
  • Tests

    • Added comprehensive test coverage for exercise history and recommendation behavior.
  • Chores

    • Updated Flutter SDK requirement.

@coderabbitai

coderabbitai Bot commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@Devasy has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 47 minutes and 15 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 47 minutes and 15 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: aeba8088-e6b0-4f67-9f5e-b64ef61a2673

📥 Commits

Reviewing files that changed from the base of the PR and between 20780e6 and 5873b01.

📒 Files selected for processing (3)
  • workout-logger/lib/services/managers/history_manager.dart
  • workout-logger/lib/services/utils/exercise_history.dart
  • workout-logger/test/exercise_history_test.dart

Walkthrough

This PR extracts exercise log lookup logic into a new findMostRecentExerciseLog utility function and refactors related services to use it. It also normalizes date range handling in storage operations, consolidates snackbar helpers in the settings screen, adjusts UI spacing, updates the Flutter SDK version, and introduces comprehensive test coverage.

Changes

Cohort / File(s) Summary
Exercise History Utility
lib/services/utils/exercise_history.dart
Adds new public function findMostRecentExerciseLog that deterministically selects an ExerciseLog for a given exercise ID by sorting sessions by date and returning the first matching exercise log, or null if not found.
Service Refactoring
lib/services/analytics_manager.dart, lib/services/workout_provider.dart
Delegates most-recent exercise log retrieval to the new utility function, replacing inline session sorting and iteration logic. Updates method documentation while preserving fallback behavior for missing data.
Storage Service
lib/services/storage_service.dart, test/test_utils/mock_storage_service.dart
Normalizes date range parameters by selecting lower and upper bounds when start is after end, ensuring consistent inclusive range filtering regardless of argument order.
UI & UX Refinements
lib/screens/profile_screen.dart, lib/screens/settings_screen.dart
Adjusts horizontal and vertical spacing in profile screen app bar padding. Refactors settings screen to use centralized snackbar helpers that verify widget mounted state before showing themed feedback.
SDK Version Update
pubspec.yaml
Bumps Flutter SDK requirement from 3.41.5 to 3.41.6.
Test Coverage
test/exercise_history_test.dart, test/workout_provider_test.dart
Introduces tests for findMostRecentExerciseLog across various scenarios (empty sessions, missing exercise, correct selection, order-independence). Adds unit tests for WorkoutProvider session retrieval and recommendation logic with non-chronological session insertion.

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: improving user feedback (snackbar helpers, mounted checks) and exercise log retrieval (new utility function, delegation in managers).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@workout-logger/lib/services/storage_service.dart`:
- Around line 132-139: HistoryManager.getSessionsInDateRange currently assumes
start <= end and can return an empty list when dates are inverted; mirror the
normalization used in StorageService.getSessionsInDateRange by computing lo =
start.isAfter(end) ? end : start and hi = start.isAfter(end) ? start : end at
the top of HistoryManager.getSessionsInDateRange, then use lo/hi in the date
comparisons instead of start/end so inverted ranges are tolerated consistently
across both implementations.

In `@workout-logger/pubspec.yaml`:
- Line 23: The pubspec currently pins the Flutter SDK to an exact version via
the flutter key (flutter: 3.41.6); change this to a range constraint (for
example flutter: ">=3.41.6 <4.0.0" or flutter: ">=3.41.6") to allow dependency
resolution flexibility—edit the flutter entry in pubspec.yaml accordingly and
rely on CI/tooling to pin exact Flutter builds if reproducible builds are
required.

In `@workout-logger/test/exercise_history_test.dart`:
- Around line 27-87: Add a test that verifies/document the tie-break behavior
when two sessions share the same DateTime: create two sessions with identical
dates using helpers _session/_log/_set (e.g., weights 1 and 2), call
findMostRecentExerciseLog('bench', [a, b]) and assert the outcome you intend
(either a specific weight if you want a defined tie-break or simply expect
non-null and add a comment asserting ties are unspecified). If you prefer
undefined behavior, instead add a clear comment to the findMostRecentExerciseLog
implementation noting that when session.date values are equal the selection is
unspecified (List.sort is not stable), so callers/tests should not rely on a
deterministic tie-break.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e2728e6f-0231-4218-88f4-c1f7cc00b9eb

📥 Commits

Reviewing files that changed from the base of the PR and between f7c5b8c and 20780e6.

📒 Files selected for processing (10)
  • workout-logger/lib/screens/profile_screen.dart
  • workout-logger/lib/screens/settings_screen.dart
  • workout-logger/lib/services/managers/analytics_manager.dart
  • workout-logger/lib/services/storage_service.dart
  • workout-logger/lib/services/utils/exercise_history.dart
  • workout-logger/lib/services/workout_provider.dart
  • workout-logger/pubspec.yaml
  • workout-logger/test/exercise_history_test.dart
  • workout-logger/test/test_utils/mock_storage_service.dart
  • workout-logger/test/workout_provider_test.dart

Comment thread workout-logger/lib/services/storage_service.dart
Comment thread workout-logger/pubspec.yaml
Comment thread workout-logger/test/exercise_history_test.dart
@Devasy
Devasy merged commit 01213a5 into main Apr 25, 2026
2 checks passed
@Devasy
Devasy deleted the feat/app-flow-corrected branch April 25, 2026 11:11
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.

1 participant