"use client"; import { useState, useCallback } from "react"; import { IconTerminal2, IconCopy, IconCheck } from "@tabler/icons-react"; import { Button } from "@kandev/ui/button"; import { Tooltip, TooltipContent, TooltipTrigger } from "@kandev/ui/tooltip"; import type { RecoveryAuthMethod } from "@/components/task/chat/types"; function buildFullCommand(termAuth: RecoveryAuthMethod["terminal_auth"]): string | null { if (!termAuth) return null; if (termAuth.args && termAuth.args.length > 0) { return `${termAuth.command} ${termAuth.args.join(" ")}`; } return termAuth.command; } export function AuthMethodsPanel({ methods, onOpenTerminal, }: { methods: RecoveryAuthMethod[]; onOpenTerminal: (command: string) => void; }) { return (
Authentication required, log in before resuming
{methods.map((method) => ( ))}
); } export function GenericAuthPanel({ onOpenTerminal }: { onOpenTerminal: () => void }) { return (
Authentication required — please log in via the terminal
); } function AuthMethodRow({ method, onOpenTerminal, }: { method: RecoveryAuthMethod; onOpenTerminal: (command: string) => void; }) { const [copied, setCopied] = useState(false); const termAuth = method.terminal_auth; const fullCommand = buildFullCommand(termAuth); const handleCopy = useCallback(async () => { if (!fullCommand) return; try { await navigator.clipboard.writeText(fullCommand); setCopied(true); setTimeout(() => setCopied(false), 2000); } catch { // clipboard API unavailable } }, [fullCommand]); return (
{method.name}
{termAuth && fullCommand ? (
{fullCommand}
Copy command Open the bottom terminal and paste this command
) : (
{method.description || "Login required"}
)}
); }