"use client"; import { memo, useCallback } from "react"; import { IconKey, IconTerminal2 } from "@tabler/icons-react"; import { Button } from "@kandev/ui/button"; import { Popover, PopoverContent, PopoverTrigger } from "@kandev/ui/popover"; import { useAppStore } from "@/components/state-provider"; import { authenticateSession } from "@/lib/api/domains/session-api"; type AuthMethodsIndicatorProps = { sessionId: string | null; }; export const AuthMethodsIndicator = memo(function AuthMethodsIndicator({ sessionId, }: AuthMethodsIndicatorProps) { const authMethods = useAppStore((state) => { if (!sessionId) return undefined; return state.agentCapabilities.bySessionId[sessionId]?.authMethods; }); const handleAuthenticate = useCallback( async (methodId: string) => { if (!sessionId) return; try { await authenticateSession(sessionId, methodId); } catch { // Auth call failed — agent will report via events if successful } }, [sessionId], ); if (!sessionId || !authMethods || authMethods.length === 0) { return null; } return (
Authentication
{authMethods.map((method) => (
{method.name}
{method.description && (
{method.description}
)} {method.terminalAuth ? (
{method.terminalAuth.command} {method.terminalAuth.args ? ` ${method.terminalAuth.args.join(" ")}` : ""}
) : ( )}
))}
); });