ref(repos): Replace useOrganizationRepositories with calls to useInfiniteQuery and useFetchAllPages#112880
ref(repos): Replace useOrganizationRepositories with calls to useInfiniteQuery and useFetchAllPages#112880
Conversation
…niteQuery and useFetchAllPages
| const result = useInfiniteQuery({ | ||
| ...organizationRepositoriesInfiniteOptions({organization}), | ||
| select: ({pages}) => pages.flatMap(page => page.json), | ||
| }); | ||
| useFetchAllPages({result}); | ||
| const {data: repositories, isFetching: isFetchingRepositories} = result; |
There was a problem hiding this comment.
Bug: The component doesn't handle the isError state from the API call. If the fetch fails, the UI will show a loading indicator indefinitely without displaying an error.
Severity: HIGH
Suggested Fix
In both autofixRepositories.tsx and addAutofixRepoModal.tsx, destructure isError from the useInfiniteQuery result. Add UI logic to check for isError and display an appropriate error message or error state to the user instead of the loading indicator when the API call fails.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: static/app/views/settings/projectSeer/autofixRepositories.tsx#L43-L48
Potential issue: The refactoring to use `useInfiniteQuery` and `useFetchAllPages` in
`autofixRepositories.tsx` and `addAutofixRepoModal.tsx` omits error handling. The
components do not check the `result.isError` property. If an API error occurs during
pagination, `useFetchAllPages` will stop fetching, but the UI will not be notified of
the failure. This results in the component remaining in a perpetual loading state,
providing no feedback to the user that something went wrong or a way to retry. This
contrasts with established patterns elsewhere in the codebase where `isError` is
explicitly handled to show an error state.
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5502bfa. Configure here.
| select: ({pages}) => pages.flatMap(page => page.json), | ||
| }); | ||
| useFetchAllPages({result}); | ||
| const {data: repositories, isFetching: isFetchingRepositories} = result; |
There was a problem hiding this comment.
Loading state flickers between sequential page fetches
Medium Severity
Using isFetching from useInfiniteQuery as the loading guard causes the UI to flicker between page fetches. After each page completes, isFetching briefly becomes false while hasNextPage is still true, causing the loading spinner to disappear and partial data to flash before useFetchAllPages triggers the next fetch via useEffect (which runs after paint). The old useFetchSequentialPages kept isFetching=true until all pages completed. The existing integrationCodeMappings.tsx shows the correct pattern: deriving the loading state as isPending || isFetchingNextPage || (!!hasNextPage && !isError).
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 5502bfa. Configure here.
| const organization = useOrganization(); | ||
| const result = useInfiniteQuery({ | ||
| ...organizationRepositoriesInfiniteOptions({organization}), | ||
| select: ({pages}) => pages.flatMap(page => page.json), |
There was a problem hiding this comment.
Deduplication of repositories by externalId removed
Low Severity
The deleted useOrganizationRepositories hook deduplicated repositories by externalId, keeping only the first occurrence and filtering out repos without an externalId. The replacement select: ({pages}) => pages.flatMap(page => page.json) does plain flattening with no deduplication. If the API returns repos sharing the same externalId (e.g., connected through multiple integrations), downstream code that keys on externalId for selection, settings, and filtering could display duplicates or behave unexpectedly.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 5502bfa. Configure here.


Having
useFetchAllPagesisn't great on a lot of pages, but it's more transparent what's going on compared to before. Also, this gets us steps closer to removinguseFetchSequentialPagesand moving it to apiOptions..Looks like
'/organizations/$organizationIdOrSlug/repos/'is going to have a mix of v1 and v2 cache entries, but i don't see anything that uses the cache, so that's fine; we're not making it worseWe also have
'/organizations/$organizationIdOrSlug/repos/'in the cache with an infinite key already, so that's expanding with this PR.