From 272563060c1bcfd635b461602f59460d69f86e9c Mon Sep 17 00:00:00 2001 From: Phillip Tarrant Date: Tue, 24 Feb 2026 15:46:04 -0600 Subject: [PATCH 1/2] feat: auto-populate suggested reps and weight in log form Pre-fill the reps and weight inputs with progression engine suggestions so users can log sets without manually retyping values each time. Suggestions flow through the template chain on initial page load and on all HTMX partial responses (log, edit, delete). --- app/routes/logging.py | 25 +++++++++++++++++++++++ app/templates/partials/exercise_card.html | 4 ++++ app/templates/partials/log_form.html | 2 ++ 3 files changed, 31 insertions(+) diff --git a/app/routes/logging.py b/app/routes/logging.py index 9b753e2..146f562 100644 --- a/app/routes/logging.py +++ b/app/routes/logging.py @@ -14,6 +14,7 @@ from sqlmodel import Session from app.database import get_db_session from app.models.user import User from app.services.log_service import LogService +from app.services.progression_service import ProgressionService from app.services.workout_session_service import WorkoutSessionService from app.utils.auth import get_current_admin_user, get_active_profile_id @@ -80,6 +81,10 @@ async def log_set( logs = log_service.list_logs_for_exercise(ws.id, exercise_id) next_set = len(logs) + 1 + # Fetch suggestion for pre-filling the next set form + progression = ProgressionService(session) + suggestion = progression.get_suggestion(active_profile_id, exercise_id) + templates = request.app.state.templates return templates.TemplateResponse("partials/log_entry.html", { "request": request, @@ -88,6 +93,8 @@ async def log_set( "workout_day_id": workout_day_id, "next_set": next_set, "session_id": ws.id, + "suggested_reps": suggestion.get("suggested_reps"), + "suggested_weight": suggestion.get("suggested_weight"), }) @@ -124,6 +131,13 @@ async def edit_log( logs = log_service.list_logs_for_exercise(log.session_id, log.exercise_id) next_set = len(logs) + 1 + # Fetch suggestion for pre-filling the next set form + active_profile_id = get_active_profile_id(request) + suggestion = {} + if active_profile_id: + progression = ProgressionService(session) + suggestion = progression.get_suggestion(active_profile_id, log.exercise_id) + templates = request.app.state.templates return templates.TemplateResponse("partials/log_entry.html", { "request": request, @@ -132,6 +146,8 @@ async def edit_log( "workout_day_id": 0, "next_set": next_set, "session_id": log.session_id, + "suggested_reps": suggestion.get("suggested_reps"), + "suggested_weight": suggestion.get("suggested_weight"), }) @@ -164,6 +180,13 @@ async def delete_log( logs = log_service.list_logs_for_exercise(session_id, exercise_id) next_set = len(logs) + 1 + # Fetch suggestion for pre-filling the next set form + active_profile_id = get_active_profile_id(request) + suggestion = {} + if active_profile_id: + progression = ProgressionService(session) + suggestion = progression.get_suggestion(active_profile_id, exercise_id) + templates = request.app.state.templates return templates.TemplateResponse("partials/log_entry.html", { "request": request, @@ -172,6 +195,8 @@ async def delete_log( "workout_day_id": 0, "next_set": next_set, "session_id": session_id, + "suggested_reps": suggestion.get("suggested_reps"), + "suggested_weight": suggestion.get("suggested_weight"), }) return HTMLResponse("") diff --git a/app/templates/partials/exercise_card.html b/app/templates/partials/exercise_card.html index 4f20536..bd9df54 100644 --- a/app/templates/partials/exercise_card.html +++ b/app/templates/partials/exercise_card.html @@ -32,6 +32,10 @@ {% if active_profile %}
+ {% if suggestions and suggestions[exercise.id] %} + {% set suggested_reps = suggestions[exercise.id].suggested_reps %} + {% set suggested_weight = suggestions[exercise.id].suggested_weight %} + {% endif %} {% if existing_logs and existing_logs[exercise.id] %} {% set logs = existing_logs[exercise.id] %} {% set exercise_id = exercise.id %} diff --git a/app/templates/partials/log_form.html b/app/templates/partials/log_form.html index c34613d..2cac77b 100644 --- a/app/templates/partials/log_form.html +++ b/app/templates/partials/log_form.html @@ -11,9 +11,11 @@ Set {{ next_set|default(1) }}