import { Input } from '@/components/ui/input' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select' import { Switch } from '@/components/ui/switch' import { Textarea } from '@/components/ui/textarea' import { Tip } from '@/components/ui/tooltip' import { useI18n } from '@/i18n' import { Check, Info } from '@/lib/icons' import type { MemoryProviderField } from '@/types/hermes' import { CONTROL_TEXT } from '../constants' // Fade the placeholder well below set values so example text never reads as data. const FIELD_INPUT = `font-mono ${CONTROL_TEXT} placeholder:text-muted-foreground/45` // Field label with an optional info tooltip, shared by the panel and modal rows. export function FieldTitle({ field }: { field: MemoryProviderField }) { const { t } = useI18n() if (!field.info) { return <>{field.label} } return ( {field.label} ) } // Values are edited as strings; the backend coerces them to native types. export function FieldControl({ field, value, onChange, onCommit }: { field: MemoryProviderField value: string onChange: (value: string) => void // Present on autosaving surfaces: discrete controls commit on change, text-like // controls commit on blur. Absent (the modal), edits stay drafts until Save. onCommit?: (value: string) => void }) { const { t } = useI18n() const set = (next: string) => { onChange(next) onCommit?.(next) } const commitDraft = onCommit ? () => onCommit(value) : undefined if (field.kind === 'bool') { return set(checked ? 'true' : 'false')} /> } if (field.kind === 'number') { return ( onChange(event.target.value)} placeholder={field.placeholder} type="number" value={value} /> ) } if (field.kind === 'json') { return (