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


##########
superset-frontend/src/explore/components/DataTablesPane/DataTablesPane.tsx:
##########
@@ -197,25 +197,34 @@ export const DataTablesPane = ({
     children: pane,
   }));
 
+  // 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;

Review Comment:
   **Suggestion:** Conditionally removing the Samples tab can leave the 
currently selected tab pointing to a key that no longer exists when the 
datasource changes from supporting samples to not supporting them. In that 
state the panel can render with no active pane and no results request, so users 
see an empty data panel until they manually recover. Add a synchronization step 
that forces the active tab back to Results whenever samples become unsupported. 
[logic error]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   ❌ Explore data panel can show blank content after switch.
   ⚠️ Samples request flag set but SamplesPane no longer mounted.
   ❌ Users must manually recover by clicking a Results tab.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Open the Explore view for a chart whose datasource supports samples; this 
renders
   `ExploreChartPanel` at
   
`superset-frontend/src/explore/components/ExploreChartPanel/index.tsx:553-564`, 
which
   includes `DataTablesPane` with the current `datasource` prop.
   
   2. In the Explore data panel, click the “Samples” tab; this triggers 
`handleTabClick` in
   `DataTablesPane` at `DataTablesPane.tsx:143-152`, setting `activeTabKey` to
   `ResultTypes.Samples` (`'samples'`) and causing the samples request branch 
in the effect
   at `DataTablesPane.tsx:107-133` to set `isRequest.samples` to `true`.
   
   3. While the panel remains open on the Samples tab, switch the datasource in 
Explore to a
   semantic view whose `datasource.supports_samples` is `false`; 
`ExploreChartPanel`
   re-renders and passes the new `datasource` into `DataTablesPane` 
(index.tsx:553-564),
   where `showSamplesTab` at `DataTablesPane.tsx:204` becomes `false` and 
`tabItems` at
   `DataTablesPane.tsx:205-228` is recomputed without any item whose `key` is
   `ResultTypes.Samples`.
   
   4. Observe that `activeTabKey` remains `'samples'` because there is no 
effect syncing it
   to `ResultTypes.Results` when `showSamplesTab` changes, and `Tabs` at
   `DataTablesPane.tsx:232-237` is rendered with `activeKey={panelOpen ? 
activeTabKey : ''}`
   but `items={tabItems}` containing only results tabs. With an `activeKey` 
that no longer
   matches any tab item, the data panel renders without a visible active tab or 
content, and
   since `SamplesPane` is no longer mounted, no new results request is issued 
until the user
   manually clicks a results tab to recover.
   ```
   </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=b97441e16bd34446bc5b7f4112f72293&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=b97441e16bd34446bc5b7f4112f72293&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:** 204:204
   **Comment:**
        *Logic Error: Conditionally removing the Samples tab can leave the 
currently selected tab pointing to a key that no longer exists when the 
datasource changes from supporting samples to not supporting them. In that 
state the panel can render with no active pane and no results request, so users 
see an empty data panel until they manually recover. Add a synchronization step 
that forces the active tab back to Results whenever samples become unsupported.
   
   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=0a13accf9ceec71eff18bb075b36ce4c56b96d4664fa8107fceb0741fef71355&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41509&comment_hash=0a13accf9ceec71eff18bb075b36ce4c56b96d4664fa8107fceb0741fef71355&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