AI Plan Generation. Clear button sets focus

This commit is contained in:
AG
2025-12-15 22:46:04 +02:00
parent 854eda98d2
commit c275804fbc
9 changed files with 542 additions and 9 deletions

View File

@@ -64,6 +64,23 @@ Users can structure their training via Plans.
* **Logic**: Supports reordering capabilities via drag-and-drop in UI.
* **3.2.2 Plan Deletion**
* Standard soft or hard delete (Cascades to PlanExercises).
* **3.2.3 AI Plan Creation**
* **Trigger**: "Create with AI" option in Plans FAB Menu, or "Ask your AI coach" link from Tracker (when no plans exist).
* **UI Flow**:
* Opens a dedicated Side Sheet in the Plans view.
* User enters a text prompt describing desired workout (e.g., "Create a 20-minute HIIT workout").
* "Generate" button initiates AI call.
* **AI Logic**:
* System sends prompt to AI service (`geminiService`).
* AI returns a structured JSON object containing: `name`, `description`, and `exercises` array.
* Each exercise object contains: `name`, `isWeighted` (boolean), `restTimeSeconds` (number).
* For **new exercises** (not in user's library), AI also provides: `type` ('reps' or 'time'), `unilateral` (boolean).
* **Auto-Creation of Exercises**:
* System parses AI response.
* For each exercise in the response, checks if it exists in the user's exercise library by name.
* If not found, creates a new `Exercise` record with AI-provided attributes (type, unilateral flag) via `saveExercise`.
* Links the new/existing exercise ID to the plan step.
* **Result**: Saves the generated `WorkoutPlan` to DB and displays it in the Plans list.
### 3.3. Exercise Library
* **3.3.1 Exercise Types**