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

ProviderSettingsPanel.tsx

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