fix(tdee): resolve inverse calorie goal bug and improve calculation transparency#916
fix(tdee): resolve inverse calorie goal bug and improve calculation transparency#916CodeWithCJ merged 1 commit intomainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug in the Adaptive TDEE calculation that caused calorie goals to invert based on activity level changes. It refines the calculation logic to ensure consistent dietary intent and enhances the user interface by providing greater transparency into maintenance calorie expenditure and clearer guidance within the settings for adaptive mode. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively resolves a critical bug in the adaptive TDEE calculation, where the calorie goal was inversely affected by the activity level setting. The solution, which decouples the user's dietary intent from the activity level by using a fixed baseline, is well-implemented and robust. Furthermore, the added transparency in the UI, such as displaying the raw expenditure and providing contextual hints in the settings, significantly improves the user experience and understanding of the feature. The code changes are clear, well-commented, and directly address the stated goals of the pull request.
Description
Provide a brief summary of your changes.
This PR addresses a technical bug in the Adaptive TDEE calculation and improves user guidance for health metrics.
Core Fixes:
Decoupled Activity Level from Goal Calculation: Fixed an issue where increasing the activity level setting mathematically decreased the final calorie goal. The calculation now uses a fixed 1.2x BMR (Sedentary) baseline to determine the user's "dietary intent" (deficit/surplus), ensuring the goal remains stable regardless of the activity setting.
Added Expenditure Transparency: Introduced a dedicated "Expenditure" line in the Adaptive TDEE information box on the Diary page. This allows users to see the raw maintenance burn calculated by the server.
Enhanced Settings Guidance: Added a helper note to the Activity Level setting in Calculation Settings to clarify its role as a fallback baseline when using Adaptive mode.
Technical Details:
Modified
DailyProgress.tsx
to standardize the calorieGoalOffset calculation.
Updated
CalculationSettings.tsx
with conditional i18n hints for Adaptive mode.
Verified mathematical stability via unit tests in calorieCalculations.test.ts.
Related Issue
PR type [x] Issue [ ] New Feature [ ] Documentation
Linked Issue: # #908
Checklist
Please check all that apply:
pnpm run validate(especially for Frontend).en) translation file (if applicable).rls_policies.sqlfor any new user-specific tables.Screenshots (if applicable)
Before
[Insert screenshot/GIF here]
After
[Insert screenshot/GIF here]
