From 3acb829c751be96bb6a1599899dd45246b4e5adc Mon Sep 17 00:00:00 2001 From: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com> Date: Fri, 16 Oct 2026 22:56:17 -0700 Subject: [PATCH] refactor(web): provider models keep their caching without "use memo" Co-Authored-By: Claude Opus 5.5 --- .../components/settings/ProviderModelsSection.tsx | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/apps/web/src/components/settings/ProviderModelsSection.tsx b/apps/web/src/components/settings/ProviderModelsSection.tsx index 106c56b0d54f..a94351ff4c93 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) => void; } -/** CustomModelEditor keys its option list on this array. */ -function useBuiltInModels(models: ReadonlyArray) { - "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);