codeant-ai-for-open-source[bot] commented on code in PR #41509:
URL: https://github.com/apache/superset/pull/41509#discussion_r3694139620


##########
superset-frontend/src/explore/components/DataTablesPane/DataTablesPane.tsx:
##########
@@ -241,25 +241,44 @@ export const DataTablesPane = ({
     }
   }, [resultsTabFallback]);
 
+  // Hide the Samples tab for datasources that don't expose raw rows
+  // (e.g. semantic views). The check is intentionally ``=== false`` so that
+  // datasources from older backends that don't send the flag still show the
+  // tab and preserve current behavior.
+  const showSamplesTab = datasource?.supports_samples !== false;
+
+  // If the datasource swaps to one that doesn't support samples while the
+  // Samples tab is active (e.g. the user picks a semantic view), the tab
+  // disappears from ``tabItems`` and ``activeTabKey`` is orphaned. Fall back
+  // to Results so the panel keeps rendering content.
+  useEffect(() => {
+    if (!showSamplesTab && activeTabKey === ResultTypes.Samples) {
+      setActiveTabKey(ResultTypes.Results);
+    }
+  }, [showSamplesTab, activeTabKey]);

Review Comment:
   **Suggestion:** When the datasource changes while `Samples` is active, this 
effect updates `activeTabKey` only after the first render. That render passes 
`activeKey="samples"` to `Tabs` even though the Samples item has already been 
removed, so Ant Design can briefly render an empty data panel before the effect 
runs. Derive a valid active key synchronously for the `Tabs` component or use a 
layout-time fallback. [state/lifecycle]
   
   <details>
   <summary><b>Severity Level:</b> Minor ๐Ÿงน</summary>
   
   ```mdx
   - โš ๏ธ Datasource switching can briefly blank the Explore data panel.
   - โš ๏ธ Results content appears only after the fallback effect rerenders.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=385a88afd9c44ea398b685c8b86bf290&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=385a88afd9c44ea398b685c8b86bf290&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/src/explore/components/DataTablesPane/DataTablesPane.tsx
   **Line:** 254:258
   **Comment:**
        *State Lifecycle: When the datasource changes while `Samples` is 
active, this effect updates `activeTabKey` only after the first render. That 
render passes `activeKey="samples"` to `Tabs` even though the Samples item has 
already been removed, so Ant Design can briefly render an empty data panel 
before the effect runs. Derive a valid active key synchronously for the `Tabs` 
component or use a layout-time fallback.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41509&comment_hash=b94f1e1fd82c32103977c9488a822268311c93a9c113ce712ae5a941d0b7d6b2&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41509&comment_hash=b94f1e1fd82c32103977c9488a822268311c93a9c113ce712ae5a941d0b7d6b2&reaction=dislike'>๐Ÿ‘Ž</a>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to