The best way to control Claude Code, Codex and more from any computer or phone
perf(web): the provider settings panel compiles with the React Compiler (#20664)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 16, 2026 at 21:55 UTC
11f66760d097996c58e4118ed5b4fd497000c93f
1 file changed
+96
-103
apps/web/src/components/settings/ProviderSettingsPanel.tsx
+96
-103
@@ -33,10 +33,9 @@ import {
33
} from "@t3tools/shared/backgroundActivitySettings";
34
import * as Arr from "effect/Array";
35
import * as Duration from "effect/Duration";
36
-import * as Equal from "effect/Equal";
36
import * as Result from "effect/Result";
37
import { PlusIcon } from "lucide-react";
39
-import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
38
+import { useRef, useState, type ReactNode } from "react";
39
40
import { isDesktopLocalConnectionTarget } from "../../connection/desktopLocal";
41
import {
@@ -292,10 +291,10 @@ function ProviderSettingsPanelContent(target: ProviderSettingsTarget) {
291
const { environments, isReady } = useEnvironments();
292
const primaryEnvironmentId = usePrimaryEnvironmentId();
293
const searchTargetId = useSettingsSearchTargetId();
295
- const options = useMemo(
296
- () =>
297
- buildProviderEnvironmentOptions(environments, primaryEnvironmentId, target.environmentIds),
298
- [environments, primaryEnvironmentId, target.environmentIds],
294
+ const options = buildProviderEnvironmentOptions(
295
+ environments,
296
+ primaryEnvironmentId,
297
+ target.environmentIds,
298
);
299
const [selectedEnvironmentId, setSelectedEnvironmentId] = useState<EnvironmentId | null>(
300
target.environmentId ?? primaryEnvironmentId,
@@ -330,7 +329,9 @@ function ProviderSettingsPanelContent(target: ProviderSettingsTarget) {
329
hasServerConfig: true,
330
}),
331
)?.environmentId;
333
- useEffect(() => {
332
+ // A search jump to a setting the selected device cannot show switches to one that can.
333
+ let searchRedirectEnvironmentId: EnvironmentId | undefined;
334
+ {
335
if (
336
!target.scoped &&
337
searchTargetId === searchableSetting("cursor-keychain-usage").id &&
@@ -338,26 +339,23 @@ function ProviderSettingsPanelContent(target: ProviderSettingsTarget) {
339
selectedEnvironment?.serverConfig?.environment.platform.os !== "darwin") &&
340
searchableCursorEnvironmentId !== undefined
341
) {
341
- setSelectedEnvironmentId(searchableCursorEnvironmentId);
342
- return;
343
- }
344
- if (
342
+ searchRedirectEnvironmentId = searchableCursorEnvironmentId;
343
+ } else if (
344
!target.scoped &&
345
(searchTargetId === searchableSetting("provider-health-check-interval").id ||
346
searchTargetId === searchableSetting("usage-providers").id) &&
347
!selectedEnvironmentCanRenderSettings &&
348
searchableEnvironmentId !== undefined
349
) {
351
- setSelectedEnvironmentId(searchableEnvironmentId);
350
+ searchRedirectEnvironmentId = searchableEnvironmentId;
351
}
353
- }, [
354
- searchTargetId,
355
- searchableCursorEnvironmentId,
356
- searchableEnvironmentId,
357
- selectedEnvironment,
358
- selectedEnvironmentCanRenderSettings,
359
- target.scoped,
360
- ]);
352
+ }
353
+ if (
354
+ searchRedirectEnvironmentId !== undefined &&
355
+ searchRedirectEnvironmentId !== selectedEnvironmentId
356
+ ) {
357
+ setSelectedEnvironmentId(searchRedirectEnvironmentId);
358
+ }
359
const onlyPrimaryDevice =
360
options.length === 1 && options[0]?.entry.target._tag === "PrimaryConnectionTarget";
361
const deviceTabs =
@@ -538,13 +536,15 @@ function AccessGatedProviderSettings({
536
);
537
}
538
539
+const NO_PROJECT_IDS: readonly ProjectId[] = [];
540
+
541
export function EnvironmentProviderSettings({
542
environmentId,
543
environmentLabel,
544
readOnly = false,
545
deviceTabs,
546
targetInstanceId,
547
- projectIds = [],
547
+ projectIds = NO_PROJECT_IDS,
548
}: {
549
readonly environmentId: EnvironmentId;
550
readonly environmentLabel: string;
@@ -593,42 +593,38 @@ export function EnvironmentProviderSettings({
593
const refreshingRef = useRef(false);
594
const updatingInstanceIdsRef = useRef<Set<ProviderInstanceId>>(new Set());
595
596
- const acceptUrlAuthentication = useCallback(
597
- (instanceId: ProviderInstanceId, action: AcpRegistryUrlAuthAction) => {
598
- void acceptAcpRegistryUrlAuth({
599
- environmentId,
600
- input: { instanceId, elicitationId: action.elicitationId },
601
- }).then((result) => {
602
- if (result._tag === "Success" && !result.value.accepted) {
603
- toastManager.add({
604
- type: "warning",
605
- title: "Authentication request expired",
606
- description: "Refresh the provider and start the authentication flow again.",
607
- });
608
- return;
609
- }
610
- if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
611
- const error = squashAtomCommandFailure(result);
612
- toastManager.add({
613
- type: "error",
614
- title: "Could not continue authentication",
615
- description:
616
- error instanceof Error ? error.message : "The authentication request expired.",
617
- });
618
- }
619
- });
620
- },
621
- [acceptAcpRegistryUrlAuth, environmentId],
622
- );
596
+ const acceptUrlAuthentication = (
597
+ instanceId: ProviderInstanceId,
598
+ action: AcpRegistryUrlAuthAction,
599
+ ) => {
600
+ void acceptAcpRegistryUrlAuth({
601
+ environmentId,
602
+ input: { instanceId, elicitationId: action.elicitationId },
603
+ }).then((result) => {
604
+ if (result._tag === "Success" && !result.value.accepted) {
605
+ toastManager.add({
606
+ type: "warning",
607
+ title: "Authentication request expired",
608
+ description: "Refresh the provider and start the authentication flow again.",
609
+ });
610
+ return;
611
+ }
612
+ if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
613
+ const error = squashAtomCommandFailure(result);
614
+ toastManager.add({
615
+ type: "error",
616
+ title: "Could not continue authentication",
617
+ description:
618
+ error instanceof Error ? error.message : "The authentication request expired.",
619
+ });
620
+ }
621
+ });
622
+ };
623
624
- const providerUpdateCandidateByInstanceId = useMemo(
625
- () =>
626
- new Map(
627
- serverProviders
628
- .filter(isProviderSettingsUpdateCandidate)
629
- .map((candidate) => [candidate.instanceId, candidate]),
630
- ),
631
- [serverProviders],
624
+ const providerUpdateCandidateByInstanceId = new Map(
625
+ serverProviders
626
+ .filter(isProviderSettingsUpdateCandidate)
627
+ .map((candidate) => [candidate.instanceId, candidate]),
628
);
629
const visibleProviderSettings = PROVIDER_SETTINGS.filter(
630
(providerSettings) =>
@@ -656,7 +652,7 @@ export function EnvironmentProviderSettings({
652
)
653
: null;
654
659
- const refreshProviders = useCallback(() => {
655
+ const refreshProviders = () => {
656
if (refreshingRef.current || !readEnvironmentScope(environmentId, AuthOrchestrationReadScope))
657
return;
658
refreshingRef.current = true;
@@ -676,55 +672,52 @@ export function EnvironmentProviderSettings({
672
});
673
}
674
})();
679
- }, [environmentId, refreshServerProviders]);
675
+ };
676
681
- const runProviderUpdate = useCallback(
682
- async (
683
- candidate: Pick<ProviderSettingsUpdateCandidate, "driver" | "instanceId">,
684
- targetVersion?: string,
685
- ) => {
686
- if (!readEnvironmentScope(environmentId, AuthProvidersManageScope)) return;
687
- // Ref-based re-entry guard, mirroring refreshProviders: a state updater
688
- // may run after this function returns, so it cannot gate the dispatch.
689
- if (updatingInstanceIdsRef.current.has(candidate.instanceId)) {
690
- return;
691
- }
692
- updatingInstanceIdsRef.current.add(candidate.instanceId);
693
- setUpdatingProviderInstanceIds((previous) => new Set(previous).add(candidate.instanceId));
677
+ const runProviderUpdate = async (
678
+ candidate: Pick<ProviderSettingsUpdateCandidate, "driver" | "instanceId">,
679
+ targetVersion?: string,
680
+ ) => {
681
+ if (!readEnvironmentScope(environmentId, AuthProvidersManageScope)) return;
682
+ // Ref-based re-entry guard, mirroring refreshProviders: a state updater
683
+ // may run after this function returns, so it cannot gate the dispatch.
684
+ if (updatingInstanceIdsRef.current.has(candidate.instanceId)) {
685
+ return;
686
+ }
687
+ updatingInstanceIdsRef.current.add(candidate.instanceId);
688
+ setUpdatingProviderInstanceIds((previous) => new Set(previous).add(candidate.instanceId));
689
695
- const result = await updateProvider({
696
- environmentId,
697
- input: {
698
- provider: candidate.driver,
699
- instanceId: candidate.instanceId,
700
- ...(targetVersion ? { targetVersion } : {}),
701
- },
702
- });
703
- if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
704
- const error = squashAtomCommandFailure(result);
705
- toastManager.add(
706
- stackedThreadToast({
707
- type: "error",
708
- title: `Could not update ${PROVIDER_DISPLAY_NAMES[candidate.driver] ?? candidate.driver}`,
709
- description:
710
- error instanceof Error
711
- ? error.message
712
- : "The provider update command could not be started.",
713
- }),
714
- );
690
+ const result = await updateProvider({
691
+ environmentId,
692
+ input: {
693
+ provider: candidate.driver,
694
+ instanceId: candidate.instanceId,
695
+ ...(targetVersion ? { targetVersion } : {}),
696
+ },
697
+ });
698
+ if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
699
+ const error = squashAtomCommandFailure(result);
700
+ toastManager.add(
701
+ stackedThreadToast({
702
+ type: "error",
703
+ title: `Could not update ${PROVIDER_DISPLAY_NAMES[candidate.driver] ?? candidate.driver}`,
704
+ description:
705
+ error instanceof Error
706
+ ? error.message
707
+ : "The provider update command could not be started.",
708
+ }),
709
+ );
710
+ }
711
+ updatingInstanceIdsRef.current.delete(candidate.instanceId);
712
+ setUpdatingProviderInstanceIds((previous) => {
713
+ if (!previous.has(candidate.instanceId)) {
714
+ return previous;
715
}
716
- updatingInstanceIdsRef.current.delete(candidate.instanceId);
717
- setUpdatingProviderInstanceIds((previous) => {
718
- if (!previous.has(candidate.instanceId)) {
719
- return previous;
720
- }
721
- const next = new Set(previous);
722
- next.delete(candidate.instanceId);
723
- return next;
724
- });
725
- },
726
- [environmentId, updateProvider],
727
- );
716
+ const next = new Set(previous);
717
+ next.delete(candidate.instanceId);
718
+ return next;
719
+ });
720
+ };
721
722
interface InstanceRow {
723
readonly instanceId: ProviderInstanceId;