diff --git a/src/renderer/src/pages/home/Tabs/components/Sessions.tsx b/src/renderer/src/pages/home/Tabs/components/Sessions.tsx index a8ccab7d00..f3bfed18d6 100644 --- a/src/renderer/src/pages/home/Tabs/components/Sessions.tsx +++ b/src/renderer/src/pages/home/Tabs/components/Sessions.tsx @@ -1,9 +1,10 @@ -import { Button, Spinner } from '@heroui/react' -import { SessionModal } from '@renderer/components/Popups/agent/SessionModal' +import { Alert, Button, Spinner } from '@heroui/react' +import { useAgent } from '@renderer/hooks/agents/useAgent' import { useSessions } from '@renderer/hooks/agents/useSessions' import { useRuntime } from '@renderer/hooks/useRuntime' import { useAppDispatch } from '@renderer/store' import { setActiveSessionIdAction, setActiveTopicOrSessionAction } from '@renderer/store/runtime' +import { CreateSessionForm } from '@renderer/types' import { AnimatePresence, motion } from 'framer-motion' import { Plus } from 'lucide-react' import { memo, useCallback, useEffect } from 'react' @@ -19,7 +20,8 @@ interface SessionsProps { const Sessions: React.FC = ({ agentId }) => { const { t } = useTranslation() - const { sessions, isLoading, deleteSession } = useSessions(agentId) + const { agent } = useAgent(agentId) + const { sessions, isLoading, error, deleteSession, createSession } = useSessions(agentId) const { chat } = useRuntime() const { activeSessionId } = chat const dispatch = useAppDispatch() @@ -32,6 +34,15 @@ const Sessions: React.FC = ({ agentId }) => { [dispatch] ) + const handleCreateSession = useCallback(() => { + if (!agent) return + const session = { + ...agent, + id: undefined + } satisfies CreateSessionForm + createSession(session) + }, [agent, createSession]) + const currentActiveSessionId = activeSessionId[agentId] useEffect(() => { @@ -52,7 +63,7 @@ const Sessions: React.FC = ({ agentId }) => { ) } - // if (error) return + if (error) return return ( = ({ agentId }) => { initial={{ opacity: 0, y: -10 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.2, delay: 0.1 }}> - setActiveSessionId(agentId, created.id)} - trigger={{ - content: ( - - ) - }} - /> + {sessions.map((session, index) => (