Skip to content

Commit f294277

Browse files
fix(kanban): a list view board laned by a lookup loads the rest of a lane's cards with "Load more" (#38178)
repo:objectstack#3 · os-tesla · session_01L9qibwxBy3QieJMqJbJtTk <!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoEynsd5XL1JYxPkwhkywADp)_ Fixes #37517 Clause-②: no Metadata-protocol: none ## 维护者速读 - 列表视图里按查找字段分道的看板,道头计数是整道的(比如 30),道里却只有第一页上的那几张卡(13 张),第一页之后的道和「未分类」道更是 0 张卡,没有任何办法看到其余记录;现在每个「已画卡数少于整道计数」的道底都有「加载更多」,就地读出该道后面的记录。 - 接在 #37327(整道计数、补画越页分道)和 #38112(越页「未分类」道)之后,补上这些道缺的加载入口。 - 只多一次按道读取,读法与列表那一页同源(同一筛选、排序、搜索),不改数据和配置;数据源不支持分组读、或分组读被拒绝或截断时不出现按钮,与现在一致,可以直接撤回。 - 无 ## What changes - `ui/packages/plugin-kanban/src/ObjectKanban.tsx`: `rawData` resolves through the same ladder as before; `boardData` is `rawData` followed, on the board handed one page, by the rows its lanes loaded past it, and the cards, the lane pages and the drag handlers read it. On that board a list view hands one page to, under the gate the lanes past the page already take (`hostLaneRead && flatLanes && lanesFromData && laneTargetObject`, now named `pastPageLanes`) and only while the grouped read answered counts, every lane whose cards on the board are fewer than its count gets a lane page through the existing `KanbanLanePagingContext`, so `KanbanImpl` draws its existing "Load more". `loadMoreHostLane` reads `find(object, { $filter: view filter AND lane value, $orderby, $expand (FLS-gated as the board's own query), $search/$searchFields (the host's), $count: true, $skip: <lane's cards on the board>, $top: 50 })`; the "Uncategorized" lane reads `laneField is_null`. The rows are appended after the host's rows in `boardData` (deduped by id), held under the question the host's page answers (filter, sort, search, reload key, the page's ids), and dropped when it changes. A read that answers no more records ends the lane's "Load more". A self-paged board (`lanePaging`) keeps its own channel. - `ui/packages/plugin-kanban/src/KanbanImpl.tsx` (one line): `hostCount` is read beside a lane page too, so a lane none of whose records is on the board still says "Cards not loaded: N" while it offers "Load more". No behaviour change on a self-paged board: `laneCounts` is set only when `hostLaneRead`, which requires that the host sent no `lanePaging`, and a board pages its own lanes only when it did, so the two paths never meet and a self-paged lane reads `null` there as before. - `ui/packages/plugin-kanban/src/KanbanLanePaging.ts`: package-private `emptyLaneQueryFilter` (the view's filter AND `laneField is_null`). Not exported from the package entry. - `patch` changeset for `@object-ui/plugin-kanban`. ## Tests `ui/packages/app-shell/src/__tests__/listKanbanEveryRecord-12619.test.tsx`, inside the #37327 describe (the #36871 rig: 70 deals, page 25; acc-a 30 with 13 on the page, acc-b 30 with 12, acc-c "Cyan Corp" 10 all past the page): - past-page lane: "Load more" offered while "Cards not loaded: 10" still shows; one click draws its 10 cards in place, the button goes, the other lanes keep their page's cards (35 in all); the read is `$skip: 0, $top: 50, $count: true`, `account = acc-c`, the host page's `$orderby`; - first-page short lane: acc-a loads from `$skip: 13` to 30 distinct cards; acc-b keeps its 12 and its button; - dedupe: a source whose lane read starts two records early draws 30 distinct cards, not 32; - under the view's filter (`amount > 9`): `$skip: 13`, filter carried, 25 cards; - "Uncategorized" past the page: `account is_null`, 10 cards; - reset: after a load, the toolbar Refresh drops the loaded cards and the lane offers them again; a toolbar search does the same and the next read carries `$search`; - CONTROL: no grouped door, a refused read and a cut read offer no "Load more" and send no lane read; a board laned by a text field offers none. <details><summary>Readings (head e4d27cf, after merging origin/main 4f7aa88; the fix commits are ef889db and 1a8a066)</summary> - Premise at 6ce1975, before the fix (probe on the same rig, kept in the project at `/mnt/project-files/card-37517/`, not in this PR): `Cyan Corp` badge 10, 0 cards, no `[data-kanban-load-more]`; acc-a 13 of 30 and acc-b 12 of 30 with no load entry either; one deal `find` in all. - Ablations on the committed fix at 1a8a066 (same counts at ef889db) through `scripts/ablation-replace.mjs`, each `vitest run …listKanbanEveryRecord-12619.test.tsx -t 37327`, each restored to blob == HEAD with `git diff HEAD` empty: - channel `{ pages: hostLanePages, loadMore: loadMoreHostLane }` → `null`: `Tests 7 failed | 22 passed`, the 7 new load pins, every control green; - `KanbanImpl` `hostCount` back to `pagedCount ? null : wholeLaneCount(…)`: `Tests 5 failed | 24 passed`, the "Cards not loaded" pins of #37327 / #37516 and the load pins that read it; - id dedupe on the merged rows removed: `Tests 1 failed`, the dedupe pin. - At 1a8a066: `pnpm --filter @object-ui/plugin-kanban type-check` exit 0; `pnpm --filter @object-ui/plugin-kanban test`: `Test Files 91 passed (91)`, `Tests 614 passed (614)`; the rig file: `Tests 38 passed (38)`; every other test file that reads `ObjectKanban.tsx`, `KanbanImpl.tsx` or `KanbanLanePaging.ts` off disk (18 files outside the package, the record-source ladder pin `object-kanban-record-source-7780.test.ts` among them): `Tests 604 passed (604)`. - CI on ef889db: `Test UI (1/16)` failed on that ladder pin, which reads the `rawData` line verbatim; 1a8a066 keeps the line and moves the appended rows to `boardData`. CI on 1a8a066: every check green. - e4d27cf merges origin/main (18 commits behind; none touches `plugin-kanban`, `plugin-list` or `core`): `plugin-kanban` type-check exit 0; the rig file and the ladder pin `Tests 55 passed (55)`. CI on e4d27cf: every check green (52 check runs, none failed). - eslint on the four changed files: 0 errors. - Derived local gates: see Acceptance notes. </details> ## Acceptance notes - Scope is the claim's: every lane on a lookup-laned list-view board whose drawn cards are fewer than its whole count, the past-page lanes and the #38112 "Uncategorized" lane included. Boards laned by declared options already page their lanes; text-field lanes are #38120; swimlane boards are #37844. - `$skip` = the lane's cards on the board is right because the list hands its kanban the first page of the view's query (it pages only its grid: `paginate` is `currentView === 'grid'`), so a lane's cards on it are that lane's first records in the same order. The id dedupe covers ties in that order. - In the rig the source does not expand lookups, so once Cyan Corp's cards load, the lane is titled by its key `acc-c`, as the page's lanes are; under a backend that expands, both are titled by the account's name. - File surface: `KanbanImpl.tsx` was outside the claimed surface; the seat agreed to the one-line change before the PR. - Local narrowing: `@object-ui/app-shell`'s full suite is left to `Test UI`; only the rig file this PR edits was run locally. - Derived local gate set at ef889db (1a8a066 changes only `ObjectKanban.tsx`, so the derived set is the same): `dispatch-gates --ran` reconciles 38 derived, 38 run, every one exit 0, 0 NOT MEASURED, 0 unrun. `check:type-check-debt` first exited 3 (prerequisite not met: this worktree's install predated a workspace dependency of `service-knowledge`); after `pnpm install --frozen-lockfile` it exited 0. ## Verification Read first (by risk): 1. `ui/packages/plugin-kanban/src/ObjectKanban.tsx`: `hostLanePages`, `loadMoreHostLane` and `lanePagingChannel` beside `keepUncolumned`; `boardData` below `rawData`. 2. `ui/packages/plugin-kanban/src/KanbanImpl.tsx`: the `hostCount` line. 3. The new pins in `listKanbanEveryRecord-12619.test.tsx`. Two-minute check: from `ui/`, `pnpm exec vitest run packages/app-shell/src/__tests__/listKanbanEveryRecord-12619.test.tsx -t 37327` shows 29 passing; set the `hostLanePages` arm of `lanePagingChannel` in `ObjectKanban.tsx` to `null` and the 7 load pins fail. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L9qibwxBy3QieJMqJbJtTk --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent b703678 commit f294277

5 files changed

Lines changed: 372 additions & 16 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/plugin-kanban': patch
3+
---
4+
5+
fix(kanban): a list view board laned by a lookup loads the rest of a lane's cards with "Load more"
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
A list view hands its kanban one page of the view's query. On a board laned by a lookup field, the grouped lane read counts every lane, so a lane could read 30 while drawing the 13 cards of it on the page, and a lane whose records all sat past the page (the trailing "Uncategorized" lane included) read 10 with no card and no way to see them. Each lane that draws fewer cards than the read counts now has "Load more" at its foot. It reads the lane's next records under the view's filter, sort and search, starting right after the lane's cards on the page, and adds them to the lane. The list's page and the cards a lane loaded are read again together when the list refetches. A source with no grouped door, or a read that is refused or cut, offers no "Load more", as before. Boards laned by a text field or by declared options are unchanged. Nothing to migrate.

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

Lines changed: 184 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
*/
3636
import React from 'react';
3737
import { describe, it, expect, vi, afterEach } from 'vitest';
38-
import { act, cleanup, render, screen, waitFor, within } from '@testing-library/react';
38+
import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
3939
import '@testing-library/jest-dom';
4040
import { ValueDataSource } from '@object-ui/core';
4141
import { ActionProvider, SchemaRendererProvider } from '@object-ui/react';
@@ -672,6 +672,189 @@ describe('a lookup-laned board under a list view counts and totals each whole la
672672
expect(screen.queryByRole('group', { name: 'Uncategorized' })).toBeNull();
673673
});
674674

675+
/**
676+
* objectstack#37517 — a lane that draws fewer cards than the lane read counts
677+
* loads the rest in place: "Load more" at its foot reads the lane's next
678+
* records under the view's query (its filter AND the lane value, its order,
679+
* its search), from right after the lane's cards on the page.
680+
*/
681+
const loadMore = (title: string) => within(lane(title)).queryByRole('button', { name: 'Load more' });
682+
/** The lane reads "Load more" sent: every `crm_deal` read that names a `$skip`. */
683+
const laneReads = (ds: any) =>
684+
ds.find.mock.calls.filter((call: any[]) => call[0] === DEAL && call[1] && '$skip' in call[1]).map((call: any[]) => call[1]);
685+
const hostPageRead = (ds: any) =>
686+
ds.find.mock.calls.find((call: any[]) => call[0] === DEAL && call[1] && !('$skip' in call[1]))![1];
687+
const cardNames = (title: string) => within(lane(title)).queryAllByRole('listitem').map((card) => card.textContent);
688+
689+
it('a lane past the page loads its 10 cards in place, from its first record, and stops offering more', async () => {
690+
const ds = dealSource();
691+
mountBoard(ds, BOARD_VIEW);
692+
693+
await onePageDrawn();
694+
await waitFor(() => expect(loadMore('Cyan Corp')).not.toBeNull());
695+
// The lane still says what it has not loaded while it offers to load it.
696+
expect(within(lane('Cyan Corp')).getByText('Cards not loaded: 10')).toBeInTheDocument();
697+
expect(laneReads(ds)).toHaveLength(0);
698+
699+
fireEvent.click(loadMore('Cyan Corp')!);
700+
701+
// Drawn from its cards now, the lane is titled as the page's lanes are: by
702+
// the record its cards reference, which this source does not expand, so by
703+
// its key (`acc-c`), and in the same place.
704+
await waitFor(() => expect(within(lane('acc-c')).getAllByRole('listitem')).toHaveLength(10));
705+
expect(laneNames().slice(-3)).toEqual(['acc-a', 'acc-b', 'acc-c']);
706+
expect(loadMore('acc-c')).toBeNull();
707+
expect(laneBadge('acc-c')).toBe('10');
708+
expect(within(lane('acc-c')).queryByText('Cards not loaded: 10')).toBeNull();
709+
// The other lanes keep their page's cards.
710+
expect(within(lane('acc-a')).getAllByRole('listitem')).toHaveLength(13);
711+
expect(cards()).toHaveLength(35);
712+
const reads = laneReads(ds);
713+
expect(reads).toHaveLength(1);
714+
expect(reads[0]).toMatchObject({ $skip: 0, $top: 50, $count: true });
715+
expect(JSON.stringify(reads[0].$filter)).toContain('"account","=","acc-c"');
716+
expect(reads[0].$orderby).toEqual(hostPageRead(ds).$orderby);
717+
});
718+
719+
it('a lane on the page with 13 of its 30 cards loads the other 17 from its 14th record, none twice', async () => {
720+
const ds = dealSource();
721+
mountBoard(ds, BOARD_VIEW);
722+
723+
await onePageDrawn();
724+
await waitFor(() => expect(loadMore('acc-a')).not.toBeNull());
725+
expect(loadMore('acc-b')).not.toBeNull();
726+
727+
fireEvent.click(loadMore('acc-a')!);
728+
729+
await waitFor(() => expect(within(lane('acc-a')).getAllByRole('listitem')).toHaveLength(30));
730+
expect(new Set(cardNames('acc-a')).size).toBe(30);
731+
expect(loadMore('acc-a')).toBeNull();
732+
expect(laneBadge('acc-a')).toBe('30');
733+
// acc-b is untouched: its page's 12 and its "Load more".
734+
expect(within(lane('acc-b')).getAllByRole('listitem')).toHaveLength(12);
735+
expect(loadMore('acc-b')).not.toBeNull();
736+
const reads = laneReads(ds);
737+
expect(reads).toHaveLength(1);
738+
expect(reads[0]).toMatchObject({ $skip: 13, $top: 50 });
739+
expect(JSON.stringify(reads[0].$filter)).toContain('"account","=","acc-a"');
740+
});
741+
742+
it('a page that repeats a card the lane already holds draws it once', async () => {
743+
// A source whose lane read starts two records early, as a sort with ties
744+
// may answer: deals 22 and 24 come back a second time.
745+
const ds = dealSource();
746+
const find = ds.find.getMockImplementation();
747+
ds.find.mockImplementation((object: string, params: any) =>
748+
find(object, params && '$skip' in params ? { ...params, $skip: Math.max(0, params.$skip - 2) } : params));
749+
mountBoard(ds, BOARD_VIEW);
750+
751+
await onePageDrawn();
752+
await waitFor(() => expect(loadMore('acc-a')).not.toBeNull());
753+
fireEvent.click(loadMore('acc-a')!);
754+
755+
await waitFor(() => expect(laneReads(ds)).toHaveLength(1));
756+
await waitFor(() => expect(within(lane('acc-a')).getAllByRole('listitem')).toHaveLength(30));
757+
expect(new Set(cardNames('acc-a')).size).toBe(30);
758+
expect(laneBadge('acc-a')).toBe('30');
759+
});
760+
761+
it('reads under the view\'s filter, the one its own window was fetched with', async () => {
762+
const ds = dealSource();
763+
mountBoard(ds, { ...BOARD_VIEW, filter: [{ field: 'amount', operator: 'greater_than', value: 9 }] });
764+
765+
await waitFor(() => expect(cards()).toHaveLength(25));
766+
await waitFor(() => expect(loadMore('acc-a')).not.toBeNull());
767+
fireEvent.click(loadMore('acc-a')!);
768+
769+
// 10, 12, … 58: 25 records, 13 of them on the page.
770+
await waitFor(() => expect(within(lane('acc-a')).getAllByRole('listitem')).toHaveLength(25));
771+
expect(loadMore('acc-a')).toBeNull();
772+
const read = laneReads(ds)[0];
773+
expect(read.$skip).toBe(13);
774+
expect(JSON.stringify(read.$filter)).toContain('amount');
775+
expect(JSON.stringify(read.$filter)).toContain('"account","=","acc-a"');
776+
});
777+
778+
it('the "Uncategorized" lane past the page loads its records with no account', async () => {
779+
const ds = dealSource(true, NO_ACCOUNT_PAST_PAGE);
780+
mountBoard(ds, BOARD_VIEW);
781+
782+
await onePageDrawn();
783+
await waitFor(() => expect(loadMore('Uncategorized')).not.toBeNull());
784+
expect(within(lane('Uncategorized')).getByText('Cards not loaded: 10')).toBeInTheDocument();
785+
fireEvent.click(loadMore('Uncategorized')!);
786+
787+
await waitFor(() => expect(within(lane('Uncategorized')).getAllByRole('listitem')).toHaveLength(10));
788+
expect(loadMore('Uncategorized')).toBeNull();
789+
expect(laneBadge('Uncategorized')).toBe('10');
790+
const read = laneReads(ds)[0];
791+
expect(read.$skip).toBe(0);
792+
expect(JSON.stringify(read.$filter)).toContain('"account","is_null"');
793+
});
794+
795+
it('the cards a lane loaded go when the list reads its page again (Refresh), and the lane offers them again', async () => {
796+
const ds = dealSource();
797+
mountBoard(ds, { ...BOARD_VIEW, compactToolbar: false });
798+
799+
await onePageDrawn();
800+
await waitFor(() => expect(loadMore('Cyan Corp')).not.toBeNull());
801+
fireEvent.click(loadMore('Cyan Corp')!);
802+
await waitFor(() => expect(within(lane('acc-c')).getAllByRole('listitem')).toHaveLength(10));
803+
804+
fireEvent.click(screen.getByTestId('refresh-button'));
805+
806+
await waitFor(() => expect(within(lane('Cyan Corp')).queryAllByRole('listitem')).toHaveLength(0));
807+
await waitFor(() => expect(loadMore('Cyan Corp')).not.toBeNull());
808+
expect(within(lane('Cyan Corp')).getByText('Cards not loaded: 10')).toBeInTheDocument();
809+
expect(cards()).toHaveLength(25);
810+
});
811+
812+
it('the cards a lane loaded go when the toolbar search changes, and the next read carries the search', async () => {
813+
const ds = dealSource();
814+
mountBoard(ds, { ...BOARD_VIEW, compactToolbar: false });
815+
816+
await onePageDrawn();
817+
await waitFor(() => expect(loadMore('Cyan Corp')).not.toBeNull());
818+
fireEvent.click(loadMore('Cyan Corp')!);
819+
await waitFor(() => expect(within(lane('acc-c')).getAllByRole('listitem')).toHaveLength(10));
820+
821+
// Every deal is named "Deal …", so the search keeps every record.
822+
fireEvent.click(screen.getByTestId('search-icon-button'));
823+
fireEvent.change(screen.getByPlaceholderText(/search/i), { target: { value: 'Deal' } });
824+
825+
await waitFor(() => expect(within(lane('Cyan Corp')).queryAllByRole('listitem')).toHaveLength(0));
826+
await waitFor(() => expect(loadMore('Cyan Corp')).not.toBeNull());
827+
fireEvent.click(loadMore('Cyan Corp')!);
828+
await waitFor(() => expect(within(lane('acc-c')).getAllByRole('listitem')).toHaveLength(10));
829+
const reads = laneReads(ds);
830+
expect(reads).toHaveLength(2);
831+
expect(reads[0].$search).toBeUndefined();
832+
expect(reads[1]).toMatchObject({ $search: 'Deal', $skip: 0 });
833+
});
834+
835+
it.each([
836+
['has no grouped door', false],
837+
['refuses the read', 'refuse'],
838+
['cuts the read (hasMore)', 'cut'],
839+
] as const)('CONTROL: when the source %s, no lane offers "Load more"', async (_, door) => {
840+
const ds = dealSource(door, NO_ACCOUNT_PAST_PAGE);
841+
mountBoard(ds, BOARD_VIEW);
842+
843+
await onePageDrawn();
844+
if (door !== false) await waitFor(() => expect(ds.queryGroupHeaders).toHaveBeenCalledTimes(1));
845+
await waitFor(() => expect(laneBadge('acc-a')).toBe('13+'));
846+
expect(screen.queryAllByRole('button', { name: 'Load more' })).toHaveLength(0);
847+
expect(laneReads(ds)).toHaveLength(0);
848+
});
849+
850+
it('CONTROL: a board laned by a text field offers no "Load more"', async () => {
851+
mountBoard(dealSource(), { ...BOARD_VIEW, kanban: { ...BOARD_VIEW.kanban, groupByField: 'tier' } });
852+
853+
await waitFor(() => expect(cards()).toHaveLength(25));
854+
await waitFor(() => expect(laneBadge('gold')).toBe('30'));
855+
expect(screen.queryAllByRole('button', { name: 'Load more' })).toHaveLength(0);
856+
});
857+
675858
it('a board laned by a text field counts each whole lane but draws no lane past the page', async () => {
676859
const ds = dealSource();
677860
mountBoard(ds, { ...BOARD_VIEW, kanban: { ...BOARD_VIEW.kanban, groupByField: 'tier' } });

‎ui/packages/plugin-kanban/src/KanbanImpl.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,11 @@ function KanbanColumnView({
12221222
// objectstack#37327 — a lane of a board handed one page of its query writes
12231223
// the grouped read's whole count, and its page count marked `+` while the
12241224
// read has not answered or cannot (see `KanbanBoardProps.laneCounts`).
1225-
const hostCount = pagedCount ? null : wholeLaneCount(laneCounts, String(column.id), safeCards.length)
1225+
// Read beside a lane page too (objectstack#37517): that board's lanes carry
1226+
// a page for their "Load more", and a lane none of whose records is on the
1227+
// board still says so. `laneCounts` is set only on a board handed one page,
1228+
// which never pages its lanes itself, so a self-paged lane reads `null` here.
1229+
const hostCount = wholeLaneCount(laneCounts, String(column.id), safeCards.length)
12261230
const laneCountOf = pagedCount ?? hostCount
12271231
// A lane that holds records none of which is on the page draws that, never
12281232
// "No cards" under a count above zero.

‎ui/packages/plugin-kanban/src/KanbanLanePaging.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ export function uncolumnedQueryFilter(base: unknown, laneField: string, laneIds:
107107
return mergeFilterNodes(base, ['or', [laneField, 'nin', [...laneIds]], [laneField, 'is_null']]);
108108
}
109109

110+
/**
111+
* The view's filter AND "no lane value": the records of the trailing
112+
* "Uncategorized" lane on a board whose lanes come from the data
113+
* (objectstack#37517), where every value the records hold is a lane of its own.
114+
*/
115+
export function emptyLaneQueryFilter(base: unknown, laneField: string): unknown {
116+
return mergeFilterNodes(base, [laneField, 'is_null']);
117+
}
118+
110119
/**
111120
* One lane query's answer as a page: its records, and the lane's count when the
112121
* source answered one. `loadedBefore` is what the lane already held, for a

0 commit comments

Comments
 (0)