This is an automated email from the ASF dual-hosted git repository.
bbovenzi pushed a commit to branch v3-4-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-4-test by this push:
new b338d473e85 [v3-4-test] UI: Send the hide-paused default with the
first Dags list request (#76689) (#77210)
b338d473e85 is described below
commit b338d473e85b4b5e5d076f20e8c255de7b46ff4c
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Nov 18 18:35:48 2026 +0000
[v3-4-test] UI: Send the hide-paused default with the first Dags list
request (#76689) (#77210)
* UI: Send the hide-paused default with the first Dags list request
With ``hide_paused_dags_by_default`` enabled the Dags list fetched twice on
every page load: the paused default was written into the URL from an effect,
after the first ``/ui/dags`` request had already gone out unfiltered. Paused
Dags flashed into the list until the second response replaced them, and the
``DagsFilters`` test that waits for them to disappear raced that second
request and failed intermittently in CI.
The list now derives the pending default during render, so the first request
already carries ``paused=false`` and the URL seed produces the same query
key.
Claude-Session: https://claude.ai/code/session_01BVx6g7GpQFxdabhHVW6KYd
* Use the defined paused default instead of hardcoded values
Address review feedback: usePausedDefault now returns the default paused
state itself rather than a flag, the URL seed is written through
pausedStateToSearchParams, the functional updater leaves an existing
paused or scheduling_state filter untouched, and the test asserts that
exactly one Dags list request is sent.
(cherry picked from commit 32550ea56b65bc3770371105ac56603fccb8f9bd)
Claude-Session: https://claude.ai/code/session_01BVx6gARFVCg8fLbs1Zfy4h
Co-authored-by: Shahar Epstein <[email protected]>
---
.../DagsList/DagsFilters/DagsFilters.test.tsx | 23 ++++++++++-
.../src/pages/DagsList/DagsFilters/DagsFilters.tsx | 4 --
.../src/airflow/ui/src/pages/DagsList/DagsList.tsx | 5 ++-
.../ui/src/pages/DagsList/usePausedDefault.ts | 47 +++++++++++++++++-----
4 files changed, 62 insertions(+), 17 deletions(-)
diff --git
a/airflow-core/src/airflow/ui/src/pages/DagsList/DagsFilters/DagsFilters.test.tsx
b/airflow-core/src/airflow/ui/src/pages/DagsList/DagsFilters/DagsFilters.test.tsx
index 380fd374c67..ff7fb341c6e 100644
---
a/airflow-core/src/airflow/ui/src/pages/DagsList/DagsFilters/DagsFilters.test.tsx
+++
b/airflow-core/src/airflow/ui/src/pages/DagsList/DagsFilters/DagsFilters.test.tsx
@@ -68,6 +68,27 @@ describe("Paused filter with hide_paused_dags_by_default
enabled", () => {
expect(screen.queryByText("paused_dag")).not.toBeInTheDocument();
});
+ it("sends the paused default on every dags request, including the first",
async () => {
+ const urls: Array<URL> = [];
+ const onRequest = ({ request }: { request: Request }) => {
+ urls.push(new URL(request.url));
+ };
+
+ server.events.on("request:start", onRequest);
+ try {
+ render(<AppWrapper initialEntries={["/dags"]} />);
+
+ await waitFor(() =>
expect(screen.getByText("tutorial_taskflow_api_success")).toBeInTheDocument());
+ } finally {
+ server.events.removeListener("request:start", onRequest);
+ }
+
+ const dagsRequests = urls.filter((url) => url.pathname === "/ui/dags");
+
+ expect(dagsRequests).toHaveLength(1);
+ expect(dagsRequests.every((url) => url.searchParams.get("paused") ===
"false")).toBe(true);
+ });
+
it("keeps draining dags under the default, since they are not paused yet",
async () => {
withDrainingDag();
render(<AppWrapper initialEntries={["/dags"]} />);
@@ -116,7 +137,7 @@ describe("Paused filter with hide_paused_dags_by_default
enabled", () => {
expect(screen.queryByText("paused_dag")).not.toBeInTheDocument();
// There is no "All" option any more; removing the pill is how you ask for
every Dag.
- fireEvent.click(screen.getByTestId("paused-pill-remove"));
+ fireEvent.click(await screen.findByTestId("paused-pill-remove"));
await waitFor(() =>
expect(screen.getByText("paused_dag")).toBeInTheDocument());
expect(screen.getByText("tutorial_taskflow_api_success")).toBeInTheDocument();
diff --git
a/airflow-core/src/airflow/ui/src/pages/DagsList/DagsFilters/DagsFilters.tsx
b/airflow-core/src/airflow/ui/src/pages/DagsList/DagsFilters/DagsFilters.tsx
index d84ecc14fb6..fcd608a8299 100644
--- a/airflow-core/src/airflow/ui/src/pages/DagsList/DagsFilters/DagsFilters.tsx
+++ b/airflow-core/src/airflow/ui/src/pages/DagsList/DagsFilters/DagsFilters.tsx
@@ -22,13 +22,9 @@ import { SearchParamsKeys } from
"src/constants/searchParams";
import { useConfig } from "src/queries/useConfig";
import { useFiltersHandler, type FilterableSearchParamsKeys } from "src/utils";
-import { usePausedDefault } from "../usePausedDefault";
-
export const DagsFilters = () => {
const multiTeamEnabled = Boolean(useConfig("multi_team"));
- usePausedDefault();
-
const searchParamKeys: Array<FilterableSearchParamsKeys> = [
SearchParamsKeys.PAUSED,
SearchParamsKeys.RUN_STATE,
diff --git a/airflow-core/src/airflow/ui/src/pages/DagsList/DagsList.tsx
b/airflow-core/src/airflow/ui/src/pages/DagsList/DagsList.tsx
index 4bbf05221fe..5fc66f4cb4e 100644
--- a/airflow-core/src/airflow/ui/src/pages/DagsList/DagsList.tsx
+++ b/airflow-core/src/airflow/ui/src/pages/DagsList/DagsList.tsx
@@ -61,6 +61,7 @@ import { createColumns, getRowKey } from "./DagsListColumns";
import { DagsListCountsProvider, useDagsListCounts, type RunStateCounts } from
"./DagsListCountsContext";
import { SortSelect } from "./SortSelect";
import { MAX_RECENT_RUNS } from "./recentRunsLayout";
+import { usePausedDefault } from "./usePausedDefault";
const {
DAG_BUNDLE,
@@ -148,7 +149,9 @@ export const DagsList = () => {
const multiTeamEnabled = Boolean(useConfig("multi_team"));
// Derived through the pill's own mapping so the query can never filter on
more than the pill shows.
- const { paused, schedulingState } =
pausedStateToQuery(pausedStateFromSearchParams(searchParams));
+ const pausedDefault = usePausedDefault();
+ const pausedState = pausedStateFromSearchParams(searchParams) ??
pausedDefault;
+ const { paused, schedulingState } = pausedStateToQuery(pausedState);
const showFavorites = searchParams.get(FAVORITE);
const lastDagRunState = searchParams.get(LAST_DAG_RUN_STATE) as DagRunState;
diff --git a/airflow-core/src/airflow/ui/src/pages/DagsList/usePausedDefault.ts
b/airflow-core/src/airflow/ui/src/pages/DagsList/usePausedDefault.ts
index 967b0cff0e8..73265332429 100644
--- a/airflow-core/src/airflow/ui/src/pages/DagsList/usePausedDefault.ts
+++ b/airflow-core/src/airflow/ui/src/pages/DagsList/usePausedDefault.ts
@@ -16,48 +16,73 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { useEffect, useRef } from "react";
+import { useEffect, useState } from "react";
import { useSearchParams } from "react-router-dom";
+import {
+ pausedStateToSearchParams,
+ type PausedStateValue,
+} from "src/components/FilterBar/filters/pausedStateParams";
+
import { SearchParamsKeys } from "src/constants/searchParams";
import { useConfig } from "src/queries/useConfig";
+const HIDE_PAUSED_DEFAULT: PausedStateValue = "not_paused";
+
+const hasPausedFilter = (params: URLSearchParams) =>
+ params.has(SearchParamsKeys.PAUSED) ||
params.has(SearchParamsKeys.SCHEDULING_STATE);
+
/**
* Writes the ``hide_paused_dags_by_default`` default into the URL so it shows
up as a
* pill instead of filtering invisibly.
*
* Seeds once per page load. Removing the pill is how you ask to see paused
Dags, so re-seeding
* whenever the param goes missing would put it straight back and leave them
unreachable.
+ *
+ * Returns the default paused state until it is in the URL, so callers can
query with it from the first render.
+ * ``hasSeeded`` flips only once the URL carries a filter: flipping it when
the write is issued would
+ * leave a render with neither the param nor the pending flag, and fire an
unfiltered request.
*/
export const usePausedDefault = () => {
const hidePausedDagsByDefault =
Boolean(useConfig("hide_paused_dags_by_default"));
const [searchParams, setSearchParams] = useSearchParams();
- const hasSeeded = useRef(false);
+ const [hasSeeded, setHasSeeded] = useState(false);
useEffect(() => {
- if (
- hasSeeded.current ||
- !hidePausedDagsByDefault ||
- searchParams.has(SearchParamsKeys.PAUSED) ||
- searchParams.has(SearchParamsKeys.SCHEDULING_STATE)
- ) {
+ if (hasSeeded || !hidePausedDagsByDefault) {
return;
}
- hasSeeded.current = true;
+ if (hasPausedFilter(searchParams)) {
+ setHasSeeded(true);
+
+ return;
+ }
// Functional form is required: PresetFiltersMenu restores a default
preset from a
// deeper effect that commits first, so an object write would clobber it
with stale params.
setSearchParams(
(prev) => {
+ if (hasPausedFilter(prev)) {
+ return prev;
+ }
+
const next = new URLSearchParams(prev);
- next.set(SearchParamsKeys.PAUSED, "false");
+
Object.entries(pausedStateToSearchParams(HIDE_PAUSED_DEFAULT)).forEach(([key,
value]) => {
+ if (value !== undefined) {
+ next.set(key, value);
+ }
+ });
return next;
},
{ replace: true },
);
- }, [hidePausedDagsByDefault, searchParams, setSearchParams]);
+ }, [hasSeeded, hidePausedDagsByDefault, searchParams, setSearchParams]);
+
+ return hidePausedDagsByDefault && !hasSeeded &&
!hasPausedFilter(searchParams)
+ ? HIDE_PAUSED_DEFAULT
+ : undefined;
};