fix: stop truncating the Basic LLM provider list at 100 entries (#16453)

Co-authored-by: Joseph Castle <josephrcastle@gmail.com>
This commit is contained in:
Joe Castle
2026-08-12 02:00:49 +00:00
committed by GitHub
co-authored by Joseph Castle
parent 2e1502f39d
commit 500b4c533e
2 changed files with 49 additions and 5 deletions
@@ -0,0 +1,45 @@
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { renderHook, waitFor } from "@testing-library/react";
import { http, HttpResponse } from "msw";
import React from "react";
import { describe, expect, it } from "vitest";
import { useSearchProviders } from "#/hooks/query/use-search-providers";
import { server } from "#/mocks/node";
const wrapper = ({ children }: { children: React.ReactNode }) => {
const client = new QueryClient({
defaultOptions: { queries: { retry: false } },
});
return <QueryClientProvider client={client}>{children}</QueryClientProvider>;
};
describe("useSearchProviders", () => {
it("returns providers that sort past the first 100 entries", async () => {
// Arrange: mirror the real local agent-server, whose litellm-derived
// provider list is ~150 entries long and sorted alphabetically, putting
// "openrouter" at index 101, past any 100-item cap.
const providers = [
...Array.from(
{ length: 101 },
(_, i) => `provider_${String(i).padStart(3, "0")}`,
),
"openrouter",
...Array.from({ length: 47 }, (_, i) => `zprovider_${i}`),
];
server.use(
http.get("/api/llm/providers", () => HttpResponse.json({ providers })),
http.get("/api/llm/models/verified", () =>
HttpResponse.json({ models: { openhands: ["claude-opus-4-7"] } }),
),
);
// Act
const { result } = renderHook(() => useSearchProviders(), { wrapper });
await waitFor(() => expect(result.current.isSuccess).toBe(true));
// Assert: the picker must surface every provider the backend reports.
const names = result.current.data?.map((provider) => provider.name) ?? [];
expect(names).toContain("openrouter");
expect(names).toHaveLength(providers.length + 1); // + the verified "openhands"
});
});
+4 -5
View File
@@ -17,11 +17,10 @@ export const useSearchProviders = () =>
queryFn: fetchVerifiedModelsByProvider,
staleTime: VERIFIED_MODELS_STALE_TIME,
});
// Providers are a small set; fetch all in one call with a high limit.
const page = await ConfigService.searchProviders(
{ limit: 100 },
verifiedByProvider,
);
// Fetch every provider in one call. Passing no limit is deliberate:
// litellm exposes ~150 providers, so any fixed cap silently truncates
// the picker: `openrouter` sorts past position 100 and disappears.
const page = await ConfigService.searchProviders({}, verifiedByProvider);
return page.items;
},
staleTime: VERIFIED_MODELS_STALE_TIME,