"use client"; import { memo } from "react"; import { useTranslation } from "react-i18next"; import type { DeepResearchFormConfig, ResearchDepth, ResearchMode, } from "@/lib/research-types"; import { summarizeResearchConfig } from "@/lib/research-types"; import { CollapsibleConfigSection, Field, INPUT_CLS, } from "@/components/chat/home/composer-field"; interface ResearchConfigPanelProps { value: DeepResearchFormConfig; errors: Record; /** * When provided, the panel is wrapped in a `CollapsibleConfigSection`. * Omit both to render bare for the chat Activity panel. */ collapsed?: boolean; onChange: (next: DeepResearchFormConfig) => void; onToggleCollapsed?: () => void; } // Note: `label` values are i18n keys resolved via `t(...)` at render time so // the dropdown options match the active UI language. const MODE_OPTIONS: Array<{ value: Exclude; label: string }> = [ { value: "notes", label: "Study Notes" }, { value: "report", label: "Report" }, { value: "comparison", label: "Comparison" }, { value: "learning_path", label: "Learning Path" }, ]; const DEPTH_OPTIONS: Array<{ value: Exclude; label: string; }> = [ { value: "quick", label: "Quick" }, { value: "standard", label: "Standard" }, { value: "deep", label: "Deep" }, { value: "manual", label: "Manual" }, ]; function NumberSlider({ label, value, min, max, onChange, }: { label: string; value: number; min: number; max: number; onChange: (n: number) => void; }) { return (
{label} onChange(Number(e.target.value))} className="h-1 flex-1 cursor-pointer appearance-none rounded-full bg-[var(--muted-foreground)]/15 accent-[var(--primary)] [&::-webkit-slider-thumb]:h-3.5 [&::-webkit-slider-thumb]:w-3.5 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[var(--primary)]" /> {value}
); } export default memo(function ResearchConfigPanel({ value, errors: _errors, collapsed, onChange, onToggleCollapsed, }: ResearchConfigPanelProps) { const { t } = useTranslation(); const update = ( key: K, next: DeepResearchFormConfig[K], ) => onChange({ ...value, [key]: next }); const rawSummary = summarizeResearchConfig(value, t); const summary = rawSummary === t("Incomplete settings") ? undefined : rawSummary; const body = ( <>
{value.depth === "manual" && (
update("manual_subtopics", n)} /> update("manual_max_iterations", n)} />
)} ); if (collapsed === undefined) { return
{body}
; } return ( undefined)} bodyClassName="space-y-2 px-3.5 pb-2.5" > {body} ); });