feat(0036b): NodeGroups admite kind=Group + loader entities
NodeGroupsWindowState gana un discriminador `kind` (Table | Group) y
un flag `focus_request` (lo consumira 0036c). Por defecto Table, asi
que el flujo historico (DuckDB rows tras expand de un nodo Table) no
cambia.
kind=Group lee directamente operations.db consultando
`entities WHERE group_id = container_id` con columnas fijas
(id, name, type_ref, status, updated_at) ordenadas por updated_at DESC.
Los nuevos loaders viven en node_groups.cpp:
- node_groups_count_for_group -> SELECT count(*) ...
- node_groups_page_for_group -> SELECT id,name,type_ref,status,
updated_at ... LIMIT ? OFFSET ?
Para columnas, opcion (A) del issue: pre-popular meta.columns con la
lista fija al abrir kind=Group, asi el render se mantiene generico.
NodeGroupsRow.values guarda los 5 campos en ese orden y row.id es la
key natural (= entity_id de la fila — al ser ya entidad, no hace falta
promocionarla).
Render en views.cpp ramifica por kind:
- Table: layout original [id_col + columns + promoted] con doble
click -> promote/focus.
- Group: layout [columns fijas] sin promoted. Doble click sobre la
fila ya pone want_focus_entity = id (los flujos posteriores 0036c-e
afinan UX). Right click ofrece "Focus in Inspector".
main.cpp dispatcha por kind al refrescar paginas y, al cerrar via X,
solo llama a node_groups_set_expanded para kind=Table (Group no usa
ese flag).
views_node_groups_windows_sync se hace kind-aware: solo reconcilia
entries kind=Table contra el set de Tables expandidas; no toca las
entries kind=Group (las gestiona views_node_groups_open).
Nueva API publica:
views_node_groups_open(app, container_id, kind, ops_db)
Crea o reusa la entry, setea focus_request=true y para kind=Group
pre-popula meta.columns + intenta leer `name` del Group para el
titulo. Sin caller todavia — la consume 0036c.
Tests:
- tests/test_node_groups_loader.py (6 tests) verifica el contrato
SQL via gx-cli. Nuevo subcomando `gx-cli group page <id>` espejea
el loader C++ exactamente (mismo SQL); tambien expuesto como tool
MCP `group_page` para que Echo pueda inspeccionar Groups.
Resultado:
- WSL: 89 -> 95 passed
- Windows: 78+11 -> 84+11 passed
- Build C++ Windows limpio, sin warnings nuevos.
- Regresion kind=Table: comportamiento identico (mismo render,
mismo loader DuckDB).
Refs: issues/0036b-kind-discriminator-and-group-loader.md
This commit is contained in:
@@ -1697,11 +1697,15 @@ static void render() {
|
||||
g_app.want_toggle_nodegroups = false;
|
||||
g_app.toggle_nodegroups_id.clear();
|
||||
}
|
||||
// Cierre via X de la ventana -> bajar expanded en BD.
|
||||
// Cierre via X de la ventana -> bajar expanded en BD (solo kind=Table).
|
||||
// En kind=Group no hay metadata `expanded`; basta con borrar la entry.
|
||||
for (auto it = g_app.node_groups_windows.begin(); it != g_app.node_groups_windows.end(); ) {
|
||||
if (!it->second.open && !g_input_path.empty()) {
|
||||
ge::node_groups_set_expanded(g_input_path.c_str(),
|
||||
it->first.c_str(), false);
|
||||
if (!it->second.open) {
|
||||
if (it->second.kind == ge::NodeGroupsKind::Table
|
||||
&& !g_input_path.empty()) {
|
||||
ge::node_groups_set_expanded(g_input_path.c_str(),
|
||||
it->first.c_str(), false);
|
||||
}
|
||||
it = g_app.node_groups_windows.erase(it);
|
||||
} else ++it;
|
||||
}
|
||||
@@ -1711,6 +1715,36 @@ static void render() {
|
||||
if (!w.page_dirty) continue;
|
||||
const auto& m = w.meta;
|
||||
w.last_error.clear();
|
||||
|
||||
if (w.kind == ge::NodeGroupsKind::Group) {
|
||||
// kind=Group: contar y paginar entidades hijas via group_id.
|
||||
bool ok_count = ge::node_groups_count_for_group(
|
||||
g_input_path.c_str(),
|
||||
m.entity_id.c_str(), &w.total_rows);
|
||||
if (!ok_count) {
|
||||
char buf[256];
|
||||
std::snprintf(buf, sizeof(buf),
|
||||
"group count failed | container=%s", m.entity_id.c_str());
|
||||
w.last_error = buf;
|
||||
std::fprintf(stderr, "[graph_explorer] %s\n", buf);
|
||||
}
|
||||
bool ok_page = ge::node_groups_page_for_group(
|
||||
g_input_path.c_str(),
|
||||
m.entity_id.c_str(),
|
||||
w.offset, 200, &w.page);
|
||||
if (!ok_page && w.last_error.empty()) {
|
||||
char buf[256];
|
||||
std::snprintf(buf, sizeof(buf),
|
||||
"group page query failed | offset=%lld limit=200",
|
||||
(long long)w.offset);
|
||||
w.last_error = buf;
|
||||
std::fprintf(stderr, "[graph_explorer] %s\n", buf);
|
||||
}
|
||||
w.page_dirty = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
// kind=Table: comportamiento original (DuckDB).
|
||||
bool ok_count = ge::node_groups_count(m.duckdb_path_abs.c_str(),
|
||||
m.table_name.c_str(),
|
||||
m.filter_sql.empty() ? nullptr : m.filter_sql.c_str(),
|
||||
|
||||
Reference in New Issue
Block a user