diff --git a/backend/main.py b/backend/main.py index f10acff..c30b46b 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1063,10 +1063,22 @@ async def analyze_pipeline(x_profile_id: Optional[str]=Header(default=None), ses @app.get("/api/prompts") def list_prompts(session: dict=Depends(require_auth)): - """List all available AI prompts.""" + """ + List AI prompts. + - Admins: see ALL prompts (including pipeline and inactive) + - Users: see only active single-analysis prompts + """ with get_db() as conn: cur = get_cursor(conn) - cur.execute("SELECT * FROM ai_prompts WHERE active=true AND slug NOT LIKE 'pipeline_%' ORDER BY sort_order") + is_admin = session.get('role') == 'admin' + + if is_admin: + # Admin sees everything + cur.execute("SELECT * FROM ai_prompts ORDER BY sort_order, slug") + else: + # Users see only active, non-pipeline prompts + cur.execute("SELECT * FROM ai_prompts WHERE active=true AND slug NOT LIKE 'pipeline_%' ORDER BY sort_order") + return [r2d(r) for r in cur.fetchall()] @app.put("/api/prompts/{prompt_id}")