From 35c8bd88c7fabe6a0d6090ac3ff470f0778b945f Mon Sep 17 00:00:00 2001 From: Kalo Chin Date: Wed, 9 Jul 2025 01:36:03 +0900 Subject: [PATCH] Fix duplicate state declaration in embedded chatbot hooks Removed a duplicate declaration of the userSelectedConversation state in hooks.tsx to prevent potential state inconsistencies. Also made a minor formatting fix in the migration script for consistency. --- .../versions/2025_07_08_0001_add_always_new_chat.py | 4 ++-- web/app/components/base/chat/embedded-chatbot/hooks.tsx | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/api/migrations/versions/2025_07_08_0001_add_always_new_chat.py b/api/migrations/versions/2025_07_08_0001_add_always_new_chat.py index 6a2c136cc6..0310e37fa7 100644 --- a/api/migrations/versions/2025_07_08_0001_add_always_new_chat.py +++ b/api/migrations/versions/2025_07_08_0001_add_always_new_chat.py @@ -1,7 +1,7 @@ """add always_new_chat boolean field to apps and sites (default true) Revision ID: 0001_add_always_new_chat -Revises: +Revises: Create Date: 2025-07-08 00:00:00.000000 """ @@ -21,4 +21,4 @@ def upgrade(): def downgrade(): for table in ('apps', 'sites'): - op.drop_column(table, 'always_new_chat') \ No newline at end of file + op.drop_column(table, 'always_new_chat') diff --git a/web/app/components/base/chat/embedded-chatbot/hooks.tsx b/web/app/components/base/chat/embedded-chatbot/hooks.tsx index 8bafefbd10..8147a9ec30 100644 --- a/web/app/components/base/chat/embedded-chatbot/hooks.tsx +++ b/web/app/components/base/chat/embedded-chatbot/hooks.tsx @@ -120,6 +120,7 @@ export const useEmbeddedChatbot = () => { defaultValue: {}, }) const allowResetChat = !conversationId + const [userSelectedConversation, setUserSelectedConversation] = useState(false) const currentConversationId = useMemo(() => { if (appData?.site?.always_new_chat && !userSelectedConversation) return '' @@ -164,8 +165,6 @@ export const useEmbeddedChatbot = () => { ) const [showNewConversationItemInList, setShowNewConversationItemInList] = useState(false) - const [userSelectedConversation, setUserSelectedConversation] = useState(false) - const pinnedConversationList = useMemo(() => { return appPinnedConversationData?.data || [] }, [appPinnedConversationData])