Skip to content

Commit 2718827

Browse files
fix(web): pull request search keeps partial-word matches after GitHub answers (#26992)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent f3da8ff commit 2718827

3 files changed

Lines changed: 61 additions & 6 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,8 @@ export function PullRequestsPage() {
712712
heldPullRequestsBySurface,
713713
} = pullRequestGroups({
714714
known: ordered?.key === filterKey ? ordered.entries : (listData?.entries ?? []),
715+
// The baseline was read without typed qualifiers, and rows cannot be checked for `checks:`.
716+
baseline: typedParsed.filters.checks === undefined ? baselineQuery.data?.entries : undefined,
715717
providers: baselineQuery.data?.providers ?? listData?.providers ?? [],
716718
viewers,
717719
involvement: search.involvement,

‎apps/web/src/components/pullRequest/pullRequestList.logic.test.ts‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
reusePullRequestEntries,
3939
settlePullRequestOverrides,
4040
} from "./pullRequestList.logic";
41+
import { pullRequestGroups } from "./pullRequestListGroups.logic";
4142
import {
4243
readPullRequestListPreferences,
4344
writePullRequestListPreferences,
@@ -177,6 +178,43 @@ describe("ranking what a search found", () => {
177178
rankPullRequestMatches([mentioned, titled], "welcome wizard").map((entry) => entry.number),
178179
).toEqual([1, 2]);
179180
});
181+
182+
it("keeps loaded partial-word matches the host's whole-word search missed, after its answer", () => {
183+
const bilal = { login: "bilal", name: null, avatarUrl: null };
184+
const hosted = row({ number: 1, title: "Notifications match the body text", author: bilal });
185+
const toast = row({ number: 2, title: "Threads show a completed toast", author: bilal });
186+
const toaster = row({ number: 3, title: "Toaster fixtures cover retries", author: bilal });
187+
const theirs = row({ number: 4, title: "Toasted sidebar" });
188+
const unrelated = row({ number: 5, title: "Cursor no longer adds attribution", author: bilal });
189+
190+
const { entries } = pullRequestGroups({
191+
known: [hosted, toast],
192+
baseline: [theirs, unrelated, toaster, toast],
193+
providers: [
194+
{
195+
host: "github.com",
196+
kind: SourceControlProviderKind.make("github"),
197+
searchesOnHost: true,
198+
projectCount: 1,
199+
configured: true,
200+
detail: null,
201+
},
202+
],
203+
viewers: VIEWERS,
204+
involvement: "all",
205+
localFilters: { author: "bilal" },
206+
hasLocalFilters: true,
207+
text: "toa",
208+
answeredLocally: true,
209+
baselineEmpty: false,
210+
held: undefined,
211+
authored: undefined,
212+
reviewing: undefined,
213+
partitionsWanted: false,
214+
});
215+
216+
expect(entries.map((entry) => entry.number)).toEqual([1, 2, 3]);
217+
});
180218
});
181219

182220
describe("default merge-readiness ranking", () => {

‎apps/web/src/components/pullRequest/pullRequestListGroups.logic.ts‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
partitionPullRequestsWithPriority,
1616
pullRequestEntryKey,
1717
pullRequestEntryViewer,
18+
rankPullRequestMatches,
1819
type EnvironmentPullRequestEntry,
1920
type PullRequestPartitionsSnapshot,
2021
} from "./pullRequestList.logic";
@@ -25,6 +26,7 @@ export const pullRequestListEntryId = (target: Parameters<typeof pullRequestSurf
2526
/** The held rows narrowed to what the reader asked for, in the groups the list shows. */
2627
export function pullRequestGroups({
2728
known,
29+
baseline,
2830
providers,
2931
viewers,
3032
involvement,
@@ -39,6 +41,8 @@ export function pullRequestGroups({
3941
partitionsWanted,
4042
}: {
4143
known: ReadonlyArray<EnvironmentPullRequestEntry>;
44+
/** The text-free rows already loaded, or undefined when the typed filters cannot vet them. */
45+
baseline: ReadonlyArray<EnvironmentPullRequestEntry> | undefined;
4246
providers: PullRequestListResult["providers"];
4347
viewers: PullRequestListResult["viewers"];
4448
involvement: PullRequestInvolvement;
@@ -56,22 +60,33 @@ export function pullRequestGroups({
5660
providers.flatMap((provider) => (provider.searchesOnHost ? [provider.host] : [])),
5761
);
5862

59-
const entries = (() => {
60-
const involvementEntries = filterPullRequestsByInvolvement(known, viewers, involvement);
61-
// Host text searches cover fields absent from rows, so do not narrow their matches locally.
62-
// Filter text locally while results are pending or when the host has no text search.
63-
const narrowedEntries = hasLocalFilters
63+
const narrowRows = (rows: ReadonlyArray<EnvironmentPullRequestEntry>) => {
64+
const involvementEntries = filterPullRequestsByInvolvement(rows, viewers, involvement);
65+
return hasLocalFilters
6466
? involvementEntries.filter((entry) =>
6567
matchesPullRequestFilters(entry, localFilters, pullRequestEntryViewer(entry, viewers)),
6668
)
6769
: involvementEntries;
70+
};
71+
72+
const entries = (() => {
73+
const narrowedEntries = narrowRows(known);
6874
if (text.length === 0) {
6975
return narrowedEntries.toSorted(comparePullRequestsByRecency);
7076
}
71-
return narrowedEntries.filter(
77+
// Host text searches cover fields absent from rows, so do not narrow their matches locally.
78+
// Filter text locally while results are pending or when the host has no text search.
79+
const matched = narrowedEntries.filter(
7280
(entry) =>
7381
(answeredLocally && searchingHosts.has(entry.host)) || matchesPullRequestQuery(entry, text),
7482
);
83+
// Host search matches whole words, so it can miss loaded rows a partial word matches here.
84+
// Those follow the host's ranked answer rather than reshuffling it.
85+
const listed = new Set(matched.map(pullRequestEntryKey));
86+
const missed = narrowRows(baseline ?? []).filter(
87+
(entry) => !listed.has(pullRequestEntryKey(entry)) && matchesPullRequestQuery(entry, text),
88+
);
89+
return missed.length === 0 ? matched : [...matched, ...rankPullRequestMatches(missed, text)];
7590
})();
7691

7792
const listedPullRequestTabStatuses: Record<string, PullRequestTabStatusSeed> = Object.fromEntries(

0 commit comments

Comments
 (0)