Repository navigation
Commit 23a18fd
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)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9C4PyYnJ5aNqKb43dZ6nK1k)_
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` #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
<details><summary>Tests (head 4c7d73b)</summary>
- `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.
</details>
<details><summary>Ablations (scripts/ablation-replace.mjs, mutation
proven on disk, each restored to HEAD blob add203e)</summary>
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).
</details>
<details><summary>Derived gate families</summary>
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.
```text
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.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmSDShXaoKYWNqiKtAC)_
<!-- signed: domain:ui#2 · os-steve · session_01ADHkmSzhXR4yUAgwq1bQRi
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 2c296cf commit 23a18fd
3 files changed
Lines changed: 286 additions & 40 deletions
File tree
- .changeset
- ui/packages/plugin-report/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
69 | 86 | | |
70 | 87 | | |
71 | 88 | | |
| |||
483 | 500 | | |
484 | 501 | | |
485 | 502 | | |
486 | | - | |
487 | | - | |
488 | | - | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
489 | 508 | | |
490 | 509 | | |
491 | 510 | | |
| |||
497 | 516 | | |
498 | 517 | | |
499 | 518 | | |
500 | | - | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
501 | 560 | | |
502 | 561 | | |
503 | 562 | | |
| |||
509 | 568 | | |
510 | 569 | | |
511 | 570 | | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
| 571 | + | |
| 572 | + | |
520 | 573 | | |
521 | 574 | | |
522 | 575 | | |
| |||
1907 | 1960 | | |
1908 | 1961 | | |
1909 | 1962 | | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
1910 | 1999 | | |
1911 | 2000 | | |
1912 | 2001 | | |
| |||
1941 | 2030 | | |
1942 | 2031 | | |
1943 | 2032 | | |
1944 | | - | |
1945 | | - | |
1946 | | - | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
1947 | 2036 | | |
1948 | 2037 | | |
1949 | 2038 | | |
| |||
1972 | 2061 | | |
1973 | 2062 | | |
1974 | 2063 | | |
1975 | | - | |
1976 | | - | |
1977 | | - | |
1978 | | - | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
1979 | 2070 | | |
1980 | 2071 | | |
1981 | 2072 | | |
1982 | 2073 | | |
1983 | 2074 | | |
1984 | 2075 | | |
1985 | | - | |
1986 | | - | |
| 2076 | + | |
| 2077 | + | |
1987 | 2078 | | |
1988 | 2079 | | |
1989 | 2080 | | |
| |||
2019 | 2110 | | |
2020 | 2111 | | |
2021 | 2112 | | |
2022 | | - | |
2023 | | - | |
2024 | | - | |
2025 | | - | |
2026 | | - | |
2027 | | - | |
2028 | | - | |
2029 | | - | |
2030 | | - | |
2031 | | - | |
2032 | | - | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
2033 | 2128 | | |
2034 | 2129 | | |
2035 | 2130 | | |
| |||
2041 | 2136 | | |
2042 | 2137 | | |
2043 | 2138 | | |
2044 | | - | |
| 2139 | + | |
2045 | 2140 | | |
2046 | 2141 | | |
2047 | 2142 | | |
| |||
0 commit comments