Skip to content

ref(repos): Refactor useOrganizationRepositoriesWithSettings to use apiOptions & useInfiniteQuery#108295

Merged
ryan953 merged 6 commits intomasterfrom
ryan953/ref-useOrganizationRepositoriesWithSettings
Feb 24, 2026
Merged

ref(repos): Refactor useOrganizationRepositoriesWithSettings to use apiOptions & useInfiniteQuery#108295
ryan953 merged 6 commits intomasterfrom
ryan953/ref-useOrganizationRepositoriesWithSettings

Conversation

@ryan953
Copy link
Member

@ryan953 ryan953 commented Feb 14, 2026

This brings in useInfiniteApiQuery to replace useFetchSequentialPages inside of useOrganizationRepositoriesWithSettings

The idea is that this will be a better foundation to use to continue to iterate on the pages that load up lists of repos (there's a seer wizard step, and also the org settings page).

I believe that the new system is a bit slower to run on orgs that have 1,000's of repos. It's because we're loading and rendering each chunk of data using react to trigger the next chunk. I like it better however because we return a proper queryResult object that useQuery knows how to keep track of. The benefit is that we can re-fetch the data instead of it being cached inside the state inside useFetchSequentialPages. Also, I'm following up with virtual rendering which will counteract the re-render penalty.

@ryan953 ryan953 requested review from a team as code owners February 14, 2026 05:03
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Feb 14, 2026
@ryan953 ryan953 marked this pull request as draft February 17, 2026 21:49
@ryan953 ryan953 marked this pull request as ready for review February 17, 2026 21:55
@ryan953 ryan953 force-pushed the ryan953/ref-useOrganizationRepositoriesWithSettings branch from fb1a520 to 0f67b66 Compare February 20, 2026 23:25
@ryan953 ryan953 force-pushed the ryan953/ref-useOrganizationRepositoriesWithSettings branch from 0f67b66 to f3b1628 Compare February 20, 2026 23:30
@ryan953 ryan953 changed the title ref(repos): Refactor useOrganizationRepositoriesWithSettings to use useInfiniteApiQuery ref(repos): Refactor useOrganizationRepositoriesWithSettings to use apiOptions & useInfiniteQuery Feb 20, 2026
@ryan953 ryan953 force-pushed the ryan953/ref-useOrganizationRepositoriesWithSettings branch 2 times, most recently from 2d82360 to 894837a Compare February 21, 2026 00:00
@ryan953 ryan953 force-pushed the ryan953/ref-useOrganizationRepositoriesWithSettings branch from 894837a to 01695aa Compare February 21, 2026 00:04
@ryan953 ryan953 force-pushed the ryan953/ref-useOrganizationRepositoriesWithSettings branch 3 times, most recently from c0a3324 to 1310781 Compare February 21, 2026 00:12
@ryan953 ryan953 force-pushed the ryan953/ref-useOrganizationRepositoriesWithSettings branch from 1310781 to b7de238 Compare February 21, 2026 00:14
@ryan953 ryan953 requested a review from a team February 21, 2026 02:22
const lowerCase = searchTerm?.toLowerCase() ?? '';
if (lowerCase) {
return sortedRepositories.filter(repository =>
repository.name.toLowerCase().includes(lowerCase)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Infinite query not invalidated after repository mutations

Medium Severity

After bulk repository settings updates, only individual repository queries are invalidated via getRepositoryWithSettingsQueryKey, but the infinite query created by organizationRepositoriesInfiniteOptions is not invalidated. This causes the repository list to show stale settings data (like enabledCodeReview status) until the page is refreshed or the cache expires. The old useFetchSequentialPages implementation didn't need invalidation because it stored data in component state, but React Query caches require explicit invalidation.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true, we have the weird mutationData stuff in there now to overcome this.

I'll revisit once #108798 is merged and we have faster rendering cycles.

// return a.status.localeCompare(b.status);
// }
return 0;
}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Select function recreated on every render

Low Severity

The select function passed to useInfiniteQuery is defined inline without memoization, causing it to be recreated on every render. This forces the select function to re-run on every render even when the underlying data hasn't changed, performing expensive operations like uniqBy, filter, toSorted, and flatMap unnecessarily. This is particularly problematic when auto-fetching multiple pages, as each page fetch triggers additional re-renders.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fn depends on sort, so that's something to revisit.

Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

/>
</InputGroup>

{hasData ? null : <LoadingIndicator mini />}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loading spinner persists when results are empty

Medium Severity

The hasData variable (derived from repositories.length > 0) is used to control the mini LoadingIndicator, but it reflects data presence rather than loading state. When loading completes with zero results (e.g., a search term that matches nothing), hasData remains false, so the spinner shows permanently alongside the "No repositories found" message. The isLoading and isLoadingMore props are already available in RepoTable but aren't used for this check.

Additional Locations (1)

Fix in Cursor Fix in Web

@ryan953 ryan953 merged commit fd0a84f into master Feb 24, 2026
62 checks passed
@ryan953 ryan953 deleted the ryan953/ref-useOrganizationRepositoriesWithSettings branch February 24, 2026 21:44
ryan953 added a commit that referenced this pull request Feb 26, 2026
…#108798)

Update & improve the rendering of `<SeerRepoTable>` which is visible on
at the path `/settings/seer/repos/`

Depends on #108295
@github-actions github-actions bot locked and limited conversation to collaborators Mar 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants