Skip to content

Commit 381a8b1

Browse files
Copilotalexr00
andauthored
Don't prompt to fetch additional remotes when user explicitly configures them (#8219)
* Initial plan * Initial analysis of remote fetching issue Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Fix: Don't prompt to fetch additional remotes when explicitly configured When users explicitly configure githubPullRequests.remotes, the extension should automatically fetch from all configured remotes instead of prompting "Continue fetching from other remotes" after finding results in the first one. This change modifies the fetchPagedData method to detect when remotes have been explicitly configured (via global, workspace, or folder settings) and skips the early break logic that was causing the prompt to appear. Fixes microsoft/vscode-pull-request-github#XXXXX Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Address code review feedback: improve variable names and readability - Renamed hasExplicitRemotesConfig to hasUserConfiguredRemotes for clarity - Extracted complex conditional logic into well-named boolean variables (hasReceivedData, isFetchingNextPage, hasReachedPreviousFetchLimit, shouldBreakEarly) to improve readability and make the logic more self-documenting Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Revert unrelated change to vscode.proposed.chatParticipantAdditions.d.ts * Fix: Preserve hasMorePages to show "Load more" button When user configures remotes and we loop through all of them, we should preserve itemData.hasMorePages so that the "Load more" button appears if any repository has more pages. Previously, we were returning hasMorePages: false which prevented the "Load more" button from showing. Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Remove unrelated change to vscode.proposed.chatParticipantAdditions.d.ts Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent adba5c4 commit 381a8b1

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

src/github/folderRepositoryManager.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,10 @@ export class FolderRepositoryManager extends Disposable {
10861086

10871087
const activeGitHubRemotes = await this.getActiveGitHubRemotes(this._allGitHubRemotes);
10881088

1089+
// Check if user has explicitly configured remotes (not using defaults)
1090+
const remotesConfig = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).inspect<string[]>(REMOTES);
1091+
const hasUserConfiguredRemotes = !!(remotesConfig?.globalValue || remotesConfig?.workspaceValue || remotesConfig?.workspaceFolderValue);
1092+
10891093
const githubRepositories = this._githubRepositories.filter(repo => {
10901094
if (!activeGitHubRemotes.find(r => r.equals(repo.remote))) {
10911095
return false;
@@ -1148,15 +1152,17 @@ export class FolderRepositoryManager extends Disposable {
11481152

11491153
pageInformation.hasMorePages = itemData.hasMorePages;
11501154

1151-
// Break early if
1155+
// Determine if we should break early from the loop:
11521156
// 1) we've received data AND
11531157
// 2) either we're fetching just the next page (case 2)
11541158
// OR we're fetching all (cases 1&3), and we've fetched as far as we had previously (or further, in case 1).
1155-
if (
1156-
itemData.items.length &&
1157-
(options.fetchNextPage ||
1158-
((options.fetchNextPage === false) && !options.fetchOnePagePerRepo && (pagesFetched >= getTotalFetchedPages())))
1159-
) {
1159+
// 3) AND the user hasn't explicitly configured remotes (if they have, we should search all of them)
1160+
const hasReceivedData = itemData.items.length > 0;
1161+
const isFetchingNextPage = options.fetchNextPage;
1162+
const hasReachedPreviousFetchLimit = (options.fetchNextPage === false) && !options.fetchOnePagePerRepo && (pagesFetched >= getTotalFetchedPages());
1163+
const shouldBreakEarly = hasReceivedData && (isFetchingNextPage || hasReachedPreviousFetchLimit) && !hasUserConfiguredRemotes;
1164+
1165+
if (shouldBreakEarly) {
11601166
if (getTotalFetchedPages() === 0) {
11611167
// We're in case 1, manually set number of pages we looked through until we found first results.
11621168
setTotalFetchedPages(pagesFetched);
@@ -1173,7 +1179,7 @@ export class FolderRepositoryManager extends Disposable {
11731179

11741180
return {
11751181
items: itemData.items,
1176-
hasMorePages: false,
1182+
hasMorePages: itemData.hasMorePages,
11771183
hasUnsearchedRepositories: false,
11781184
totalCount: itemData.totalCount
11791185
};

0 commit comments

Comments
 (0)