feat(yahweh-widget-stat-card): promover patrón stat card como widget

Iter 15. El patrón "tarjeta de dashboard con border-l accent +
label + value grande + descripción + listing opcional" tenía 2
consumers (minga-explorer + brahman-broker-explorer). Ahora vale
extraer al stack yahweh.

crates/modules/ui_engine/widgets/stat-card/:
- pub fn stat_card(cx, label, value: impl Into<SharedString>,
  description, accent, text, text_dim, recent_items: &[String])
  -> impl IntoElement.
- Compone yahweh-widget-card::card_themed; sin theme directo
  (caller pasa text/text_dim ya resueltos).
- 3 tests #[gpui::test] con TestAppContext + theme: smoke con/sin
  items, type-check value.

minga-explorer:
- Borra fn stat_card local (~60 líneas).
- Borra dep yahweh-widget-card.
- 3 callsites pasan value.to_string() (widget acepta
  Into<SharedString>).

brahman-broker-explorer:
- fn state_card refactorizada como wrap del stat_card compartido,
  preservando la traducción ProbeState→(accent,value,description)
  como helper local app-specific.
- Borra dep yahweh-widget-card.

Sub-header del listing: pasa de "recent (N de TOTAL):" a
"recent (N):" — el widget no conoce TOTAL; el caller lo pone en
label si quiere ("Nodos AST (5 de 247)"). Trade-off aceptable
por reusabilidad genérica.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Sergio
2026-05-10 12:33:02 +00:00
parent 1493d616fd
commit af7417ce08
9 changed files with 276 additions and 97 deletions
+55
View File
@@ -6,6 +6,61 @@ ratio/diff ver `git show <sha>`.
## 2026-05-10
### feat(yahweh-widget-stat-card): promover el patrón stat card como widget
Iter 15. El patrón "tarjeta de dashboard con border-l accent +
label + valor grande + descripción + listing opcional" tenía 2
consumers (`minga-explorer` y `brahman-broker-explorer`); ahora vale
extraer al stack yahweh para reusabilidad y mantenimiento single-place.
Crate nuevo `crates/modules/ui_engine/widgets/stat-card/`
(`yahweh-widget-stat-card`):
- **Deps**: `gpui` + `yahweh-widget-card` (compone `card_themed`).
Sin theme directo — el caller pasa `text` y `text_dim` ya
resueltos del theme.
- **`pub fn stat_card(cx, label, value, description, accent,
text, text_dim, recent_items)`**:
- `cx: &App` (acepta `&Context<T>` por deref auto-coerce).
- `value: impl Into<SharedString>` — sirve para counts (`"3"`),
status text (`"UP"`), o cualquier label corto.
- `recent_items: &[String]` — si no vacío, agrega sub-header
`"recent (N):"` + una linea por item.
- 3 tests `#[gpui::test]` con TestAppContext: smoke con/sin
recent_items, type-check de `value` con literal/format/owned.
- Dev-deps: gpui con `test-support` + yahweh-theme para construir
el cx con un theme global.
Cambios consumer:
- **`minga-explorer`**: sustituye su `fn stat_card` local
(~60 líneas) por `use yahweh_widget_stat_card::stat_card`.
Borra dep `yahweh-widget-card` (ya no se usa directo). Adapta
los 3 callsites para pasar `value.to_string()` (el widget
acepta `Into<SharedString>`).
- **`brahman-broker-explorer`**: refactoriza su `fn state_card`
para que sea un wrap de `stat_card` con la traducción
`ProbeState → (accent, value, description)`. La función queda
como helper local porque la mapping del enum es app-specific,
pero el rendering pasa por el widget compartido. Borra dep
`yahweh-widget-card`.
Tests stack: nuevos 3 del widget. Suites de los 2 consumers
intactas (4 minga-explorer, 2 broker-explorer). Stack total ~120
verdes (varía por compilation cache).
Beneficio operativo:
- Cualquier app nueva que necesite cards de dashboard usa
`stat_card(...)` directo; no re-implementa el pattern.
- Cambios visuales (text sizes, padding, sub-header format)
ahora viven en un solo lugar.
- `value: impl Into<SharedString>` es más expressive que el
`usize` rígido del original local.
Pequeña simplificación documentada: el sub-header del listing
pasa de `"recent (N de TOTAL):"` a `"recent (N):"`. El "TOTAL"
ya no se calcula porque el widget no lo conoce — el caller que
quiera mostrarlo lo formatea en el label/value (ej. label `"Nodos
AST (5 de 247)"`). Acceptable trade-off por la reusabilidad
genérica.
### feat(brahman-broker-explorer): nueva app probe del broker brahman
Iter 14. Cierra otro frente: visibilidad del broker brahman (el
broker handshake que matchea Cards consumer/producer). Hasta ahora