This is an automated email from the ASF dual-hosted git repository.

EnxDev pushed a commit to branch test/chatbot-local
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 96f2fb36592fca777e7962750fa7f90441b2797b
Author: Enzo Martellucci <[email protected]>
AuthorDate: Wed May 27 09:57:05 2026 +0200

    fix(extensions): defer chatbot render until settings load; isolate provider 
errors
    
    - Don't call getActiveChatbot before settings arrive — start with null
      so no chatbot is rendered until the admin selection is known, avoiding
      a flash of the wrong chatbot when multiple are registered
    - On settings fetch failure fall back to first-to-register instead of
      rendering nothing forever
    - Wrap provider call in a ChatbotRenderer child component so
      ErrorBoundary actually catches provider-level throws (calling the
      provider inline during render means errors bubble before the boundary
      can mount)
    
    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
---
 superset-frontend/src/components/ChatbotMount/index.tsx | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/superset-frontend/src/components/ChatbotMount/index.tsx 
b/superset-frontend/src/components/ChatbotMount/index.tsx
index e85a0d3bf7c..87d4894a918 100644
--- a/superset-frontend/src/components/ChatbotMount/index.tsx
+++ b/superset-frontend/src/components/ChatbotMount/index.tsx
@@ -17,6 +17,7 @@
  * under the License.
  */
 import { useState, useEffect, useCallback } from 'react';
+import { ReactElement } from 'react';
 import { SupersetClient } from '@superset-ui/core';
 import { css, useTheme } from '@apache-superset/core/theme';
 import { ErrorBoundary } from 'src/components/ErrorBoundary';
@@ -27,12 +28,19 @@ import { CHATBOT_LOCATION } from 'src/views/contributions';
 
 const CHATBOT_EDGE_MARGIN = 24;
 
+type ActiveChatbot = { provider: () => ReactElement };
+
+// Renders the provider as a component so ErrorBoundary catches provider-level 
throws.
+const ChatbotRenderer = ({ provider }: { provider: () => ReactElement }) =>
+  provider();
+
 const ChatbotMount = () => {
   const theme = useTheme();
   const [adminSelectedId, setAdminSelectedId] = useState<string | null>(null);
   const [enabledMap, setEnabledMap] = useState<Record<string, boolean>>({});
-  const [activeChatbot, setActiveChatbot] = useState(() =>
-    getActiveChatbot(null, {}),
+  // null = settings not yet loaded; don't render anything until settings 
arrive.
+  const [activeChatbot, setActiveChatbot] = useState<ActiveChatbot | null>(
+    null,
   );
 
   const fetchSettings = useCallback(() => {
@@ -48,6 +56,7 @@ const ChatbotMount = () => {
       })
       .catch(() => {
         // Settings fetch failure is non-fatal — fall back to 
first-to-register.
+        setActiveChatbot(getActiveChatbot(null, {}));
       });
     return () => {
       cancelled = true;
@@ -81,7 +90,9 @@ const ChatbotMount = () => {
         z-index: ${theme.zIndexPopupBase + 2};
       `}
     >
-      <ErrorBoundary>{activeChatbot.provider()}</ErrorBoundary>
+      <ErrorBoundary>
+        <ChatbotRenderer provider={activeChatbot.provider} />
+      </ErrorBoundary>
     </div>
   );
 };

Reply via email to