Back to Blocks

Claude Terminal

Loading...

Task Details
PXL-725Done
Urgent

🪄 Fix setup form issues

Assignee
Ahmed KhalafAhmed Khalaf
b2-herawizardui/ux

Fixes bugs in the setup wizard where your inputs weren't being saved correctly.


> Technical Details

Problem

Unable to update maintenance settings in the wizard form and persist changes. This appears to be a broader issue affecting multiple areas of the wizard flows.

Tasks
  1. Investigate and fix maintenance settings update issue: The maintenance settings form in the wizard is not properly updating/persisting changes when the user submits the form. Debug the data flow to identify where the update is failing.
  2. Audit all wizard forms: Systematically review all wizard flows in the app to identify any other areas that may have similar update/persistence issues. Check:
    • Maintenance settings wizard
    • Goal setup wizard
    • Profile setup wizard
    • Any other multi-step wizard flows
  3. Move cancel confirmation dialogs: Currently, cancel confirmation dialogs are attached to the sheet's dismiss action. This should be refactored so the confirmation dialog is triggered by the cancel button itself, not the sheet dismissal. This provides better UX control and prevents unintended confirmation prompts.
    • Update all wizard sheets to implement this pattern
    • Ensure the cancel button triggers the confirmation dialog
    • Allow sheet dismissal via swipe without triggering confirmation (or handle appropriately based on UX requirements)
Technical Context
  • This involves wizard/onboarding flows that use sheet presentations
  • Forms use SwiftUI's form bindings and state management
  • Need to verify data persistence layer is correctly saving changes
  • Cancel confirmation dialogs likely use .confirmationDialog or .alert modifiers
Acceptance Criteria
  • Maintenance settings can be successfully updated through the wizard form
  • All wizard flows have been audited and any similar update issues are fixed
  • Cancel confirmation dialogs are consistently triggered from the cancel button across all wizard sheets
  • Changes persist correctly after form submission
  • No regression in existing wizard functionality
Build Instructions

Build instruction: Use -destination 'platform=iOS Simulator,name=iPhone 17 Pro' when building this project

Comments (1)
Ahmed Khalaf
Ahmed KhalafJan 12, 2026, 1:10 PM

Test Scenarios for PXL-725

🎯 Critical Test - Body Composition Persistence (Main Bug Fix)

✅ Scenario 1: Katch-McArdle Formula with Body Fat %

  1. Open energy target settings for a day
  2. Click "Use Wizard" (if no target) or edit existing maintenance
  3. Choose "Calculate from Maintenance" → "Calculate from Components"
  4. Resting Energy: Select "BMR Formula"
  5. Select "Katch-McArdle" formula (requires body composition)
  6. Enter weight: 80 kg
  7. Enter body fat percentage: 15.5%
  8. Complete the wizard
  9. Close the energy target sheet completely
  10. Reopen energy target settings for the same day
  11. Click "Maintenance" button to view settings
  12. VERIFY: Body fat % shows 15.5% (not blank/lost)
  13. VERIFY: Body composition method is set to "Enter Body Fat %"

✅ Scenario 2: Cunningham Formula with Lean Body Mass

  1. Repeat steps 1-5 above
  2. Select "Cunningham" formula
  3. Enter weight: 75 kg
  4. Switch to "Lean Body Mass" input
  5. Enter lean body mass: 65.2 kg
  6. Complete the wizard
  7. Close and reopen energy target settings
  8. Open maintenance settings
  9. VERIFY: Lean body mass shows 65.2 kg (not blank)
  10. VERIFY: Body composition method is "Enter Lean Body Mass"

📝 Full Configuration Persistence Test

✅ Scenario 3: Components Mode with All Settings

  1. Use wizard: Components mode
  2. Resting Energy: BMR Formula (Mifflin-St Jeor)
  3. Enter: Weight 70 kg, Height 175 cm, Age 30, Sex: Male
  4. Active Energy: Activity Multiplier → "Moderately Active"
  5. Adjustment: Deficit of 500 kcal
  6. Complete wizard
  7. Save the target
  8. Close app or navigate away and back
  9. Reopen energy target for that day
  10. Open maintenance settings
  11. VERIFY ALL:
    • Mode: Components
    • Resting: BMR Formula (Mifflin-St Jeor)
    • Weight: 70 kg, Height: 175 cm, Age: 30, Sex: Male
    • Active: Activity Multiplier (Moderately Active)

✅ Scenario 4: Energy Balance Mode Persistence

  1. Use wizard: Energy Balance
  2. Select "Last 7 Days"
  3. Complete with calculated value showing
  4. Close and reopen
  5. VERIFY: Energy balance settings and calculated value persist

🚫 Cancel Confirmation Tests (Should Already Work)

✅ Scenario 5: Cancel with Progress

  1. Start energy wizard
  2. Proceed to step 2 or 3
  3. Click "Cancel" button (top left)
  4. VERIFY: Confirmation dialog appears asking "Cancel Setup?"
  5. Click "Continue Setup" → wizard stays open
  6. Click "Cancel" again → "Cancel Setup" → wizard closes

✅ Scenario 6: Cancel on First Step

  1. Open wizard
  2. Immediately click "Cancel" (still on step 1)
  3. VERIFY: Dialog should NOT appear (dismisses immediately)

✅ Scenario 7: Maintenance Sheet Cancel with Changes

  1. Open existing energy target maintenance settings
  2. Change a value (e.g., change weight from 70 to 75)
  3. Click "Cancel"
  4. VERIFY: "Discard Changes?" dialog appears
  5. Test both "Discard" and "Cancel" options work

🔄 Edge Cases to Test

✅ Scenario 8: Switch Between Body Composition Methods

  1. Complete wizard with Katch-McArdle + Body Fat % = 20
  2. Reopen maintenance
  3. Switch to "Enter Lean Body Mass"
  4. Enter LBM: 60 kg
  5. Click "Set Maintenance"
  6. Reopen
  7. VERIFY: LBM value 60 persists (not reverted to body fat)

✅ Scenario 9: Apple Health Sync Body Composition

  1. Use wizard with Katch-McArdle formula
  2. Tap "Sync" button to pull from Apple Health
  3. Complete wizard
  4. Reopen
  5. VERIFY: Synced body composition values persist

⚠️ Known Limitations (May Need Follow-up)

✅ Scenario 10: Macro Wizard Body Mass (May Still Have Issues)

  1. Open Protein target wizard
  2. Choose "Per Body Mass" calculation
  3. If there's an Apple Health sync for body composition data
  4. Complete wizard
  5. CHECK: Does body fat/LBM data persist? (May not - found in audit)

📋 Changes Made

  1. WizardResultApplier.swift: Added body composition field application (leanBodyMass, bodyFatPercent, bodyCompositionMethod)
  2. NutrientTargetSheet.swift: Added MaintenanceConfiguration save after wizard completion
  3. NutrientTargetViewModel.swift: Added saveMaintenanceConfigurationToDay() method

All cancel confirmation dialogs already use the correct pattern (attached to Cancel button, not sheet dismissal).

Created Dec 12, 2025, 5:58 PM | Updated Jan 16, 2026, 6:09 PM