import React from "react"; import { RefreshCw, RotateCcw } from "lucide-react"; import { useI18n } from "../../../../application/i18n/I18nProvider"; import { Button } from "../../../ui/button"; import { Switch } from "../../../ui/switch"; import { cn } from "../../../../lib/utils"; import type { GrokRuntime } from "../../../../infrastructure/ai/types"; import type { AgentPathInfo } from "./types"; export const CopilotCliCard: React.FC<{ pathInfo: AgentPathInfo | null; isResolvingPath: boolean; customPath: string; onCustomPathChange: (path: string) => void; onRecheckPath: () => void; onResetPath?: () => void; i18nPrefix?: "ai.copilot" | "ai.cursor" | "ai.opencode" | "ai.grok"; allowEmptyCheck?: boolean; showCustomPathInput?: boolean; /** Grok only: ACP (default) vs headless streaming-json. */ grokRuntime?: GrokRuntime; onGrokRuntimeChange?: (runtime: GrokRuntime) => void; }> = ({ pathInfo, isResolvingPath, customPath, onCustomPathChange, onRecheckPath, onResetPath, i18nPrefix = "ai.copilot", allowEmptyCheck = false, showCustomPathInput = true, grokRuntime = "acp", onGrokRuntimeChange, }) => { const { t } = useI18n(); const found = pathInfo?.available; const showGrokRuntime = i18nPrefix === "ai.grok" && typeof onGrokRuntimeChange === "function"; const statusText = isResolvingPath ? t(`${i18nPrefix}.detecting`) : found ? t(`${i18nPrefix}.detected`) : t(`${i18nPrefix}.notFound`); const statusClassName = isResolvingPath ? "text-muted-foreground" : found ? "text-emerald-500" : "text-amber-500"; return (

{t(`${i18nPrefix}.description`)}

{statusText}
{found && (
{t(`${i18nPrefix}.path`)} {pathInfo.path} {pathInfo.version && ( <> | {pathInfo.version} )}
)} {!isResolvingPath && (
{!found && (

{t(`${i18nPrefix}.notFoundHint`)}

)}
{showCustomPathInput && ( onCustomPathChange(e.target.value)} placeholder={t(`${i18nPrefix}.customPathPlaceholder`)} className="flex-1 h-8 rounded-md border border-input bg-background px-3 text-sm font-mono placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring" /> )} {showCustomPathInput && onResetPath && ( )}
)} {showGrokRuntime && found && (
{t("ai.grok.runtime.acp.title")} {t("ai.grok.runtime.acp.default")}

{t("ai.grok.runtime.acp.description")}

{grokRuntime === "streaming-json" && (

{t("ai.grok.runtime.streamingJson.hint")}

)}
onGrokRuntimeChange?.(checked ? "acp" : "streaming-json") } />
)}
); };