data_table v1.3.0: Dots renderer for status timelines + fix dag_engine_ui antipattern + pitfalls doc (issue 0081-O.5)

PARTE A - CellRenderer::Dots (v1.3.0):
- Add Dots=8 to CellRenderer enum (data_table_types.h)
- Add dots_separator/dots_max/dots_show_count/dots_glyph_size fields to ColumnSpec
- Implement draw_cell_custom case Dots in data_table.cpp
  - Parses comma-separated cell value into tokens
  - Looks up each token in badges for color + optional glyph override
  - Per-dot tooltip via tooltip_on_hover
- tql_emit: serialize renderer="dots" + dots_max/dots_show_count/dots_glyph_size/dots_separator
- tql_apply: deserialize all Dots fields
- tql_emit_test: +6 assertions (58 total, 0 failed)
- tql_apply_test: +8 assertions (114 total, 0 failed)
- test_column_specs: +2 tests (10/10 pass)

PARTE B - dag_engine_ui fix: 10 cols -> 6 cols (submodule commit 61314b7)

PARTE C - docs/capabilities/data_table_renderers.md:
- Update to v1.3.0
- Add decision tree for renderer selection
- Add CellRenderer::Dots section with canonical example
- Add Common pitfalls section (multiple columns, badge for free-text, etc.)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-15 17:24:53 +02:00
parent 304f48ccac
commit 4acf6986d3
10 changed files with 389 additions and 18 deletions
+94 -1
View File
@@ -1,5 +1,6 @@
// test_column_specs.cpp — Smoke / back-compat tests for declarative cell renderers.
// Issue 0081-N, v1.1.0. Phase 2 (issue 0081-O, v1.2.0).
// Phase 2.5 (issue 0081-O.5, v1.3.0): Dots renderer.
//
// These tests verify:
// 1. TableInput without column_specs compiles and links (back-compat).
@@ -7,6 +8,7 @@
// 6. Button renderer: TableEvent struct is constructible; events_out pointer accepted.
// 7. Tooltip field: ColumnSpec with tooltip_on_hover=true compiles and links.
// 8. render() overload with events_out=nullptr back-compat (symbol resolution only).
// 9. Dots renderer: ColumnSpec with CellRenderer::Dots + badges constructs correctly.
//
// None of these tests call data_table::render() (requires ImGui context).
// They only verify that the new types are usable and that the symbols from
@@ -305,6 +307,95 @@ static void test_render_backcompat_overload() {
std::printf("PASS: test_render_backcompat_overload (both render() signatures link)\n");
}
// ---------------------------------------------------------------------------
// Test 9: Dots renderer — ColumnSpec with CellRenderer::Dots + badges.
// Cell value "ok,error,ok,running,ok" — 5 tokens, 5 badge rules, dots_max=5.
// ---------------------------------------------------------------------------
static void test_dots_column_spec() {
// Dataset with one column holding comma-separated run statuses.
static const char* cells_dots[] = {
"ok,error,ok,running,ok",
"ok,ok,ok",
"failed,failed",
};
std::vector<std::string> hdrs = {"recent"};
std::vector<ColumnType> types = {ColumnType::String};
TableInput t;
t.name = "t_dots";
t.rows = 3;
t.cols = 1;
t.cells = cells_dots;
t.headers = hdrs;
t.types = types;
ColumnSpec cs;
cs.id = "recent";
cs.renderer = CellRenderer::Dots;
cs.badges = {
BadgeRule{"ok", "#22c55e", ""}, // default glyph ●
BadgeRule{"error", "#ef4444", ""},
BadgeRule{"failed", "#ef4444", ""},
BadgeRule{"running", "#eab308", ""},
BadgeRule{"pending", "#94a3b8", ""},
};
cs.dots_max = 5;
cs.dots_show_count = false;
cs.tooltip_on_hover = true;
t.column_specs.resize(1);
t.column_specs[0] = cs;
assert(t.column_specs[0].renderer == CellRenderer::Dots);
assert(t.column_specs[0].dots_max == 5);
assert(t.column_specs[0].badges.size() == 5);
assert(t.column_specs[0].dots_show_count == false);
assert(t.column_specs[0].tooltip_on_hover == true);
assert(t.column_specs[0].dots_separator == ',');
// Verify that the struct is copyable and the enum value is distinct.
ColumnSpec cs2 = cs;
assert(cs2.renderer == CellRenderer::Dots);
assert(cs2.dots_max == 5);
std::printf("PASS: test_dots_column_spec "
"(5 badge rules, dots_max=5, tooltip_on_hover=true)\n");
}
// ---------------------------------------------------------------------------
// Test 10: Dots TQL roundtrip — emit + apply preserves Dots fields.
// ---------------------------------------------------------------------------
static void test_dots_tql_roundtrip() {
// Import tql::emit / tql::apply via the smoke test include paths.
// This test checks that the new Dots fields survive a TQL roundtrip.
// We populate aux_column_specs[0] and verify apply reconstructs them.
// We only check struct construction + enum identity here (no Lua context
// available without the full fn_table_viz library; the roundtrip is covered
// by test_fn_table_viz_smoke.cpp test_tql_roundtrip).
ColumnSpec cs;
cs.id = "recent";
cs.renderer = CellRenderer::Dots;
cs.dots_separator = ',';
cs.dots_max = 5;
cs.dots_show_count = false;
cs.badges = {{"ok", "#22c55e", ""}, {"error", "#ef4444", ""}};
// Build a State with aux_column_specs to verify the container accepts Dots.
data_table::State st;
st.stages.push_back(data_table::Stage{});
st.aux_column_specs.push_back({cs});
assert(st.aux_column_specs.size() == 1);
assert(st.aux_column_specs[0].size() == 1);
assert(st.aux_column_specs[0][0].renderer == CellRenderer::Dots);
assert(st.aux_column_specs[0][0].dots_max == 5);
assert(st.aux_column_specs[0][0].badges.size() == 2);
std::printf("PASS: test_dots_tql_roundtrip "
"(State::aux_column_specs accepts Dots spec)\n");
}
// ---------------------------------------------------------------------------
// main
// ---------------------------------------------------------------------------
@@ -318,6 +409,8 @@ int main() {
test_button_column_spec_and_event_struct();
test_tooltip_column_spec();
test_render_backcompat_overload();
std::printf("=== ALL TESTS PASSED (8/8) ===\n");
test_dots_column_spec();
test_dots_tql_roundtrip();
std::printf("=== ALL TESTS PASSED (10/10) ===\n");
return 0;
}