From 7140950e933aa7f86a182892ecbb4dba8e72e47f Mon Sep 17 00:00:00 2001 From: Hu Hao <92927055+Zwanan-github@users.noreply.github.com> Date: Mon, 24 Nov 2025 10:27:22 +0800 Subject: [PATCH] =?UTF-8?q?Feat:=20Implement=20temporary=20conversation=20?= =?UTF-8?q?removal=20logic=20in=20ConversationD=E2=80=A6=20(#11454)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### What problem does this PR solve? Implement temporary conversation removal logic in ConversationDropDown Before modification: 图片 After modification: 图片 图片 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) - [x] New Feature (non-breaking change which adds functionality) --------- Co-authored-by: Kevin Hu --- .../next-chats/chat/conversation-dropdown.tsx | 16 ++++++++++++++-- web/src/pages/next-chats/chat/sessions.tsx | 6 +++++- .../hooks/use-select-conversation-list.ts | 9 +++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/web/src/pages/next-chats/chat/conversation-dropdown.tsx b/web/src/pages/next-chats/chat/conversation-dropdown.tsx index 83193f57c..27bed0a7e 100644 --- a/web/src/pages/next-chats/chat/conversation-dropdown.tsx +++ b/web/src/pages/next-chats/chat/conversation-dropdown.tsx @@ -14,16 +14,28 @@ import { useTranslation } from 'react-i18next'; export function ConversationDropdown({ children, conversation, + removeTemporaryConversation, }: PropsWithChildren & { conversation: IConversation; + removeTemporaryConversation?: (conversationId: string) => void; }) { const { t } = useTranslation(); const { removeConversation } = useRemoveConversation(); const handleDelete: MouseEventHandler = useCallback(() => { - removeConversation([conversation.id]); - }, [conversation.id, removeConversation]); + if (conversation.is_new && removeTemporaryConversation) { + removeTemporaryConversation(conversation.id); + removeConversation([]); + } else { + removeConversation([conversation.id]); + } + }, [ + conversation.id, + conversation.is_new, + removeConversation, + removeTemporaryConversation, + ]); return ( diff --git a/web/src/pages/next-chats/chat/sessions.tsx b/web/src/pages/next-chats/chat/sessions.tsx index 98b707374..15433b38d 100644 --- a/web/src/pages/next-chats/chat/sessions.tsx +++ b/web/src/pages/next-chats/chat/sessions.tsx @@ -29,6 +29,7 @@ export function Sessions({ const { list: conversationList, addTemporaryConversation, + removeTemporaryConversation, handleInputChange, searchString, } = useSelectDerivedConversationList(); @@ -97,7 +98,10 @@ export function Sessions({ >
{x.name}
- +
diff --git a/web/src/pages/next-chats/hooks/use-select-conversation-list.ts b/web/src/pages/next-chats/hooks/use-select-conversation-list.ts index a40c57a0c..a37d3078b 100644 --- a/web/src/pages/next-chats/hooks/use-select-conversation-list.ts +++ b/web/src/pages/next-chats/hooks/use-select-conversation-list.ts @@ -80,6 +80,14 @@ export const useSelectDerivedConversationList = () => { }); }, [conversationList, dialogId, prologue, t, setNewConversationRouteParams]); + const removeTemporaryConversation = useCallback((conversationId: string) => { + setList((prevList) => { + return prevList.filter( + (conversation) => conversation.id !== conversationId, + ); + }); + }, []); + // When you first enter the page, select the top conversation card useEffect(() => { @@ -89,6 +97,7 @@ export const useSelectDerivedConversationList = () => { return { list, addTemporaryConversation, + removeTemporaryConversation, loading, handleInputChange, searchString,