Skip to content

feat(sdk): typed table sort keys in the dialog protocol (0.18.0)#149

Merged
facontidavide merged 3 commits into
mainfrom
feat/table-item-typed-values
Jul 18, 2026
Merged

feat(sdk): typed table sort keys in the dialog protocol (0.18.0)#149
facontidavide merged 3 commits into
mainfrom
feat/table-item-typed-values

Conversation

@GNERSIS

@GNERSIS GNERSIS commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

What

Numeric table columns in plugin dialogs sort lexicographically ("720" < "7" < "65") because the dialog protocol carries cells as display text only. This release lets a plugin ship the value beside the text so the host can sort on it:

  • PJ::TableItem{text, optional<NumericValue>}. Native widths survive exactly (int64/uint64 past 2⁵³ never round through a double); TableItem(v, "display") expresses hidden keys (show a date, sort on nanoseconds).
  • setTableRows(name, vector<vector<TableItem>>) — an overload beside the string one, which is kept verbatim. Emits the unchanged rows plus a sparse per-column column_values map (null for valueless cells, keyless columns omitted).
  • setTableSortIndicator(name, col, asc) — the header arrow for tables the plugin sorts via onHeaderClicked.
  • WidgetDataView::tableColumnValues() / tableSortIndicator() for hosts, rejecting malformed input (count mismatch, bad keys); tableRows() now keeps a row's shape when a cell is not a string.
  • The string overload erases stale column_values; long double is rejected at the constraint; non-finite keys are documented + test-pinned to degrade to keyless cells (JSON has no NaN/inf).

Compatibility

old host new host
old plugin today reads rows, no keys → text fallback
new plugin ignores column_values → today typed sort

Additive JSON only — no C ABI change, PJ_DIALOG_PROTOCOL_VERSION unchanged, abi/baseline.abi unchanged, abi_major stays 5. Version 0.17.0 → 0.18.0 (MINOR). One source-level sharp edge, documented in the guide: a braced literal setTableRows("t", {{"a","b"}}) becomes ambiguous (compile error on recompile only; no plugin writes that).

Docs & tests

dialog-plugin-guide.md gains a sortable-tables section with the authoring constraints (never combine sortingEnabled with onHeaderClicked; no item drag/drop on sortable tables). 41 tests in widget_data_test / widget_data_view_test cover the wire round-trip: exactness, sparsity, null cells, non-finite degradation, indicator, malformed input.

Release

After merge this should be tagged v0.18.0 (version triple already aligned: conanfile.py, CMakeLists.txt, recipe.yaml) so PJ4 and pj-official-plugins can pin it — companion PRs in both repos.

Numeric table columns sorted lexicographically because the dialog protocol
carried cells as display text only ("720" < "7" < "65"). Sort keys now travel
beside the display text:

- PJ::TableItem{text, optional<NumericValue>} — the display string and the
  ordering truth. NumericValue keeps the native width, so int64/uint64 keys
  past 2^53 stay exact; TableItem(v, "display") expresses hidden keys (show a
  date, sort on nanoseconds). long double is rejected up front instead of
  failing deep inside std::variant.
- setTableRows(name, vector<vector<TableItem>>) — an overload BESIDE the
  string one, which is kept verbatim for compatibility. Emits the unchanged
  `rows` plus a sparse per-column `column_values` map; columns with no keys
  are omitted, valueless cells are null. Old hosts keep reading `rows` as
  before; old plugins keep compiling and running. The string overload now
  erases stale column_values so alternating overloads can never pair fresh
  rows with old keys.
- setTableSortIndicator(name, col, ascending) — draws the header arrow for a
  table the plugin sorts via onHeaderClicked (Qt paints none while its own
  sorting is off).
- WidgetDataView::tableColumnValues()/tableSortIndicator() for hosts, with
  malformed-input rejection (count mismatch, bad keys); tableRows() keeps a
  row's shape when a cell is not a string instead of mis-aligning the row.
- Non-finite keys (NaN, ±inf) do not survive JSON — documented and pinned:
  they arrive keyless and sort in the text rank.

Additive JSON only: no C ABI change, PJ_DIALOG_PROTOCOL_VERSION unchanged,
abi/baseline.abi unchanged, abi_major stays 5. Version 0.17.0 -> 0.18.0
(MINOR). The dialog-plugin guide gains a sortable-tables section including
the authoring constraints (no sortingEnabled+onHeaderClicked mix, no item
drag/drop on sortable tables) and the braced-literal ambiguity note.

41 tests in widget_data_test / widget_data_view_test cover the wire
round-trip: int64/uint64/float exactness, sparsity, null cells, non-finite
degradation, sort indicator, malformed input.
@facontidavide
facontidavide merged commit bdd1776 into main Jul 18, 2026
4 checks passed
@facontidavide
facontidavide deleted the feat/table-item-typed-values branch July 18, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants