diff --git a/web/src/App.svelte b/web/src/App.svelte index 6216845..634aba9 100644 --- a/web/src/App.svelte +++ b/web/src/App.svelte @@ -745,7 +745,8 @@ { role: 'user', content: `Create a personalized weight-loss plan using these details: height ${settings.heightCm} cm, current weight ${settings.weightKg} kg, target weight ${settings.targetWeightKg || 'not set'} kg, activity ${settings.activityLevel}, pace ${settings.pace}. Include daily calorie range, protein target, habits, weekly review steps, and safety notes. Recent meals: ${entries.slice(-10).map(entry => `${entry.date} ${entry.mealType}: ${entry.mealName || entry.description}, ${entry.calories || 0} kcal`).join('; ') || 'none logged yet'}.` }, ], }); - const plan = { id: entryId(), title: `Weight-loss plan ${plans.length + 1}`, version: plans.length + 1, content, createdAt: new Date().toISOString() }; + const version = Math.max(0, ...plans.map(p => Number(p.version || 0))) + 1; + const plan = { id: entryId(), title: 'Weight-loss plan', version, content, createdAt: new Date().toISOString() }; await savePlan(plan); planStatus = 'Plan generated.'; } catch (error) { @@ -777,7 +778,7 @@ ], }); const version = Math.max(0, ...plans.map(plan => Number(plan.version || 0))) + 1; - const updatedPlan = { id: entryId(), title: `Updated plan ${version}`, version, content, createdAt: new Date().toISOString(), previousPlanId: currentPlan.id }; + const updatedPlan = { id: entryId(), title: 'Weight-loss plan', version, content, createdAt: new Date().toISOString(), previousPlanId: currentPlan.id }; await savePlan(updatedPlan); tuneNote = ''; planStatus = 'Plan updated.';