refactor(dashboard): discover via docker compose ls #37
Reference in New Issue
Block a user
Delete Branch "chunk-5-dashboard"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
PRD 0018 chunk 5 (the last one). The dashboard's operator-edit verbs (
routes edit,pipelock edit) enumerated running sidecars viadocker ps --filter name=...prefix scans. Switch todocker compose ls-driven discovery so the dashboard, cleanup CLI, and launch step all agree on what's running.Mechanics
claude_bottle/backend/docker/compose.pygrows three shared helpers:list_compose_projects(*, include_stopped=True)— the JSON parse that used to live in cleanup.py, now reusable.slug_from_compose_project(project)— inverse ofcompose_project_name; returns""for projects that don't start with theclaude-bottle-prefix (defends against unrelated compose projects on the host).list_active_slugs(*, include_stopped=False)— sugar for the common "what's running?" question.cleanup.py drops its private
_list_compose_projects+_PROJECT_PREFIXin favor of the shared ones;list_activesimplifies to onecompose lscall instead of two.dashboard.py's
_discover_sidecar_slugsbecomes_discover_active_with_service: cross-references the active slug list with a label-filtereddocker psso only bottles whose given service container is actually up surface in the edit menu. Bottles without an egress sidecar (nobottle.egress.routes) no longer appear forroutes edit.Status
discover_egress_slugsanddiscover_pipelock_slugsreturn the expected slugPRD 0018 chunk 5. The dashboard's operator-edit verbs (`routes edit`, `pipelock edit`) enumerated running sidecars via `docker ps --filter name=...` prefix scans. Switch to `docker compose ls`-based discovery so the dashboard, cleanup CLI, and launch step all agree on what's running. Mechanics: - `claude_bottle/backend/docker/compose.py` grows three shared helpers: `list_compose_projects` (the JSON parse moved out of cleanup), `slug_from_compose_project` (inverse of `compose_project_name`), and `list_active_slugs` (sugar over the first two for the common "what's running?" question). - cleanup.py drops its private `_list_compose_projects` + `_PROJECT_PREFIX` in favor of the shared ones; `list_active` simplifies (one compose-ls call, not two). - dashboard.py's `_discover_sidecar_slugs` becomes `_discover_active_with_service`: cross-references the active slug list with a label-filtered `docker ps` so only bottles whose given service container is actually up surface in the edit menu. Bottles without an egress sidecar (no bottle.egress.routes) no longer appear for `routes edit`. 3 new unit tests cover the slug ↔ compose-project naming contract; manual probe with a fake compose project confirms both `discover_egress_slugs` and `discover_pipelock_slugs` return the expected slug.