You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "guan404ming (via GitHub)" <gi...@apache.org> on 2025/09/13 08:16:31 UTC

[PR] Add filer for HITL TaskInstances page and support select filter in FilterBar [airflow]

guan404ming opened a new pull request, #55620:
URL: https://github.com/apache/airflow/pull/55620

   <!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
   
      http://www.apache.org/licenses/LICENSE-2.0
   
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
    -->
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ## Why
   
   lack of filter in hitl ti pages
   
   ## How
   
   - implement select type filter
   - add filter for hitl ti pages
   
   
   https://github.com/user-attachments/assets/25d76a72-ea58-4468-a6f9-68c1de2945d5
   
   
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add filter for HITL TaskInstances page [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #55620:
URL: https://github.com/apache/airflow/pull/55620#discussion_r2352965829


##########
airflow-core/src/airflow/ui/src/constants/filterConfigs.tsx:
##########
@@ -89,6 +90,16 @@ export const useFilterConfigs = () => {
       min: -1,
       type: FilterTypes.NUMBER,
     },
+    [SearchParamsKeys.RESPONSE_RECEIVED]: {
+      icon: <FiUser />,
+      label: translate("hitl:requiredActionState"),
+      options: [
+        { label: translate("hitl:filters.response.all"), value: "all" },

Review Comment:
   I've removed the original the filter. These are default options for new select filter. Please let me know if I misunderstood anything, thanks!



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add filter for HITL TaskInstances page [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #55620:
URL: https://github.com/apache/airflow/pull/55620#discussion_r2352965829


##########
airflow-core/src/airflow/ui/src/constants/filterConfigs.tsx:
##########
@@ -89,6 +90,16 @@ export const useFilterConfigs = () => {
       min: -1,
       type: FilterTypes.NUMBER,
     },
+    [SearchParamsKeys.RESPONSE_RECEIVED]: {
+      icon: <FiUser />,
+      label: translate("hitl:requiredActionState"),
+      options: [
+        { label: translate("hitl:filters.response.all"), value: "all" },

Review Comment:
   I've removed the original the filter. This is for default options for select filter. Please let me know if I misunderstood anything, thanks!



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add filter for HITL TaskInstances page [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #55620:
URL: https://github.com/apache/airflow/pull/55620#discussion_r2349875678


##########
airflow-core/src/airflow/ui/src/components/FilterBar/filters/SelectFilter.tsx:
##########
@@ -0,0 +1,108 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { createListCollection, Box, Text } from "@chakra-ui/react";
+
+import { Select } from "src/components/ui";
+
+import { FilterPill } from "../FilterPill";
+import type { FilterPluginProps, FilterConfig } from "../types";
+
+type SelectOption = {
+  label: string;
+  value: string;

Review Comment:
   Did you try allowing label to be a react component so that we can visually match the dropdown with the required action state badge?



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add filter for HITL TaskInstances page [airflow]

Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on PR #55620:
URL: https://github.com/apache/airflow/pull/55620#issuecomment-3302796697

   Related: https://github.com/apache/airflow/issues/53040


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add filter for HITL TaskInstances page [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #55620:
URL: https://github.com/apache/airflow/pull/55620#discussion_r2352958454


##########
airflow-core/src/airflow/ui/src/components/FilterBar/filters/SelectFilter.tsx:
##########
@@ -0,0 +1,108 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { createListCollection, Box, Text } from "@chakra-ui/react";
+
+import { Select } from "src/components/ui";
+
+import { FilterPill } from "../FilterPill";
+import type { FilterPluginProps, FilterConfig } from "../types";
+
+type SelectOption = {
+  label: string;
+  value: string;

Review Comment:
   Thanks for the nice suggestion! I've tried  it and looks good for me.
   
   
   https://github.com/user-attachments/assets/c16aa26f-28be-4be0-9ae0-2b473be8c7b5
   
   



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add filter for HITL TaskInstances page [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi merged PR #55620:
URL: https://github.com/apache/airflow/pull/55620


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add filter for HITL TaskInstances page [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #55620:
URL: https://github.com/apache/airflow/pull/55620#discussion_r2352979436


##########
airflow-core/src/airflow/ui/src/components/FilterBar/filters/SelectFilter.tsx:
##########
@@ -0,0 +1,108 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { createListCollection, Box, Text } from "@chakra-ui/react";
+
+import { Select } from "src/components/ui";
+
+import { FilterPill } from "../FilterPill";
+import type { FilterPluginProps, FilterConfig } from "../types";
+
+type SelectOption = {
+  label: string;
+  value: string;

Review Comment:
   Nice!



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add filter for HITL TaskInstances page [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #55620:
URL: https://github.com/apache/airflow/pull/55620#discussion_r2349924937


##########
airflow-core/src/airflow/ui/src/pages/HITLTaskInstances/HITLTaskInstances.tsx:
##########
@@ -122,71 +127,46 @@ export const HITLTaskInstances = () => {
   const [sort] = sorting;
   const responseReceived = searchParams.get(RESPONSE_RECEIVED_PARAM);
 
+  const dagIdPattern = searchParams.get(DAG_DISPLAY_NAME_PATTERN) ?? undefined;
+  const taskIdPattern = searchParams.get(TASK_ID_PATTERN) ?? undefined;
+  const filterResponseReceived = searchParams.get(RESPONSE_RECEIVED_PARAM) ?? undefined;
+
+  // Use the filter value if available, otherwise fall back to the old responseReceived param
+  const effectiveResponseReceived = filterResponseReceived ?? responseReceived;
+
   const { data, error, isLoading } = useHumanInTheLoopServiceGetHitlDetails({
     dagId,
+    dagIdPattern,
     dagRunId: runId,
     limit: pagination.pageSize,
     offset: pagination.pageIndex * pagination.pageSize,
     orderBy: sort ? [`${sort.desc ? "-" : ""}${sort.id}`] : [],
-    responseReceived: Boolean(responseReceived) ? responseReceived === "true" : undefined,
-    state: responseReceived === "false" ? ["deferred"] : undefined,
+    responseReceived:
+      Boolean(effectiveResponseReceived) && effectiveResponseReceived !== "all"
+        ? effectiveResponseReceived === "true"
+        : undefined,
+    state: effectiveResponseReceived === "false" ? ["deferred"] : undefined,
     taskId,
+    taskIdPattern,
   });
 
-  const enabledOptions = createListCollection({
-    items: [
-      { label: translate("filters.response.all"), value: "all" },
-      { label: translate("filters.response.pending"), value: "false" },
-      { label: translate("filters.response.received"), value: "true" },
-    ],
-  });
-
-  const handleResponseChange = useCallback(
-    ({ value }: { value: Array<string> }) => {
-      const [val] = value;
-
-      if (val === undefined || val === "all") {
-        searchParams.delete(RESPONSE_RECEIVED_PARAM);
-      } else {
-        searchParams.set(RESPONSE_RECEIVED_PARAM, val);
-      }
-      setTableURLState({
-        pagination: { ...pagination, pageIndex: 0 },
-        sorting,
-      });
-      searchParams.delete(OFFSET_PARAM);
-      setSearchParams(searchParams);
-    },
-    [searchParams, setSearchParams, pagination, sorting, setTableURLState],
-  );
+  const handleResponseChange = useCallback(() => {
+    setTableURLState({
+      pagination: { ...pagination, pageIndex: 0 },
+      sorting,
+    });
+    searchParams.delete(OFFSET_PARAM);
+    setSearchParams(searchParams);
+  }, [pagination, searchParams, setSearchParams, setTableURLState, sorting]);
 
   return (
-    <Box>
+    <VStack align="start" gap={4}>

Review Comment:
   The filter to table gap is too large:
   
   <img width="656" height="624" alt="Screenshot 2025-09-15 at 3 36 24 PM" src="https://github.com/user-attachments/assets/a762d851-2142-448f-b362-6687a4778013" />
   



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add filter for HITL TaskInstances page [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #55620:
URL: https://github.com/apache/airflow/pull/55620#discussion_r2349921985


##########
airflow-core/src/airflow/ui/src/constants/filterConfigs.tsx:
##########
@@ -89,6 +90,16 @@ export const useFilterConfigs = () => {
       min: -1,
       type: FilterTypes.NUMBER,
     },
+    [SearchParamsKeys.RESPONSE_RECEIVED]: {
+      icon: <FiUser />,
+      label: translate("hitl:requiredActionState"),
+      options: [
+        { label: translate("hitl:filters.response.all"), value: "all" },

Review Comment:
   We don't need this option anymore. We can just remove the filter instead.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add filter for HITL TaskInstances page [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #55620:
URL: https://github.com/apache/airflow/pull/55620#discussion_r2352961374


##########
airflow-core/src/airflow/ui/src/pages/HITLTaskInstances/HITLTaskInstances.tsx:
##########
@@ -122,71 +127,46 @@ export const HITLTaskInstances = () => {
   const [sort] = sorting;
   const responseReceived = searchParams.get(RESPONSE_RECEIVED_PARAM);
 
+  const dagIdPattern = searchParams.get(DAG_DISPLAY_NAME_PATTERN) ?? undefined;
+  const taskIdPattern = searchParams.get(TASK_ID_PATTERN) ?? undefined;
+  const filterResponseReceived = searchParams.get(RESPONSE_RECEIVED_PARAM) ?? undefined;
+
+  // Use the filter value if available, otherwise fall back to the old responseReceived param
+  const effectiveResponseReceived = filterResponseReceived ?? responseReceived;
+
   const { data, error, isLoading } = useHumanInTheLoopServiceGetHitlDetails({
     dagId,
+    dagIdPattern,
     dagRunId: runId,
     limit: pagination.pageSize,
     offset: pagination.pageIndex * pagination.pageSize,
     orderBy: sort ? [`${sort.desc ? "-" : ""}${sort.id}`] : [],
-    responseReceived: Boolean(responseReceived) ? responseReceived === "true" : undefined,
-    state: responseReceived === "false" ? ["deferred"] : undefined,
+    responseReceived:
+      Boolean(effectiveResponseReceived) && effectiveResponseReceived !== "all"
+        ? effectiveResponseReceived === "true"
+        : undefined,
+    state: effectiveResponseReceived === "false" ? ["deferred"] : undefined,
     taskId,
+    taskIdPattern,
   });
 
-  const enabledOptions = createListCollection({
-    items: [
-      { label: translate("filters.response.all"), value: "all" },
-      { label: translate("filters.response.pending"), value: "false" },
-      { label: translate("filters.response.received"), value: "true" },
-    ],
-  });
-
-  const handleResponseChange = useCallback(
-    ({ value }: { value: Array<string> }) => {
-      const [val] = value;
-
-      if (val === undefined || val === "all") {
-        searchParams.delete(RESPONSE_RECEIVED_PARAM);
-      } else {
-        searchParams.set(RESPONSE_RECEIVED_PARAM, val);
-      }
-      setTableURLState({
-        pagination: { ...pagination, pageIndex: 0 },
-        sorting,
-      });
-      searchParams.delete(OFFSET_PARAM);
-      setSearchParams(searchParams);
-    },
-    [searchParams, setSearchParams, pagination, sorting, setTableURLState],
-  );
+  const handleResponseChange = useCallback(() => {
+    setTableURLState({
+      pagination: { ...pagination, pageIndex: 0 },
+      sorting,
+    });
+    searchParams.delete(OFFSET_PARAM);
+    setSearchParams(searchParams);
+  }, [pagination, searchParams, setSearchParams, setTableURLState, sorting]);
 
   return (
-    <Box>
+    <VStack align="start" gap={4}>

Review Comment:
   Fixed~
   
   <img width="687" height="421" alt="image" src="https://github.com/user-attachments/assets/78a9ecd8-864d-4f9c-a20c-b59d5b0971c0" />
   



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org