diff --git a/src/renderer/src/components/Popups/agent/AgentModal.tsx b/src/renderer/src/components/Popups/agent/AgentModal.tsx index ea772fb1e6..d190c33179 100644 --- a/src/renderer/src/components/Popups/agent/AgentModal.tsx +++ b/src/renderer/src/components/Popups/agent/AgentModal.tsx @@ -1,6 +1,5 @@ import { Button, - cn, Form, Input, Modal, @@ -34,7 +33,7 @@ import { UpdateAgentForm } from '@renderer/types' import { AlertTriangleIcon } from 'lucide-react' -import { ChangeEvent, FormEvent, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react' +import { ChangeEvent, FormEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import { ErrorBoundary } from '../../ErrorBoundary' @@ -57,43 +56,30 @@ const buildAgentForm = (existing?: AgentWithTools): BaseAgentForm => ({ name: existing?.name ?? 'Claude Code', description: existing?.description, instructions: existing?.instructions, - model: existing?.model ?? 'claude-4-sonnet', + model: existing?.model ?? '', accessible_paths: existing?.accessible_paths ? [...existing.accessible_paths] : [], allowed_tools: existing?.allowed_tools ? [...existing.allowed_tools] : [], mcps: existing?.mcps ? [...existing.mcps] : [], configuration: AgentConfigurationSchema.parse(existing?.configuration ?? {}) }) -interface BaseProps { +type Props = { agent?: AgentWithTools -} - -interface TriggerProps extends BaseProps { - trigger: { content: ReactNode; className?: string } - isOpen?: never - onClose?: never -} - -interface StateProps extends BaseProps { - trigger?: never isOpen: boolean onClose: () => void } -type Props = TriggerProps | StateProps - /** * Modal component for creating or editing an agent. * * Either trigger or isOpen and onClose is given. * @param agent - Optional agent entity for editing mode. - * @param trigger - Optional trigger element that opens the modal. It MUST propagate the click event to trigger the modal. * @param isOpen - Optional controlled modal open state. From useDisclosure. * @param onClose - Optional callback when modal closes. From useDisclosure. * @returns Modal component for agent creation/editing */ -export const AgentModal: React.FC = ({ agent, trigger, isOpen: _isOpen, onClose: _onClose }) => { - const { isOpen, onClose, onOpen } = useDisclosure({ isOpen: _isOpen, onClose: _onClose }) +export const AgentModal: React.FC = ({ agent, isOpen: _isOpen, onClose: _onClose }) => { + const { isOpen, onClose } = useDisclosure({ isOpen: _isOpen, onClose: _onClose }) const { t } = useTranslation() const loadingRef = useRef(false) // const { setTimeoutTimer } = useTimer() @@ -359,23 +345,6 @@ export const AgentModal: React.FC = ({ agent, trigger, isOpen: _isOpen, o return ( - {/* NOTE: Hero UI Modal Pattern: Combine the Button and Modal components into a single - encapsulated component. This is because the Modal component needs to bind the onOpen - event handler to the Button for proper focus management. - - Or just use external isOpen/onOpen/onClose to control modal state. - */} - - {trigger && ( -
{ - e.stopPropagation() - onOpen() - }} - className={cn('w-full', trigger.className)}> - {trigger.content} -
- )} = ({ onCreateAssistant }) => { const { t } = useTranslation() const [isPopoverOpen, setIsPopoverOpen] = useState(false) - const [isAgentModalOpen, setIsAgentModalOpen] = useState(false) + const { isOpen: isAgentModalOpen, onOpen: onAgentModalOpen, onClose: onAgentModalClose } = useDisclosure() const handleAddAssistant = () => { setIsPopoverOpen(false) @@ -22,7 +22,7 @@ const UnifiedAddButton: FC = ({ onCreateAssistant }) => { const handleAddAgent = () => { setIsPopoverOpen(false) - setIsAgentModalOpen(true) + onAgentModalOpen() } return ( @@ -53,7 +53,7 @@ const UnifiedAddButton: FC = ({ onCreateAssistant }) => { - setIsAgentModalOpen(false)} /> + ) }