fix(prs): bound refreshes by each tracker read (#19403)

This commit is contained in:
Bilal Bakr authored and GitHub committed 2026-10-15 09:24:45 -07:00
1 parent 42da166d13
commit 98bc998e73
3 files changed
+38 -1

No files matched your search

@@ -9,6 +9,7 @@ import { describe, expect, it } from "vite-plus/test";
import {
pullRequestHostActions,
largestPullRequestReadCount,
pullRequestQuickActions,
filterPullRequestsByInvolvement,
findScopedProject,
@@ -1759,3 +1760,24 @@ describe("pull request quick actions", () => {
]);
});
});
describe("refresh page size", () => {
const twoPagesAcrossFourRepositories = (provider: "github" | "gitlab") =>
["a", "b", "c", "d"].flatMap((name) =>
Array.from({ length: 198 }, (_, index) =>
entry({
number: index + 1,
provider: SourceControlProviderKind.make(provider),
repository: `pingdotgg/${name}`,
}),
),
);
it("asks each repository for its own rows where repositories are read one at a time", () => {
expect(largestPullRequestReadCount(twoPagesAcrossFourRepositories("gitlab"))).toBe(198);
});
it("asks for the whole host where one search reads every repository", () => {
expect(largestPullRequestReadCount(twoPagesAcrossFourRepositories("github"))).toBe(792);
});
});
@@ -1304,3 +1304,16 @@ export function pullRequestQuickActions(
: ["close", "merge"];
return forState.filter((action) => hostActions.has(action));
}
export function largestPullRequestReadCount(
entries: ReadonlyArray<EnvironmentPullRequestEntry>,
): number {
const counts = new Map<string, number>();
for (const entry of entries) {
const read = `${entry.environmentId} ${entry.host.toLowerCase()} ${
entry.provider === "github" ? "" : entry.repository.toLowerCase()
}`;
counts.set(read, (counts.get(read) ?? 0) + 1);
}
return Math.max(0, ...counts.values());
}
+3 -1
View File
@@ -91,6 +91,7 @@ import {
reusePullRequestEntries,
settlePullRequestOverrides,
pullRequestHostActions,
largestPullRequestReadCount,
} from "../components/pullRequest/pullRequestList.logic";
import {
pullRequestListPreferences,
@@ -1238,7 +1239,8 @@ function PullRequestsRouteView() {
return;
}
if (related.length > 0) listQuery.refresh(related);
const loadedCount = ordered?.key === filterKey ? ordered.entries.length : pageSize;
const loadedCount =
ordered?.key === filterKey ? largestPullRequestReadCount(ordered.entries) : pageSize;
setPage({
key: filterKey,
regrown: [],