From d6b35465e52c438a4d02dc05b88f3a8d6496f7ad Mon Sep 17 00:00:00 2001 From: Henry Heng Date: Thu, 19 Dec 2024 13:36:32 +0000 Subject: [PATCH] Bugfix/Share Chatbot Config (#3742) fix chatbot config --- packages/ui/src/views/chatbot/index.jsx | 8 ++++---- packages/ui/src/views/chatflows/ShareChatbot.jsx | 14 ++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/packages/ui/src/views/chatbot/index.jsx b/packages/ui/src/views/chatbot/index.jsx index 4f247302..a0a77b06 100644 --- a/packages/ui/src/views/chatbot/index.jsx +++ b/packages/ui/src/views/chatbot/index.jsx @@ -88,12 +88,12 @@ const ChatbotFull = () => { parsedConfig = { ...parsedConfig, ...JSON.parse(chatflowData.chatbotConfig) } setChatbotTheme(parsedConfig) if (parsedConfig.overrideConfig) { - // Generate new sessionId - if (parsedConfig.overrideConfig.generateNewSession) { - parsedConfig.overrideConfig.sessionId = Date.now().toString() - } setChatbotOverrideConfig(parsedConfig.overrideConfig) } + + if (parsedConfig.generateNewSession) { + localStorage.removeItem(`${chatflowData.id}_EXTERNAL`) + } } catch (e) { console.error(e) setChatbotTheme(parsedConfig) diff --git a/packages/ui/src/views/chatflows/ShareChatbot.jsx b/packages/ui/src/views/chatflows/ShareChatbot.jsx index 165673d9..960378af 100644 --- a/packages/ui/src/views/chatflows/ShareChatbot.jsx +++ b/packages/ui/src/views/chatflows/ShareChatbot.jsx @@ -111,8 +111,7 @@ const ShareChatbot = ({ isSessionMemory, isAgentCanvas }) => { userMessage: { showAvatar: false }, - textInput: {}, - overrideConfig: {} + textInput: {} } if (title) obj.title = title if (titleAvatarSrc) obj.titleAvatarSrc = titleAvatarSrc @@ -137,7 +136,7 @@ const ShareChatbot = ({ isSessionMemory, isAgentCanvas }) => { if (textInputPlaceholder) obj.textInput.placeholder = textInputPlaceholder if (textInputSendButtonColor) obj.textInput.sendButtonColor = textInputSendButtonColor - if (isSessionMemory) obj.overrideConfig.generateNewSession = generateNewSession + if (isSessionMemory) obj.generateNewSession = generateNewSession if (renderHTML) { obj.renderHTML = true @@ -145,8 +144,6 @@ const ShareChatbot = ({ isSessionMemory, isAgentCanvas }) => { obj.renderHTML = false } - if (chatbotConfig?.starterPrompts) obj.starterPrompts = chatbotConfig.starterPrompts - if (isAgentCanvas) { // if showAgentMessages is undefined, default to true if (showAgentMessages === undefined || showAgentMessages === null) { @@ -156,9 +153,10 @@ const ShareChatbot = ({ isSessionMemory, isAgentCanvas }) => { } } - if (chatbotConfig?.fullFileUpload) obj.fullFileUpload = chatbotConfig?.fullFileUpload - - return obj + return { + ...chatbotConfig, + ...obj + } } const onSave = async () => {