Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix: prioritize URL conversation_id over localStorage in embedded chatbot (#35519)
treekimm5a7a95521057
diff --git a/web/app/components/base/chat/embedded-chatbot/__tests__/hooks.spec.tsx b/web/app/components/base/chat/embedded-chatbot/__tests__/hooks.spec.tsxindex b4f3f01070c..a6a35f4c7b3 100644--- a/web/app/components/base/chat/embedded-chatbot/__tests__/hooks.spec.tsx+++ b/web/app/components/base/chat/embedded-chatbot/__tests__/hooks.spec.tsx@@ -532,6 +532,7 @@ describe('useEmbeddedChatbot', () => {})it('handleChangeConversation updates current conversation and refetches chat list', async () => {+ mockStoreState.embeddedConversationId = nullconst { result } = await renderWithClient(() => useEmbeddedChatbot(AppSourceType.webApp))act(() => {@@ -548,6 +549,39 @@ describe('useEmbeddedChatbot', () => {expect(result.current.clearChatList).toBe(false)})+ // Scenario: URL-provided conversation_id should take precedence over localStorage value.+ it('should prioritize URL conversation_id over localStorage', async () => {+ localStorage.setItem(CONVERSATION_ID_INFO, JSON.stringify({+ 'app-1': { 'embedded-user-1': 'stored-conv-id' },+ }))+ mockStoreState.embeddedConversationId = 'url-conv-id'+ mockGetProcessedSystemVariablesFromUrlParams.mockResolvedValue({+ user_id: 'embedded-user-1',+ conversation_id: 'url-conv-id',+ })++ const { result } = await renderWithClient(() => useEmbeddedChatbot(AppSourceType.webApp))++ await waitFor(() => {+ expect(result.current.currentConversationId).toBe('url-conv-id')+ })+ })++ // Scenario: When no URL conversation_id is provided, fall back to localStorage.+ it('should fall back to localStorage when no URL conversation_id is provided', async () => {+ localStorage.setItem(CONVERSATION_ID_INFO, JSON.stringify({+ 'app-1': { DEFAULT: 'stored-conv-id' },+ }))+ mockStoreState.embeddedConversationId = null+ mockStoreState.embeddedUserId = null++ const { result } = await renderWithClient(() => useEmbeddedChatbot(AppSourceType.webApp))++ await waitFor(() => {+ expect(result.current.currentConversationId).toBe('stored-conv-id')+ })+ })+it('handleFeedback invokes updateFeedback service successfully', async () => {const { updateFeedback } = await import('@/service/share')const { result } = await renderWithClient(() => useEmbeddedChatbot(AppSourceType.webApp))diff --git a/web/app/components/base/chat/embedded-chatbot/hooks.tsx b/web/app/components/base/chat/embedded-chatbot/hooks.tsxindex 4ce6bc63180..39cbe66fbb1 100644--- a/web/app/components/base/chat/embedded-chatbot/hooks.tsx+++ b/web/app/components/base/chat/embedded-chatbot/hooks.tsx@@ -113,7 +113,7 @@ export const useEmbeddedChatbot = (appSourceType: AppSourceType, tryAppId?: stri})}, [setConversationIdInfo])const allowResetChat = !conversationId- const currentConversationId = useMemo(() => conversationIdInfo?.[appId || '']?.[userId || 'DEFAULT'] || conversationId || '', [appId, conversationIdInfo, userId, conversationId])+ const currentConversationId = useMemo(() => conversationId || conversationIdInfo?.[appId || '']?.[userId || 'DEFAULT'] || '', [appId, conversationIdInfo, userId, conversationId])const handleConversationIdInfoChange = useCallback((changeConversationId: string) => {if (appId) {let prevValue = conversationIdInfo?.[appId || '']