"use client"; import { useState } from "react"; import { useTranslation } from "react-i18next"; import { Label } from "@kandev/ui/label"; import { Switch } from "@kandev/ui/switch"; import { ModelCombobox } from "@/components/settings/model-combobox"; import { FallbackOptionHelp, ModelFallbackSettingsShell, } from "@/components/settings/model-fallback-settings-shell"; // ModelFallbackFields renders the no-silent-model-fallback controls for the // inline CLI profile editor inside the shared fallback-settings disclosure. export function ModelFallbackFields({ availableModels, fallbackModel, fallbackModelGone, autoFallback, currentModelId, onFallbackModelChange, onAutoFallbackChange, }: { availableModels: { id: string; name: string }[]; fallbackModel: string; fallbackModelGone: boolean; autoFallback: boolean; currentModelId: string | undefined; onFallbackModelChange: (v: string) => void; onAutoFallbackChange: (v: boolean) => void; }) { const { t } = useTranslation(); // Checking the attached switch with no value yet must keep the selector // visible until a model is picked, so a transient local flag extends the // value-derived enabled state. const [optedIn, setOptedIn] = useState(false); const fallbackEnabled = Boolean(fallbackModel) || optedIn; return (

{t("settings:autoFallbackHelper")}

} explicitOption={
{ setOptedIn(checked); if (!checked) onFallbackModelChange(""); }} aria-label={t("settings:agentFallback")} />
{fallbackEnabled && ( )}

{autoFallback ? t("settings:agentFallbackDisabledHelper") : t("settings:agentFallbackHelper")}

} /> ); }