bbovenzi commented on code in PR #59507:
URL: https://github.com/apache/airflow/pull/59507#discussion_r2623942492


##########
airflow-core/src/airflow/ui/src/pages/TaskInstance/ExtraLinks.tsx:
##########
@@ -21,17 +21,33 @@ import { useTranslation } from "react-i18next";
 import { useParams } from "react-router-dom";
 
 import { useTaskInstanceServiceGetExtraLinks } from "openapi/queries";
+import { useAutoRefresh } from "src/utils";
 
 export const ExtraLinks = () => {
   const { t: translate } = useTranslation("dag");
   const { dagId = "", mapIndex = "-1", runId = "", taskId = "" } = useParams();
 
-  const { data } = useTaskInstanceServiceGetExtraLinks({
-    dagId,
-    dagRunId: runId,
-    mapIndex: parseInt(mapIndex, 10),
-    taskId,
-  });
+  const refetchInterval = useAutoRefresh({ dagId });
+
+  const { data } = useTaskInstanceServiceGetExtraLinks(
+    {
+      dagId,
+      dagRunId: runId,
+      mapIndex: parseInt(mapIndex, 10),
+      taskId,
+    },
+    undefined,
+    {
+      refetchInterval: (query) => {
+        // If we have extra links, stop polling to reduce server load
+        const hasLinks =
+          query.state.data?.extra_links && 
Object.keys(query.state.data.extra_links).length > 0;
+
+        // Continue polling if auto-refresh is enabled and we don't have links 
yet
+        return !hasLinks && refetchInterval ? refetchInterval : false;

Review Comment:
   This will poll forever if the task doesn't have extra links. Lets also call 
`useTaskServiceGetTask` and see if `task.extraLinks.length > 0` first.
   
   We probably want to make that change in `TaskInstance/Details.tsx` to check 
if we even want to render the extra links component at all



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