Open History to see the last commit
1import { pipe } from "effect/Function";
2import { ChevronsLeftRightEllipsisIcon, PlusIcon, TerminalIcon } from "lucide-react";
3import { useAtomValue } from "@effect/atom-react";
4import { type KeyboardEvent, type ReactNode, useEffect, useRef, useState } from "react";
5import {
6 type DesktopDiscoveredSshHost,
7 type DesktopSshEnvironmentTarget,
8} from "@t3tools/contracts";
9import {
10 RelayConnectionRegistration,
11 RelayConnectionTarget,
12} from "@t3tools/client-runtime/connection";
13import {
14 isAtomCommandInterrupted,
15 squashAtomCommandFailure,
16} from "@t3tools/client-runtime/state/runtime";
17import * as Option from "effect/Option";
18
19import { cn } from "../../lib/utils";
20import { formatDesktopSshTarget } from "./EnvironmentRow";
21import { Input } from "../ui/input";
22import { CommandShortcut } from "../ui/command";
23import {
24 Autocomplete,
25 AutocompleteEmpty,
26 AutocompleteInput,
27 AutocompleteItem,
28 AutocompleteList,
29 AutocompletePopup,
30} from "../ui/autocomplete";
31import {
32 Dialog,
33 DialogDescription,
34 DialogHeader,
35 DialogPanel,
36 DialogPopup,
37 DialogTitle,
38 DialogTrigger,
39} from "../ui/dialog";
40import { stackedThreadToast, toastManager } from "../ui/toast";
41import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
42import { Alert, AlertDescription } from "../ui/alert";
43import { Button } from "../ui/button";
44import { AnimatedHeight } from "../AnimatedHeight";
45import { environmentCatalog } from "~/connection/catalog";
46import {
47 connectPairing as connectPairingAtom,
48 connectSshEnvironment as connectSshEnvironmentAtom,
49} from "~/connection/onboarding";
50import { useEnvironmentQuery } from "~/state/query";
51import { desktopSshHostsStateAtom, filterDiscoveredSshHosts } from "~/state/desktopSshHosts";
52import { type EnvironmentPresentation, useRelayEnvironmentDiscovery } from "~/state/environments";
53import { useAtomCommand } from "../../state/use-atom-command";
54import { primaryServerKeybindingsAtom } from "~/state/server";
55import {
56 resolveShortcutCommand,
57 shortcutLabelForCommand,
58 threadJumpCommandForIndex,
59 threadJumpIndexFromCommand,
60} from "../../keybindings";
61import {
62 parseManualDesktopSshTarget,
63 parsePairingUrlFields,
64 parseRemotePairingFields,
65 formatDesktopSshConnectionError,
66} from "./ConnectionsSettings.logic";
67
68const EMPTY_DISCOVERED_SSH_HOSTS: ReadonlyArray<DesktopDiscoveredSshHost> = [];
69// known_hosts can list one host on several ports. Its own bracketed form keeps an IPv6
70// host's port separate from the address; no portless known_hosts entry has that form.
71const sshHostSuggestionValue = (target: DesktopDiscoveredSshHost) =>
72 target.port === null ? target.alias : `[${target.alias}]:${target.port}`;
73
74export function AddEnvironmentDialog({
75 open,
76 routeTarget,
77 error,
78 savedEnvironments,
79 onOpenChange,
80 onErrorChange,
81}: {
82 readonly open: boolean;
83 readonly routeTarget: EnvironmentPresentation | null;
84 readonly error: string | null;
85 readonly savedEnvironments: ReadonlyArray<EnvironmentPresentation>;
86 readonly onOpenChange: (open: boolean) => void;
87 readonly onErrorChange: (error: string | null) => void;
88}) {
89 const desktopBridge = window.desktopBridge;
90 const keybindings = useAtomValue(primaryServerKeybindingsAtom);
91 const connectPairing = useAtomCommand(connectPairingAtom, { reportFailure: false });
92 const connectSshEnvironment = useAtomCommand(connectSshEnvironmentAtom, {
93 reportFailure: false,
94 });
95 const registerEnvironment = useAtomCommand(environmentCatalog.register, {
96 reportFailure: false,
97 });
98 const relayDiscoveryState = useRelayEnvironmentDiscovery();
99 const savedDesktopSshEnvironmentKeys = (() => {
100 const keys = new Set<string>();
101 for (const environment of savedEnvironments) {
102 const profile = environment.entry.profile;
103 if (
104 environment.entry.target._tag !== "SshConnectionTarget" ||
105 Option.isNone(profile) ||
106 profile.value._tag !== "SshConnectionProfile"
107 ) {
108 continue;
109 }
110 const target = profile.value.target;
111 keys.add(target.alias);
112 keys.add(formatDesktopSshTarget(target));
113 }
114 return keys;
115 })();
116 const [savedBackendMode, setSavedBackendMode] = useState<"remote" | "ssh">("remote");
117 const [savedBackendHost, setSavedBackendHost] = useState("");
118 const [savedBackendPairingCode, setSavedBackendPairingCode] = useState("");
119 const [savedBackendSshHost, setSavedBackendSshHost] = useState("");
120 const [savedBackendSshUsername, setSavedBackendSshUsername] = useState("");
121 const [savedBackendSshPort, setSavedBackendSshPort] = useState("");
122 const [sshHostSuggestionsOpen, setSshHostSuggestionsOpen] = useState(false);
123 const highlightedSshHostRef = useRef<DesktopDiscoveredSshHost | undefined>(undefined);
124 const [isAddingSavedBackend, setIsAddingSavedBackend] = useState(false);
125 const savedBackendSessionRef = useRef(0);
126 const isSshDiscoveryActive = desktopBridge !== undefined && open && savedBackendMode === "ssh";
127 const desktopSshHosts = useEnvironmentQuery(
128 isSshDiscoveryActive ? desktopSshHostsStateAtom : null,
129 );
130 // The discovery atom is kept alive across dialog opens, so re-read SSH config
131 // each time the SSH tab is shown; stale hosts stay visible while it refreshes.
132 const refreshDesktopSshHosts = desktopSshHosts.refresh;
133 // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- rereads desktop SSH config through the bridge each time the SSH tab is shown
134 useEffect(() => {
135 if (isSshDiscoveryActive) refreshDesktopSshHosts();
136 }, [isSshDiscoveryActive, refreshDesktopSshHosts]);
137 const discoveredSshHosts = desktopSshHosts.data ?? EMPTY_DISCOVERED_SSH_HOSTS;
138 const unsavedDiscoveredSshHosts = discoveredSshHosts.filter((target) => {
139 const address = formatDesktopSshTarget(target);
140 return (
141 !savedDesktopSshEnvironmentKeys.has(target.alias) &&
142 (target.source === "ssh-config" || !savedDesktopSshEnvironmentKeys.has(address))
143 );
144 });
145 const filteredDiscoveredSshHosts = filterDiscoveredSshHosts(
146 unsavedDiscoveredSshHosts,
147 savedBackendSshHost,
148 );
149 const isLoadingDiscoveredSshHosts = desktopSshHosts.isPending && desktopSshHosts.data === null;
150 const discoveredSshHostsError = desktopSshHosts.error;
151 const hasSshHostSuggestionContent =
152 desktopBridge !== undefined &&
153 (isLoadingDiscoveredSshHosts || unsavedDiscoveredSshHosts.length > 0);
154 const handleOpenChange = (nextOpen: boolean) => {
155 if (!nextOpen) {
156 savedBackendSessionRef.current += 1;
157 setSavedBackendMode("remote");
158 setSavedBackendHost("");
159 setSavedBackendPairingCode("");
160 setSavedBackendSshHost("");
161 setSavedBackendSshUsername("");
162 setSavedBackendSshPort("");
163 }
164 onOpenChange(nextOpen);
165 };
166 const connectSavedBackendSshTarget = async (target: DesktopSshEnvironmentTarget) => {
167 const session = savedBackendSessionRef.current;
168 setIsAddingSavedBackend(true);
169 onErrorChange(null);
170 const result = await connectSshEnvironment({
171 target,
172 label: "",
173 ...(routeTarget ? { expectedEnvironmentId: routeTarget.environmentId } : {}),
174 });
175 if (result._tag === "Failure") {
176 if (session === savedBackendSessionRef.current && !isAtomCommandInterrupted(result)) {
177 pipe(squashAtomCommandFailure(result), formatDesktopSshConnectionError, onErrorChange);
178 }
179 setIsAddingSavedBackend(false);
180 return;
181 }
182
183 handleOpenChange(false);
184 toastManager.add({
185 type: "success",
186 title: routeTarget ? "Route added" : "Environment connected",
187 description: routeTarget
188 ? `${routeTarget.label} can now be reached over SSH ${target.alias}.`
189 : `${target.alias} is ready over an SSH-managed tunnel.`,
190 });
191 setIsAddingSavedBackend(false);
192 };
193
194 const handleAddSavedBackend = async () => {
195 if (savedBackendMode === "ssh") {
196 let target: DesktopSshEnvironmentTarget;
197 try {
198 target = parseManualDesktopSshTarget({
199 host: savedBackendSshHost,
200 username: savedBackendSshUsername,
201 port: savedBackendSshPort,
202 });
203 } catch (error) {
204 onErrorChange(formatDesktopSshConnectionError(error));
205 return;
206 }
207
208 await connectSavedBackendSshTarget(target);
209 return;
210 }
211
212 setIsAddingSavedBackend(true);
213 onErrorChange(null);
214 let remotePairingInput: ReturnType<typeof parseRemotePairingFields>;
215 try {
216 remotePairingInput = parseRemotePairingFields({
217 host: savedBackendHost,
218 pairingCode: savedBackendPairingCode,
219 });
220 } catch (error) {
221 const message = error instanceof Error ? error.message : "Failed to add backend.";
222 onErrorChange(message);
223 toastManager.add(
224 stackedThreadToast({
225 type: "error",
226 title: "Could not add backend",
227 description: message,
228 }),
229 );
230 setIsAddingSavedBackend(false);
231 return;
232 }
233
234 const result = await connectPairing({
235 ...remotePairingInput,
236 ...(routeTarget ? { expectedEnvironmentId: routeTarget.environmentId } : {}),
237 });
238 if (result._tag === "Failure") {
239 if (!isAtomCommandInterrupted(result)) {
240 const error = squashAtomCommandFailure(result);
241 const message = error instanceof Error ? error.message : "Failed to add backend.";
242 onErrorChange(message);
243 toastManager.add(
244 stackedThreadToast({
245 type: "error",
246 title: "Could not add backend",
247 description: message,
248 }),
249 );
250 }
251 setIsAddingSavedBackend(false);
252 return;
253 }
254
255 handleOpenChange(false);
256 toastManager.add(
257 routeTarget
258 ? {
259 type: "success",
260 title: "Route added",
261 description: `${routeTarget.label} now has another way to connect.`,
262 }
263 : {
264 type: "success",
265 title: "Backend added",
266 description: "The environment is saved and will reconnect on app startup.",
267 },
268 );
269 setIsAddingSavedBackend(false);
270 };
271
272 const handleSavedBackendSshFieldKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
273 if (event.nativeEvent.isComposing || event.keyCode === 229) return;
274 if (event.key === "Enter" && savedBackendSshHost.trim().length > 0) {
275 event.preventDefault();
276 void handleAddSavedBackend();
277 }
278 };
279
280 const handleSelectSshHostSuggestion = async (target: DesktopDiscoveredSshHost) => {
281 if (isAddingSavedBackend || !desktopBridge) return;
282
283 const session = savedBackendSessionRef.current;
284 setIsAddingSavedBackend(true);
285 onErrorChange(null);
286 setSavedBackendSshHost(target.alias);
287 let resolved: DesktopSshEnvironmentTarget;
288 try {
289 resolved = await desktopBridge.resolveSshHost(target.alias);
290 } catch (error) {
291 if (session === savedBackendSessionRef.current) {
292 onErrorChange(formatDesktopSshConnectionError(error));
293 }
294 setIsAddingSavedBackend(false);
295 return;
296 }
297 if (session !== savedBackendSessionRef.current) {
298 setIsAddingSavedBackend(false);
299 return;
300 }
301 if (target.port !== null) resolved = { ...resolved, port: target.port };
302 setSavedBackendSshUsername(resolved.username ?? "");
303 setSavedBackendSshPort(resolved.port === null ? "" : String(resolved.port));
304 await connectSavedBackendSshTarget(resolved);
305 };
306
307 const handleSavedBackendSshHostKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
308 if (event.nativeEvent.isComposing || event.keyCode === 229) return;
309
310 const isSshHostPopupVisible = sshHostSuggestionsOpen && hasSshHostSuggestionContent;
311 if (isSshHostPopupVisible) {
312 const command = resolveShortcutCommand(event, keybindings, {
313 platform: navigator.platform,
314 context: { modelPickerOpen: false },
315 });
316 const index = threadJumpIndexFromCommand(command ?? "");
317 const target = index === null ? undefined : filteredDiscoveredSshHosts[index];
318 if (target) {
319 event.preventDefault();
320 event.stopPropagation();
321 setSshHostSuggestionsOpen(false);
322 void handleSelectSshHostSuggestion(target);
323 return;
324 }
325
326 if (event.key === "Escape") {
327 event.preventDefault();
328 event.stopPropagation();
329 return;
330 }
331 }
332
333 const hasHighlightedSshHost =
334 isSshHostPopupVisible && highlightedSshHostRef.current !== undefined;
335 if (
336 !event.defaultPrevented &&
337 !hasHighlightedSshHost &&
338 event.key === "Enter" &&
339 savedBackendSshHost.trim().length > 0
340 ) {
341 event.preventDefault();
342 void handleAddSavedBackend();
343 }
344 };
345
346 const handleSavedBackendHostChange = (value: string) => {
347 const parsedPairingUrl = parsePairingUrlFields(value);
348 if (parsedPairingUrl) {
349 setSavedBackendHost(parsedPairingUrl.host);
350 setSavedBackendPairingCode(parsedPairingUrl.pairingCode);
351 return;
352 }
353 setSavedBackendHost(value);
354 };
355 const renderConnectionModeCard = (input: {
356 readonly mode: "remote" | "ssh";
357 readonly title: string;
358 readonly description: string;
359 readonly icon?: ReactNode;
360 }) => {
361 const selected = savedBackendMode === input.mode;
362 return (
363 <button
364 type="button"
365 aria-pressed={selected}
366 className={cn(
367 "group flex min-h-24 items-start gap-3 rounded-lg border p-4 text-left",
368 selected ? "border-primary/50 bg-primary/5" : "border-border/60 hover:bg-muted/40",
369 )}
370 disabled={isAddingSavedBackend}
371 onClick={() => {
372 setSavedBackendMode(input.mode);
373 }}
374 >
375 {input.icon ? (
376 <span
377 className={cn(
378 "mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md border",
379 selected
380 ? "border-primary/30 bg-primary/10 text-primary"
381 : "border-border/70 bg-background text-muted-foreground group-hover:text-foreground",
382 )}
383 >
384 {input.icon}
385 </span>
386 ) : null}
387 <span className="min-w-0">
388 <span className="block text-sm font-medium text-foreground">{input.title}</span>
389 <span className="mt-1 block text-xs leading-relaxed text-muted-foreground">
390 {input.description}
391 </span>
392 </span>
393 </button>
394 );
395 };
396
397 const renderRemoteFields = () => (
398 <div className="space-y-3">
399 <div className="grid gap-3 sm:grid-cols-[minmax(0,1fr)_10rem]">
400 <label className="block">
401 <span className="mb-1.5 block text-xs font-medium text-foreground">Host</span>
402 <Input
403 value={savedBackendHost}
404 onChange={(event) => handleSavedBackendHostChange(event.target.value)}
405 placeholder="backend.example.com"
406 disabled={isAddingSavedBackend}
407 spellCheck={false}
408 />
409 </label>
410 <label className="block">
411 <span className="mb-1.5 block text-xs font-medium text-foreground">Pairing code</span>
412 <Input
413 value={savedBackendPairingCode}
414 onChange={(event) => setSavedBackendPairingCode(event.target.value)}
415 placeholder="PAIRCODE"
416 disabled={isAddingSavedBackend}
417 spellCheck={false}
418 />
419 </label>
420 </div>
421 <div>
422 <span className="mt-1 block text-2xs text-muted-foreground">
423 Paste a full pairing URL here to fill both fields automatically.
424 </span>
425 </div>
426 </div>
427 );
428 const relayRouteOffer =
429 routeTarget !== null &&
430 !routeTarget.relayManaged &&
431 relayDiscoveryState.environments.has(routeTarget.environmentId)
432 ? relayDiscoveryState.environments.get(routeTarget.environmentId)!.environment
433 : null;
434 const addRelayRoute = async () => {
435 if (relayRouteOffer === null || routeTarget === null) return;
436 setIsAddingSavedBackend(true);
437 const result = await registerEnvironment(
438 new RelayConnectionRegistration({
439 target: new RelayConnectionTarget({
440 environmentId: relayRouteOffer.environmentId,
441 label: routeTarget.label,
442 }),
443 }),
444 );
445 setIsAddingSavedBackend(false);
446 if (result._tag === "Failure") {
447 if (!isAtomCommandInterrupted(result)) {
448 const error = squashAtomCommandFailure(result);
449 onErrorChange(error instanceof Error ? error.message : "Could not add the route.");
450 }
451 return;
452 }
453 handleOpenChange(false);
454 toastManager.add({
455 type: "success",
456 title: "Route added",
457 description: `${routeTarget.label} falls back to T3 Connect when its other routes are unreachable.`,
458 });
459 };
460 const renderRemoteModeBody = () => (
461 <div className="space-y-4">
462 {relayRouteOffer !== null ? (
463 <div className="flex items-center justify-between gap-3 rounded-md border border-border px-3 py-2">
464 <p className="text-xs text-muted-foreground">
465 This machine is on your T3 Connect account. Use it as a fallback route.
466 </p>
467 <Button
468 size="xs"
469 variant="outline"
470 disabled={isAddingSavedBackend}
471 onClick={() => void addRelayRoute()}
472 >
473 Add T3 Connect
474 </Button>
475 </div>
476 ) : null}
477 {renderRemoteFields()}
478 {error ? <p className="text-xs text-destructive">{error}</p> : null}
479 <Button
480 variant="outline"
481 className="w-full"
482 disabled={isAddingSavedBackend}
483 onClick={() => void handleAddSavedBackend()}
484 >
485 <PlusIcon className="size-3.5" />
486 {isAddingSavedBackend ? "Adding…" : routeTarget ? "Add route" : "Add environment"}
487 </Button>
488 </div>
489 );
490 const renderSshFields = () => (
491 <div className="space-y-4">
492 <div className="space-y-3">
493 <div className="block">
494 <label
495 htmlFor="saved-backend-ssh-host"
496 className="mb-1.5 block text-xs font-medium text-foreground"
497 >
498 SSH host or alias
499 </label>
500 <Autocomplete
501 items={filteredDiscoveredSshHosts}
502 itemToStringValue={sshHostSuggestionValue}
503 mode="none"
504 openOnInputClick
505 open={sshHostSuggestionsOpen}
506 onOpenChange={setSshHostSuggestionsOpen}
507 onItemHighlighted={(target) => {
508 highlightedSshHostRef.current = target;
509 }}
510 value={savedBackendSshHost}
511 onValueChange={(value, eventDetails) => {
512 setSavedBackendSshHost(value);
513 if (eventDetails.reason !== "item-press") return;
514
515 const target = filteredDiscoveredSshHosts.find(
516 (host) => sshHostSuggestionValue(host) === value,
517 );
518 if (target) void handleSelectSshHostSuggestion(target);
519 }}
520 >
521 <AutocompleteInput
522 id="saved-backend-ssh-host"
523 onKeyDown={handleSavedBackendSshHostKeyDown}
524 placeholder="Search hosts or type devbox"
525 disabled={isAddingSavedBackend}
526 spellCheck={false}
527 />
528 {hasSshHostSuggestionContent ? (
529 <AutocompletePopup>
530 {isLoadingDiscoveredSshHosts ? (
531 <div className="px-3 py-2 text-xs text-muted-foreground">Loading hosts…</div>
532 ) : filteredDiscoveredSshHosts.length > 0 ? (
533 <AutocompleteList className="max-h-72">
534 {filteredDiscoveredSshHosts.map((target, index) => {
535 const address = formatDesktopSshTarget(target);
536 const shortcutCommand = index < 9 ? threadJumpCommandForIndex(index) : null;
537 const shortcutLabel = shortcutCommand
538 ? shortcutLabelForCommand(keybindings, shortcutCommand, navigator.platform)
539 : null;
540 return (
541 <AutocompleteItem
542 key={`${target.alias}:${target.hostname}:${target.port ?? ""}`}
543 value={target}
544 className="h-8 min-h-8 whitespace-nowrap"
545 >
546 <span className="min-w-0 truncate text-sm font-medium">
547 {target.alias}
548 </span>
549 {address !== target.alias ? (
550 <span className="min-w-0 flex-1 truncate text-xs text-muted-foreground">
551 {address}
552 </span>
553 ) : (
554 <span className="flex-1" />
555 )}
556 {shortcutLabel ? (
557 <CommandShortcut className="shrink-0">{shortcutLabel}</CommandShortcut>
558 ) : null}
559 </AutocompleteItem>
560 );
561 })}
562 </AutocompleteList>
563 ) : (
564 <AutocompleteEmpty className="break-all">
565 No hosts match "{savedBackendSshHost.trim()}".
566 </AutocompleteEmpty>
567 )}
568 </AutocompletePopup>
569 ) : null}
570 </Autocomplete>
571 </div>
572 <div className="grid gap-3 sm:grid-cols-[minmax(0,1fr)_7rem]">
573 <label className="block">
574 <span className="mb-1.5 block text-xs font-medium text-foreground">Username</span>
575 <Input
576 value={savedBackendSshUsername}
577 onChange={(event) => setSavedBackendSshUsername(event.target.value)}
578 onKeyDown={handleSavedBackendSshFieldKeyDown}
579 placeholder="root"
580 disabled={isAddingSavedBackend}
581 spellCheck={false}
582 />
583 </label>
584 <label className="block">
585 <span className="mb-1.5 block text-xs font-medium text-foreground">Port</span>
586 <Input
587 value={savedBackendSshPort}
588 onChange={(event) => setSavedBackendSshPort(event.target.value)}
589 onKeyDown={handleSavedBackendSshFieldKeyDown}
590 placeholder="22"
591 inputMode="numeric"
592 disabled={isAddingSavedBackend}
593 spellCheck={false}
594 />
595 </label>
596 </div>
597 {error || discoveredSshHostsError ? (
598 <Alert variant="error">
599 <AlertDescription>{error ?? discoveredSshHostsError}</AlertDescription>
600 </Alert>
601 ) : null}
602 <Button
603 variant="outline"
604 className="w-full"
605 disabled={isAddingSavedBackend}
606 onClick={() => void handleAddSavedBackend()}
607 >
608 <PlusIcon className="size-3.5" />
609 {isAddingSavedBackend ? "Adding…" : routeTarget ? "Add route" : "Add environment"}
610 </Button>
611 </div>
612 </div>
613 );
614
615 return (
616 <Dialog open={open} onOpenChange={handleOpenChange}>
617 <Tooltip>
618 <TooltipTrigger
619 render={
620 <DialogTrigger
621 render={
622 <Button size="xs" variant="ghost-muted" aria-label="Add environment">
623 <PlusIcon className="size-3" />
624 <span>Add environment</span>
625 </Button>
626 }
627 />
628 }
629 />
630 <TooltipPopup side="top">Add environment</TooltipPopup>
631 </Tooltip>
632 <DialogPopup className="max-h-[80dvh] sm:max-w-3xl">
633 <DialogHeader>
634 <DialogTitle>
635 {routeTarget ? `Add a route to ${routeTarget.label}` : "Add Environment"}
636 </DialogTitle>
637 <DialogDescription>
638 {routeTarget
639 ? "Pair this machine again over another address, such as its Tailscale name. It joins the existing routes instead of adding a second machine."
640 : "Pair another environment to this client."}
641 </DialogDescription>
642 </DialogHeader>
643 <DialogPanel>
644 <div className="space-y-4">
645 <div className="grid gap-3 sm:grid-cols-2">
646 {renderConnectionModeCard({
647 mode: "remote",
648 title: "Remote link",
649 description: "Enter a backend host and pairing code.",
650 icon: <ChevronsLeftRightEllipsisIcon aria-hidden className="size-4" />,
651 })}
652 {desktopBridge
653 ? renderConnectionModeCard({
654 mode: "ssh",
655 title: "SSH",
656 description: "Use local SSH config, agent, and tunnels for the backend.",
657 icon: <TerminalIcon aria-hidden className="size-4" />,
658 })
659 : null}
660 </div>
661 <AnimatedHeight>
662 {savedBackendMode === "ssh" ? renderSshFields() : renderRemoteModeBody()}
663 </AnimatedHeight>
664 </div>
665 </DialogPanel>
666 </DialogPopup>
667 </Dialog>
668 );
669}