Skip to content

Commit 4758c77

Browse files
perf(web): the provider models section compiles with the React Compiler
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 70d60e0 commit 4758c77

2 files changed

Lines changed: 18 additions & 14 deletions

File tree

‎apps/web/reactCompiledFiles.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,5 @@ export const REACT_COMPILED_FILES = [
9696
"apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx",
9797
"apps/web/src/components/ThreadTerminalDrawer.tsx",
9898
"apps/web/src/components/settings/SettingsPanels.tsx",
99+
"apps/web/src/components/settings/ProviderModelsSection.tsx",
99100
] as const;

‎apps/web/src/components/settings/ProviderModelsSection.tsx‎

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
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";
55
import {
66
ProviderDriverKind,
77
type ProviderInstanceId,
@@ -113,6 +113,12 @@ interface ProviderModelsSectionProps {
113113
readonly onModelOrderChange: (next: ReadonlyArray<string>) => void;
114114
}
115115

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+
116122
export function ProviderModelsSection({
117123
instanceId,
118124
driverKind,
@@ -136,22 +142,18 @@ export function ProviderModelsSection({
136142
const [editingSlug, setEditingSlug] = useState<string | null>(null);
137143
const listRef = useRef<HTMLDivElement>(null);
138144
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+
});
150152
const favoriteCount = displayModels.filter((model) => favoriteModelSet.has(model.slug)).length;
151153
const hiddenCount = displayModels.filter(
152154
(model) => !model.isCustom && hiddenModelSet.has(model.slug),
153155
).length;
154-
const builtInModels = useMemo(() => models.filter((model) => !model.isCustom), [models]);
156+
const builtInModels = useBuiltInModels(models);
155157
const allBuiltInModelsHidden =
156158
builtInModels.length > 0 && builtInModels.every((model) => hiddenModelSet.has(model.slug));
157159
const showFilter = models.length > FILTER_THRESHOLD;
@@ -165,6 +167,7 @@ export function ProviderModelsSection({
165167
)
166168
: displayModels;
167169

170+
// A model added or moved lands in a later commit, so each commit looks for the pending row.
168171
useEffect(() => {
169172
const slug = scrollToSlugRef.current;
170173
if (slug === null) return;
@@ -174,7 +177,7 @@ export function ProviderModelsSection({
174177
if (!row) return;
175178
scrollToSlugRef.current = null;
176179
row.scrollIntoView({ block: "nearest" });
177-
}, [displayModels]);
180+
});
178181

179182
const handleAdd = () => {
180183
if (!canManageCustomModels || driverKind === "antigravity") return;

0 commit comments

Comments
 (0)