Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix: preserve TopicChatDrawer state during close animation (#14803)

Tsuki081a0886aaf6
diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.test.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.test.tsx
index 71c9831c5bb..41e36d12ae1 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.test.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.test.tsx
@@ -55,6 +55,7 @@ vi.mock('@lobehub/ui', () => ({
open ? <div data-testid="topic-drawer">{children}</div> : null,
DropdownMenu: ({ children }: { children?: ReactNode }) => <>{children}</>,
Flexbox: ({ children }: { children?: ReactNode }) => <div>{children}</div>,
+ Freeze: ({ children }: { children?: ReactNode; frozen?: boolean }) => <>{children}</>,
Text: ({ children }: { children?: ReactNode }) => <span>{children}</span>,
}));
diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx
index bfc18f14812..a842fafba3a 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx
@@ -2,7 +2,15 @@
import type { ConversationContext } from '@lobechat/types';
import type { DropdownItem } from '@lobehub/ui';
-import { ActionIcon, copyToClipboard, Drawer, DropdownMenu, Flexbox, Text } from '@lobehub/ui';
+import {
+ ActionIcon,
+ copyToClipboard,
+ Drawer,
+ DropdownMenu,
+ Flexbox,
+ Freeze,
+ Text,
+} from '@lobehub/ui';
import { cssVar } from 'antd-style';
import { Copy, MoreHorizontal, Share2 } from 'lucide-react';
import dynamic from 'next/dynamic';
@@ -200,17 +208,20 @@ const TopicChatDrawer = memo(() => {
)
) : null;
+ // Freeze title/extra/body during the close animation so the drawer keeps
+ // its last rendered state instead of flashing to the empty/"untitled" view
+ // while topicId/agentId clear.
return (
<Drawer
destroyOnHidden
containerMaxWidth={'auto'}
- extra={extra}
+ extra={<Freeze frozen={!open}>{extra}</Freeze>}
getContainer={false}
mask={false}
open={open}
placement={'right'}
push={false}
- title={title}
+ title={<Freeze frozen={!open}>{title}</Freeze>}
width={640}
styles={{
body: { padding: 0 },
@@ -228,9 +239,11 @@ const TopicChatDrawer = memo(() => {
}}
onClose={closeTopicDrawer}
>
- {open && activeTaskId && (
- <TopicChatDrawerBody agentId={agentId!} taskId={activeTaskId} topicId={topicId!} />
- )}
+ <Freeze frozen={!open}>
+ {open && activeTaskId && (
+ <TopicChatDrawerBody agentId={agentId!} taskId={activeTaskId} topicId={topicId!} />
+ )}
+ </Freeze>
</Drawer>
);
});