diff --git a/components/Terminal.tsx b/components/Terminal.tsx index e96f5f169..0d756f544 100644 --- a/components/Terminal.tsx +++ b/components/Terminal.tsx @@ -218,7 +218,7 @@ const TerminalComponent: React.FC = ({ // Pending connection credentials (set after auth dialog submit) const pendingAuthRef = useRef<{ - authMethod: "password" | "key"; + authMethod: "password" | "key" | "certificate"; username: string; password?: string; keyId?: string; @@ -722,7 +722,9 @@ const TerminalComponent: React.FC = ({ // SSH connection (default) // Check if host needs authentication info const hasPassword = host.authMethod === "password" && host.password; - const hasKey = host.authMethod === "key" && host.identityFileId; + const hasKey = + (host.authMethod === "key" || host.authMethod === "certificate") && + host.identityFileId; const hasPendingAuth = pendingAuthRef.current; if (!hasPassword && !hasKey && !hasPendingAuth && !host.username) { @@ -1114,7 +1116,7 @@ const TerminalComponent: React.FC = ({ : undefined; // Prepare jump host chain configuration - const jumpHosts = resolvedChainHosts.map((jumpHost) => { + const jumpHosts = resolvedChainHosts.map((jumpHost) => { const jumpKey = jumpHost.identityFileId ? keys.find((k) => k.id === jumpHost.identityFileId) : undefined; @@ -1674,7 +1676,7 @@ const TerminalComponent: React.FC = ({ const isAuthValid = () => { if (!authUsername.trim()) return false; if (authMethod === "password") return authPassword.trim().length > 0; - if (authMethod === "key") return !!authKeyId; + if (authMethod === "key" || authMethod === "certificate") return !!authKeyId; return false; }; @@ -1686,8 +1688,14 @@ const TerminalComponent: React.FC = ({ authMethod, username: authUsername, password: authMethod === "password" ? authPassword : undefined, - keyId: authMethod === "key" ? (authKeyId ?? undefined) : undefined, - passphrase: authMethod === "key" ? authPassphrase || undefined : undefined, + keyId: + authMethod === "key" || authMethod === "certificate" + ? (authKeyId ?? undefined) + : undefined, + passphrase: + authMethod === "key" || authMethod === "certificate" + ? authPassphrase || undefined + : undefined, }; // Save credentials to host if requested @@ -1697,7 +1705,10 @@ const TerminalComponent: React.FC = ({ username: authUsername, authMethod: authMethod, password: authMethod === "password" ? authPassword : undefined, - identityFileId: authMethod === "key" ? (authKeyId ?? undefined) : undefined, + identityFileId: + authMethod === "key" || authMethod === "certificate" + ? (authKeyId ?? undefined) + : undefined, }; onUpdateHost(updatedHost); } diff --git a/components/terminal/TerminalAuthDialog.tsx b/components/terminal/TerminalAuthDialog.tsx index 4448fb66c..dcb376a7d 100644 --- a/components/terminal/TerminalAuthDialog.tsx +++ b/components/terminal/TerminalAuthDialog.tsx @@ -11,7 +11,7 @@ import { Input } from '../ui/input'; import { Label } from '../ui/label'; import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover'; -export type TerminalAuthMethod = 'password' | 'key'; +export type TerminalAuthMethod = 'password' | 'key' | 'certificate'; export interface TerminalAuthDialogProps { authMethod: TerminalAuthMethod; @@ -64,8 +64,11 @@ export const TerminalAuthDialog: React.FC = ({ } }; - // Show all keys (both regular keys and certificates) when in key mode - const selectableKeys = keys.filter((k) => k.category === 'key' || Boolean(k.certificate?.trim())); + // Show all keys (both regular keys and certificates) in the single key picker. + const selectableKeys = React.useMemo( + () => keys.filter((k) => k.category === 'key' || Boolean(k.certificate?.trim())), + [keys], + ); const [keyDropdownOpen, setKeyDropdownOpen] = React.useState(false); @@ -90,7 +93,7 @@ export const TerminalAuthDialog: React.FC = ({