From 6c233fef9f7a7ab96f56bda270528c7f6070e1c2 Mon Sep 17 00:00:00 2001 From: suyao Date: Sat, 20 Sep 2025 15:55:42 +0800 Subject: [PATCH] Add smooth animations to SessionsTab and Sessions components - Replace static conditional rendering with Framer Motion animations for no-agent and session states - Animate session list items with staggered entrance and exit transitions - Add loading spinner animation with fade effect - Apply motion to session creation button with delayed entrance --- .../src/pages/home/Tabs/SessionsTab.tsx | 30 ++++++-- .../pages/home/Tabs/components/Sessions.tsx | 74 +++++++++++++------ 2 files changed, 74 insertions(+), 30 deletions(-) diff --git a/src/renderer/src/pages/home/Tabs/SessionsTab.tsx b/src/renderer/src/pages/home/Tabs/SessionsTab.tsx index 57d5f0fe09..b1adc7c04f 100644 --- a/src/renderer/src/pages/home/Tabs/SessionsTab.tsx +++ b/src/renderer/src/pages/home/Tabs/SessionsTab.tsx @@ -1,4 +1,5 @@ import { useRuntime } from '@renderer/hooks/useRuntime' +import { AnimatePresence,motion } from 'framer-motion' import { FC, memo } from 'react' import Sessions from './components/Sessions' @@ -9,14 +10,29 @@ const SessionsTab: FC = () => { const { chat } = useRuntime() const { activeAgentId } = chat - if (!activeAgentId) { - return
No active agent.
- } - return ( - <> - - + + {!activeAgentId ? ( + + No active agent. + + ) : ( + + + + )} + ) } diff --git a/src/renderer/src/pages/home/Tabs/components/Sessions.tsx b/src/renderer/src/pages/home/Tabs/components/Sessions.tsx index 4d775ef5ae..5de522d49f 100644 --- a/src/renderer/src/pages/home/Tabs/components/Sessions.tsx +++ b/src/renderer/src/pages/home/Tabs/components/Sessions.tsx @@ -3,6 +3,7 @@ import { SessionModal } from '@renderer/components/Popups/agent/SessionModal' import { useSessions } from '@renderer/hooks/agents/useSessions' import { useAppDispatch } from '@renderer/store' import { setActiveSessionIdAction, setActiveTopicOrSessionAction } from '@renderer/store/runtime' +import { AnimatePresence,motion } from 'framer-motion' import { Plus } from 'lucide-react' import { memo, useCallback } from 'react' import { useTranslation } from 'react-i18next' @@ -28,36 +29,63 @@ const Sessions: React.FC = ({ agentId }) => { [dispatch] ) - if (isLoading) return + if (isLoading) { + return ( + + + + ) + } // if (error) return return ( -
+ {/* TODO: Add session button */} - e.continuePropagation()} - className="mb-2 w-full justify-start bg-transparent text-foreground-500 hover:bg-accent"> - - {t('agent.session.add.title')} - - ) - }} - /> - {sessions.map((session) => ( - + deleteSession(session.id)} - onPress={() => setActiveSessionId(agentId, session.id)} + trigger={{ + content: ( + + ) + }} /> - ))} -
+ + + {sessions.map((session, index) => ( + + deleteSession(session.id)} + onPress={() => setActiveSessionId(agentId, session.id)} + /> + + ))} + + ) }