Populate the program stack select from castle-api
The dashboard's stack dropdown hardcoded its options (python-cli/fastapi/ react-vite), so a supabase program showed "(none)" — the value had no matching option. Make the backend the single source of truth instead: - core: available_stacks() returns sorted(HANDLERS) — the stacks castle has handlers for. - castle-api: GET /stacks exposes it. - cli: --stack choices derive from available_stacks() (drops the duplicated list). - app: ProgramFields fetches /stacks (useStacks) and renders options from it, always including the current value so it never silently blanks; StackBadge gets a Supabase label. A new backend stack now appears everywhere without a frontend edit.
This commit is contained in:
@@ -4,12 +4,19 @@ from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, HTTPException, status
|
||||
|
||||
from castle_core.stacks import available_actions, run_action
|
||||
from castle_core.stacks import available_actions, available_stacks, run_action
|
||||
|
||||
from castle_api.config import get_config
|
||||
|
||||
programs_router = APIRouter(tags=["programs"])
|
||||
|
||||
|
||||
@programs_router.get("/stacks")
|
||||
def list_stacks() -> list[str]:
|
||||
"""Stack names castle has handlers for — populates the dashboard's stack select
|
||||
and keeps it in sync with the backend (no hardcoded frontend list)."""
|
||||
return available_stacks()
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Unified program action endpoint
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user