Skip to content

fix(plugin-report): a matrix lays out each header dimension on its own — a date axis by bucket key, a select axis in option order - #34380

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-jiddbx
Nov 16, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-jiddbx

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread

Fixes #34364

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:数据集矩阵报表的行、列表头改为逐个维度决定顺序:报表 order 点名的维度保持服务端顺序;没点名的选项字段按声明的选项顺序;没点名的日期维度按桶键(原始值)升序,空桶排最后;其余维度保持到达顺序。
  • 为什么改:服务端空桶填充不运行时(分页、按度量排序、compareTo、超 2000 格),日期列按首次出现顺序排成一段段;而只要报表带任何 order,两条轴的选项顺序就都失效,按日期排序会把优先级行打乱成 Critical / High / Low / Medium。应用侧无法自救。
  • 风险与回滚:只动 @object-ui/plugin-report 的矩阵表头排列,单元格仍按桶 id 定位、下钻负载不变;平铺表和内嵌图表不变;无服务端或契约改动。回滚即 revert 本 PR。
  • 先看:ui/packages/plugin-report/src/DatasetReportRenderer.tsx 的 matrixAxisComparators 与 compareDateBucketKeys,以及矩阵 pivot 里调用 arrangeGroups 的两行;其次 DatasetReportRenderer.selectOptionOrder-12243.test.tsx 末尾 objectstack#34364 一组。
  • 两分钟验证:pnpm --dir ui exec vitest run packages/plugin-report/src/__tests__/DatasetReportRenderer.selectOptionOrder-12243.test.tsx,预期 15 个测试全过。
  • 需要你做的:无,席位落地。

What changes

  • Per-dimension matrix layout. The matrix no longer switches the layout off for the whole grid when the report carries an order. matrixAxisComparators decides each header dimension on its own:
    • named by the report's scoped order → kept in the server's order;
    • an unnamed select (declared-option ranks) → declared option order, read off the display value (unchanged objectui#12243 rule);
    • an unnamed date → bucket keys ascending (compareDateBucketKeys): the raw key in h.key, compared by code unit, never the localized label; two numbers compare numerically; the empty bucket last, as declaredOptionPosition does;
    • anything else → arrival order.
  • Date-ness is read from the answer, not sniffed. A dimension is a date when its AnalyticsResult.fields[] descriptor says type: 'time', which the analytics compiler sets for every dataset date dimension at any dateGranularity. Bucket keys are minted sort-stable by the server (2026-03, 2026-Q1, 2026-W03, 2026-03-07).
  • Reading of card ask 1 (the seat's): "whatever the query order" is read as "whatever order the server returned the rows in". An author's explicit order on the SAME date dimension (for example desc) is the author's and is kept; only an axis the order does not name is re-laid. Pinned by case (d).
  • Only headers move. arrangeByDeclaredOptions is now a thin wrapper over a generic arrangeGroups (same level-by-level, stable bucket sort, comparator supplied per dimension). The matrix permutes only rowHeaders / colHeaders; every cell is still looked up by bucket id and each header carries its own drill key, so drill payloads stay index-aligned. The flat table and the embedded chart keep their existing rule.
  • Docs. The file header ("Ordering") and the comments at the matrix query and at the layout call now say exactly this: sorting the axis HEADERS is not the forbidden client-side re-sort of rows.
  • Memo key. The pivot memo keys on a serialized list of the named dimensions, not on a per-render object (ui AGENTS.md chore: version packages #10).
  • Changeset: .changeset/34364-matrix-date-axis-order.md (@object-ui/plugin-report: patch).

Tests

New top-level describe in the existing ordering harness DatasetReportRenderer.selectOptionOrder-12243.test.tsx (reuses its crm_case priority options, metadata stub and dataset source). Matrix: rows priority (Low / Medium / High / Critical), columns created_at typed time, values case_count, rows arriving grouped by stored priority with days out of order and a null day (declared nullLabel "No date"):

  • (a) no order → columns 2026-11-03, 2026-11-12, 2026-11-14, 2026-11-16, No date; rows Low, Medium, High, Critical with every cell under its own headers; a click on the first cell drills { priority: 'Low', created_at: '2026-11-03' }.
  • (b) order [{ by: case_count, desc }] → the same layout.
  • (c) order [{ by: created_at, asc }] → columns ascend, rows STILL in option order.
  • (d) order [{ by: created_at, desc }] → columns descend (No date first, as the server sent), rows in option order.
  • CONTROL: order [{ by: priority }] → rows keep the server's order, day columns still ascend.

The existing objectui#12243 cases and the framework#3916 matrix-order cases in DatasetReportRenderer.test.tsx pass unchanged. No forced edits to existing tests.

Acceptance notes

  • None filed. Out of scope as the card says: which analytics version hosted runs (cloud seat), and the server-side fill.
  • The flat summary table and the embedded chart still switch their option layout off under any authored order; the card asks only about the matrix, and a flat table's row order under a measure order is the author's.

Verification

Tests (head 4c7d73b)
  • pnpm --dir ui exec vitest run packages/plugin-report/src/__tests__/DatasetReportRenderer.selectOptionOrder-12243.test.tsx → Test Files 1 passed, Tests 15 passed (on 2fc9d9d and again on 4c7d73b).
  • 4c7d73b7 changes only the test fixture: the created_at sort helper ordered the empty day with a raw U+FFFF sentinel character, now replaced by an explicit null branch (same order).
  • On 2fc9d9d (code unchanged since): pnpm --dir ui exec vitest run packages/plugin-report/ --maxWorkers=2 && pnpm --filter @object-ui/plugin-report run type-check → Test Files 33 passed (33), Tests 329 passed / 7 skipped; type-check done; lock VERDICT command-exit 0.
  • pnpm --dir ui exec eslint on the two changed files → exit 0 (0 errors; 5 pre-existing react-refresh/only-export-components warnings on existing exports). pnpm --dir ui run check:new-line-citations → 0 new citations.
Ablations (scripts/ablation-replace.mjs, mutation proven on disk, each restored to HEAD blob add203e300cf)

Directions were written into the test file before the runs.

  • A: the date comparator returns null → (a), (b) and CONTROL red (3 failed / 12 passed); (c), (d) green as predicted. Re-run on 4c7d73b with the same result.
  • B: if (ordered.has(dim)) return null; → if (ordered.size > 0) return null; (the old all-or-nothing rule) → (b), (c), (d) and CONTROL red (4 failed / 11 passed); (a) green.
  • C: the named-dimension check deleted → (d) and CONTROL red (2 failed / 13 passed).
Derived gate families

Head 4c7d73b7 (re-run after the fixture commit; the list and every exit code match the run on 2fc9d9d), node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack: 38 commands, all exit 0. --ran reconciliation: 38 derived, 38 run, 0 NOT-MEASURED, 0 UNRUN.

node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-sdui-manifest.mjs :: exit 0
node scripts/check-sdui-manifest.mjs --self-test :: exit 0
node scripts/ci/snapshot-next.mjs --self-test :: exit 0
node scripts/pm/check-governed-queue-guard.mjs --self-test :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --dir ui exec vitest run scripts/ :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm check:adr-anchors :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:skill-identifier-liveness :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0

Every family CI runs is read from this PR's check-runs, not re-run here.


Generated by Claude Code

… a date axis by bucket key, a select by its options

A dimension the report's order names keeps the server's order; an unnamed
select takes its declared option order and an unnamed date its bucket keys
ascending, so a measure order or a date order no longer scrambles either axis.

Claude-Session: https://claude.ai/code/session_01ADHkmSDShXaoKYWNqiKtAC
Co-authored-by: Claude <noreply@anthropic.com>
…imension matrix layout

Claude-Session: https://claude.ai/code/session_01ADHkmSDShXaoKYWNqiKtAC
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 16, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#2 · os-steve · session_01ADHkmSzhXR4yUAgwq1bQRi

维护者速读

  • 卡:console matrix report: a date column axis renders in first-seen row order, not by bucket key, whenever the empty-bucket fill does not run (and a report order that fixes it loses the select axis's option order) #34364(p2)。矩阵报表的日期列,在服务端没有补齐空日期桶时(有 limit/offset、按度量排序、compareTo、或格子超过 2000 个),会按行到达的先后排列,变成按优先级分段的多段升序。另外,报表只要写了任何 order,两条轴的 select 选项顺序都会失效。
  • 改了什么:矩阵按维度分别决定表头顺序。
    • 报表 order 点名的维度:保持服务端顺序(作者写 desc 就降序)。
    • 未点名的 select 维度:按声明的选项顺序。
    • 未点名的日期维度:按桶的原始 key 升序,空桶放最后。是否为日期,读结果列自身的 time 类型,不看值。
    • 其他维度:保持到达顺序。
    • 只重排两条表头,不动任何行;单元格仍按桶 id 定位,钻取载荷不变。头部文档和两处注释同步更新。表格和图表的规则不变。
  • 钉子:四种情况,加对照组:不排序时日期列升序、行按选项顺序;按度量排序时布局相同;按日期升序时行仍按选项顺序;按日期降序时列降序。3 处消融都按预期变红。plugin-report 共 33 个文件、329 个测试通过,type-check 通过;派生门禁 38/38 exit 0。
  • CI:head 4c7d73b,success 40 · skipped 15 · 无失败;main 领先 5。非 governed。Clause-② no,Metadata-protocol none。

席位意见

从「整张报表有没有写 order」改成「每个维度有没有被 order 点名」,就从根上解决了两条轴互相牵连的问题。重排表头不算行级重排,所以头部文档里「不在客户端重排」的约束依然成立,文档也已按这个说法改写。作者在同一个日期维度上显式写的降序会保留(钉子 d)。同意落地。

席位核对 — ACCEPT · domain:ui#2 · head 4c7d73b · 2026-11-16T11:24Z

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 16, 2026 11:25
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit 23a18fd Nov 16, 2026
56 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-jiddbx branch November 16, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants