TypeScript
refactor(web): provider models keep their caching without "use memo" (#20775)
Julius Marminge275e7de026e6
diff --git a/apps/web/src/components/settings/ProviderModelsSection.tsx b/apps/web/src/components/settings/ProviderModelsSection.tsxindex 106c56b0d54..a94351ff4c9 100644--- a/apps/web/src/components/settings/ProviderModelsSection.tsx+++ b/apps/web/src/components/settings/ProviderModelsSection.tsx@@ -113,12 +113,6 @@ interface ProviderModelsSectionProps {readonly onModelOrderChange: (next: ReadonlyArray<string>) => void;}-/** CustomModelEditor keys its option list on this array. */-function useBuiltInModels(models: ReadonlyArray<ServerProviderModel>) {- "use memo";- return models.filter((model) => !model.isCustom);-}-export function ProviderModelsSection({instanceId,driverKind,@@ -153,9 +147,6 @@ export function ProviderModelsSection({const hiddenCount = displayModels.filter((model) => !model.isCustom && hiddenModelSet.has(model.slug),).length;- const builtInModels = useBuiltInModels(models);- const allBuiltInModelsHidden =- builtInModels.length > 0 && builtInModels.every((model) => hiddenModelSet.has(model.slug));const showFilter = models.length > FILTER_THRESHOLD;const normalizedFilter = filter.trim().toLowerCase();const isFiltering = showFilter && normalizedFilter.length > 0;@@ -179,6 +170,12 @@ export function ProviderModelsSection({row.scrollIntoView({ block: "nearest" });});+ // CustomModelEditor keys its option list on this array. Derived after the effect and+ // checked against `hiddenModels` rather than the set built above it, so it stays cached.+ const builtInModels = models.filter((model) => !model.isCustom);+ const allBuiltInModelsHidden =+ builtInModels.length > 0 && builtInModels.every((model) => hiddenModels.includes(model.slug));+const handleAdd = () => {if (!canManageCustomModels || driverKind === "antigravity") return;const normalized = normalizeCustomModelSlug(input);