From 0c9db255d46c718bccd2e859fb2982b05f216bbf Mon Sep 17 00:00:00 2001 From: Arnab Nandy Date: Fri, 3 Jul 2026 01:15:41 +0530 Subject: [PATCH] Hide repo batch queries from search results --- src/features/issues/server/github-search.ts | 16 ++++++++++++---- .../features/issues/server/github-search.test.ts | 3 +++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/features/issues/server/github-search.ts b/src/features/issues/server/github-search.ts index b6b3980..edc1550 100644 --- a/src/features/issues/server/github-search.ts +++ b/src/features/issues/server/github-search.ts @@ -274,6 +274,12 @@ export async function searchGitHubIssues({ queryParts.push(linkedPrQualifier); } + const displayQuery = repoTopicQuery + ? [repoTopicQuery, `label:${quoteSearchValue(label)}`, linkedPrQualifier] + .filter(Boolean) + .join(" ") + : queryParts.join(" "); + const repoBatches = repoTopicQuery && matchingRepos.length > 0 ? Array.from( @@ -288,7 +294,7 @@ export async function searchGitHubIssues({ if (repoTopicQuery && repoBatches.length === 0) { return { - query: repoTopicQuery, + query: displayQuery, totalCount: 0, candidateCount: 0, rateLimitRemaining: null, @@ -307,7 +313,6 @@ export async function searchGitHubIssues({ ].join(" "), ) : [queryParts.join(" ")]; - const query = issueQueries.join(" | "); const searchUrls = issueQueries.flatMap((issueQuery) => { const pageNumbers = @@ -328,7 +333,10 @@ export async function searchGitHubIssues({ const searchResults = await Promise.all( searchUrls.map((url) => githubFetch(url, token, 180)), ); - const totalCount = searchResults[0]?.data.total_count ?? 0; + const totalCount = + repoBatches.length > 0 + ? searchResults.reduce((count, result) => count + result.data.total_count, 0) + : searchResults[0]?.data.total_count ?? 0; const rateLimitRemaining = searchResults.at(-1)?.rateLimitRemaining ?? null; const candidateIssues = dedupeIssues(searchResults.flatMap((result) => result.data.items)); const repoEntriesFromSearch = matchingRepos.map((repo) => [repo.full_name, repo] as const); @@ -446,7 +454,7 @@ export async function searchGitHubIssues({ })); return { - query, + query: displayQuery, totalCount, candidateCount: rankedIssues.length, rateLimitRemaining, diff --git a/tests/features/issues/server/github-search.test.ts b/tests/features/issues/server/github-search.test.ts index dc5a8cc..3273443 100644 --- a/tests/features/issues/server/github-search.test.ts +++ b/tests/features/issues/server/github-search.test.ts @@ -177,6 +177,9 @@ describe("searchGitHubIssues", () => { "is:issue is:open archived:false label:\"help wanted\" repo:spring-projects/spring-boot", ); expect(issueQuery).not.toContain("Spring Boot"); + expect(result.query).toBe( + 'topic:spring-boot archived:false language:Java label:"help wanted"', + ); expect(result.issues[0]).toMatchObject({ repo: "spring-projects/spring-boot", stars: 82000,