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:
2026-06-30 21:43:11 -07:00
parent bd9ea76d6a
commit 14145c9f15
6 changed files with 38 additions and 9 deletions

View File

@@ -520,6 +520,13 @@ def get_handler(stack: str | None) -> StackHandler | None:
return HANDLERS.get(stack)
def available_stacks() -> list[str]:
"""The stack names castle has handlers for — the single source of truth for the
CLI ``--stack`` choices, the ``GET /stacks`` endpoint, and the dashboard select.
"""
return sorted(HANDLERS)
def _declared_commands(comp: ProgramSpec, verb: str) -> list[list[str]] | None:
"""Declared argv-lists for a verb, or None.