Jacob Hinkle 1a2509ab34 Add Plan page with phase timeline and agent phase management API
- New /plan page shows all phases in order with current phase highlighted
- Add GET/POST/PUT /api/agent/phases endpoints for the AI coach
- Plan link added to navigation bar
- Agent config updated with phase management instructions
2026-06-29 10:51:28 -04:00

27 lines
850 B
Python

from fastapi import APIRouter, Request, Depends
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates
from sqlalchemy import select, desc
from app.models.base import async_session
from app.models.user import User
from app.models.workout import Phase
from app.auth import get_current_user
router = APIRouter()
templates = Jinja2Templates(directory="app/templates")
@router.get("/plan", response_class=HTMLResponse)
async def plan_page(request: Request, user: User = Depends(get_current_user)):
async with async_session() as session:
result = await session.execute(
select(Phase).order_by(Phase.start_date.nulls_last())
)
phases = result.scalars().all()
return templates.TemplateResponse(request, "plan.html", {
"user": user,
"phases": phases,
})