fix(AgentEssentialSettings): handle undefined name and description states

Ensure proper handling of undefined values for agent name and description by making state types optional. Also update the updateName function to handle optional name input.
This commit is contained in:
icarus 2025-09-25 23:21:11 +08:00
parent 14f14b75b0
commit 5c7784622e

View File

@ -19,13 +19,13 @@ interface AgentEssentialSettingsProps {
const AgentEssentialSettings: FC<AgentEssentialSettingsProps> = ({ agent, update }) => {
const { t } = useTranslation()
const [name, setName] = useState<string>((agent?.name ?? '').trim())
const [description, setDescription] = useState<string>((agent?.description ?? '').trim())
const [name, setName] = useState<string | undefined>(agent?.name?.trim())
const [description, setDescription] = useState<string | undefined>(agent?.description?.trim())
const { models } = useApiModels({ providerType: 'anthropic' })
const updateName = (name: string) => {
const updateName = (name: UpdateAgentForm['name']) => {
if (!agent) return
update({ id: agent.id, name: name.trim() })
update({ id: agent.id, name: name?.trim() })
}
const updateModel = (model: UpdateAgentForm['model']) => {