Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ProviderSettingsPanel.tsx

1,319 lines48.4 KB

1import { SettingsGroup } from "./SettingsGroup";
2import { RefreshIcon } from "~/components/ui/refresh-icon";
3import {
4 AuthSettingsWriteScope,
5 AuthProvidersManageScope,
6 AuthOrchestrationReadScope,
7} from "@t3tools/contracts";
8import { useEnvironmentScope, readEnvironmentScope } from "../../state/session";
9import { useAtomValue } from "@effect/atom-react";
10import { connectionStatusTitle } from "@t3tools/client-runtime/connection";
11import { safeErrorLogAttributes } from "@t3tools/client-runtime/errors";
12import {
13 isAtomCommandInterrupted,
14 squashAtomCommandFailure,
15} from "@t3tools/client-runtime/state/runtime";
16import {
17 defaultInstanceIdForDriver,
18 type EnvironmentId,
19 type AcpRegistryUrlAuthAction,
20 PROVIDER_DISPLAY_NAMES,
21 ProviderDriverKind,
22 type ProviderInstanceConfig,
23 type ProviderInstanceId,
24 resolveEnvironmentMachineKind,
25 resolveProviderInstanceEnabled,
26} from "@t3tools/contracts";
27import { DEFAULT_UNIFIED_SETTINGS } from "@t3tools/contracts/settings";
28import {
29 getBackgroundActivityPresetSettings,
30 resolveServerBackgroundActivitySettings,
31} from "@t3tools/shared/backgroundActivitySettings";
32import * as Arr from "effect/Array";
33import * as Duration from "effect/Duration";
34import * as Equal from "effect/Equal";
35import * as Result from "effect/Result";
36import { PlusIcon } from "lucide-react";
37import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
38​
39import { isDesktopLocalConnectionTarget } from "../../connection/desktopLocal";
40import {
41 useEnvironmentSettings,
42 usePersistEnvironmentProviderInstanceMutation,
43 useUpdateClientSettings,
44 useUpdateEnvironmentSettings,
45} from "../../hooks/useSettings";
46import { EnvironmentMachineIcon } from "../EnvironmentMachineIcon";
47import { cn } from "../../lib/utils";
48import { resolveAppModelSelectionState } from "../../modelSelection";
49import {
50 useEnvironments,
51 usePrimaryEnvironmentId,
52 type EnvironmentPresentation,
53} from "../../state/environments";
54import { EMPTY_SERVER_PROVIDERS, serverEnvironment } from "../../state/server";
55import { useEnvironmentSessionState } from "../../state/session";
56import { useProjects } from "../../state/entities";
57import { useAtomCommand } from "../../state/use-atom-command";
58import { getRelativeTimeState } from "../../timestampFormat";
59import {
60 ConnectionStatusDot,
61 connectionPhaseDotClassName,
62 connectionPhasePingClassName,
63} from "../ConnectionStatusDot";
64import {
65 isProviderSettingsUpdateCandidate,
66 isProviderUpdateActive,
67 type ProviderSettingsUpdateCandidate,
68} from "../ProviderUpdateLaunchNotification.logic";
69import { ProviderUpdatesAction } from "../ProviderUpdatesAction";
70import { Button } from "../ui/button";
71import {
72 Empty,
73 EmptyContent,
74 EmptyDescription,
75 EmptyHeader,
76 EmptyMedia,
77 EmptyTitle,
78} from "../ui/empty";
79import {
80 NumberField,
81 NumberFieldDecrement,
82 NumberFieldGroup,
83 NumberFieldIncrement,
84 NumberFieldInput,
85} from "../ui/number-field";
86import { ScrollArea } from "../ui/scroll-area";
87import { Toggle, ToggleGroup } from "../ui/toggle-group";
88import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
89import { stackedThreadToast, toastManager } from "../ui/toast";
90import { AddProviderInstanceDialog } from "./AddProviderInstanceDialog";
91import { ExpandableText } from "./ExpandableText";
92import { ProviderInstanceCard } from "./ProviderInstanceCard";
93import { UsageProviderSettings } from "./UsageProviderSettings";
94import { ProviderSetupSection, readAntigravityAuthMethod } from "./ProviderSetupSection";
95import { ProviderAuthenticationSection } from "./ProviderAuthenticationSection";
96import { CodexSetupSection, CodexManagedRuntimeFields } from "./CodexSetupSection";
97import { readCodexSetupMode } from "./CodexSetupSection.logic";
98import { providerClients } from "./providerDriverMeta";
99import { searchableSetting } from "./settingsSearch";
100import {
101 backgroundActivityOverrideSettings,
102 buildProviderInstanceUpdatePatch,
103 durationToSeconds,
104 normalizeIntervalSeconds,
105 PROVIDER_HEALTH_INTERVAL_STEP_SECONDS,
106} from "./SettingsPanels.logic";
107import {
108 PolicyTooltip,
109 SettingResetButton,
110 SettingsPageContainer,
111 SettingsRow,
112 SettingsSection,
113 useRelativeTimeTick,
114 useSettingsSearchTargetId,
115} from "./settingsLayout";
116import {
117 buildProviderEnvironmentOptions,
118 classifyProviderEnvironmentAccess,
119 isProviderSettingsEnvironmentAvailable,
120 type ProviderEnvironmentAccess,
121 type ProviderOperateAccess,
122 resolveRemoteOperateAccess,
123 resolveSelectedProviderEnvironmentId,
124} from "./ProviderSettingsPanel.logic";
125​
126function withoutProviderInstanceKey<V>(
127 record: Readonly<Record<ProviderInstanceId, V>> | undefined,
128 key: ProviderInstanceId,
129): Record<ProviderInstanceId, V> {
130 const next = { ...record } as Record<ProviderInstanceId, V>;
131 delete next[key];
132 return next;
134​
135function withoutProviderInstanceFavorites(
136 favorites: ReadonlyArray<{ readonly provider: ProviderInstanceId; readonly model: string }>,
137 instanceId: ProviderInstanceId,
138) {
139 return favorites.filter((favorite) => favorite.provider !== instanceId);
141​
142function providerConfigString(config: unknown, key: string): string | null {
143 if (config === null || typeof config !== "object") return null;
144 const value = (config as Record<string, unknown>)[key];
145 return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
147​
148const PROVIDER_SETTINGS = providerClients.definitions.map((definition) => ({
149 provider: definition.driverKind,
150 hasDefaultInstance: definition.hasDefaultInstance !== false,
151}));
152​
153function configuredBinaryPath(config: unknown): string {
154 if (config === null || typeof config !== "object" || !("binaryPath" in config)) return "";
155 return typeof config.binaryPath === "string" ? config.binaryPath.trim() : "";
157​
158function ProviderLastChecked({ lastCheckedAt }: { lastCheckedAt: string | null }) {
159 useRelativeTimeTick();
160 const lastCheckedRelative = getRelativeTimeState(lastCheckedAt);
161​
162 if (lastCheckedRelative.status === "missing") {
163 return null;
164 }
165​
166 if (lastCheckedRelative.status === "invalid") {
167 return <span>Checked unavailable</span>;
168 }
169​
170 return (
171 <span>
172 {lastCheckedRelative.suffix ? (
173 <>
174 Checked <span className="font-mono tabular-nums">{lastCheckedRelative.value}</span>{" "}
175 {lastCheckedRelative.suffix}
176 </>
177 ) : (
178 <>Checked {lastCheckedRelative.value}</>
179 )}
180 </span>
181 );
183​
184function providerEnvironmentDetail(environment: EnvironmentPresentation): string {
185 if (environment.entry.target._tag === "PrimaryConnectionTarget") return "Primary device";
186 if (environment.relayManaged) return "T3 Connect";
187 if (environment.entry.target._tag === "SshConnectionTarget") return "SSH";
188 if (isDesktopLocalConnectionTarget(environment.entry.target)) return "Local device";
189 return environment.displayUrl ?? "Remote device";
191​
192// Shared by the editor grid and the placeholder states so switching devices
193// never changes the card's footprint.
194const providerCardHeightClassName =
195 "@min-[48rem]/providers:h-[min(44rem,calc(100dvh-11rem))] @min-[48rem]/providers:min-h-[32rem]";
196​
197/**
198 * Same chrome as the provider editor (section heading, floating device tabs,
199 * tall card) for states that cannot render provider settings yet.
200 */
201function ProviderSettingsPlaceholder({
202 deviceTabs,
203 icon,
204 title,
205 description,
206 children,
207}: {
208 readonly deviceTabs?: ReactNode;
209 readonly icon: ReactNode;
210 readonly title: string;
211 readonly description: string;
212 readonly children?: ReactNode;
213}) {
214 return (
215 <SettingsSection {...searchableSetting("providers")} variant="plain">
216 {deviceTabs ? (
217 <div className="flex min-h-11 min-w-0 items-center px-3 sm:px-4">{deviceTabs}</div>
218 ) : null}
219 <SettingsGroup
220 divided={false}
221 className={cn(
222 providerCardHeightClassName,
223 "scrollbar-gutter-both flex overflow-x-hidden overflow-y-auto",
224 )}
225 >
226 <Empty>
227 <EmptyMedia variant="icon">{icon}</EmptyMedia>
228 <EmptyHeader>
229 <EmptyTitle>{title}</EmptyTitle>
230 <EmptyDescription>{description}</EmptyDescription>
231 </EmptyHeader>
232 {children ? <EmptyContent className="max-w-xl">{children}</EmptyContent> : null}
233 </Empty>
234 </SettingsGroup>
235 </SettingsSection>
236 );
238​
239function EnvironmentUnavailablePlaceholder({
240 environment,
241 access,
242 deviceTabs,
243}: {
244 readonly environment: EnvironmentPresentation;
245 readonly access: Exclude<ProviderEnvironmentAccess, { kind: "editable" | "read-only" }>;
246 readonly deviceTabs?: ReactNode;
247}) {
248 const isLoading = access.kind === "loading";
249 const title = isLoading
250 ? "Loading provider settings"
251 : access.kind === "error"
252 ? "Could not connect to this device"
253 : "Provider settings are unavailable";
254 // Keep the description to a short status; the raw failure can be a
255 // multi-paragraph CLI dump, so it goes below, clamped and expandable.
256 const description = isLoading
257 ? access.reason === "permissions"
258 ? "Checking what this session is allowed to change."
259 : `Waiting for ${environment.label}'s configuration.`
260 : connectionStatusTitle(environment.connection);
261 const error = isLoading ? null : environment.connection.error;
262 // No spinner: this state can persist indefinitely for a wedged device, and a
263 // continuously repainting animation would run the whole time.
264 return (
265 <ProviderSettingsPlaceholder
266 deviceTabs={deviceTabs}
267 icon={
268 <EnvironmentMachineIcon kind={resolveEnvironmentMachineKind(environment.serverConfig)} />
269 }
270 title={title}
271 description={description}
272 >
273 {error ? (
274 <ExpandableText
275 key={environment.environmentId}
276 text={error}
277 className="w-full text-left font-mono text-xs leading-relaxed text-muted-foreground"
278 />
279 ) : null}
280 </ProviderSettingsPlaceholder>
281 );
283​
284interface ProviderSettingsTarget {
285 readonly environmentId?: EnvironmentId;
286 readonly instanceId?: ProviderInstanceId;
287 readonly scoped?: boolean;
288 readonly environmentIds?: readonly EnvironmentId[];
290​
291export function ProviderSettingsPanel(target: ProviderSettingsTarget) {
292 return (
293 <SettingsPageContainer width="wide" className="@container/providers gap-8">
294 <ProviderSettingsPanelContent
295 key={`${target.environmentId ?? ""}:${target.instanceId ?? ""}`}
296 {...target}
297 />
298 </SettingsPageContainer>
299 );
301​
302function ProviderSettingsPanelContent(target: ProviderSettingsTarget) {
303 const { environments, isReady } = useEnvironments();
304 const primaryEnvironmentId = usePrimaryEnvironmentId();
305 const searchTargetId = useSettingsSearchTargetId();
306 const options = useMemo(
307 () =>
308 buildProviderEnvironmentOptions(environments, primaryEnvironmentId, target.environmentIds),
309 [environments, primaryEnvironmentId, target.environmentIds],
310 );
311 // Raw user intent; the effective selection is re-derived every render so a
312 // device that drops out of the catalog falls back without erasing the pick —
313 // if it reappears (e.g. after a reconnect) the selection is restored.
314 const [selectedEnvironmentId, setSelectedEnvironmentId] = useState<EnvironmentId | null>(
315 target.environmentId ?? primaryEnvironmentId,
316 );
317 const targetEnvironmentMissing =
318 target.environmentId !== undefined &&
319 selectedEnvironmentId === target.environmentId &&
320 !options.some((environment) => environment.environmentId === target.environmentId);
321 const effectiveEnvironmentId =
322 target.scoped || targetEnvironmentMissing
323 ? target.environmentId
324 : resolveSelectedProviderEnvironmentId(options, selectedEnvironmentId, primaryEnvironmentId);
325 const selectedEnvironment =
326 options.find((environment) => environment.environmentId === effectiveEnvironmentId) ?? null;
327 const selectedEnvironmentCanRenderSettings =
328 selectedEnvironment !== null &&
329 isProviderSettingsEnvironmentAvailable({
330 connectionPhase: selectedEnvironment.connection.phase,
331 hasServerConfig: selectedEnvironment.serverConfig !== null,
332 });
333 const searchableEnvironmentId = options.find((environment) =>
334 isProviderSettingsEnvironmentAvailable({
335 connectionPhase: environment.connection.phase,
336 hasServerConfig: environment.serverConfig !== null,
337 }),
338 )?.environmentId;
339 const searchableCursorEnvironmentId = options.find(
340 (environment) =>
341 environment.serverConfig?.environment.platform.os === "darwin" &&
342 isProviderSettingsEnvironmentAvailable({
343 connectionPhase: environment.connection.phase,
344 hasServerConfig: true,
345 }),
346 )?.environmentId;
347 useEffect(() => {
348 if (
349 !target.scoped &&
350 searchTargetId === searchableSetting("cursor-keychain-usage").id &&
351 (!selectedEnvironmentCanRenderSettings ||
352 selectedEnvironment?.serverConfig?.environment.platform.os !== "darwin") &&
353 searchableCursorEnvironmentId !== undefined
354 ) {
355 setSelectedEnvironmentId(searchableCursorEnvironmentId);
356 return;
357 }
358 if (
359 !target.scoped &&
360 (searchTargetId === searchableSetting("provider-health-check-interval").id ||
361 searchTargetId === searchableSetting("usage-providers").id) &&
362 !selectedEnvironmentCanRenderSettings &&
363 searchableEnvironmentId !== undefined
364 ) {
365 setSelectedEnvironmentId(searchableEnvironmentId);
366 }
367 }, [
368 searchTargetId,
369 searchableCursorEnvironmentId,
370 searchableEnvironmentId,
371 selectedEnvironment,
372 selectedEnvironmentCanRenderSettings,
373 target.scoped,
374 ]);
375 const onlyPrimaryDevice =
376 options.length === 1 && options[0]?.entry.target._tag === "PrimaryConnectionTarget";
377 const deviceTabs =
378 !target.scoped && !onlyPrimaryDevice && options.length > 0 ? (
379 <ScrollArea radius="none" hideScrollbars scrollFade className="h-11 min-w-0 flex-1">
380 <ToggleGroup
381 aria-label="Devices"
382 variant="segmented"
383 className="my-2"
384 value={effectiveEnvironmentId ? [effectiveEnvironmentId] : []}
385 onValueChange={(next) => {
386 const environment = options.find((option) => option.environmentId === next[0]);
387 if (environment) setSelectedEnvironmentId(environment.environmentId);
388 }}
389 >
390 {options.map((environment) => {
391 const machine = resolveEnvironmentMachineKind(environment.serverConfig);
392 const detail = providerEnvironmentDetail(environment);
393 const statusText = connectionStatusTitle(environment.connection);
394 return (
395 <Tooltip key={environment.environmentId}>
396 <TooltipTrigger
397 render={
398 <Toggle value={environment.environmentId}>
399 <EnvironmentMachineIcon
400 kind={machine}
401 className="size-3.5 shrink-0"
402 aria-hidden
403 />
404 <span className="max-w-40 truncate">{environment.label}</span>
405 {environment.connection.phase !== "connected" ? (
406 <ConnectionStatusDot
407 dotClassName={connectionPhaseDotClassName(environment.connection.phase)}
408 pingClassName={connectionPhasePingClassName(environment.connection.phase)}
409 />
410 ) : null}
411 <span className="sr-only">
412 {detail}, {statusText}
413 </span>
414 </Toggle>
415 }
416 />
417 <TooltipPopup side="top">
418 {detail} · {statusText}
419 </TooltipPopup>
420 </Tooltip>
421 );
422 })}
423 </ToggleGroup>
424 </ScrollArea>
425 ) : null;
426​
427 return (
428 <>
429 {targetEnvironmentMissing ? (
430 <ProviderSettingsPlaceholder
431 deviceTabs={deviceTabs}
432 icon={<EnvironmentMachineIcon kind={resolveEnvironmentMachineKind(null)} />}
433 title="Device unavailable"
434 description="Reconnect this device to set up its provider, or select another device."
435 />
436 ) : null}
437 {options.length === 0 && !targetEnvironmentMissing ? (
438 <ProviderSettingsPlaceholder
439 icon={<EnvironmentMachineIcon kind={resolveEnvironmentMachineKind(null)} />}
440 title={isReady ? "No connected devices" : "Loading devices"}
441 description={
442 isReady
443 ? "Connect an execution environment before configuring providers."
444 : "Reading connected execution environments."
445 }
446 />
447 ) : null}
448​
449 {selectedEnvironment ? (
450 <SelectedEnvironmentProviderSettings
451 key={selectedEnvironment.environmentId}
452 environment={selectedEnvironment}
453 deviceTabs={deviceTabs}
454 targetInstanceId={
455 target.environmentId === undefined ||
456 selectedEnvironment.environmentId === target.environmentId
457 ? target.instanceId
458 : undefined
459 }
460 />
461 ) : null}
462 </>
463 );
465​
466function SelectedEnvironmentProviderSettings({
467 environment,
468 deviceTabs,
469 targetInstanceId,
470}: {
471 readonly environment: EnvironmentPresentation;
472 readonly deviceTabs?: ReactNode;
473 readonly targetInstanceId?: ProviderInstanceId | undefined;
474}) {
475 return (
476 <RemoteSessionGatedProviderSettings
477 environment={environment}
478 deviceTabs={deviceTabs}
479 targetInstanceId={targetInstanceId}
480 />
481 );
483​
484function RemoteSessionGatedProviderSettings({
485 environment,
486 deviceTabs,
487 targetInstanceId,
488}: {
489 readonly environment: EnvironmentPresentation;
490 readonly deviceTabs?: ReactNode;
491 readonly targetInstanceId?: ProviderInstanceId | undefined;
492}) {
493 const sessionState = useEnvironmentSessionState(environment.environmentId);
494 const operateAccess = resolveRemoteOperateAccess({
495 session: sessionState.data,
496 isPending: sessionState.isPending,
497 hasError: sessionState.hasError,
498 });
499 return (
500 <AccessGatedProviderSettings
501 environment={environment}
502 operateAccess={operateAccess}
503 deviceTabs={deviceTabs}
504 targetInstanceId={targetInstanceId}
505 />
506 );
508​
509function AccessGatedProviderSettings({
510 environment,
511 operateAccess,
512 deviceTabs,
513 targetInstanceId,
514}: {
515 readonly environment: EnvironmentPresentation;
516 readonly operateAccess: ProviderOperateAccess;
517 readonly deviceTabs?: ReactNode;
518 readonly targetInstanceId?: ProviderInstanceId | undefined;
519}) {
520 const access = classifyProviderEnvironmentAccess({
521 connectionPhase: environment.connection.phase,
522 hasServerConfig: environment.serverConfig !== null,
523 operateAccess,
524 });
525 if (access.kind !== "editable" && access.kind !== "read-only") {
526 return (
527 <EnvironmentUnavailablePlaceholder
528 environment={environment}
529 access={access}
530 deviceTabs={deviceTabs}
531 />
532 );
533 }
534 return (
535 <EnvironmentProviderSettings
536 environmentId={environment.environmentId}
537 environmentLabel={environment.label}
538 readOnly={access.kind === "read-only"}
539 deviceTabs={deviceTabs}
540 targetInstanceId={targetInstanceId}
541 />
542 );
544​
545export function EnvironmentProviderSettings({
546 environmentId,
547 environmentLabel,
548 readOnly = false,
549 deviceTabs,
550 targetInstanceId,
551}: {
552 readonly environmentId: EnvironmentId;
553 readonly environmentLabel: string;
554 readonly deviceTabs?: ReactNode;
555 readonly targetInstanceId?: ProviderInstanceId | undefined;
556 /**
557 * Grey out and freeze every write control when this session's credential
558 * lacks `providers:manage` on the environment. Selecting providers
559 * still works so the real configuration stays readable; switches, forms,
560 * are inert so no write is offered and then rejected.
561 */
562 readonly readOnly?: boolean;
563}) {
564 const settings = useEnvironmentSettings(environmentId);
565 const canWriteSettings = useEnvironmentScope(environmentId, AuthSettingsWriteScope);
566 const canRefreshProviders = useEnvironmentScope(environmentId, AuthOrchestrationReadScope);
567 const updateSettings = useUpdateEnvironmentSettings(environmentId);
568 const persistProviderInstance = usePersistEnvironmentProviderInstanceMutation(environmentId);
569 const updateClientSettings = useUpdateClientSettings();
570 const serverProviders =
571 useAtomValue(serverEnvironment.providersValueAtom(environmentId)) ?? EMPTY_SERVER_PROVIDERS;
572 const projects = useProjects().filter((project) => project.environmentId === environmentId);
573 const refreshServerProviders = useAtomCommand(serverEnvironment.refreshProviders, {
574 reportFailure: false,
575 });
576 const updateProvider = useAtomCommand(serverEnvironment.updateProvider, {
577 reportFailure: false,
578 });
579 const uninstallAcpRegistryManagedBinary = useAtomCommand(
580 serverEnvironment.uninstallAcpRegistryManagedBinary,
581 { reportFailure: false },
582 );
583 const acceptAcpRegistryUrlAuth = useAtomCommand(serverEnvironment.acceptAcpRegistryUrlAuth, {
584 reportFailure: false,
585 });
586 const [isRefreshingProviders, setIsRefreshingProviders] = useState(false);
587 const [isAddInstanceDialogOpen, setIsAddInstanceDialogOpen] = useState(false);
588 const [selectedInstanceId, setSelectedInstanceId] = useState<ProviderInstanceId | null>(
589 targetInstanceId ?? null,
590 );
591 const [updatingProviderInstanceIds, setUpdatingProviderInstanceIds] = useState<
592 ReadonlySet<ProviderInstanceId>
593 >(() => new Set());
594 const refreshingRef = useRef(false);
595 const updatingInstanceIdsRef = useRef<Set<ProviderInstanceId>>(new Set());
596​
597 const acceptUrlAuthentication = useCallback(
598 (instanceId: ProviderInstanceId, action: AcpRegistryUrlAuthAction) => {
599 void acceptAcpRegistryUrlAuth({
600 environmentId,
601 input: { instanceId, elicitationId: action.elicitationId },
602 }).then((result) => {
603 if (result._tag === "Success" && !result.value.accepted) {
604 toastManager.add({
605 type: "warning",
606 title: "Authentication request expired",
607 description: "Refresh the provider and start the authentication flow again.",
608 });
609 return;
610 }
611 if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
612 const error = squashAtomCommandFailure(result);
613 toastManager.add({
614 type: "error",
615 title: "Could not continue authentication",
616 description:
617 error instanceof Error ? error.message : "The authentication request expired.",
618 });
619 }
620 });
621 },
622 [acceptAcpRegistryUrlAuth, environmentId],
623 );
624​
625 const providerUpdateCandidateByInstanceId = useMemo(
626 () =>
627 new Map(
628 serverProviders
629 .filter(isProviderSettingsUpdateCandidate)
630 .map((candidate) => [candidate.instanceId, candidate]),
631 ),
632 [serverProviders],
633 );
634 const visibleProviderSettings = PROVIDER_SETTINGS.filter(
635 (providerSettings) =>
636 providerSettings.provider !== "cursor" ||
637 serverProviders.some(
638 (provider) =>
639 provider.instanceId === defaultInstanceIdForDriver(ProviderDriverKind.make("cursor")),
640 ),
641 );
642 const textGenerationModelSelection = resolveAppModelSelectionState(settings, serverProviders);
643 const textGenInstanceId = textGenerationModelSelection.instanceId;
644 const resolvedBackgroundActivity = resolveServerBackgroundActivitySettings(settings);
645 const providerHealthPreset = getBackgroundActivityPresetSettings(
646 resolvedBackgroundActivity.profile,
647 ).providerHealthRefreshInterval;
648 const providerHealthRefreshIntervalSeconds = durationToSeconds(
649 resolvedBackgroundActivity.providerHealthRefreshInterval,
650 );
651 const defaultProviderHealthRefreshIntervalSeconds = durationToSeconds(providerHealthPreset);
652 const lastCheckedAt =
653 serverProviders.length > 0
654 ? serverProviders.reduce(
655 (latest, provider) => (provider.checkedAt > latest ? provider.checkedAt : latest),
656 serverProviders[0]!.checkedAt,
657 )
658 : null;
659​
660 const refreshProviders = useCallback(() => {
661 if (refreshingRef.current || !readEnvironmentScope(environmentId, AuthOrchestrationReadScope))
662 return;
663 refreshingRef.current = true;
664 setIsRefreshingProviders(true);
665 void (async () => {
666 const result = await refreshServerProviders({
667 environmentId,
668 input: { refreshModels: true },
669 });
670 refreshingRef.current = false;
671 setIsRefreshingProviders(false);
672 if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
673 console.warn("Failed to refresh providers", {
674 operation: "refresh-providers",
675 environmentId,
676 ...safeErrorLogAttributes(squashAtomCommandFailure(result)),
677 });
678 }
679 })();
680 }, [environmentId, refreshServerProviders]);
681​
682 const runProviderUpdate = useCallback(
683 async (
684 candidate: Pick<ProviderSettingsUpdateCandidate, "driver" | "instanceId">,
685 targetVersion?: string,
686 ) => {
687 if (!readEnvironmentScope(environmentId, AuthProvidersManageScope)) return;
688 // Ref-based re-entry guard, mirroring refreshProviders: a state updater
689 // may run after this function returns, so it cannot gate the dispatch.
690 if (updatingInstanceIdsRef.current.has(candidate.instanceId)) {
691 return;
692 }
693 updatingInstanceIdsRef.current.add(candidate.instanceId);
694 setUpdatingProviderInstanceIds((previous) => new Set(previous).add(candidate.instanceId));
695​
696 const result = await updateProvider({
697 environmentId,
698 input: {
699 provider: candidate.driver,
700 instanceId: candidate.instanceId,
701 ...(targetVersion ? { targetVersion } : {}),
702 },
703 });
704 if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
705 const error = squashAtomCommandFailure(result);
706 toastManager.add(
707 stackedThreadToast({
708 type: "error",
709 title: `Could not update ${PROVIDER_DISPLAY_NAMES[candidate.driver] ?? candidate.driver}`,
710 description:
711 error instanceof Error
712 ? error.message
713 : "The provider update command could not be started.",
714 }),
715 );
716 }
717 updatingInstanceIdsRef.current.delete(candidate.instanceId);
718 setUpdatingProviderInstanceIds((previous) => {
719 if (!previous.has(candidate.instanceId)) {
720 return previous;
721 }
722 const next = new Set(previous);
723 next.delete(candidate.instanceId);
724 return next;
725 });
726 },
727 [environmentId, updateProvider],
728 );
729​
730 interface InstanceRow {
731 readonly instanceId: ProviderInstanceId;
732 readonly instance: ProviderInstanceConfig;
733 readonly driver: ProviderDriverKind;
734 readonly isDefault: boolean;
735 readonly isDirty?: boolean;
736 }
737​
738 const instancesByDriver = new Map<
739 ProviderDriverKind,
740 Array<[ProviderInstanceId, ProviderInstanceConfig]>
741 >();
742 for (const [rawId, instance] of Object.entries(settings.providerInstances ?? {})) {
743 const driver = instance.driver;
744 const list = instancesByDriver.get(driver) ?? [];
745 list.push([rawId as ProviderInstanceId, instance]);
746 instancesByDriver.set(driver, list);
747 }
748​
749 const defaultSlotIdsBySource = new Set<string>(
750 visibleProviderSettings.map((providerSettings) =>
751 String(defaultInstanceIdForDriver(providerSettings.provider)),
752 ),
753 );
754​
755 const rows: InstanceRow[] = [];
756 const visibleDriverKinds = new Set<ProviderDriverKind>(
757 visibleProviderSettings.map((providerSettings) => providerSettings.provider),
758 );
759​
760 for (const providerSettings of visibleProviderSettings) {
761 const driver = providerSettings.provider;
762 const defaultInstanceId = defaultInstanceIdForDriver(driver);
763 const explicitInstance = settings.providerInstances?.[defaultInstanceId];
764 // An unconfigured default slot runs with the driver's default config.
765 const effectiveInstance: ProviderInstanceConfig = explicitInstance ?? { driver };
766 const isDirty = explicitInstance !== undefined;
767 // Drivers without a default instance list only their configured instances.
768 const hasDefaultSlot = providerSettings.hasDefaultInstance || explicitInstance !== undefined;
769 if (
770 hasDefaultSlot &&
771 (driver === "codex" ||
772 driver === "claudeAgent" ||
773 isDirty ||
774 resolveProviderInstanceEnabled(effectiveInstance) ||
775 defaultInstanceId === targetInstanceId)
776 ) {
777 rows.push({
778 instanceId: defaultInstanceId,
779 instance: effectiveInstance,
780 driver,
781 isDefault: true,
782 isDirty,
783 });
784 }
785 for (const [id, instance] of instancesByDriver.get(providerSettings.provider) ?? []) {
786 if (id === defaultInstanceId) continue;
787 rows.push({ instanceId: id, instance, driver: instance.driver, isDefault: false });
788 }
789 }
790 for (const [driver, list] of instancesByDriver) {
791 if (visibleDriverKinds.has(driver)) continue;
792 for (const [id, instance] of list) {
793 rows.push({
794 instanceId: id,
795 instance,
796 driver: instance.driver,
797 isDefault: defaultSlotIdsBySource.has(String(id)),
798 });
799 }
800 }
801​
802 const targetInstanceMissing =
803 targetInstanceId !== undefined &&
804 selectedInstanceId === targetInstanceId &&
805 !rows.some((row) => row.instanceId === targetInstanceId);
806 const selectedRow =
807 rows.find((row) => row.instanceId === selectedInstanceId) ??
808 (targetInstanceMissing ? null : (rows[0] ?? null));
809​
810 const updateProviderInstance = async (
811 row: InstanceRow,
812 next: ProviderInstanceConfig,
813 options?: {
814 readonly textGenerationModelSelection?: Parameters<
815 typeof buildProviderInstanceUpdatePatch
816 >[0]["textGenerationModelSelection"];
817 },
818 ) => {
819 const { providerInstances: _providerInstances, ...patch } = buildProviderInstanceUpdatePatch({
820 settings,
821 instanceId: row.instanceId,
822 instance: next,
823 textGenerationModelSelection: options?.textGenerationModelSelection,
824 });
825 const result = await persistProviderInstance(
826 { operation: "upsert", instanceId: row.instanceId, instance: next },
827 patch,
828 );
829 if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
830 const error = squashAtomCommandFailure(result);
831 toastManager.add({
832 type: "error",
833 title: "Could not update provider instance",
834 description: error instanceof Error ? error.message : "The settings update failed.",
835 });
836 }
837 };
838​
839 const deleteProviderInstance = async (row: InstanceRow) => {
840 const updateResult = await persistProviderInstance({
841 operation: "remove",
842 instanceId: row.instanceId,
843 });
844 if (updateResult._tag === "Failure") {
845 const error = squashAtomCommandFailure(updateResult);
846 toastManager.add({
847 type: "error",
848 title: "Could not delete provider instance",
849 description: error instanceof Error ? error.message : "The settings update failed.",
850 });
851 return;
852 }
853​
854 if (row.driver !== ProviderDriverKind.make("acpRegistry")) return;
855 if (providerConfigString(row.instance.config, "source") === "local") return;
856 const agentId = providerConfigString(row.instance.config, "agentId");
857 if (agentId === null) return;
858​
859 // The server decides from its latest settings whether this was the last
860 // instance using the managed agent. A client-side snapshot check can race
861 // two removals and make both callers skip cleanup.
862 const uninstallResult = await uninstallAcpRegistryManagedBinary({
863 environmentId,
864 input: { agentId },
865 });
866 if (uninstallResult._tag === "Failure" && !isAtomCommandInterrupted(uninstallResult)) {
867 const error = squashAtomCommandFailure(uninstallResult);
868 toastManager.add({
869 type: "warning",
870 title: "Provider deleted, but managed files remain",
871 description: error instanceof Error ? error.message : "Managed binary cleanup failed.",
872 });
873 }
874 };
875​
876 const updateProviderModelPreferences = (
877 instanceId: ProviderInstanceId,
878 next: {
879 readonly hiddenModels: ReadonlyArray<string>;
880 readonly modelOrder: ReadonlyArray<string>;
881 },
882 ) => {
883 const hiddenModels = [...new Set(next.hiddenModels.filter((slug) => slug.trim().length > 0))];
884 const modelOrder = [...new Set(next.modelOrder.filter((slug) => slug.trim().length > 0))];
885 const rest = withoutProviderInstanceKey(settings.providerModelPreferences, instanceId);
886 updateClientSettings({
887 providerModelPreferences:
888 hiddenModels.length === 0 && modelOrder.length === 0
889 ? rest
890 : {
891 ...rest,
892 [instanceId]: {
893 hiddenModels,
894 modelOrder,
895 },
896 },
897 });
898 };
899​
900 const updateProviderFavoriteModels = (
901 instanceId: ProviderInstanceId,
902 nextFavoriteModels: ReadonlyArray<string>,
903 ) => {
904 const favoriteModels = [
905 ...new Set(
906 Arr.filterMap(nextFavoriteModels, (slug) => {
907 const trimmedSlug = slug.trim();
908 return trimmedSlug.length > 0 ? Result.succeed(trimmedSlug) : Result.failVoid;
909 }),
910 ),
911 ];
912 updateClientSettings({
913 favorites: [
914 ...withoutProviderInstanceFavorites(settings.favorites ?? [], instanceId),
915 ...favoriteModels.map((model) => ({ provider: instanceId, model })),
916 ],
917 });
918 };
919​
920 const resetDefaultInstance = async (driverKind: ProviderDriverKind) => {
921 const result = await persistProviderInstance({
922 operation: "remove",
923 instanceId: defaultInstanceIdForDriver(driverKind),
924 });
925 if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
926 const error = squashAtomCommandFailure(result);
927 toastManager.add({
928 type: "error",
929 title: "Could not reset provider instance",
930 description: error instanceof Error ? error.message : "The settings update failed.",
931 });
932 }
933 };
934​
935 const renderProviderInstance = (row: InstanceRow, mode: "list" | "editor") => {
936 const driverOption = providerClients.get(row.driver);
937 const liveProvider = serverProviders.find(
938 (candidate) => candidate.instanceId === row.instanceId,
939 );
940 const updateCandidate = providerUpdateCandidateByInstanceId.get(row.instanceId);
941 const isInstanceUpdateRunning =
942 updatingProviderInstanceIds.has(row.instanceId) ||
943 (liveProvider !== undefined && isProviderUpdateActive(liveProvider));
944 const showInlineUpdateButton = updateCandidate !== undefined;
945 const canRunInlineUpdate = updateCandidate !== undefined && !isInstanceUpdateRunning;
946 const modelPreferences = settings.providerModelPreferences?.[row.instanceId] ?? {
947 hiddenModels: [],
948 modelOrder: [],
949 };
950 const favoriteModels = Arr.filterMap(settings.favorites ?? [], (favorite) =>
951 favorite.provider === row.instanceId ? Result.succeed(favorite.model) : Result.failVoid,
952 );
953 const resetLabel = driverOption?.label ?? String(row.driver);
954​
955 return (
956 <ProviderInstanceCard
957 key={row.instanceId}
958 environmentId={environmentId}
959 acpProjects={projects}
960 onAcceptUrlAuth={
961 readOnly ? undefined : (action) => acceptUrlAuthentication(row.instanceId, action)
962 }
963 instanceId={row.instanceId}
964 instance={row.instance}
965 driverOption={driverOption}
966 liveProvider={liveProvider}
967 mode={mode}
968 selected={mode === "list" && selectedRow?.instanceId === row.instanceId}
969 onSelect={mode === "list" ? () => setSelectedInstanceId(row.instanceId) : undefined}
970 readOnly={readOnly}
971 runtime={
972 mode === "editor" &&
973 row.driver === "codex" &&
974 readCodexSetupMode(row.instance.config) === "managed" ? (
975 <CodexManagedRuntimeFields
976 environmentId={environmentId}
977 instanceId={row.instanceId}
978 provider={liveProvider}
979 />
980 ) : undefined
981 }
982 canWriteSettings={canWriteSettings}
983 setup={
984 mode === "editor" && row.driver === "antigravity" ? (
985 <ProviderSetupSection
986 environmentId={environmentId}
987 environmentLabel={environmentLabel}
988 instanceId={row.instanceId}
989 provider={liveProvider}
990 binaryPath={configuredBinaryPath(row.instance.config)}
991 authMethod={readAntigravityAuthMethod(row.instance.config)}
992 enabled={resolveProviderInstanceEnabled(row.instance)}
993 readOnly={readOnly}
994 onEnable={() => updateProviderInstance(row, { ...row.instance, enabled: true })}
995 />
996 ) : mode === "editor" &&
997 row.driver === "codex" &&
998 readCodexSetupMode(row.instance.config) === "managed" ? (
999 <CodexSetupSection
1000 environmentId={environmentId}
1001 instanceId={row.instanceId}
1002 provider={liveProvider}
1003 mode={readCodexSetupMode(row.instance.config)}
1004 enabled={resolveProviderInstanceEnabled(row.instance)}
1005 readOnly={readOnly}
1006 onModeChange={(setupMode) =>
1007 updateProviderInstance(row, {
1008 ...row.instance,
1009 enabled: true,
1010 config: {
1011 ...(row.instance.config !== null && typeof row.instance.config === "object"
1012 ? row.instance.config
1013 : {}),
1014 enabled: true,
1015 setupMode,
1016 },
1017 })
1019 />
1020 ) : mode === "editor" &&
1021 !readOnly &&
1022 liveProvider &&
1023 (liveProvider.setup?.canAuthenticate ||
1024 (liveProvider.driver === "acpRegistry" && liveProvider.installed)) ? (
1025 <ProviderAuthenticationSection
1026 key={`${environmentId}:${row.instanceId}`}
1027 environmentId={environmentId}
1028 environmentLabel={environmentLabel}
1029 instanceId={row.instanceId}
1030 provider={liveProvider}
1031 readOnly={readOnly}
1032 />
1033 ) : mode === "editor" &&
1034 !readOnly &&
1035 row.driver === "cursor" &&
1036 liveProvider?.setup?.canAuthenticate === false ? (
1037 <SettingsRow
1038 title="Cursor account"
1039 description="Using CURSOR_API_KEY. Remove it from this provider's environment to use browser sign-in."
1040 />
1041 ) : null
1043 onUpdate={(next) => {
1044 const wasEnabled = resolveProviderInstanceEnabled(row.instance);
1045 const isDisabling = next.enabled === false && wasEnabled;
1046 const shouldClearTextGen =
1047 isDisabling &&
1048 textGenInstanceId === row.instanceId &&
1049 readEnvironmentScope(environmentId, AuthSettingsWriteScope);
1050 updateProviderInstance(
1051 row,
1052 next,
1053 shouldClearTextGen
1054 ? {
1055 textGenerationModelSelection:
1056 DEFAULT_UNIFIED_SETTINGS.textGenerationModelSelection,
1058 : undefined,
1059 );
1060 }}
1061 onDelete={
1062 mode === "editor" && !row.isDefault ? () => deleteProviderInstance(row) : undefined
1064 headerAction={
1065 mode === "editor" && row.isDefault && row.isDirty ? (
1066 <SettingResetButton
1067 label={`${resetLabel} provider settings`}
1068 onClick={() => resetDefaultInstance(row.driver)}
1069 />
1070 ) : null
1072 hiddenModels={modelPreferences.hiddenModels}
1073 favoriteModels={favoriteModels}
1074 modelOrder={modelPreferences.modelOrder}
1075 onHiddenModelsChange={(hiddenModels) =>
1076 updateProviderModelPreferences(row.instanceId, {
1077 ...modelPreferences,
1078 hiddenModels,
1079 })
1081 onFavoriteModelsChange={(next) => updateProviderFavoriteModels(row.instanceId, next)}
1082 onModelOrderChange={(modelOrder) =>
1083 updateProviderModelPreferences(row.instanceId, {
1084 ...modelPreferences,
1085 modelOrder,
1086 })
1088 onInstallRecommended={
1089 !readOnly &&
1090 liveProvider?.compatibilityAdvisory?.message &&
1091 liveProvider.compatibilityAdvisory.recommendedVersion &&
1092 liveProvider.versionAdvisory?.canInstallVersion
1093 ? () => {
1094 void runProviderUpdate(
1095 liveProvider,
1096 liveProvider.compatibilityAdvisory?.recommendedVersion ?? undefined,
1097 );
1099 : undefined
1101 onRunUpdate={
1102 !readOnly && showInlineUpdateButton && updateCandidate
1103 ? () => {
1104 if (canRunInlineUpdate) void runProviderUpdate(updateCandidate);
1106 : undefined
1108 isUpdating={isInstanceUpdateRunning}
1109 />
1110 );
1111 };
1112​
1113 return (
1114 <>
1115 <SettingsSection
1116 {...searchableSetting("providers")}
1117 variant="plain"
1118 titleAction={
1119 !readOnly ? (
1120 <Tooltip>
1121 <TooltipTrigger
1122 render={
1123 <Button
1124 size="icon-xs"
1125 variant="ghost-muted"
1126 onClick={() => setIsAddInstanceDialogOpen(true)}
1127 aria-label="Add provider"
1129 <PlusIcon />
1130 </Button>
1132 />
1133 <TooltipPopup side="top">Add provider</TooltipPopup>
1134 </Tooltip>
1135 ) : null
1137 headerAction={
1138 <div className="flex min-w-0 items-center gap-2">
1139 <ProviderUpdatesAction />
1140 <Tooltip>
1141 <TooltipTrigger
1142 render={
1143 <Button
1144 size="xs"
1145 variant="ghost-muted"
1146 disabled={isRefreshingProviders || !canRefreshProviders}
1147 aria-busy={isRefreshingProviders}
1148 onClick={() => void refreshProviders()}
1150 <RefreshIcon refreshing={isRefreshingProviders} />
1151 <span className="sr-only">Refresh provider status</span>
1152 <span className="hidden min-w-0 truncate sm:inline">
1153 {isRefreshingProviders ? (
1154 "Refreshing providers"
1155 ) : (
1156 <ProviderLastChecked lastCheckedAt={lastCheckedAt} />
1157 )}
1158 </span>
1159 </Button>
1161 />
1162 <TooltipPopup side="top">Refresh provider status</TooltipPopup>
1163 </Tooltip>
1164 </div>
1167 {deviceTabs ? (
1168 <div className="flex min-h-11 min-w-0 items-center gap-2 px-3 sm:px-4">{deviceTabs}</div>
1169 ) : null}
1170 {readOnly ? (
1171 <SettingsGroup divided={false} className="overflow-hidden">
1172 <SettingsRow
1173 title="Limited permissions"
1174 description={`This session can view ${environmentLabel}'s providers but can't change their settings.`}
1175 />
1176 </SettingsGroup>
1177 ) : null}
1178 <SettingsGroup
1179 divided={false}
1180 className={cn(
1181 providerCardHeightClassName,
1182 "overflow-hidden @min-[48rem]/providers:grid @min-[48rem]/providers:grid-cols-[17rem_minmax(0,1fr)]",
1183 )}
1185 <div className="border-b border-border/60 bg-muted/10 @min-[48rem]/providers:flex @min-[48rem]/providers:min-h-0 @min-[48rem]/providers:flex-col @min-[48rem]/providers:border-r @min-[48rem]/providers:border-b-0">
1186 <ScrollArea
1187 scrollFade
1188 chainVerticalScroll
1189 className="@min-[48rem]/providers:min-h-0 @min-[48rem]/providers:flex-1"
1191 <div className="divide-y divide-border/50">
1192 {rows.map((row) => renderProviderInstance(row, "list"))}
1193 {!readOnly ? (
1194 <button
1195 type="button"
1196 className="flex w-full cursor-pointer items-center gap-3 px-3 py-3 text-left text-sm text-muted-foreground transition-colors outline-none hover:bg-muted/25 hover:text-foreground focus-visible:bg-muted/25 focus-visible:text-foreground sm:px-4"
1197 onClick={() => setIsAddInstanceDialogOpen(true)}
1199 <PlusIcon className="size-4 shrink-0" />
1200 Add provider
1201 </button>
1202 ) : null}
1203 </div>
1204 </ScrollArea>
1205 </div>
1206​
1207 <div className="min-w-0 @min-[48rem]/providers:min-h-0">
1208 {selectedRow ? (
1209 <ScrollArea scrollFade chainVerticalScroll className="@min-[48rem]/providers:h-full">
1210 <div className="space-y-6 p-4">{renderProviderInstance(selectedRow, "editor")}</div>
1211 </ScrollArea>
1212 ) : (
1213 <div className="p-6 text-sm text-muted-foreground">
1214 {targetInstanceMissing
1215 ? "This provider instance is no longer available on this device."
1216 : "No providers configured."}
1217 </div>
1218 )}
1219 </div>
1220 </SettingsGroup>
1221 </SettingsSection>
1222​
1223 <UsageProviderSettings
1224 key={environmentId}
1225 environmentId={environmentId}
1226 environmentLabel={environmentLabel}
1227 sources={settings.usageLimitSources}
1228 cursorKeychainUsageEnabled={settings.cursorKeychainUsageEnabled}
1229 readOnly={readOnly}
1230 />
1231​
1232 <SettingsSection title="Advanced">
1233 <SettingsRow
1234 id={searchableSetting("provider-health-check-interval").id}
1235 title={
1236 <span className="inline-flex items-center gap-1.5">
1237 {searchableSetting("provider-health-check-interval").title}
1238 <PolicyTooltip>
1239 This interval is configured here, then the shared Background activity policy decides
1240 whether provider probes may run when the timer fires. Custom intervals appear as
1241 Advanced in General settings.
1242 </PolicyTooltip>
1243 </span>
1245 description="Refresh provider status, versions, and models in the background. Set to 0 to disable."
1246 resetAction={
1247 providerHealthRefreshIntervalSeconds !== defaultProviderHealthRefreshIntervalSeconds ? (
1248 <span
1249 inert={!canWriteSettings}
1250 className={!canWriteSettings ? "opacity-50" : undefined}
1252 <SettingResetButton
1253 label="provider health check interval"
1254 onClick={() =>
1255 updateSettings(
1256 backgroundActivityOverrideSettings(
1257 settings.backgroundActivity,
1258 resolvedBackgroundActivity,
1259 { providerHealthRefreshInterval: undefined },
1260 ),
1263 />
1264 </span>
1265 ) : null
1267 control={
1268 <div
1269 inert={!canWriteSettings}
1270 aria-disabled={!canWriteSettings || undefined}
1271 className={cn(
1272 "flex shrink-0 items-center gap-2",
1273 !canWriteSettings && "opacity-50 select-none",
1274 )}
1276 <NumberField
1277 value={providerHealthRefreshIntervalSeconds}
1278 min={0}
1279 step={PROVIDER_HEALTH_INTERVAL_STEP_SECONDS}
1280 size="sm"
1281 className="w-32"
1282 onValueChange={(value) =>
1283 updateSettings(
1284 backgroundActivityOverrideSettings(
1285 settings.backgroundActivity,
1286 resolvedBackgroundActivity,
1288 providerHealthRefreshInterval: Duration.seconds(
1289 normalizeIntervalSeconds(value),
1290 ),
1291 },
1292 ),
1296 <NumberFieldGroup>
1297 <NumberFieldDecrement aria-label="Decrease provider health check interval" />
1298 <NumberFieldInput aria-label="Provider health check interval in seconds" />
1299 <NumberFieldIncrement aria-label="Increase provider health check interval" />
1300 </NumberFieldGroup>
1301 </NumberField>
1302 <span className="text-xs text-muted-foreground">seconds</span>
1303 </div>
1305 />
1306 </SettingsSection>
1307​
1308 {isAddInstanceDialogOpen && !readOnly ? (
1309 <AddProviderInstanceDialog
1310 open
1311 environmentId={environmentId}
1312 environmentLabel={environmentLabel}
1313 onOpenChange={setIsAddInstanceDialogOpen}
1314 onCreated={setSelectedInstanceId}
1315 />
1316 ) : null}
1317 </>
1318 );