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


##########
superset-frontend/src/hooks/useUnsavedChangesPrompt/index.ts:
##########
@@ -88,6 +95,10 @@ export const useUnsavedChangesPrompt = ({
         return undefined;
       }
 
+      if (isInPlaceTransition?.(state)) {
+        return undefined;
+      }

Review Comment:
   **Suggestion:** The in-place transition check runs before consuming 
`manualSaveRef.current`. If a user-initiated save sets this flag and an 
in-place chart-state transition occurs while the save modal is still active, 
the flag remains set; a subsequent real navigation can then take the 
manual-save branch and bypass the unsaved-changes prompt, discarding edits. 
Consume or clear the manual-save flag before allowing the in-place transition. 
[stale reference]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Real navigation can bypass the unsaved-changes prompt.
   - ⚠️ Explore edits may be discarded during an active save modal.
   - ⚠️ Browser Back can navigate without confirmation.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. In Explore, click the chart save button; `ExploreChartHeader.showModal()` 
at
   
`superset-frontend/src/explore/components/ExploreChartHeader/index.tsx:278-280` 
calls
   `triggerManualSave()`, which sets `manualSaveRef.current = true` at
   `superset-frontend/src/hooks/useUnsavedChangesPrompt/index.ts:75-78` and 
opens the save
   modal.
   
   2. While the save modal remains visible, trigger a chart-state history 
update through
   `ExploreViewContainer.addHistory()` at
   
`superset-frontend/src/explore/components/ExploreViewContainer/index.tsx:482-503`;
   `updateHistory` pushes an in-place entry at
   
`superset-frontend/src/explore/components/ExploreViewContainer/index.tsx:239-251`.
   
   3. The history blocker invokes `blockCallback()` at
   `superset-frontend/src/hooks/useUnsavedChangesPrompt/index.ts:80-118`; 
because the
   destination is recognized by `isChartStateTransition()` in 
`ExploreChartHeader` at
   
`superset-frontend/src/explore/components/ExploreChartHeader/index.tsx:252-260`,
 lines
   98-100 return before consuming `manualSaveRef.current`.
   
   4. Navigate away before the save modal visibility changes to false, such as 
with browser
   Back; `blockCallback()` reaches the manual-save branch at
   `superset-frontend/src/hooks/useUnsavedChangesPrompt/index.ts:102-105`, 
clears the blocker
   without showing the unsaved-changes modal, and can discard the remaining 
edits. The
   cleanup at lines 131-136 only clears the flag after `isSaveModalVisible` 
becomes false.
   ```
   </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=0a3ac88577594f2f8d4127a32a1fe329&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=0a3ac88577594f2f8d4127a32a1fe329&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/hooks/useUnsavedChangesPrompt/index.ts
   **Line:** 98:100
   **Comment:**
        *Stale Reference: The in-place transition check runs before consuming 
`manualSaveRef.current`. If a user-initiated save sets this flag and an 
in-place chart-state transition occurs while the save modal is still active, 
the flag remains set; a subsequent real navigation can then take the 
manual-save branch and bypass the unsaved-changes prompt, discarding edits. 
Consume or clear the manual-save flag before allowing the in-place transition.
   
   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%2F42473&comment_hash=e2678ee8a3a4ae80f63950dc578d0b55231a14af1cf9678dc0f26a75a1df4a1f&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42473&comment_hash=e2678ee8a3a4ae80f63950dc578d0b55231a14af1cf9678dc0f26a75a1df4a1f&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