mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-07 13:59:28 +08:00
feat(sessions): replace manual list with virtual list for better performance
This commit is contained in:
parent
75296babe3
commit
947695fdc7
@ -1,4 +1,5 @@
|
|||||||
import { Alert, Button, Spinner } from '@heroui/react'
|
import { Alert, Button, Spinner } from '@heroui/react'
|
||||||
|
import { DynamicVirtualList } from '@renderer/components/VirtualList'
|
||||||
import { useAgent } from '@renderer/hooks/agents/useAgent'
|
import { useAgent } from '@renderer/hooks/agents/useAgent'
|
||||||
import { useSessions } from '@renderer/hooks/agents/useSessions'
|
import { useSessions } from '@renderer/hooks/agents/useSessions'
|
||||||
import { useRuntime } from '@renderer/hooks/useRuntime'
|
import { useRuntime } from '@renderer/hooks/useRuntime'
|
||||||
@ -108,22 +109,25 @@ const Sessions: React.FC<SessionsProps> = ({ agentId }) => {
|
|||||||
</Button>
|
</Button>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
{sessions.map((session, index) => (
|
{/* h-9 */}
|
||||||
<motion.div
|
<DynamicVirtualList list={sessions} estimateSize={() => 9 * 4}>
|
||||||
key={session.id}
|
{(session, index) => (
|
||||||
initial={{ opacity: 0, x: 20 }}
|
<motion.div
|
||||||
animate={{ opacity: 1, x: 0 }}
|
key={session.id}
|
||||||
transition={{ duration: 0.3, delay: index * 0.05 }}>
|
initial={{ opacity: 0, x: 20 }}
|
||||||
<SessionItem
|
animate={{ opacity: 1, x: 0 }}
|
||||||
session={session}
|
transition={{ duration: 0.3, delay: index * 0.05 }}>
|
||||||
agentId={agentId}
|
<SessionItem
|
||||||
isDisabled={sessionWaiting[session.id]}
|
session={session}
|
||||||
isLoading={sessionWaiting[session.id]}
|
agentId={agentId}
|
||||||
onDelete={() => handleDeleteSession(session.id)}
|
isDisabled={sessionWaiting[session.id]}
|
||||||
onPress={() => setActiveSessionId(agentId, session.id)}
|
isLoading={sessionWaiting[session.id]}
|
||||||
/>
|
onDelete={() => handleDeleteSession(session.id)}
|
||||||
</motion.div>
|
onPress={() => setActiveSessionId(agentId, session.id)}
|
||||||
))}
|
/>
|
||||||
|
</motion.div>
|
||||||
|
)}
|
||||||
|
</DynamicVirtualList>
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user