Skip to content

Commit d650777

Browse files
perf(web): the provider settings form compiles without manual memoization
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a702563 commit d650777

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

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

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

3-
import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";
3+
import { useEffect, useRef, useState, type ReactNode } from "react";
44
import * as Option from "effect/Option";
55
import * as Schema from "effect/Schema";
66
import {
@@ -154,19 +154,21 @@ function commandArgumentsEqual(left: ReadonlyArray<string>, right: ReadonlyArray
154154
return left.length === right.length && left.every((argument, index) => argument === right[index]);
155155
}
156156

157+
function configuredCommandArgs(value: ProviderSettingsFormProps["value"]) {
158+
const configured =
159+
value !== null && typeof value === "object"
160+
? (value as Record<string, unknown>).commandArgs
161+
: undefined;
162+
return Array.isArray(configured)
163+
? configured.filter((argument): argument is string => typeof argument === "string")
164+
: [];
165+
}
166+
157167
function ProviderCommandArguments({
158168
value,
159169
onChange,
160170
}: Pick<ProviderSettingsFormProps, "value" | "onChange">) {
161-
const args = useMemo(() => {
162-
const configured =
163-
value !== null && typeof value === "object"
164-
? (value as Record<string, unknown>).commandArgs
165-
: undefined;
166-
return Array.isArray(configured)
167-
? configured.filter((argument): argument is string => typeof argument === "string")
168-
: [];
169-
}, [value]);
171+
const args = configuredCommandArgs(value);
170172
const [rows, setRows] = useState(() => args.map(makeCommandArgumentDraftRow));
171173
const rowsRef = useRef(rows);
172174
const previousArgsRef = useRef(args);
@@ -551,10 +553,7 @@ export function ProviderSettingsForm({
551553
variant,
552554
onChange,
553555
}: ProviderSettingsFormProps) {
554-
const fields = useMemo(
555-
() => deriveProviderSettingsFields(definition, value),
556-
[definition, value],
557-
);
556+
const fields = deriveProviderSettingsFields(definition, value);
558557
const isLocalAcp =
559558
definition.driverKind === "acpRegistry" &&
560559
readProviderConfigString(value, "source") === "local";

0 commit comments

Comments
 (0)