The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 06:45 UTC
perf(web): the provider models section compiles with the React Compiler (#20617)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 16, 2026 at 22:00 UTC
a4f6caf8cf43f33aa623ae03df6d6078546bbba2
1 file changed
+17
-14
apps/web/src/components/settings/ProviderModelsSection.tsx
+17
-14
@@ -1,7 +1,7 @@
1
"use client";
2
3
import { ArrowDownIcon, ArrowUpIcon, PencilIcon, PlusIcon, StarIcon, XIcon } from "lucide-react";
4
-import { useEffect, useMemo, useRef, useState } from "react";
4
+import { useEffect, useRef, useState } from "react";
5
import {
6
ProviderDriverKind,
7
type ProviderInstanceId,
@@ -113,6 +113,12 @@ interface ProviderModelsSectionProps {
113
readonly onModelOrderChange: (next: ReadonlyArray<string>) => void;
114
}
115
116
+/** CustomModelEditor keys its option list on this array. */
117
+function useBuiltInModels(models: ReadonlyArray<ServerProviderModel>) {
118
+ "use memo";
119
+ return models.filter((model) => !model.isCustom);
120
+}
121
+
122
export function ProviderModelsSection({
123
instanceId,
124
driverKind,
@@ -136,22 +142,18 @@ export function ProviderModelsSection({
142
const [editingSlug, setEditingSlug] = useState<string | null>(null);
143
const listRef = useRef<HTMLDivElement>(null);
144
const scrollToSlugRef = useRef<string | null>(null);
139
- const hiddenModelSet = useMemo(() => new Set(hiddenModels), [hiddenModels]);
140
- const favoriteModelSet = useMemo(() => new Set(favoriteModels), [favoriteModels]);
141
- const displayModels = useMemo(
142
- () =>
143
- groupModelsForDisplay(models, {
144
- favoriteModels: favoriteModelSet,
145
- hiddenModels: hiddenModelSet,
146
- modelOrder,
147
- }),
148
- [favoriteModelSet, hiddenModelSet, modelOrder, models],
149
- );
145
+ const hiddenModelSet = new Set(hiddenModels);
146
+ const favoriteModelSet = new Set(favoriteModels);
147
+ const displayModels = groupModelsForDisplay(models, {
148
+ favoriteModels: favoriteModelSet,
149
+ hiddenModels: hiddenModelSet,
150
+ modelOrder,
151
+ });
152
const favoriteCount = displayModels.filter((model) => favoriteModelSet.has(model.slug)).length;
153
const hiddenCount = displayModels.filter(
154
(model) => !model.isCustom && hiddenModelSet.has(model.slug),
155
).length;
154
- const builtInModels = useMemo(() => models.filter((model) => !model.isCustom), [models]);
156
+ const builtInModels = useBuiltInModels(models);
157
const allBuiltInModelsHidden =
158
builtInModels.length > 0 && builtInModels.every((model) => hiddenModelSet.has(model.slug));
159
const showFilter = models.length > FILTER_THRESHOLD;
@@ -165,6 +167,7 @@ export function ProviderModelsSection({
167
)
168
: displayModels;
169
170
+ // A model added or moved lands in a later commit, so each commit looks for the pending row.
171
useEffect(() => {
172
const slug = scrollToSlugRef.current;
173
if (slug === null) return;
@@ -174,7 +177,7 @@ export function ProviderModelsSection({
177
if (!row) return;
178
scrollToSlugRef.current = null;
179
row.scrollIntoView({ block: "nearest" });
177
- }, [displayModels]);
180
+ });
181
182
const handleAdd = () => {
183
if (!canManageCustomModels || driverKind === "antigravity") return;