"use client"; import { useEffect } from "react"; import { AnimatePresence, motion, useReducedMotion } from "framer-motion"; import { CheckCircleIcon } from "@/components/icons"; import { useI18n } from "@/lib/i18n"; import { springSheet } from "@/lib/motion"; import { useIsPhone } from "@/lib/use-phone"; import type { ChatModelChoice } from "@/lib/chat"; import { cn } from "@/lib/utils"; /** * Model chip picker: a bottom sheet on phones, a small dropdown on desktop. * The list is the server's CHAT_MODELS allowlist (from the health check) with * text/vision badges and availability; picking one remembers it. */ export function ModelPicker({ open, onClose, models, value, onChange, }: { open: boolean; onClose: () => void; models: ChatModelChoice[]; value: string; onChange: (model: string) => void; }) { const { t } = useI18n(); const isPhone = useIsPhone(); const reduceMotion = useReducedMotion(); useEffect(() => { if (!open) return; const onKey = (event: KeyboardEvent) => { if (event.key === "Escape") onClose(); }; window.addEventListener("keydown", onKey); return () => window.removeEventListener("keydown", onKey); }, [open, onClose]); const badge = (model: ChatModelChoice) => model.badge === "vision" ? t("chat.modelVision") : model.badge === "both" ? t("chat.modelBoth") : t("chat.modelText"); const rows = (
{t("chat.modelNote")}
{t("chat.modelNote")}