"use client"; /** * CapabilityConfigCard — section card hosted at the bottom of the chat * Activity panel that holds the configuration form for the active * capability (Quiz / Animator / Visualize / Research). * * The body (the actual form) is provided by the parent as children so this * card stays agnostic of which fields the capability collects. The card * provides the chrome: header (capability icon + label) and a confirm * footer that gates message sending. * * Sending a message is allowed only after the user clicks *Confirm*. Any * subsequent field edit invalidates the confirmation upstream (see * page.tsx), restoring the Confirm button. */ import { memo, type ReactNode } from "react"; import { BarChart3, Check, Clapperboard, Microscope, PenLine, type LucideIcon, } from "lucide-react"; import { useTranslation } from "react-i18next"; export type ConfigurableCapability = | "deep_question" | "math_animator" | "visualize" | "deep_research"; interface CapabilityChrome { icon: LucideIcon; label: string; } const CAPABILITY_CHROME: Record = { deep_question: { icon: PenLine, label: "Quiz settings" }, math_animator: { icon: Clapperboard, label: "Animator settings" }, visualize: { icon: BarChart3, label: "Visualize settings" }, deep_research: { icon: Microscope, label: "Research settings" }, }; interface CapabilityConfigCardProps { capability: ConfigurableCapability; confirmed: boolean; canConfirm: boolean; validationErrors?: string[]; onConfirm: () => void; children: ReactNode; } function CapabilityConfigCardInner({ capability, confirmed, canConfirm, validationErrors, onConfirm, children, }: CapabilityConfigCardProps) { const { t } = useTranslation(); const { icon: Icon, label } = CAPABILITY_CHROME[capability]; const hasErrors = !!validationErrors?.length; return (
{t(label)} {confirmed ? ( {t("Confirmed")} ) : ( {t("Required")} )}
{/* The form body provided by the parent (a bare ConfigPanel). */}
{children}
{hasErrors ? ( ) : null}
); } const CapabilityConfigCard = memo(CapabilityConfigCardInner); export default CapabilityConfigCard;