Use adjusted calorie goal for summary and per meal targets - #1543
Conversation
The Nutrition Summary panel showed the raw stored calorie goal while the Daily Energy Goal widget showed the TDEE-adjusted value — causing inconsistent targets on the same Diary page. Compute adjusted macros server-side (percentage-based when available, proportional fallback otherwise) and expose them in the daily summary response. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
DiaryTopControls now reads adjustedGoals from the cached daily summary and overlays the TDEE-adjusted calorie and macro targets so both panels show consistent values. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Prefer adjustedGoals from the API response for protein, carbs, and fat targets so the mobile dashboard stays consistent with the TDEE-adjusted calorie goal. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
PR Validation ResultsChange Detection
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for adjusted nutritional goals across the web frontend, mobile app, and backend server. It fetches and applies adjustedGoals when they differ from raw goals, ensuring that users see dynamically adjusted targets. The review feedback highlights a few key issues: the mobile hook extracts adjustedGoals but fails to use them in the top-level calorie calculations; the web frontend does not include the loading state of the daily summary hook in its page loading check, potentially causing layout shifts; and the backend service uses any types and complex parsing logic that can be simplified for better type safety.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Lift the adjustedGoals logic from DiaryTopControls into Diary.tsx so both the Nutrition Summary and the per-meal cards (Breakfast, Lunch, Dinner, Snacks) use the same TDEE-adjusted calorie goal for their target calculations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
42ca905 to
13bc825
Compare
Description
What problem does this PR solve?
The Diary page shows inconsistent calorie and macro goals: the Daily Energy Goal widget displays the TDEE-adjusted value but the Nutrition Summary and per-meal targets (Breakfast, Lunch, Dinner, Snacks) still use the raw stored goal. This makes the page contradict itself when Adaptive TDEE or goal mode adjustments are active.
How did you implement the solution?
The server already computes adjusted goals internally via goalService.getUserGoals(..., true) but never exposed them in the API response. This PR adds an adjustedGoals field (nullable) to the daily summary response containing the adjusted calories and macros. The web and mobile frontends use this field to display consistent targets across all diary components.
How to Test
PR Type
Checklist
All PRs:
New features only:
Frontend changes (
SparkyFitnessFrontend/):pnpm run validateand it passes.en) translation file.Backend changes (
SparkyFitnessServer/):rls_policies.sqlfor any new user-specific tables.UI changes (components, screens, pages):
Mobile changes (
SparkyFitnessMobile/):Notes for Reviewers