Repository navigation
Commit 2d18ba8
fix(ui): grouped grid and used-currency read treat a cut grouped answer as partial (#37317)
Fixes #37278
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:在设了默认分页大小的部署上,按服务器分组的表格在分组数超过一页时,顶部多一行提示「更多分组未加载」,且不再报出偏少的记录总数;表单里币种字段的「可用」组在币种读取被截断时不再只列出部分已用币种,改为不列已用币种(所有币种仍在「全部」组里可选)。
-
为什么做:分组表头查询在被服务器截断时,上一张卡已把「截断」信号传给前端,但只有看板读了它;这次补上分组表格和币种读取两处,把同一族问题收口。
- 出错会怎样:最坏是分组表格多一行提示、批量栏不显示「全选 N 条」,或币种「可用」组少列已用币种;不会显示错误数字,可直接撤回。
- 要你做什么:无
## What changes
Both readers of `DataSource.queryGroupHeaders` that `#36870` left
reading a cut answer as whole now read `hasMore`:
- **Server-grouped grid** (`@object-ui/plugin-grid`):
`useServerGroupHeaders` reports `partial` when any depth's answer says
`hasMore`. The grid then draws one status line above the rows
(`grid.grouping.moreGroupsNotLoaded`, "More groups were not loaded: this
view has more groups than the server returns in one read, so only some
are listed.", translated in all eleven locale packs (zh-Hant regenerated
with `gen:zh-hant`) and in the grid's English fallback map), and
`serverGroupTotalOf` tells no record total instead of summing the listed
groups' counts. Listed groups keep their exact counts. A whole answer
draws exactly as before.
- **Used-currency read** (`@object-ui/components`):
`readUsedCurrencyCodes` reads a partial answer as no codes, so the code
field gets what a failed read gives it (home + rated + the record's own
code under "available"; every code stays under "all"). This is the
kanban lane statistic's shape (a cut answer is read as no answer), not a
second marker.
- **Nit N2** (`@object-ui/types`): `ListViewGroupHeaderAnswer`'s jsdoc
warns that `hasMore` lives on the array and a copy drops it. The type is
declared in `ui/packages/types/src/data.ts` (the claim named the import
site in `data-objectstack`).
- **Nit N1**: `content/docs/frontend/data-objectstack.mdx` says the
answer can be partial and how to read the flag.
Relation to `objectui#10881` ruling F: that ruling retired the
`grid.grouping.partial*` keys, the marker over a grid that grouped one
fetched page, whose every count was a page slice; this note is a
separate key outside that namespace, because here every listed group's
count is the server's exact count and only the group list is cut, so it
says more groups were not loaded rather than marking the counts partial.
Why a marker / no-answer and not a re-read, for both readers: measured
at the public door, a grouped read cannot be completed by the caller.
`EngineAggregateOptions` (the header query's contract) carries no
`limit`, the grouped branch of `POST /data/:object/query` slices in
memory and reads no `offset`, and an explicit `limit` over the maximum
page size is refused with `400 MAX_RECORDS_EXCEEDED`. Completing the
currency read would need a contract change to the header query; it is
not cheap, so it is not done here.
## Tests
<details><summary>Reach: both readers' query is cut at the public door
(temporary probe, not committed)</summary>
A throwaway test beside
`packages/rest/src/data-query-read-limits.test.ts` (same harness: real
`SqlDriver` on SQLite, the real `POST /api/v1/data/:object/query` route,
five rows, five distinct `label` values) sent the header query exactly
as `compileListViewGroupQuery` compiles it for both readers, with no
`limit`. Tree: objectstack, base 08bf7d2.
```
PROBE query {"groupBy":["label"],"aggregations":[{"function":"count","alias":"count"}]}
PROBE cut 200 {"n":2,"hasMore":true,"total":5} OS_DATA_DEFAULT_PAGE_SIZE=2
PROBE maxOnly 200 {"n":3,"hasMore":true} OS_DATA_MAX_PAGE_SIZE=3 alone
PROBE whole 200 {"n":5,"hasMore":false} no limits
PROBE explicit-limit-3 200 {"n":3,"hasMore":true} default 2, max 3, limit 3
PROBE explicit-limit-4-over-max 400 "MAX_RECORDS_EXCEEDED" default 2, max 3, limit 4
```
Both readers send that query with no `limit` (`useServerGrouping.ts`,
`usedCurrencyCodes.ts`), so both reach users on any deployment whose
default page size is below the group count. The grid reaches users on
the hosted plane's figure (maximum page size 5,000) for a grouping with
more than 5,000 distinct values. The used-currency read groups an ISO
4217 code field (domain-checked on write, so at most one group per code
plus the empty group, under 200): it reaches users only where a
deployment sets a default page size below the number of codes in use.
Both are fixed.
</details>
<details><summary>Pins, and the ablation that turns each red</summary>
New pins, each driven by a double that answers the compiled header query
the way the door does under a default page size (every group, sliced to
the page, `hasMore` on the answer when the slice dropped one), each
beside a control with a whole answer:
- `serverGrouping-7189.test.tsx`, new top-level describe: a cut answer
(page 3 of 5 groups) draws the partial note and the listed groups' exact
counts; the control (page 100) draws five groups and no note;
`useServerGroupHeaders` reports `partial` and `serverGroupTotalOf` tells
no total over the cut answer, 186 over the whole one.
- `form-used-currency-codes-27188.test.tsx`, new top-level describe: a
cut answer (page 2 of 4 groups) hands down no used codes; the control
(page 10) hands down `EUR, GBP, USD`; `readUsedCurrencyCodes` on a
flagged and an unflagged answer.
Run, at head `f652fe491`:
```
pnpm --dir ui exec vitest run --maxWorkers=2 packages/i18n/ THE_TWO_PIN_FILES
Test Files 113 passed (113)
Tests 2052 passed | 13 skipped (2065)
```
That run holds the whole i18n package, including
`groupingPartialRetired-10881.test.ts`, `zh-hant-generated.test.ts` and
the key-parity tests. The ablation below was measured at `cf697b4f9`;
the rename at `f652fe491` changes only the key and test-id names it
reads.
Ablation (`scripts/ablation-replace.mjs`, anchor hit 1 -> 0 on disk,
restored to the HEAD blob with `git diff HEAD` empty; the tests import
the sources directly, no `dist/` in the path):
```
useServerGrouping.ts partial = headers.some(... hasMore === true) -> partial = false
x says more groups were not loaded, over the groups it did get
x folds no record total over a cut answer — and the whole total over a whole one
Tests 2 failed | 12 passed (14) (both controls stay green)
usedCurrencyCodes.ts the hasMore early return deleted
x a cut answer hands down no used codes — never the groups it happened to list (expected [ 'EUR', 'USD' ] to be undefined)
x readUsedCurrencyCodes reads a partial answer as no codes, a whole one as its codes
Tests 2 failed (control stays green)
```
</details>
## Acceptance notes
- The retired `grid.grouping.partial*` namespace stays empty:
`groupingPartialRetired-10881.test.ts` is untouched and green.
- A partial grid tells the bulk bar no total, so "Select all N" is not
offered with a wrong N there; the listed groups and their rows work as
before.
- Completing either read would need the header query to carry a `limit`
(a change to `EngineAggregateOptions`) and the grouped read to page;
this PR does not go there.
## Verification
Read first, by risk: `ui/packages/plugin-grid/src/useServerGrouping.ts`
(the one `hasMore` read for the grid),
`ui/packages/plugin-grid/src/objectGridGrouping.ts`
(`serverGroupTotalOf`),
`ui/packages/components/src/renderers/form/usedCurrencyCodes.ts`
(`readUsedCurrencyCodes`).
Two-minute check: `pnpm --dir ui exec vitest run
packages/plugin-grid/src/__tests__/serverGrouping-7189.test.tsx` —
expect the three `objectstack#37278` cases green beside the existing
ones.
Readings at head `f652fe491`: type-check of `@object-ui/plugin-grid`,
`@object-ui/components`, `@object-ui/i18n` all `Done`
(`@object-ui/types` at `cf697b4f9`, unchanged since) (lock VERDICT
command-exit 0); the run above 2052 passed. Local gate subset green
(exit 0 each): `check:test-source-alias`, `check:nul-bytes`,
`check:doc-authoring`, `check:doc-anchors`,
`check:cross-package-test-inputs`, `check:docs-single-h1`,
`check:doc-frontmatter`, `check:docs-redirects`,
`check:docs-transcript-drift`, `check:type-check-coverage`,
`check:undeclared-dep-imports`, the changeset gates, and
`ui/scripts/check-i18n-call-site-keys.mjs`, `check-i18n-en-drift.mjs`,
`check-i18n-dead-keys.mjs`. Declared narrowing: the rest of the derived
families (48 of 73 by `dispatch-gates --ran`), the full plugin-grid /
components suites and lint run in CI.
---
_Generated by [Claude
Code](https://claude.ai/code/session_012MmDsSBHy5paNUz6zke9Re)_
<!-- signed: repo:objectstack#6 · os-lizheng ·
session_012MmDsSBHy5paNUz6zke9Re -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent fd06b11 commit 2d18ba8
21 files changed
Lines changed: 250 additions & 15 deletions
File tree
- .changeset
- content/docs/frontend
- ui/packages
- components/src/renderers/form
- __tests__
- i18n/src/locales
- plugin-grid/src
- __tests__
- types/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
221 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
222 | 229 | | |
223 | 230 | | |
224 | 231 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
| |||
148 | 152 | | |
149 | 153 | | |
150 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
24 | 35 | | |
25 | 36 | | |
26 | 37 | | |
| |||
47 | 58 | | |
48 | 59 | | |
49 | 60 | | |
50 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
51 | 65 | | |
| 66 | + | |
52 | 67 | | |
53 | 68 | | |
54 | 69 | | |
| |||
66 | 81 | | |
67 | 82 | | |
68 | 83 | | |
69 | | - | |
70 | | - | |
| 84 | + | |
| 85 | + | |
71 | 86 | | |
72 | 87 | | |
73 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
739 | 739 | | |
740 | 740 | | |
741 | 741 | | |
| 742 | + | |
742 | 743 | | |
743 | 744 | | |
744 | 745 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
681 | 681 | | |
682 | 682 | | |
683 | 683 | | |
| 684 | + | |
684 | 685 | | |
685 | 686 | | |
686 | 687 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
924 | 924 | | |
925 | 925 | | |
926 | 926 | | |
| 927 | + | |
927 | 928 | | |
928 | 929 | | |
929 | 930 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
699 | 699 | | |
700 | 700 | | |
701 | 701 | | |
| 702 | + | |
702 | 703 | | |
703 | 704 | | |
704 | 705 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
694 | 694 | | |
695 | 695 | | |
696 | 696 | | |
| 697 | + | |
697 | 698 | | |
698 | 699 | | |
699 | 700 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
681 | 681 | | |
682 | 682 | | |
683 | 683 | | |
| 684 | + | |
684 | 685 | | |
685 | 686 | | |
686 | 687 | | |
| |||
0 commit comments