fix(webui): polish remote setup and simplify connection dialogs
This commit is contained in:
1 parent
5aa91b66cc
commit
0ffdf86619
28 files changed
+972
-149
No files matched your search
@@ -9,7 +9,7 @@ import { DisclosureContent } from "@/components/ui/disclosure";
|
||||
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
|
||||
import { useClient } from "@/providers/ClientProvider";
|
||||
import { groupRemoteProfiles, remoteAction, type RemoteInspection, type RemoteProfile } from "@/lib/remote-instances";
|
||||
import { groupRemoteProfiles, isCompatibilityError, remoteAction, type RemoteInspection, type RemoteProfile } from "@/lib/remote-instances";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { parseSSHAddress } from "@/lib/ssh-address";
|
||||
import { clearPairReturn, readPairReturn, subscribePairReturn } from "@/lib/remote-pair-return";
|
||||
@@ -18,6 +18,8 @@ import { SSHHostPicker } from "./SSHHostPicker";
|
||||
import { QuickPairSetup } from "./QuickPairSetup";
|
||||
import { PairRouteSettings } from "./PairRouteSettings";
|
||||
import { HostConnectionStatus } from "./HostConnectionStatus";
|
||||
import { HostCompatibilityDialog } from "./HostCompatibilityDialog";
|
||||
import "./remote-layout.css";
|
||||
|
||||
const emptyProfile = (): Omit<RemoteProfile, "id" | "connected"> => ({
|
||||
name: "", host: "", port: null, ssh_config: "", identity_file: "",
|
||||
@@ -37,8 +39,12 @@ export function RemoteConnectionsPage({ mainNavigationExpanded = false, hostChro
|
||||
const [editorOpen, setEditorOpen] = useState(false);
|
||||
const returnedPair = useSyncExternalStore(subscribePairReturn, readPairReturn);
|
||||
const [quickOpen, setQuickOpen] = useState(!!returnedPair);
|
||||
const [quickReturn, setQuickReturn] = useState(returnedPair);
|
||||
const [pairRoute, setPairRoute] = useState("");
|
||||
const [details, setDetails] = useState("");
|
||||
const [detailsOpen, setDetailsOpen] = useState(false);
|
||||
const [routeOpen, setRouteOpen] = useState(false);
|
||||
const [versionId, setVersionId] = useState("");
|
||||
const [renaming, setRenaming] = useState<RemoteProfile | null>(null);
|
||||
const [name, setName] = useState("");
|
||||
const [renameError, setRenameError] = useState("");
|
||||
@@ -73,7 +79,7 @@ export function RemoteConnectionsPage({ mainNavigationExpanded = false, hostChro
|
||||
useEffect(() => { if (removing) lastRemoval.current = removing; }, [removing]);
|
||||
useEffect(() => { if (disconnecting) lastDisconnect.current = disconnecting; }, [disconnecting]);
|
||||
|
||||
useEffect(() => { if (returnedPair) setQuickOpen(true); }, [returnedPair]);
|
||||
useEffect(() => { if (returnedPair) { setQuickReturn(returnedPair); setQuickOpen(true); } }, [returnedPair]);
|
||||
|
||||
useEffect(() => {
|
||||
mounted.current = true;
|
||||
@@ -168,6 +174,15 @@ export function RemoteConnectionsPage({ mainNavigationExpanded = false, hostChro
|
||||
if (wanted(attempt)) { setEditorOpen(false); setFingerprint(null); }
|
||||
} catch (reason) {
|
||||
if (!wanted(attempt)) return;
|
||||
if (reason instanceof Error && reason.message === "local_webui_unavailable") {
|
||||
showError(reason);
|
||||
return;
|
||||
}
|
||||
if (reason instanceof Error && isCompatibilityError(reason.message)) {
|
||||
await refresh?.().catch(() => {});
|
||||
if (wanted(attempt)) { setEditorOpen(false); setVersionId(id); showError(reason); }
|
||||
return;
|
||||
}
|
||||
if (reason instanceof Error && reason.message === "host_key_unknown") {
|
||||
try {
|
||||
const result = await remoteAction<{ fingerprint: string; challenge: string }>(client, "fingerprint", { id });
|
||||
@@ -269,10 +284,10 @@ export function RemoteConnectionsPage({ mainNavigationExpanded = false, hostChro
|
||||
const detailConnection = detailGroup?.connections.find((profile) => profile.connected || connections.openHostIds.includes(profile.id));
|
||||
const removalIsShared = groups.some((group) => group.connections.length > 1 && group.connections.some((profile) => profile.id === removalProfile?.id));
|
||||
const connectionActions = (profile: RemoteProfile, grouped = false) => <>
|
||||
{!profile.paired && <DropdownMenuItem disabled={profile.connected || connections.openHostIds.includes(profile.id)} onSelect={() => { setDetails(""); beginEditor(profile); }}>{t("remote.edit")}</DropdownMenuItem>}
|
||||
{profile.paired && <DropdownMenuItem disabled={profile.connected || connections.openHostIds.includes(profile.id)} onSelect={() => { setDetails(""); setPairRoute(profile.id); }}>{t("remote.pair.route")}</DropdownMenuItem>}
|
||||
{(profile.connected || connections.openHostIds.includes(profile.id)) && <DropdownMenuItem onSelect={() => { setDetails(""); setError(""); setDisconnecting(profile); }}>{t("remote.disconnect")}</DropdownMenuItem>}
|
||||
<DropdownMenuItem tone="destructive" onSelect={() => { setDetails(""); setError(""); setRemoving(profile); }}>{t(grouped ? "remote.sameInstance.forgetConnection" : "remote.forget")}</DropdownMenuItem>
|
||||
{!profile.paired && <DropdownMenuItem disabled={profile.connected || connections.openHostIds.includes(profile.id)} onSelect={() => { setDetailsOpen(false); beginEditor(profile); }}>{t("remote.edit")}</DropdownMenuItem>}
|
||||
{profile.paired && <DropdownMenuItem disabled={profile.connected || connections.openHostIds.includes(profile.id)} onSelect={() => { setDetailsOpen(false); setPairRoute(profile.id); setRouteOpen(true); }}>{t("remote.pair.route")}</DropdownMenuItem>}
|
||||
{(profile.connected || connections.openHostIds.includes(profile.id)) && <DropdownMenuItem onSelect={() => { setDetailsOpen(false); setError(""); setDisconnecting(profile); }}>{t("remote.disconnect")}</DropdownMenuItem>}
|
||||
<DropdownMenuItem tone="destructive" onSelect={() => { setDetailsOpen(false); setError(""); setRemoving(profile); }}>{t(grouped ? "remote.sameInstance.forgetConnection" : "remote.forget")}</DropdownMenuItem>
|
||||
</>;
|
||||
|
||||
return <div ref={page} tabIndex={-1} role="region" aria-label={t("remote.title")} className="flex min-h-0 flex-1 flex-col overflow-hidden bg-settings-canvas outline-none">
|
||||
@@ -309,6 +324,9 @@ export function RemoteConnectionsPage({ mainNavigationExpanded = false, hostChro
|
||||
<span className="min-w-0 flex-1"><span className="block truncate text-[14px] font-medium">{profile.name}</span><span className="mt-0.5 block truncate text-xs text-muted-foreground">{profile.host}</span>
|
||||
{groups.some((other) => other.id !== groupId && other.profile.name === profile.name && other.profile.host === profile.host) && <span className="mt-0.5 block truncate text-xs text-muted-foreground" title={profile.config_path}>{profile.port ? `:${profile.port} · ` : ""}{profile.config_path}</span>}
|
||||
<span id={`${statusId}-${profile.id}`} className="mt-1 block"><HostConnectionStatus state={connections.hostStates[profile.id] || "closed"} /></span>
|
||||
{profile.compatibility && profile.compatibility.status !== "compatible" && <span className="mt-1 block text-xs text-muted-foreground">
|
||||
{t(`remote.compatibility.${profile.compatibility.status}`)}
|
||||
</span>}
|
||||
{profile.paired && typeof profile.authorized_until === "number" && Number.isFinite(profile.authorized_until)
|
||||
&& profile.authorized_until * 1000 <= Date.now() + 7 * 86_400_000 && <span className="mt-1 block text-xs leading-5 text-muted-foreground">
|
||||
{t(profile.authorized_until * 1000 <= Date.now() ? "remote.pair.expiredDevice" : "remote.pair.expiringDevice", {
|
||||
@@ -324,7 +342,8 @@ export function RemoteConnectionsPage({ mainNavigationExpanded = false, hostChro
|
||||
aria-label={t("remote.manage", { name: profile.name })}><MoreHorizontal className="h-4 w-4" /></Button></DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem onSelect={() => { setRenaming(profile); setName(profile.name); setRenameError(""); }}>{t("remote.rename.action")}</DropdownMenuItem>
|
||||
{entries.length > 1 ? <DropdownMenuItem onSelect={() => setDetails(groupId)}>{t("remote.sameInstance.details")}</DropdownMenuItem> : connectionActions(profile)}
|
||||
<DropdownMenuItem onSelect={() => setVersionId(profile.id)}>{t("remote.compatibility.title")}</DropdownMenuItem>
|
||||
{entries.length > 1 ? <DropdownMenuItem onSelect={() => { setDetails(groupId); setDetailsOpen(true); }}>{t("remote.sameInstance.details")}</DropdownMenuItem> : connectionActions(profile)}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>)}
|
||||
@@ -333,14 +352,14 @@ export function RemoteConnectionsPage({ mainNavigationExpanded = false, hostChro
|
||||
<p role="status" className="min-w-0 truncate text-xs text-muted-foreground">{t("remote.preparing", { name: openingProfile.name })}</p>
|
||||
<Button variant="ghost" size="sm" className="shrink-0" onClick={closeEditor}>{t("remote.cancelSwitch")}</Button>
|
||||
</div>}
|
||||
<div className="settings-list-inset"><Button variant="ghost" className="gap-2" disabled={!!busy} onClick={(event) => {
|
||||
editorTrigger.current = event.currentTarget; setQuickOpen(true);
|
||||
<div className="settings-list-inset"><Button variant="ghost" className="remote-action gap-2" disabled={!!busy} onClick={(event) => {
|
||||
editorTrigger.current = event.currentTarget; setQuickReturn(null); setQuickOpen(true);
|
||||
}}><Plus className="h-4 w-4" />{t("remote.add")}</Button></div>
|
||||
</>}
|
||||
{!directory && !directoryError && <div role="status" className="settings-list-inset flex items-center gap-2 text-sm text-muted-foreground"><Loader2 className="h-4 w-4 animate-spin" />{t("remote.loading")}</div>}
|
||||
{directory && !directory.available && <p className="settings-list-inset text-sm text-muted-foreground">{t("remote.unavailable")}</p>}
|
||||
{pageError && !editorOpen && !fingerprint && !removing && !disconnecting && <div className="settings-list-inset space-y-2">
|
||||
<p role="alert" className="flex items-start gap-2 text-[13px] leading-5 text-foreground"><AlertCircle aria-hidden="true" className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" />{pageError}</p>
|
||||
<p role="alert" className="remote-alert items-start gap-2 text-[13px] leading-5 text-foreground"><AlertCircle aria-hidden="true" className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" />{pageError}</p>
|
||||
{directoryError && <Button variant="ghost" size="sm" disabled={!!busy} onClick={() => {
|
||||
setBusy("refresh"); setError(""); void refresh?.().catch((reason: unknown) => { if (mounted.current) showError(reason); }).finally(() => { if (mounted.current) setBusy(""); });
|
||||
}}>{t("remote.retry")}</Button>}
|
||||
@@ -349,8 +368,10 @@ export function RemoteConnectionsPage({ mainNavigationExpanded = false, hostChro
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<HostCompatibilityDialog profile={directory?.profiles.find((profile) => profile.id === versionId)}
|
||||
clientVersion={directory?.client_version} onClose={() => setVersionId("")} />
|
||||
<Dialog open={!!renaming} onOpenChange={(open) => { if (!open && !busy) setRenaming(null); }}>
|
||||
<DialogContent className="max-h-[85dvh] max-w-sm overflow-y-auto" onOpenAutoFocus={(event) => {
|
||||
<DialogContent className="remote-dialog max-h-[85dvh] max-w-sm overflow-y-auto" onOpenAutoFocus={(event) => {
|
||||
event.preventDefault(); nameInput.current?.focus(); nameInput.current?.select();
|
||||
}} onCloseAutoFocus={(event) => { event.preventDefault(); editorTrigger.current?.focus({ preventScroll: true }); }}>
|
||||
<DialogHeader className="pr-5 text-left">
|
||||
@@ -358,14 +379,12 @@ export function RemoteConnectionsPage({ mainNavigationExpanded = false, hostChro
|
||||
<DialogDescription>{t("remote.rename.hint")}</DialogDescription>
|
||||
</DialogHeader>
|
||||
<form className="space-y-4" onSubmit={(event) => { event.preventDefault(); void rename(); }}>
|
||||
<div className="space-y-2">
|
||||
<label htmlFor={nameId} className="text-[13px] font-medium">{t("remote.rename.name")}</label>
|
||||
<Input ref={nameInput} id={nameId} value={name} maxLength={64} required disabled={!!busy}
|
||||
aria-invalid={!!renameError} aria-describedby={renameError ? `${nameId}-error` : undefined}
|
||||
onChange={(event) => { setName(event.target.value); setRenameError(""); }} />
|
||||
</div>
|
||||
<Input ref={nameInput} id={nameId} value={name} maxLength={64} required disabled={!!busy}
|
||||
aria-label={t("remote.rename.name")}
|
||||
aria-invalid={!!renameError} aria-describedby={renameError ? `${nameId}-error` : undefined}
|
||||
onChange={(event) => { setName(event.target.value); setRenameError(""); }} />
|
||||
{renameError && <p id={`${nameId}-error`} role="alert" className="text-[13px] leading-5 text-foreground">{renameError}</p>}
|
||||
<div className="flex justify-end gap-2">
|
||||
<div className="remote-dialog-actions">
|
||||
<Button type="button" variant="ghost" disabled={!!busy} onClick={() => setRenaming(null)}>{t("common.cancel")}</Button>
|
||||
<Button type="submit" disabled={!!busy || !name.trim() || name.trim() === renaming?.name} aria-busy={!!busy}>
|
||||
{busy && <Loader2 aria-hidden className="mr-2 h-4 w-4 animate-spin motion-reduce:animate-none" />}{t(busy ? "remote.saving" : "remote.save")}
|
||||
@@ -374,14 +393,14 @@ export function RemoteConnectionsPage({ mainNavigationExpanded = false, hostChro
|
||||
</form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
<Dialog open={!!detailGroup} onOpenChange={(open) => { if (!open) setDetails(""); }}>
|
||||
<DialogContent className="flex max-h-[85dvh] max-w-md flex-col overflow-hidden">
|
||||
<Dialog open={detailsOpen && !!detailGroup} onOpenChange={(open) => { if (!open) setDetailsOpen(false); }}>
|
||||
<DialogContent className="remote-dialog flex max-h-[85dvh] max-w-md flex-col overflow-hidden">
|
||||
<DialogHeader className="pr-5 text-left"><DialogTitle>{t("remote.sameInstance.details")}</DialogTitle><DialogDescription>{t("remote.sameInstance.detailsHint")}</DialogDescription></DialogHeader>
|
||||
<div className="min-h-0 space-y-2 overflow-y-auto">
|
||||
{detailGroup?.connections.map((profile, index) => <div key={profile.id} className="flex items-center gap-2 rounded-2xl bg-muted/40 p-3">
|
||||
<button type="button" disabled={!!busy || (!!detailConnection && detailConnection.id !== profile.id)} aria-current={connections.activeHostId === profile.id || undefined}
|
||||
className="min-w-0 flex-1 rounded-xl text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
||||
onClick={() => { setDetails(""); void connect(profile.id); }}>
|
||||
onClick={() => { setDetailsOpen(false); void connect(profile.id); }}>
|
||||
<span className="flex items-center gap-2 text-[13px] font-medium">{t("remote.sameInstance.connection", { count: index + 1 })}{connections.activeHostId === profile.id && <Check aria-label={t("remote.current")} className="h-3.5 w-3.5" />}</span>
|
||||
<span className="mt-1 block truncate text-xs text-muted-foreground">{profile.host}</span>
|
||||
<HostConnectionStatus state={connections.hostStates[profile.id] || "closed"} />
|
||||
@@ -397,17 +416,17 @@ export function RemoteConnectionsPage({ mainNavigationExpanded = false, hostChro
|
||||
</Dialog>
|
||||
|
||||
<Dialog open={quickOpen} onOpenChange={(open) => { setQuickOpen(open); if (!open) clearPairReturn(); }}>
|
||||
<DialogContent className="flex max-h-[85dvh] max-w-md flex-col overflow-hidden">
|
||||
{quickOpen && <QuickPairSetup key={returnedPair?.code || "new"} returned={returnedPair} onSSH={() => { clearPairReturn(); setQuickOpen(false); beginEditor(); }} onClose={() => { clearPairReturn(); setQuickOpen(false); }} />}
|
||||
<DialogContent className="remote-dialog flex max-h-[85dvh] max-w-md flex-col overflow-hidden">
|
||||
<QuickPairSetup key={quickReturn?.code || "new"} returned={quickReturn} active={quickOpen} onSSH={() => { clearPairReturn(); setQuickOpen(false); beginEditor(); }} onClose={() => { clearPairReturn(); setQuickOpen(false); }} />
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
<Dialog open={!!pairRoute} onOpenChange={(open) => { if (!open) setPairRoute(""); }}>
|
||||
<DialogContent className="max-w-md"><DialogHeader><DialogTitle>{t("remote.pair.route")}</DialogTitle><DialogDescription>{t("remote.pair.routeDescription")}</DialogDescription></DialogHeader>
|
||||
{pairRoute && <PairRouteSettings id={pairRoute} onSaved={() => setPairRoute("")} />}
|
||||
<Dialog open={routeOpen} onOpenChange={setRouteOpen}>
|
||||
<DialogContent className="remote-dialog max-w-md overflow-y-auto"><DialogHeader className="pr-5 text-left"><DialogTitle>{t("remote.pair.route")}</DialogTitle><DialogDescription>{t("remote.pair.routeHint")}</DialogDescription></DialogHeader>
|
||||
{pairRoute && <PairRouteSettings key={pairRoute} id={pairRoute} showHint={false} onSaved={() => setRouteOpen(false)} />}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
<Dialog open={editorOpen || !!fingerprint} onOpenChange={(open) => { if (!open) closeEditor(); }}>
|
||||
<DialogContent className="flex max-h-[85dvh] max-w-md flex-col overflow-hidden" onOpenAutoFocus={(event) => {
|
||||
<DialogContent className="remote-dialog flex max-h-[85dvh] max-w-md flex-col overflow-hidden" onOpenAutoFocus={(event) => {
|
||||
if (!fingerprint) { event.preventDefault(); hostInput.current?.focus(); }
|
||||
}} onCloseAutoFocus={(event) => {
|
||||
event.preventDefault();
|
||||
@@ -423,15 +442,15 @@ export function RemoteConnectionsPage({ mainNavigationExpanded = false, hostChro
|
||||
<code className="block select-text break-all text-xs text-muted-foreground">{fingerprint.fingerprint}</code>
|
||||
</div>
|
||||
<p className="text-xs leading-5 text-muted-foreground">{t("remote.verifyHint")}</p>
|
||||
{error && <p role="alert" className="flex items-start gap-2 text-[13px] leading-5 text-foreground"><AlertCircle aria-hidden="true" className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" />{error}</p>}
|
||||
<div className="grid grid-cols-2 gap-2 sm:flex sm:flex-wrap sm:items-center sm:justify-end">
|
||||
{editorOpen && <Button variant="ghost" disabled={!!busy} className="mr-auto gap-1" onClick={() => { setFingerprint(null); setError(""); setErrorCode(""); setInspection(null); setInspectBeforeConnect(true); }}><ChevronLeft className="h-4 w-4" />{t("remote.back")}</Button>}
|
||||
{error && <p role="alert" className="remote-alert items-start gap-2 text-[13px] leading-5 text-foreground"><AlertCircle aria-hidden="true" className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" /><span>{error}</span></p>}
|
||||
<div className="remote-dialog-actions">
|
||||
{editorOpen && <Button variant="ghost" disabled={!!busy} className="gap-1" onClick={() => { setFingerprint(null); setError(""); setErrorCode(""); setInspection(null); setInspectBeforeConnect(true); }}><ChevronLeft className="h-4 w-4" />{t("remote.back")}</Button>}
|
||||
<Button variant="ghost" onClick={closeEditor}>{t("common.cancel")}</Button>
|
||||
<Button className="col-span-2 h-auto min-h-10 whitespace-normal" disabled={!!busy} aria-busy={!!busy} onClick={() => { void trustHost(); }}>{busy && <Loader2 aria-hidden className="mr-2 h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none" />}{t("remote.verifyConnect")}</Button>
|
||||
</div>
|
||||
</> : <form onSubmit={(event) => { event.preventDefault(); if (!busy && form.host.trim() && (!locationStep || form.config_path.trim())) void save(); }} className="flex min-h-0 flex-col gap-4">
|
||||
<div className="-mx-1 min-h-0 space-y-4 overflow-y-auto overscroll-contain px-1">
|
||||
{!editing && <ol aria-label={t("remote.setup.progress")} className="flex items-center gap-3 text-xs text-muted-foreground">
|
||||
{!editing && <ol aria-label={t("remote.setup.progress")} className="flex flex-wrap items-center gap-3 text-xs text-muted-foreground">
|
||||
<li aria-current={!locationStep ? "step" : undefined} className={cn("flex items-center gap-1.5", !locationStep && "text-foreground")}>
|
||||
{locationStep ? <Check className="h-3.5 w-3.5" /> : <span>1</span>}{t("remote.setup.server")}</li>
|
||||
<li aria-hidden="true" className="h-px w-5 bg-border" />
|
||||
@@ -440,7 +459,7 @@ export function RemoteConnectionsPage({ mainNavigationExpanded = false, hostChro
|
||||
{locationStep && !editing ? <div className="space-y-4">
|
||||
<div className="flex items-center justify-between gap-3 rounded-2xl bg-muted/40 px-3 py-2.5">
|
||||
<span className="min-w-0 text-[13px]"><span className="block font-medium">{t("remote.setup.signedIn")}</span><span className="block truncate text-xs text-muted-foreground">{form.host}</span></span>
|
||||
<Button type="button" size="sm" variant="ghost" disabled={!!busy} onClick={editSSH}>{t("remote.setup.changeServer")}</Button>
|
||||
<Button type="button" size="sm" variant="ghost" className="remote-action" disabled={!!busy} onClick={editSSH}>{t("remote.setup.changeServer")}</Button>
|
||||
</div>
|
||||
{!!inspection?.candidates.length && <fieldset className="space-y-2">
|
||||
<legend className="mb-2 text-[13px] font-medium">{t("remote.setup.chooseNanobot")}</legend>
|
||||
@@ -448,7 +467,7 @@ export function RemoteConnectionsPage({ mainNavigationExpanded = false, hostChro
|
||||
<input type="radio" name="nanobot-location" className="mt-1 accent-foreground" disabled={!!busy}
|
||||
checked={!manualLocation && form.config_path === candidate.config_path && form.runtime_user === candidate.runtime_user}
|
||||
onChange={() => { setManualLocation(false); setForm({ ...form, config_path: candidate.config_path, runtime_user: candidate.runtime_user }); setError(""); setErrorCode(""); }} />
|
||||
<span className="min-w-0 text-[13px]"><span className="block font-medium">{candidate.service || t("remote.setup.yourNanobot")}</span>
|
||||
<span className="min-w-0 text-[13px]"><span className="block font-medium [overflow-wrap:anywhere]">{candidate.service || t("remote.setup.yourNanobot")}</span>
|
||||
<span className="block break-all text-xs leading-5 text-muted-foreground">{candidate.config_path}</span>
|
||||
{candidate.runtime_user && <span className="mt-1 block text-xs leading-5 text-muted-foreground">{t("remote.setup.serviceAccount", { user: candidate.runtime_user })}</span>}
|
||||
</span>
|
||||
@@ -459,7 +478,7 @@ export function RemoteConnectionsPage({ mainNavigationExpanded = false, hostChro
|
||||
<p className="text-xs leading-5 text-muted-foreground">{t("remote.setup.notFoundHint")}</p>
|
||||
</div>}
|
||||
{inspection?.incomplete && <p className="text-xs leading-5 text-muted-foreground">{t("remote.setup.limitedSearch")}</p>}
|
||||
{!manualLocation && <Button type="button" variant="ghost" size="sm" disabled={!!busy} onClick={() => setManualLocation(true)}>{t("remote.setup.manualLocation")}</Button>}
|
||||
{!manualLocation && <Button type="button" variant="ghost" size="sm" className="remote-action" disabled={!!busy} onClick={() => setManualLocation(true)}>{t("remote.setup.manualLocation")}</Button>}
|
||||
</div> : <>
|
||||
<SSHHostPicker inputRef={hostInput} disabled={!!busy} value={form.host} configFile={form.ssh_config} imported={commandImported}
|
||||
suggestions={!editingProfile || form.host !== editingProfile.host || form.ssh_config !== editingProfile.ssh_config}
|
||||
@@ -488,15 +507,15 @@ export function RemoteConnectionsPage({ mainNavigationExpanded = false, hostChro
|
||||
</div>
|
||||
<div className="shrink-0 space-y-3 pt-1">
|
||||
{error && <div className="space-y-1">
|
||||
<p role="alert" className="flex items-start gap-2 text-[13px] leading-5 text-foreground"><AlertCircle aria-hidden="true" className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" />{error}</p>
|
||||
<p role="alert" className="remote-alert items-start gap-2 text-[13px] leading-5 text-foreground"><AlertCircle aria-hidden="true" className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" /><span>{error}</span></p>
|
||||
{!sshOptions && /^(ssh_|local_file_not_found)/.test(errorCode) && <Button type="button" variant="ghost" size="sm" disabled={!!busy} onClick={editSSH}>{t("remote.setup.sshSettings")}</Button>}
|
||||
</div>}
|
||||
{busy.startsWith("pick-") && <p role="status" className="text-xs text-muted-foreground">{t("remote.setup.pickingFile")}</p>}
|
||||
<div className="grid grid-cols-[auto_minmax(0,1fr)] items-center gap-2">
|
||||
<div className="remote-dialog-actions">
|
||||
<Button type="button" variant="ghost" onClick={closeEditor}>{t("common.cancel")}</Button>
|
||||
<Button type="submit" className="min-w-0" title={t(editorLabel)} aria-label={t(editorLabel)} aria-busy={!!busy} disabled={!!busy || !form.host.trim() || (locationStep && !form.config_path.trim())}>
|
||||
{busy && !busy.startsWith("pick-") && <Loader2 aria-hidden className="mr-2 h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none" />}
|
||||
<span role={busy && !busy.startsWith("pick-") ? "status" : undefined} className="truncate">{t(editorLabel)}</span>
|
||||
<span role={busy && !busy.startsWith("pick-") ? "status" : undefined} className="min-w-0">{t(editorLabel)}</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -504,17 +523,17 @@ export function RemoteConnectionsPage({ mainNavigationExpanded = false, hostChro
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
<Dialog open={!!disconnecting} onOpenChange={(value) => { if (!value && !busy) setDisconnecting(null); }}>
|
||||
<DialogContent className="max-h-[85dvh] max-w-sm overflow-y-auto"><DialogHeader className="pr-5 text-left"><DialogTitle className="break-words leading-snug">{t("remote.disconnectTitle", { name: disconnectProfile?.name })}</DialogTitle><DialogDescription>{t("remote.disconnectDescription")}</DialogDescription></DialogHeader>
|
||||
{error && <p role="alert" className="flex items-start gap-2 text-[13px] leading-5 text-foreground"><AlertCircle aria-hidden="true" className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" />{error}</p>}
|
||||
<div className="grid grid-cols-2 gap-2"><Button variant="ghost" disabled={!!busy} onClick={() => setDisconnecting(null)}>{t("common.cancel")}</Button><Button variant="outline" className="min-w-0" disabled={!!busy} aria-busy={!!busy} onClick={() => { if (disconnecting) void disconnect(disconnecting.id); }}>{busy && <Loader2 aria-hidden className="mr-2 h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none" />}<span className="truncate">{t("remote.disconnect")}</span></Button></div>
|
||||
<DialogContent className="remote-dialog max-h-[85dvh] max-w-sm overflow-y-auto"><DialogHeader className="pr-5 text-left"><DialogTitle className="leading-snug [overflow-wrap:anywhere]">{t("remote.disconnectTitle", { name: disconnectProfile?.name })}</DialogTitle><DialogDescription>{t("remote.disconnectDescription")}</DialogDescription></DialogHeader>
|
||||
{error && <p role="alert" className="remote-alert items-start gap-2 text-[13px] leading-5 text-foreground"><AlertCircle aria-hidden="true" className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" /><span>{error}</span></p>}
|
||||
<div className="remote-dialog-actions"><Button variant="ghost" disabled={!!busy} onClick={() => setDisconnecting(null)}>{t("common.cancel")}</Button><Button variant="outline" className="min-w-0" disabled={!!busy} aria-busy={!!busy} onClick={() => { if (disconnecting) void disconnect(disconnecting.id); }}>{busy && <Loader2 aria-hidden className="mr-2 h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none" />}<span>{t("remote.disconnect")}</span></Button></div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
<Dialog open={!!removing} onOpenChange={(value) => { if (!value && !busy) setRemoving(null); }}>
|
||||
<DialogContent className="max-h-[85dvh] max-w-sm overflow-y-auto"><DialogHeader className="pr-5 text-left"><DialogTitle className="break-words leading-snug">{t(removalIsShared ? "remote.sameInstance.forgetTitle" : "remote.forgetTitle", { name: removalProfile?.name })}</DialogTitle><DialogDescription>{t(removalIsShared ? "remote.sameInstance.forgetHint" : "remote.forgetDescription")}</DialogDescription></DialogHeader>
|
||||
<DialogContent className="remote-dialog max-h-[85dvh] max-w-sm overflow-y-auto"><DialogHeader className="pr-5 text-left"><DialogTitle className="leading-snug [overflow-wrap:anywhere]">{t(removalIsShared ? "remote.sameInstance.forgetTitle" : "remote.forgetTitle", { name: removalProfile?.name })}</DialogTitle><DialogDescription>{t(removalIsShared ? "remote.sameInstance.forgetHint" : "remote.forgetDescription")}</DialogDescription></DialogHeader>
|
||||
{removalProfile && (removalProfile.connected || connections.openHostIds.includes(removalProfile.id)) && <p role="note" className="rounded-xl bg-muted/40 p-3 text-xs leading-5">{t("remote.activeForgetWarning")}</p>}
|
||||
{removalProfile?.paired && <div className="space-y-2 text-xs text-muted-foreground"><p>{t("remote.pair.forgetHint")}</p>{removalProfile.revoke_command && <CodeBlock language="bash" code={removalProfile.revoke_command} highlight={false} className="min-w-0 [&_pre]:[overflow-wrap:anywhere]" />}</div>}
|
||||
{error && <p role="alert" className="flex items-start gap-2 text-[13px] leading-5 text-foreground"><AlertCircle aria-hidden="true" className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" />{error}</p>}
|
||||
<div className="grid grid-cols-2 gap-2"><Button variant="ghost" disabled={!!busy} onClick={() => setRemoving(null)}>{t("common.cancel")}</Button><Button variant="destructive" className="h-auto min-h-10 min-w-0" disabled={!!busy} aria-busy={!!busy} onClick={() => { void remove(); }}>{busy && <Loader2 aria-hidden className="mr-2 h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none" />}<span className="whitespace-normal break-words">{t(removalIsShared ? "remote.sameInstance.forgetAction" : "remote.forget")}</span></Button></div>
|
||||
{removalProfile?.paired && <div className="space-y-2 text-xs leading-5 text-muted-foreground"><p>{t("remote.pair.forgetHint")}</p>{removalProfile.revoke_command && <CodeBlock language="bash" code={removalProfile.revoke_command} highlight={false} className="min-w-0 [&_pre]:[overflow-wrap:anywhere]" />}</div>}
|
||||
{error && <p role="alert" className="remote-alert items-start gap-2 text-[13px] leading-5 text-foreground"><AlertCircle aria-hidden="true" className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" /><span>{error}</span></p>}
|
||||
<div className="remote-dialog-actions"><Button variant="ghost" disabled={!!busy} onClick={() => setRemoving(null)}>{t("common.cancel")}</Button><Button variant="destructive" className="h-auto min-h-10 min-w-0" disabled={!!busy} aria-busy={!!busy} onClick={() => { void remove(); }}>{busy && <Loader2 aria-hidden className="mr-2 h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none" />}<span className="whitespace-normal break-words">{t(removalIsShared ? "remote.sameInstance.forgetAction" : "remote.forget")}</span></Button></div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>;
|
||||
|
||||
Reference in new issue
Block a user