yuseok89 commented on code in PR #65835:
URL: https://github.com/apache/airflow/pull/65835#discussion_r3161771225


##########
airflow-core/src/airflow/ui/src/components/Clear/TaskInstance/ClearGroupTaskInstanceDialog.tsx:
##########
@@ -106,8 +107,28 @@ export const ClearGroupTaskInstanceDialog = ({ onClose, 
open, taskInstance }: Pr
     total_entries: 0,
   };
 
-  const shouldShowBundleVersionOption =
-    dagDetails?.bundle_version !== null && dagDetails?.bundle_version !== "";
+  const latestDagVersionNumber = 
dagDetails?.latest_dag_version?.version_number;
+  const groupDagVersionNumber = taskInstance.dag_version_number ?? undefined;
+  const dagVersionsDiffer =
+    latestDagVersionNumber !== undefined &&
+    groupDagVersionNumber !== undefined &&
+    latestDagVersionNumber !== groupDagVersionNumber;
+  // Fall back to legacy heuristic when grid summary has no version (older 
API).
+  const shouldShowRunOnLatestOption =
+    dagVersionsDiffer || (dagDetails?.bundle_version !== null && 
dagDetails?.bundle_version !== "");
+
+  useEffect(() => {
+    if (!open) {
+      userToggledRunOnLatestRef.current = false;
+    }
+  }, [open]);
+
+  useEffect(() => {
+    if (!open || userToggledRunOnLatestRef.current) {
+      return;
+    }
+    setRunOnLatestVersion(dagVersionsDiffer);
+  }, [open, dagVersionsDiffer]);

Review Comment:
   Thanks! I understood the concern as too many useEffects. Replacing them with 
`onOpenChange` looked like it would miss the case where `onClose` is called 
programmatically, so I combined the two useEffects into one instead. Let me 
know if you have other thoughts.



-- 
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]

Reply via email to