Skip to content

Commit 30c1efb

Browse files
fix(web): refresh refetches the preferred server's pull request reads
Refresh cleared remembered host reads, which sends a shared repository back to the preferred server, but only refetched the fallback targets. The preferred server's list stayed on its cached failure, which is older than the reset and so ignored, and the repository's pull requests hid behind that error. Refresh now refetches the targets the cleared assignment reads. AI-assisted; verified with the tests and tools listed above.
1 parent c9ae6cc commit 30c1efb

2 files changed

Lines changed: 52 additions & 38 deletions

File tree

‎apps/web/src/components/pullRequest/PullRequestsPage.tsx‎

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ export function PullRequestsPage() {
171171
selectedProject,
172172
queryEnvironmentIds,
173173
environmentQueries,
174+
preferredEnvironmentQueries,
174175
assignmentKey,
175176
linkedSelection,
176177
expectedHosts,
@@ -316,47 +317,51 @@ export function PullRequestsPage() {
316317
});
317318
}
318319

319-
const listTargets = environmentQueries.flatMap(({ environmentId, projectIds }) => {
320-
const cursors = sentCursors?.[environmentId];
321-
if (sentCursors !== null && cursors === undefined && !sentRegrown.includes(environmentId)) {
322-
return [];
323-
}
324-
return [
325-
{
326-
environmentId,
327-
input: {
328-
state: search.state,
329-
involvement: search.involvement,
330-
limit: pageSize,
331-
...(scopedProjectId ? { projectId: scopedProjectId } : {}),
332-
...(projectIds ? { projectIds } : {}),
333-
...(search.host ? { host: search.host } : {}),
334-
...(hasFilters ? { filters } : {}),
335-
...(sentParsed.text ? { query: sentParsed.text } : {}),
336-
...(cursors === undefined ? {} : { cursors }),
337-
} satisfies PullRequestListInput,
338-
},
339-
];
340-
});
320+
const listTargetsFor = (queries: typeof environmentQueries) =>
321+
queries.flatMap(({ environmentId, projectIds }) => {
322+
const cursors = sentCursors?.[environmentId];
323+
if (sentCursors !== null && cursors === undefined && !sentRegrown.includes(environmentId)) {
324+
return [];
325+
}
326+
return [
327+
{
328+
environmentId,
329+
input: {
330+
state: search.state,
331+
involvement: search.involvement,
332+
limit: pageSize,
333+
...(scopedProjectId ? { projectId: scopedProjectId } : {}),
334+
...(projectIds ? { projectIds } : {}),
335+
...(search.host ? { host: search.host } : {}),
336+
...(hasFilters ? { filters } : {}),
337+
...(sentParsed.text ? { query: sentParsed.text } : {}),
338+
...(cursors === undefined ? {} : { cursors }),
339+
} satisfies PullRequestListInput,
340+
},
341+
];
342+
});
343+
const listTargets = listTargetsFor(environmentQueries);
341344
const listQuery = usePullRequestList(listTargets);
342345

343346
/**
344347
* Kept as its own read rather than remembered from an earlier answer because an answer cannot
345348
* say which question it belongs to: mid-switch the text has already changed and the data has
346349
* not, and a search's answer would file itself under the workspace.
347350
*/
348-
const baselineTargets = environmentQueries.map(({ environmentId, projectIds }) => ({
349-
environmentId,
350-
input: {
351-
state: search.state,
352-
involvement: search.involvement,
353-
limit: PAGE_SIZE,
354-
...(scopedProjectId ? { projectId: scopedProjectId } : {}),
355-
...(projectIds ? { projectIds } : {}),
356-
...(search.host ? { host: search.host } : {}),
357-
...(menuFiltered ? { filters: menuFilters } : {}),
358-
} satisfies PullRequestListInput,
359-
}));
351+
const baselineTargetsFor = (queries: typeof environmentQueries) =>
352+
queries.map(({ environmentId, projectIds }) => ({
353+
environmentId,
354+
input: {
355+
state: search.state,
356+
involvement: search.involvement,
357+
limit: PAGE_SIZE,
358+
...(scopedProjectId ? { projectId: scopedProjectId } : {}),
359+
...(projectIds ? { projectIds } : {}),
360+
...(search.host ? { host: search.host } : {}),
361+
...(menuFiltered ? { filters: menuFilters } : {}),
362+
} satisfies PullRequestListInput,
363+
}));
364+
const baselineTargets = baselineTargetsFor(environmentQueries);
360365
const baselineQuery = usePullRequestList(baselineTargets);
361366
const observedHosts = rememberPullRequestHosts(
362367
rememberPullRequestHosts(hostReads, baselineQuery.observations),
@@ -908,7 +913,10 @@ export function PullRequestsPage() {
908913
await Promise.all(
909914
queryEnvironmentIds.map((environmentId) => invalidate({ environmentId, input: {} })),
910915
);
911-
listQuery.refresh([...listTargets, ...baselineTargets]);
916+
listQuery.refresh([
917+
...listTargetsFor(preferredEnvironmentQueries),
918+
...baselineTargetsFor(preferredEnvironmentQueries),
919+
]);
912920
setHostReads(resetPullRequestHosts);
913921
setInvalidating(false);
914922
refreshListAndStats(requestedStatsScope);

‎apps/web/src/components/pullRequest/usePullRequestListView.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,19 @@ export function usePullRequestScope(
121121
scopedProjectId,
122122
projectsKnown,
123123
);
124-
const environmentQueries = ((): ReadonlyArray<{
124+
const queriesFor = (
125+
availability?: PullRequestHostAvailability,
126+
): ReadonlyArray<{
125127
readonly environmentId: EnvironmentId;
126128
readonly projectIds?: ReadonlyArray<ProjectId>;
127129
}> => {
128130
const plain = queryEnvironmentIds.map((environmentId) => ({ environmentId }));
129131
if (!projectsKnown || scopedProjectId !== undefined) return plain;
130-
return pullRequestProjectQueries(projects, queryEnvironmentIds, hostAvailability);
131-
})();
132+
return pullRequestProjectQueries(projects, queryEnvironmentIds, availability);
133+
};
134+
const environmentQueries = queriesFor(hostAvailability);
135+
// What the page reads once a refresh forgets host reads; refresh must refetch these too.
136+
const preferredEnvironmentQueries = queriesFor();
132137
const assignmentKey = environmentQueries
133138
.map(({ environmentId, projectIds }) => `${environmentId}#${projectIds?.join("+") ?? "*"}`)
134139
.join("|");
@@ -178,6 +183,7 @@ export function usePullRequestScope(
178183
selectedProject,
179184
queryEnvironmentIds,
180185
environmentQueries,
186+
preferredEnvironmentQueries,
181187
assignmentKey,
182188
linkedSelection,
183189
expectedHosts,

0 commit comments

Comments
 (0)