fix: auto-load repositories when insufficient content in dropdown (#10697)

Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: Rohit Malhotra <rohitvinodmalhotra@gmail.com>
This commit is contained in:
sp.wack 2025-08-30 01:17:27 +04:00 committed by GitHub
parent 6eb32e9ae4
commit c0fa41da65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,4 @@
import { useMemo } from "react";
import { useMemo, useEffect } from "react";
import { Provider } from "#/types/settings";
import { GitRepository } from "#/types/git";
import { useGitRepositories } from "#/hooks/query/use-git-repositories";
@ -75,6 +75,35 @@ export function useRepositoryData(
inputValue,
]);
// Auto-load more repositories when there aren't enough items to create a scrollable dropdown
// This is particularly important for SaaS mode with installations that might have very few repos
useEffect(() => {
const shouldAutoLoad =
!disabled &&
!isLoading &&
!isFetchingNextPage &&
!isSearchLoading &&
hasNextPage &&
!processedSearchInput && // Not during search (use all repos, not search results)
urlSearchResults.length === 0 &&
repositories.length > 0 && // Have some repositories loaded
repositories.length < 10; // But not enough to create a scrollable dropdown
if (shouldAutoLoad) {
fetchNextPage();
}
}, [
disabled,
isLoading,
isFetchingNextPage,
isSearchLoading,
hasNextPage,
processedSearchInput,
urlSearchResults.length,
repositories.length,
fetchNextPage,
]);
return {
repositories,
allRepositories,