Open History to see the last commit
1import { SessionPermissions } from "./SessionPermissions";
2import {
3 ChevronRightIcon,
4 ChevronsLeftRightEllipsisIcon,
5 EllipsisIcon,
6 RouteIcon,
7} from "lucide-react";
8import { useAtomValue } from "@effect/atom-react";
9import { useEffect, useEffectEvent, useState } from "react";
10import {
11 AuthRelayWriteScope,
12 type EnvironmentId,
13 connectReachabilityHelpUrl,
14 formatConnectReachable,
15 resolveEnvironmentMachineKind,
16} from "@t3tools/contracts";
17import {
18 connectionRoutes,
19 hasSavedBearerRoute,
20 connectionStatusText,
21 environmentMcpUrl,
22} from "@t3tools/client-runtime/connection";
23import * as Option from "effect/Option";
24
25import { useCopyToClipboard } from "../../hooks/useCopyToClipboard";
26import { cn } from "../../lib/utils";
27import { SettingsRow } from "./settingsLayout";
28import { searchableSetting } from "./settingsSearch";
29import { EnvironmentIconMenu } from "./EnvironmentIconPicker";
30import { EnvironmentRoutesList } from "./EnvironmentRoutesList";
31import {
32 ConnectionDiagnosisPanel,
33 ConnectionDiagnosisSummary,
34 useConnectionDiagnosis,
35} from "./ConnectionDiagnosisDetails";
36import { usePreparedConnection } from "~/state/session";
37import { EnvironmentRow, environmentTransportLabel } from "./EnvironmentRow";
38import { Menu, MenuItem, MenuPopup, MenuSeparator, MenuTrigger } from "../ui/menu";
39import { Switch } from "../ui/switch";
40import { stackedThreadToast, toastManager } from "../ui/toast";
41import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
42import { Button } from "../ui/button";
43import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "../ui/empty";
44import {
45 resolveServerConfigVersionMismatch,
46 resolveServerSelfUpdateCapability,
47 supportsDesktopAppUpdate,
48 supportsServerUpdateThreadContinuation,
49} from "~/versionSkew";
50import { hasCloudPublicConfig } from "~/cloud/publicConfig";
51import { isElectron } from "~/env";
52import { useCloudLinkController } from "~/cloud/useCloudLinkController";
53import { environmentCatalog } from "~/connection/catalog";
54import { readEnvironmentScope } from "~/state/session";
55import {
56 type EnvironmentPresentation,
57 useRelayEnvironmentDiscovery,
58 usePrimaryEnvironmentId,
59} from "~/state/environments";
60import { APP_VERSION } from "~/branding";
61import { useAtomCommand } from "../../state/use-atom-command";
62import { serverEnvironment } from "~/state/server";
63import {
64 OutdatedServerUpdateAction,
65 ServerUpdateAction,
66 ServerUpdateProgress,
67} from "../ServerUpdateAction";
68import { CloudEnvironmentConnectRows } from "../cloud/CloudEnvironmentConnectList";
69import { useT3ConnectAuthPrompt } from "../clerk/useT3ConnectAuthPrompt";
70
71type SavedBackendListRowProps = {
72 environment: EnvironmentPresentation;
73 removingEnvironmentId: EnvironmentId | null;
74 onSetEnabled: (environmentId: EnvironmentId, enabled: boolean) => void;
75 onRemove: (environment: EnvironmentPresentation) => void;
76 onAddRoute: (environment: EnvironmentPresentation) => void;
77};
78
79function savedBackendStatus(environment: EnvironmentPresentation): {
80 readonly text: string;
81 readonly tone: "muted" | "error";
82} {
83 if (!environment.entry.enabled && environment.connection.phase !== "unsupported")
84 return { text: "Off", tone: "muted" };
85 const { connection } = environment;
86 switch (connection.phase) {
87 case "connected":
88 return { text: "Connected", tone: "muted" };
89 case "connecting":
90 return { text: "Connecting", tone: "muted" };
91 case "reconnecting":
92 return {
93 text: connection.error ? `Reconnecting: ${connection.error}` : "Reconnecting",
94 tone: "error",
95 };
96 case "unsupported":
97 return { text: "Client not supported", tone: "muted" };
98 case "error":
99 return {
100 text: connection.error ? `Connection failed: ${connection.error}` : "Connection failed",
101 tone: "error",
102 };
103 case "offline":
104 return { text: "Offline", tone: "muted" };
105 case "available":
106 return { text: "Not connected", tone: "muted" };
107 }
108}
109
110export function SavedBackendListRow({
111 environment,
112 removingEnvironmentId,
113 onSetEnabled,
114 onRemove,
115 onAddRoute,
116}: SavedBackendListRowProps) {
117 const [routesOpen, setRoutesOpen] = useState(false);
118 const [permissionsOpen, setPermissionsOpen] = useState(false);
119 const [diagnosisOpen, setDiagnosisOpen] = useState(false);
120 const environmentId = environment.environmentId;
121 const unsupported = environment.connection.phase === "unsupported";
122 const blocked = unsupported && !hasSavedBearerRoute(environment.entry);
123 const enabled = environment.entry.enabled && !unsupported;
124 const isConnected = environment.connection.phase === "connected";
125 const isRemoving = removingEnvironmentId === environmentId;
126 const errorTraceId = environment.connection.traceId;
127 const { copyToClipboard: copyTraceIdToClipboard } = useCopyToClipboard<{ traceId: string }>({
128 target: "trace ID",
129 onCopy: ({ traceId }) => {
130 toastManager.add({
131 type: "success",
132 title: "Trace ID copied",
133 description: traceId,
134 });
135 },
136 onError: (error) => {
137 toastManager.add(
138 stackedThreadToast({
139 type: "error",
140 title: "Could not copy trace ID",
141 description: error.message,
142 }),
143 );
144 },
145 });
146 const copyTraceId = (traceId: string) => {
147 copyTraceIdToClipboard(traceId, { traceId });
148 };
149 const { copyToClipboard: copyMcpUrl } = useCopyToClipboard<{ url: string }>({
150 target: "MCP URL",
151 onCopy: ({ url }) => {
152 toastManager.add({
153 type: "success",
154 title: "MCP URL copied",
155 description: `Add it to an agent, e.g. claude mcp add --transport http t3 ${url}`,
156 });
157 },
158 onError: (error) => {
159 toastManager.add(
160 stackedThreadToast({
161 type: "error",
162 title: "Could not copy MCP URL",
163 description: error.message,
164 }),
165 );
166 },
167 });
168 const versionMismatch = resolveServerConfigVersionMismatch(environment.serverConfig);
169 const serverUpdateState = useAtomValue(serverEnvironment.updateStateAtom(environmentId));
170 const resumingServerUpdate =
171 serverUpdateState.status === "running" && serverUpdateState.stage === "resuming";
172 const status = savedBackendStatus(environment);
173 const serverVersion = environment.serverConfig?.environment.serverVersion ?? null;
174 // Discovery empties its map on every refresh, so hold the last descriptor
175 // seen or the glyph would blink back to the generic one each time.
176 const relayDiscovery = useRelayEnvironmentDiscovery();
177 const discoveredDescriptor = Option.getOrNull(
178 relayDiscovery.environments.get(environmentId)?.status ?? Option.none(),
179 )?.descriptor;
180 const [lastDescriptor, setLastDescriptor] = useState(discoveredDescriptor);
181 if (discoveredDescriptor !== undefined && discoveredDescriptor !== lastDescriptor) {
182 setLastDescriptor(discoveredDescriptor);
183 }
184 const discoveredRelayHttpBaseUrl =
185 relayDiscovery.environments.get(environmentId)?.environment.endpoint.httpBaseUrl;
186 const [lastRelayHttpBaseUrl, setLastRelayHttpBaseUrl] = useState(discoveredRelayHttpBaseUrl);
187 if (
188 discoveredRelayHttpBaseUrl !== undefined &&
189 discoveredRelayHttpBaseUrl !== lastRelayHttpBaseUrl
190 ) {
191 setLastRelayHttpBaseUrl(discoveredRelayHttpBaseUrl);
192 }
193 const retryNow = useAtomCommand(environmentCatalog.retryNow);
194 const {
195 diagnosis: currentDiagnosis,
196 state: connectionState,
197 relayOnly,
198 } = useConnectionDiagnosis(environment);
199 const diagnosis = resumingServerUpdate ? null : currentDiagnosis;
200 const prepared = usePreparedConnection(environmentId);
201 const connectedTarget = isConnected && prepared._tag === "Some" ? prepared.value.target : null;
202 const mcpUrl = environmentMcpUrl({
203 entry: environment.entry,
204 relayHttpBaseUrl: discoveredRelayHttpBaseUrl ?? lastRelayHttpBaseUrl,
205 connectedTarget,
206 });
207 const machineKind = resolveEnvironmentMachineKind(
208 environment.serverConfig ??
209 (lastDescriptor === undefined ? null : { environment: lastDescriptor }),
210 );
211 const routeCount = connectionRoutes(environment.entry).length;
212 const subtitleText = [
213 environmentTransportLabel(environment, connectedTarget),
214 // The headline below names the failure in full.
215 diagnosis ? null : resumingServerUpdate ? "Restarting" : status.text,
216 enabled && versionMismatch ? serverVersion : null,
217 ]
218 .filter((value): value is string => value !== null)
219 .join(" · ");
220
221 const showUpdateAction =
222 enabled &&
223 isConnected &&
224 versionMismatch !== null &&
225 (serverUpdateState.status === "idle" || serverUpdateState.status === "failed");
226
227 const statusTooltip = `${
228 unsupported
229 ? (environment.connection.error ?? connectionStatusText(environment.connection))
230 : enabled
231 ? connectionStatusText(environment.connection)
232 : "Switched off"
233 }${
234 versionMismatch
235 ? `\nUpdate available: ${versionMismatch.serverVersion} → ${versionMismatch.clientVersion}`
236 : ""
237 }`;
238
239 return (
240 <EnvironmentRow
241 kind={machineKind}
242 label={environment.label}
243 dimmed={!enabled}
244 subtitle={
245 <span className="flex min-w-0 items-center gap-1">
246 <Tooltip>
247 {/* The status can change while the tooltip is open, and base-ui only
248 re-measures the popup when the trigger's payload changes. */}
249 <TooltipTrigger
250 payload={statusTooltip}
251 render={
252 <span
253 className={cn(
254 "min-w-0 truncate",
255 enabled &&
256 status.tone === "error" &&
257 !resumingServerUpdate &&
258 !diagnosis &&
259 "text-destructive",
260 )}
261 />
262 }
263 >
264 {subtitleText}
265 </TooltipTrigger>
266 <TooltipPopup side="top" className="whitespace-pre-wrap">
267 {statusTooltip}
268 </TooltipPopup>
269 </Tooltip>
270 <span aria-hidden className="shrink-0">
271 ·
272 </span>
273 <button
274 type="button"
275 aria-expanded={routesOpen}
276 onClick={() => setRoutesOpen((open) => !open)}
277 className="inline-flex shrink-0 items-center gap-0.5 rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring"
278 >
279 {routeCount === 1 ? "Routes" : `${routeCount} routes`}
280 <ChevronRightIcon
281 aria-hidden
282 className={cn(
283 "size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",
284 routesOpen && "rotate-90",
285 )}
286 />
287 </button>
288 <span aria-hidden className="shrink-0">
289 ·
290 </span>
291 <button
292 type="button"
293 aria-expanded={permissionsOpen}
294 aria-controls={`remote-permissions-${environmentId}`}
295 onClick={() => setPermissionsOpen((open) => !open)}
296 className="inline-flex shrink-0 items-center gap-0.5 rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring"
297 >
298 Permissions
299 <ChevronRightIcon
300 aria-hidden
301 className={cn(
302 "size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",
303 permissionsOpen && "rotate-90",
304 )}
305 />
306 </button>
307 </span>
308 }
309 below={
310 <>
311 {diagnosis ? (
312 <ConnectionDiagnosisSummary
313 diagnosis={diagnosis}
314 retryAt={connectionState.phase === "backoff" ? connectionState.retryAt : null}
315 attempt={connectionState.attempt}
316 expanded={diagnosisOpen}
317 onToggle={() => setDiagnosisOpen((open) => !open)}
318 />
319 ) : null}
320 {serverUpdateState.status !== "idle" ? (
321 <div className="mt-1 max-w-md">
322 <ServerUpdateProgress state={serverUpdateState} />
323 </div>
324 ) : null}
325 </>
326 }
327 detail={
328 <>
329 {diagnosis && diagnosisOpen ? (
330 <ConnectionDiagnosisPanel
331 hostLabel={environment.label}
332 diagnosis={diagnosis}
333 onRetry={() => void retryNow(environmentId)}
334 onAddRoute={relayOnly ? () => onAddRoute(environment) : null}
335 />
336 ) : null}
337 {routesOpen && (
338 <EnvironmentRoutesList
339 environment={environment}
340 onAddRoute={() => onAddRoute(environment)}
341 />
342 )}
343 {permissionsOpen && (
344 <div
345 id={`remote-permissions-${environmentId}`}
346 className="mt-2 border-t border-border/50"
347 >
348 <SessionPermissions
349 environmentId={environmentId}
350 connected={isConnected}
351 routeContext
352 />
353 </div>
354 )}
355 </>
356 }
357 >
358 {unsupported &&
359 environment.entry.serverUpdateRequired === true &&
360 serverUpdateState.status !== "running" ? (
361 <OutdatedServerUpdateAction
362 environmentId={environmentId}
363 serverLabel={`${environment.label} server`}
364 fromVersion={lastDescriptor?.serverVersion}
365 targetVersion={APP_VERSION}
366 label={serverUpdateState.status === "failed" ? "Retry update" : "Update"}
367 />
368 ) : null}
369 {showUpdateAction ? (
370 <ServerUpdateAction
371 environmentId={environmentId}
372 serverLabel={`${environment.label} server`}
373 selfUpdate={resolveServerSelfUpdateCapability(environment.serverConfig)}
374 installation={environment.serverConfig?.environment.capabilities.serverInstallation}
375 desktopAppUpdate={supportsDesktopAppUpdate(environment.serverConfig)}
376 threadContinuation={supportsServerUpdateThreadContinuation(environment.serverConfig)}
377 targetVersion={versionMismatch.clientVersion}
378 label={serverUpdateState.status === "failed" ? "Retry update" : "Update"}
379 appearance="icon"
380 />
381 ) : null}
382 <Tooltip>
383 <TooltipTrigger
384 render={
385 <Switch
386 size="sm"
387 checked={enabled}
388 disabled={isRemoving || blocked}
389 aria-label={`${enabled ? "Switch off" : "Switch on"} ${environment.label}`}
390 onCheckedChange={(checked) => onSetEnabled(environmentId, checked)}
391 />
392 }
393 />
394 <TooltipPopup side="top">
395 {blocked ? "Client not supported" : enabled ? "Switch off" : "Switch on"}
396 </TooltipPopup>
397 </Tooltip>
398 <Menu>
399 <MenuTrigger
400 render={
401 <Button
402 type="button"
403 variant="ghost-muted"
404 size="icon-xs"
405 disabled={isRemoving}
406 aria-label={`More actions for ${environment.label}`}
407 />
408 }
409 >
410 <EllipsisIcon className="size-3.5" />
411 </MenuTrigger>
412 <MenuPopup align="end">
413 <EnvironmentIconMenu
414 environmentId={environmentId}
415 serverConfig={environment.serverConfig}
416 />
417 <MenuItem onClick={() => setRoutesOpen((open) => !open)}>
418 <RouteIcon />
419 {routesOpen ? "Hide routes" : "Routes"}
420 </MenuItem>
421 {mcpUrl ? (
422 <MenuItem onClick={() => copyMcpUrl(mcpUrl, { url: mcpUrl })}>Copy MCP URL</MenuItem>
423 ) : null}
424 {errorTraceId ? (
425 <MenuItem onClick={() => copyTraceId(errorTraceId)}>Copy trace ID</MenuItem>
426 ) : null}
427 <MenuSeparator />
428 <MenuItem variant="destructive" onClick={() => onRemove(environment)}>
429 {isRemoving ? "Removing…" : "Remove from this device…"}
430 </MenuItem>
431 </MenuPopup>
432 </Menu>
433 </EnvironmentRow>
434 );
435}
436
437function CloudLinkSwitch({
438 checked,
439 disabled,
440 disabledReason,
441 onCheckedChange,
442 ariaLabel = "Enable T3 Connect",
443}: {
444 readonly checked: boolean;
445 readonly disabled: boolean;
446 readonly disabledReason: string | null;
447 readonly onCheckedChange?: (enabled: boolean) => void;
448 readonly ariaLabel?: string;
449}) {
450 const control = (
451 <Switch
452 aria-label={ariaLabel}
453 checked={checked}
454 disabled={disabled}
455 {...(onCheckedChange ? { onCheckedChange } : {})}
456 />
457 );
458 return disabledReason ? (
459 <Tooltip>
460 <TooltipTrigger render={<span className="inline-flex">{control}</span>} />
461 <TooltipPopup side="top">{disabledReason}</TooltipPopup>
462 </Tooltip>
463 ) : (
464 control
465 );
466}
467
468function ConfiguredCloudLinkRow({ canManageRelay }: { readonly canManageRelay: boolean }) {
469 const primaryEnvironmentId = usePrimaryEnvironmentId();
470 const {
471 isSignedIn,
472 linkState: primaryCloudLinkState,
473 linkRevoked,
474 managedTunnelActive,
475 managedTunnelOutOfSync,
476 publishAgentActivity,
477 holdWebhooksWhileOffline,
478 operationError,
479 reconcileCloudState,
480 } = useCloudLinkController();
481 const { openAuthPrompt } = useT3ConnectAuthPrompt();
482 const [isUpdating, setIsUpdating] = useState(false);
483 const [isUpdatingPreference, setIsUpdatingPreference] = useState(false);
484
485 const disabledReason = canManageRelay
486 ? null
487 : "Your session does not have permission to manage T3 Connect access.";
488 const isBusy = isUpdating || isUpdatingPreference;
489 const switchDisabled =
490 !canManageRelay ||
491 !isSignedIn ||
492 primaryCloudLinkState.data === null ||
493 primaryCloudLinkState.isPending ||
494 isBusy;
495 // `isSignedIn` is undefined until Clerk loads. Signed out, one row shows a
496 // sign-in button instead of its switch; the onboarding dialog that opens after
497 // a fresh sign-in offers both linking and publishing.
498 const signedOut = isSignedIn === false;
499 const signInButton = (
500 <Button size="sm" variant="outline" onClick={openAuthPrompt}>
501 Sign in
502 </Button>
503 );
504 const refreshLinkState = useEffectEvent(primaryCloudLinkState.refresh);
505 // The server rechecks reachability when the tunnel's 30 s readiness poll changes.
506 // Poll while mounted, so a failed read does not stop later ones.
507 useEffect(() => {
508 const interval = window.setInterval(() => refreshLinkState(), 30_000);
509 return () => window.clearInterval(interval);
510 }, []);
511 const reachability = managedTunnelActive ? primaryCloudLinkState.data?.reachability : undefined;
512 const reachabilityStatus =
513 reachability?.status === "reachable" ? (
514 formatConnectReachable(reachability)
515 ) : reachability?.status === "unreachable" ? (
516 <span className="block text-destructive">
517 {[reachability.reason, reachability.hint, `Fix: ${reachability.fix}`]
518 .filter(Boolean)
519 .join(" ")}{" "}
520 <a
521 href={connectReachabilityHelpUrl(reachability.cause)}
522 target="_blank"
523 rel="noreferrer"
524 className="underline underline-offset-2"
525 >
526 More info
527 </a>
528 </span>
529 ) : null;
530
531 const updateManagedTunnel = async (enabled: boolean) => {
532 if (
533 primaryEnvironmentId === null ||
534 !readEnvironmentScope(primaryEnvironmentId, AuthRelayWriteScope)
535 )
536 return;
537 setIsUpdating(true);
538 const ok = await reconcileCloudState({ managedTunnel: enabled, publish: publishAgentActivity });
539 if (ok) {
540 toastManager.add({
541 type: "success",
542 title: enabled
543 ? "T3 Connect linked"
544 : publishAgentActivity
545 ? "T3 Connect tunnel disabled"
546 : "T3 Connect unlinked",
547 description: enabled
548 ? "This environment is available through T3 Connect."
549 : publishAgentActivity
550 ? "The managed tunnel was removed. Agent activity publishing stays on."
551 : "This environment is no longer available through T3 Connect.",
552 });
553 }
554 setIsUpdating(false);
555 };
556
557 const updatePublishAgentActivity = async (enabled: boolean) => {
558 if (
559 primaryEnvironmentId === null ||
560 !readEnvironmentScope(primaryEnvironmentId, AuthRelayWriteScope)
561 )
562 return;
563 setIsUpdatingPreference(true);
564 const ok = await reconcileCloudState({ managedTunnel: managedTunnelActive, publish: enabled });
565 if (ok) {
566 toastManager.add({
567 type: "success",
568 title: enabled ? "Agent activity enabled" : "Agent activity disabled",
569 description: enabled
570 ? "This environment publishes agent activity to your mobile clients."
571 : "This environment will stop publishing agent activity.",
572 });
573 }
574 setIsUpdatingPreference(false);
575 };
576
577 const updateHoldWebhooks = async (enabled: boolean) => {
578 setIsUpdatingPreference(true);
579 const ok = await reconcileCloudState({
580 managedTunnel: managedTunnelActive,
581 publish: publishAgentActivity,
582 holdWebhooksWhileOffline: enabled,
583 });
584 if (ok) {
585 toastManager.add({
586 type: "success",
587 title: enabled ? "Webhooks held while offline" : "Webhooks no longer held",
588 description: enabled
589 ? "T3 Connect keeps webhook requests for up to 24 hours while this environment is offline."
590 : "Requests to an offline environment now fail. Anything already held is still delivered.",
591 });
592 }
593 setIsUpdatingPreference(false);
594 };
595
596 return (
597 <>
598 {isElectron ? (
599 <SettingsRow
600 title={searchableSetting("t3-connect").title}
601 description={
602 signedOut
603 ? "Sign in to make this environment available to your other devices through T3 Connect."
604 : linkRevoked
605 ? "This environment was removed from T3 Connect. Turn it on to link it again."
606 : managedTunnelActive
607 ? reachability?.status === "unreachable"
608 ? "T3 Connect is on, but other devices cannot reach this environment."
609 : reachability?.status === "reachable"
610 ? "This environment is available to your other devices through T3 Connect."
611 : "T3 Connect is on. Reachability has not been checked yet."
612 : managedTunnelOutOfSync
613 ? "T3 Connect is out of sync. This environment is linked only to publish agent activity, so other devices cannot connect. Turn T3 Connect on to repair it."
614 : "Make this environment available to your other devices through T3 Connect."
615 }
616 status={operationError ?? primaryCloudLinkState.error ?? reachabilityStatus}
617 control={
618 signedOut ? (
619 signInButton
620 ) : (
621 <CloudLinkSwitch
622 checked={managedTunnelActive}
623 disabled={switchDisabled}
624 disabledReason={disabledReason}
625 onCheckedChange={(enabled) => void updateManagedTunnel(enabled)}
626 />
627 )
628 }
629 />
630 ) : linkRevoked ? (
631 <SettingsRow
632 title={searchableSetting("t3-connect").title}
633 description="This environment was removed from T3 Connect. Run `t3 connect link` on the host to link it again."
634 />
635 ) : null}
636 {signedOut && isElectron ? null : (
637 <SettingsRow
638 title={searchableSetting("publish-agent-activity").title}
639 description={
640 signedOut
641 ? "Sign in to send activity to mobile notifications and Live Activities."
642 : "Send activity to mobile notifications and Live Activities without T3 Connect."
643 }
644 control={
645 signedOut ? (
646 signInButton
647 ) : (
648 <CloudLinkSwitch
649 ariaLabel="Publish agent activity to mobile clients"
650 checked={publishAgentActivity}
651 disabled={switchDisabled}
652 disabledReason={disabledReason}
653 onCheckedChange={(enabled) => void updatePublishAgentActivity(enabled)}
654 />
655 )
656 }
657 />
658 )}
659 {managedTunnelActive && !signedOut ? (
660 <SettingsRow
661 title={searchableSetting("hold-webhooks-while-offline").title}
662 description="Keep webhook requests for up to 24 hours while this environment is offline, then deliver them. Off: T3 Connect only forwards requests and stores nothing."
663 control={
664 <CloudLinkSwitch
665 ariaLabel="Hold webhook requests while this environment is offline"
666 checked={holdWebhooksWhileOffline}
667 disabled={switchDisabled}
668 disabledReason={disabledReason}
669 onCheckedChange={(enabled) => void updateHoldWebhooks(enabled)}
670 />
671 }
672 />
673 ) : null}
674 </>
675 );
676}
677
678export function CloudLinkRow({
679 canReadRelay,
680 canManageRelay,
681}: {
682 readonly canReadRelay: boolean;
683 readonly canManageRelay: boolean;
684}) {
685 if (!hasCloudPublicConfig()) return null;
686 if (!canReadRelay) {
687 return (
688 <SettingsRow
689 title="T3 Connect"
690 description="To edit these settings, pair this connection with both View relay and Manage relay permissions."
691 />
692 );
693 }
694 return <ConfiguredCloudLinkRow canManageRelay={canManageRelay} />;
695}
696
697function EmptyRemoteEnvironments({ cloudEnabled = true }: { readonly cloudEnabled?: boolean }) {
698 return (
699 <Empty className="min-h-52">
700 <EmptyMedia variant="icon">
701 <ChevronsLeftRightEllipsisIcon />
702 </EmptyMedia>
703 <EmptyHeader>
704 <EmptyTitle>No saved remote environments</EmptyTitle>
705 <EmptyDescription>
706 {cloudEnabled
707 ? "Click “Add environment” to pair another environment, or connect one from T3 Connect."
708 : "Click “Add environment” to pair another environment."}
709 </EmptyDescription>
710 </EmptyHeader>
711 </Empty>
712 );
713}
714
715export function CloudRemoteEnvironmentRows({
716 primaryEnvironmentId,
717 savedEnvironments,
718}: {
719 readonly primaryEnvironmentId: EnvironmentId | null;
720 readonly savedEnvironments: ReadonlyArray<EnvironmentPresentation>;
721}) {
722 return hasCloudPublicConfig() ? (
723 <CloudEnvironmentConnectRows
724 primaryEnvironmentId={primaryEnvironmentId}
725 savedEnvironments={savedEnvironments}
726 empty={<EmptyRemoteEnvironments />}
727 />
728 ) : savedEnvironments.length === 0 ? (
729 <EmptyRemoteEnvironments cloudEnabled={false} />
730 ) : null;
731}