Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-8277 fix(issues): load every Gantt page when the server caps page size (#9573)
sarankumarfa37dcef3fe2
diff --git a/packages/core/issues/queries.test.ts b/packages/core/issues/queries.test.tsindex 1f7ef40c10..db4f98adaf 100644--- a/packages/core/issues/queries.test.ts+++ b/packages/core/issues/queries.test.ts@@ -462,6 +462,26 @@ describe("projectGanttIssuesOptions", () => {expect(data).toHaveLength(total);});+ it("loads every page when the server caps the page size at 100 (#9572)", async () => {+ // The server clamps `limit` to 100 regardless of what the client asks for.+ const SERVER_PAGE_CAP = 100;+ const total = 334;+ const all = Array.from({ length: total }, (_, i) => makeIssue(i));+ const listIssues = vi+ .fn<(params?: ListIssuesParams) => Promise<ListIssuesResponse>>()+ .mockImplementation(async (params) => {+ const offset = params?.offset ?? 0;+ const limit = Math.min(params?.limit ?? SERVER_PAGE_CAP, SERVER_PAGE_CAP);+ return { issues: all.slice(offset, offset + limit), total };+ });+ installFakeApi(listIssues);++ const data = await qc.fetchQuery(projectGanttIssuesOptions(WS_ID, PROJECT_ID));++ expect(data).toHaveLength(total);+ expect(listIssues.mock.calls.map(([p]) => p?.offset)).toEqual([0, 100, 200, 300]);+ });+it("stops looping when the server reports a smaller-than-limit page (safety net for total drift)", async () => {// Server says `total` is huge but only ever returns short pages — the// loop must terminate on the first short page to avoid an infinite fetch.diff --git a/packages/core/issues/queries.ts b/packages/core/issues/queries.tsindex af3665a8f2..f807589057 100644--- a/packages/core/issues/queries.ts+++ b/packages/core/issues/queries.ts@@ -380,8 +380,12 @@ export function issueListOptions(wsId: string, sort?: IssueSortParam) {* Page size for the scheduled-issue fetch. The Gantt view always pulls every* scheduled issue (no client pagination), so this is just the chunk size we* use to walk the server's `(limit, offset)` window until we hit `total`.+ *+ * Must not exceed the server's `ListIssues` page-size cap (100): the server+ * silently clamps larger values, and a clamped page would otherwise look like+ * a short final page.*/-export const PROJECT_GANTT_PAGE_LIMIT = 500;+export const PROJECT_GANTT_PAGE_LIMIT = 100;/*** Paranoia cap on the loop in {@link fetchProjectGanttIssues}. Real projects@@ -406,9 +410,14 @@ async function fetchProjectGanttIssues(offset,});issues.push(...res.issues);- if (res.issues.length < PROJECT_GANTT_PAGE_LIMIT) break;+ if (res.issues.length === 0) break;if (issues.length >= res.total) break;- offset += PROJECT_GANTT_PAGE_LIMIT;+ if (res.issues.length < PROJECT_GANTT_PAGE_LIMIT) break;+ // Advance by what the server actually returned. This does not make the+ // loop tolerate a server cap below PROJECT_GANTT_PAGE_LIMIT — a capped+ // page is short and ends the loop above — so the constant must stay in+ // sync with the server's ListIssues page-size cap.+ offset += res.issues.length;}return issues;}