import React, { useState, useCallback, useEffect } from 'react'; import { X } from 'lucide-react'; /** * Modal for adding (or editing) the in-the-loop human participant. * * The user enters a name and a freeform self-description (experience, * personality, etc.). On Approve the parent saves immediately and * generates the structured credential summary in the background. */ export default function HumanParticipantModal({ isOpen, initial, onClose, onSave, onRemove, }) { const [name, setName] = useState(''); const [profileText, setProfileText] = useState(''); useEffect(() => { if (!isOpen) return; setName(initial?.name || 'Pat'); setProfileText(initial?.profile_text || ''); }, [isOpen, initial]); const handleApprove = useCallback(() => { if (!name.trim()) return; if (!profileText.trim()) return; const pid = initial?.participant_id || `human_${Date.now()}`; onSave({ participant_id: pid, name: name.trim(), profile_text: profileText.trim(), }); }, [name, profileText, initial, onSave]); if (!isOpen) return null; return (