Skip to content

Commit 830ff8b

Browse files
fix(list): a data-laned kanban's footer counts the whole query, as its lanes do (#38681)
<!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ844kETyNGBBt9atKc1Snfzd)_ Fixes #38558 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:列表里按查找字段或文本字段分道的看板,页脚现在显示整个视图的记录数(例如 70 条),与各道计数之和一致;只有看板确实只画了第一页的道时,才保留「只显示前 N 条」。 - 为什么做:同一块看板上页脚写 25 条、各道加起来却是 70 条,两个数字互相矛盾(看板页脚计数卡)。 - 出错会怎样:最坏是页脚数字或「只显示前 N 条」提示显示错,不影响数据本身;可直接撤回本 PR。 - 要你做的:无。 ## What changes - `ui/packages/plugin-list/src/ListView.tsx`, the record-count bar under a board the list hands its window to (`kanbanLaneStatisticHosted`). With a numeric `fetchedTotal`, the count is the query's total instead of the window's length, which is the number the board's lanes add up to. The same figure feeds the view switcher's count (`leadingRecordCount`). - The "Showing first N" line is dropped only where the board reaches every record by itself (`kanbanHostedBoardReachesEveryRecord`): lanes from the data, a lookup or text lane field, no declared lanes, no swimlanes, and a source with `queryGroupHeaders`. Number, boolean and date lane fields, declared lanes, swimlanes and a source with no grouped door draw only the page's lanes, so the line stays there. i18n wording is unchanged. - Pin: a new top-level describe in the shared harness `ui/packages/app-shell/src/__tests__/listKanbanEveryRecord-12619.test.tsx` (AGENTS.md shared-harness rule). Text-laned and lookup-laned boards read "70 records" with no warning, and the text board's lane sum equals the footer figure. CONTROLs: a number-laned board and a source with no grouped door keep "Showing first 25 records". - Changeset `.changeset/38558-kanban-footer-count.md` (patch, `@object-ui/plugin-list`). ## Tests Head `e4b485a5`, after building the `@object-ui/app-shell^...` closure under os-verify-lock (command-exit 0): - `pnpm exec vitest run --maxWorkers=2 packages/app-shell/src/__tests__/listKanbanEveryRecord-12619.test.tsx` (under the lock): 1 file, 49 tests passed (45 existing, the #38506 pin included and still green, plus 4 new). - `pnpm exec vitest run --maxWorkers=2 packages/plugin-list/`: 190 files, 2083 tests passed. - `@object-ui/plugin-list` `type-check` (tsc + tsconfig.test.json): exit 0. - Ablation A1 (`hostedBoardTotal` forced to null): all 4 new tests red (footer lacks "70 records"). Ablation A2 (the warning gate's `&& kanbanHostedBoardReachesEveryRecord` removed): 2 CONTROLs red, 2 pins green. Both restored, blob == HEAD. ## Acceptance notes - The warning gate is static: if the lane read is refused or cut at runtime, the board shows page counts marked `+` and no lane past the page, while the footer reads the full total with no "Showing first N". The total is still true, but past-page records are not reachable on the board in that state. ## Verification - `dispatch-gates --commands` at `e4b485a5`: 38 derived families, 38 run, all exit 0 (the `ui scripts/` vitest under the lock: 172 files passed, 2 skipped; 5159 tests passed). `--ran`: 0 NOT-MEASURED. - `overlap-check.mjs` at `e4b485a5` against origin/main `0ba5e06a`: clean (#38550 shares ListView.tsx and merges cleanly). - CI check-runs: read on this PR. Files to read first: `ListView.tsx` hunks at `kanbanHostedBoardReachesEveryRecord` and `hostedBoardTotal` (the risk is the warning gate). Two-minute check: open a list-view kanban laned by a lookup field with more records than its page size. The footer should read the full count, equal to the sum of the lane badges, with no "Showing first N". 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01JQwxbamiNxp7695qyaEYsH <!-- signed: repo:objectstack#2 · os-warren · session_01JQwxbamiNxp7695qyaEYsH --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 714124a commit 830ff8b

3 files changed

Lines changed: 161 additions & 3 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@object-ui/plugin-list': patch
3+
---
4+
5+
Clause-②: no
6+
Metadata-protocol: none
7+
8+
A kanban board under a list view whose lanes come from the data (a lookup or text lane field) now shows the view's full record count in its footer, the same count its lanes add up to. Before, the footer counted only the first page handed to the board ("25 records" plus "Showing first 25 records") while the lanes counted every record (70). The "Showing first N" line now appears only on boards that draw only the first page's lanes (number, boolean or date lane fields, declared lanes, swimlanes, or a source with no grouped read).

‎ui/packages/app-shell/src/__tests__/listKanbanEveryRecord-12619.test.tsx‎

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,3 +1022,123 @@ describe('a lookup-laned board under a list view counts and totals each whole la
10221022
expect(headerTotal('acc-b')).toBe('0.7');
10231023
});
10241024
});
1025+
1026+
/**
1027+
* objectstack#38558 — the footer of a board handed the list's window counts
1028+
* what its lanes count: the whole query. Each lane badge of a data-laned
1029+
* board counts its whole lane (objectstack#37327), so a footer that counted
1030+
* the window ("25 records" plus "Showing first 25 records") read against
1031+
* lanes adding up to 70. The footer now states the query's total; the
1032+
* "Showing first N" line goes only where the board reaches every record
1033+
* itself (a lookup or text lane field, flat lanes, the grouped door), and
1034+
* stays where it draws the page's lanes only.
1035+
*/
1036+
describe('a data-laned board under a list view: the footer counts the whole query, as the lanes do (objectstack#38558)', () => {
1037+
const DEAL = 'crm_deal';
1038+
const ACCOUNT = 'crm_account';
1039+
/** 70 deals: 30 + 30 on the first pages, the last 10 in a third lane past page one. */
1040+
const DEALS: Row[] = Array.from({ length: 70 }, (_, i) => ({
1041+
id: `deal-${String(i).padStart(2, '0')}`,
1042+
name: `Deal ${String(i).padStart(2, '0')}`,
1043+
account: i >= 60 ? 'acc-c' : i % 2 === 0 ? 'acc-a' : 'acc-b',
1044+
tier: i >= 60 ? 'bronze' : i % 2 === 0 ? 'gold' : 'silver',
1045+
rank: i >= 60 ? 3 : i % 2 === 0 ? 1 : 2,
1046+
}));
1047+
const DEFS: Record<string, unknown> = {
1048+
[DEAL]: {
1049+
name: DEAL,
1050+
label: 'Deal',
1051+
fields: {
1052+
name: { type: 'text', label: 'Deal Name' },
1053+
account: { type: 'lookup', label: 'Account', reference: ACCOUNT },
1054+
tier: { type: 'text', label: 'Tier' },
1055+
rank: { type: 'number', label: 'Rank' },
1056+
},
1057+
},
1058+
[ACCOUNT]: { name: ACCOUNT, label: 'Account', nameField: 'name', fields: { name: { type: 'text', label: 'Name' } } },
1059+
};
1060+
const ACCOUNTS: Row[] = [
1061+
{ id: 'acc-a', name: 'Amber Ltd' },
1062+
{ id: 'acc-b', name: 'Birch Inc' },
1063+
{ id: 'acc-c', name: 'Cyan Corp' },
1064+
];
1065+
const boardView = (groupByField: string) => ({
1066+
type: 'list-view',
1067+
objectName: DEAL,
1068+
viewType: 'kanban',
1069+
columns: [{ field: 'name' }, { field: groupByField }],
1070+
pagination: { pageSize: 25 },
1071+
kanban: { groupByField, titleField: 'name' },
1072+
});
1073+
1074+
/** A source answering `total`, with (or without) the grouped door counting each group. */
1075+
function countSource(door = true) {
1076+
const stores: Record<string, ValueDataSource<Row>> = {
1077+
[DEAL]: new ValueDataSource<Row>({ items: DEALS }),
1078+
[ACCOUNT]: new ValueDataSource<Row>({ items: ACCOUNTS }),
1079+
};
1080+
const queryGroupHeaders = vi.fn(async (object: string, query: any) => {
1081+
const kept = (await stores[object].find(object, { ...(query.where ? { $filter: query.where } : {}), $top: 100000 } as any)) as any;
1082+
const rows: Row[] = Array.isArray(kept) ? kept : kept.data ?? kept.records ?? [];
1083+
const key = query.groupBy[0];
1084+
const groups = new Map<unknown, number>();
1085+
for (const row of rows) groups.set(row[key] ?? null, (groups.get(row[key] ?? null) ?? 0) + 1);
1086+
return [...groups].map(([k, n]) => {
1087+
const out: Row = { [key]: k };
1088+
for (const agg of query.aggregations) out[agg.alias] = agg.function === 'count' ? n : null;
1089+
return out;
1090+
});
1091+
});
1092+
return {
1093+
find: vi.fn(async (object: string, params: any) => stores[object].find(object, params)),
1094+
findOne: vi.fn(),
1095+
create: vi.fn(),
1096+
update: vi.fn(),
1097+
delete: vi.fn(),
1098+
getObjectSchema: vi.fn(async (object: string) => DEFS[object]),
1099+
...(door ? { queryGroupHeaders } : {}),
1100+
} as any;
1101+
}
1102+
1103+
const laneBadge = (title: string) =>
1104+
(within(lane(title)).getByRole('heading').parentElement!.querySelector('span')!.textContent ?? '').trim();
1105+
const footer = () => screen.getByTestId('record-count-bar');
1106+
1107+
it('a text-laned board: the footer reads 70 records, the sum of its lanes 30 + 30 + 10, and no "Showing first 25"', async () => {
1108+
mountBoard(countSource(), boardView('tier'));
1109+
1110+
await waitFor(() => expect(cards()).toHaveLength(25));
1111+
await waitFor(() => expect(laneBadge('bronze')).toBe('10'));
1112+
const laneSum = Number(laneBadge('gold')) + Number(laneBadge('silver')) + Number(laneBadge('bronze'));
1113+
expect(laneSum).toBe(DEALS.length);
1114+
await waitFor(() => expect(footer()).toHaveTextContent(`${laneSum} records`));
1115+
expect(screen.queryByTestId('data-limit-warning')).not.toBeInTheDocument();
1116+
});
1117+
1118+
it('a lookup-laned board: the footer reads 70 records and no "Showing first 25"', async () => {
1119+
mountBoard(countSource(), boardView('account'));
1120+
1121+
await waitFor(() => expect(cards()).toHaveLength(25));
1122+
await waitFor(() => expect(screen.getByRole('group', { name: 'Cyan Corp' })).toBeInTheDocument());
1123+
await waitFor(() => expect(footer()).toHaveTextContent('70 records'));
1124+
expect(screen.queryByTestId('data-limit-warning')).not.toBeInTheDocument();
1125+
});
1126+
1127+
it('CONTROL: a number-laned board draws the page\'s lanes only, so the footer reads 70 records and keeps "Showing first 25"', async () => {
1128+
mountBoard(countSource(), boardView('rank'));
1129+
1130+
await waitFor(() => expect(cards()).toHaveLength(25));
1131+
await waitFor(() => expect(laneBadge('1')).toBe('30'));
1132+
expect(screen.queryByRole('group', { name: '3' })).toBeNull();
1133+
await waitFor(() => expect(footer()).toHaveTextContent('70 records'));
1134+
expect(screen.getByTestId('data-limit-warning')).toHaveTextContent('Showing first 25 records');
1135+
});
1136+
1137+
it('CONTROL: over a source with no grouped door the board reaches no lane past the page, so "Showing first 25" stays', async () => {
1138+
mountBoard(countSource(false), boardView('tier'));
1139+
1140+
await waitFor(() => expect(cards()).toHaveLength(25));
1141+
await waitFor(() => expect(footer()).toHaveTextContent('70 records'));
1142+
expect(screen.getByTestId('data-limit-warning')).toHaveTextContent('Showing first 25 records');
1143+
});
1144+
});

‎ui/packages/plugin-list/src/ListView.tsx‎

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4077,6 +4077,27 @@ export const ListView = React.forwardRef<ListViewHandle, ListViewProps>(({
40774077
listFetchesForItself &&
40784078
!!schema.objectName &&
40794079
typeof dataSource?.find === 'function';
4080+
/**
4081+
* objectstack#38558 — can the board handed this component's window reach
4082+
* every record of the view on its own? It can where its lanes come from the
4083+
* data, flat, over a lookup or a text lane field, and the source has the
4084+
* grouped-aggregate door: the board's lane read then draws a lane for every
4085+
* value of the query, a lane past the page included, and each lane loads its
4086+
* records past the page itself ("Load more", objectstack#37327,
4087+
* objectstack#38120, objectstack#38506). The footer then says no
4088+
* "Showing first N": the board is not a window. Any other lane field (a
4089+
* number, boolean or date field), declared lanes or swimlanes draw the
4090+
* page's lanes only, so the line stays.
4091+
*/
4092+
const kanbanLaneFieldDef: { type?: unknown; reference?: unknown } | undefined =
4093+
kanbanLaneField ? objectDef?.fields?.[kanbanLaneField] : undefined;
4094+
const kanbanHostedBoardReachesEveryRecord =
4095+
kanbanLaneStatisticHosted &&
4096+
((typeof kanbanLaneFieldDef?.reference === 'string' && kanbanLaneFieldDef.reference !== '') ||
4097+
kanbanLaneFieldDef?.type === 'text') &&
4098+
!kanbanDeclaredLanes(kanbanBlockOf(schema).lanes, undefined) &&
4099+
!(groupingConfig?.fields?.length) &&
4100+
typeof dataSource?.queryGroupHeaders === 'function';
40804101

40814102
/**
40824103
* The calendar's date bindings, for the fetch effect's window
@@ -7088,8 +7109,17 @@ export const ListView = React.forwardRef<ListViewHandle, ListViewProps>(({
70887109
// objectstack#35702 — a grid that draws its resident footer row says the
70897110
// count there, in its first cell; the bar keeps only the cap warning.
70907111
const recordCountTextShown = recordCountShown && !(currentView === 'grid' && gridDrawsCount);
7112+
// objectstack#38558 — the board handed this component's window counts each
7113+
// lane over the whole query, so the footer counts the whole query too: the
7114+
// total this component's own query answered, not the window's length. The
7115+
// "Showing first N" line goes only where the board reaches every record
7116+
// itself (`kanbanHostedBoardReachesEveryRecord`).
7117+
const hostedBoardTotal: number | null =
7118+
kanbanLaneStatisticHosted && typeof fetchedTotal === 'number' ? fetchedTotal : null;
7119+
const recordCountFigure = hostedBoardTotal ?? serverTotal ?? data.length;
70917120
const dataLimitWarningShown =
7092-
recordCountShown && dataLimitReached && !(paginate && serverTotal != null) && !infiniteScroll;
7121+
recordCountShown && dataLimitReached && !(paginate && serverTotal != null) && !infiniteScroll &&
7122+
!(hostedBoardTotal !== null && kanbanHostedBoardReachesEveryRecord);
70937123
// objectui#12619 — a board that pages its own lanes draws every record of the
70947124
// view, a page per lane at a time, so the footer counts the VIEW: the total
70957125
// this component's own query answered, which is the sum of the board's lane
@@ -7102,7 +7132,7 @@ export const ListView = React.forwardRef<ListViewHandle, ListViewProps>(({
71027132
const leadingRecordCount: number | null = boardRecordCountShown
71037133
? (fetchedTotal as number)
71047134
: !loading && surfaceDrawsFetchedRows && schema.showRecordCount !== false && !calendarWindowed && !kanbanLanesPaged
7105-
? (serverTotal ?? data.length)
7135+
? recordCountFigure
71067136
: null;
71077137
const drawnToolbarLeading = typeof toolbarLeading === 'function'
71087138
? toolbarLeading({ recordCount: leadingRecordCount, layout: currentView })
@@ -9107,7 +9137,7 @@ export const ListView = React.forwardRef<ListViewHandle, ListViewProps>(({
91079137
view's total. */}
91089138
{calendarWindowed
91099139
? t('list.calendarRecordCount', { count: data.length })
9110-
: t('list.recordCount', { count: serverTotal ?? data.length })}
9140+
: t('list.recordCount', { count: recordCountFigure })}
91119141
</span>
91129142
)}
91139143
{/* The cap warning is about rows the user CANNOT REACH. A paged grid

0 commit comments

Comments
 (0)