codeant-ai-for-open-source[bot] commented on code in PR #43228:
URL: https://github.com/apache/superset/pull/43228#discussion_r3790342626
##########
superset-frontend/src/components/Chart/chartReducer.ts:
##########
@@ -223,6 +223,11 @@ export default function chartReducer(
}
if (action.type in actionHandlers) {
+ // handlers read the previous chart state, which is gone if the chart was
+ // removed while one of its actions was still in flight
+ if (!charts[action.key]) {
+ return charts;
+ }
Review Comment:
**Suggestion:** The missing-state guard applies to `ADD_CHART` as well as
actions that require an existing chart. Since `addSliceToDashboard` dispatches
`ADD_CHART` precisely for a key not yet present, this returns the unchanged map
and prevents dynamically added dashboard charts from entering Redux state.
Handle `ADD_CHART` before this guard or exclude it from the missing-chart
check. [api mismatch]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Dynamically added dashboard charts never enter Redux state.
- ❌ Dashboard layout additions fail to render.
- ⚠️ Subsequent chart actions also have no chart state.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=e790d0f461104d74857708a6a6da0152&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=e790d0f461104d74857708a6a6da0152&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/src/components/Chart/chartReducer.ts
**Line:** 228:230
**Comment:**
*Api Mismatch: The missing-state guard applies to `ADD_CHART` as well
as actions that require an existing chart. Since `addSliceToDashboard`
dispatches `ADD_CHART` precisely for a key not yet present, this returns the
unchanged map and prevents dynamically added dashboard charts from entering
Redux state. Handle `ADD_CHART` before this guard or exclude it from the
missing-chart check.
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%2F43228&comment_hash=6cbb10505a24908c9bd0608bb20c9b029a916a6586e7fbc1536470a6d63cbbf5&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43228&comment_hash=6cbb10505a24908c9bd0608bb20c9b029a916a6586e7fbc1536470a6d63cbbf5&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]