Skip to content

Show recent task states on the Dags list page - #69619

Merged
bbovenzi merged 21 commits into
apache:mainfrom
yuseok89:feature/66947-dag-list-latest-run-ti-state-counts
Oct 6, 2026
Merged

bbovenzi merged 21 commits into
apache:mainfrom
yuseok89:feature/66947-dag-list-latest-run-ti-state-counts

Conversation

@yuseok89

@yuseok89 yuseok89 commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

closes: #66947

Each Dag card and table row on the Dags list now shows the task instance states of the Dag's recent runs as clickable badges, like the "Recent Tasks" column in Airflow 2. The counts cover all running Dag runs, or the most recent run when none is running. Clicking a badge opens the task instance list filtered to those runs and that state.

What changed

  • New endpoint: GET /ui/dags/recent_task_instance_state_counts. It takes the latest run ids the Dag list already returns (dag_run_ids, bounded by the API max page limit) and counts, in one statement, the task instances of each Dag's running runs, or of that latest run when none is running. Each entry returns the counted run_ids and the state_counts.
  • Card view: he badges appear in the card's second row, under Latest Run and Next Run, next to the run state badges.
  • Table view: a new "Recent tasks" column with an info tooltip explaining what is counted. The badges stay on one line.
  • Dynamic badges: only the states present are shown, ordered by priority. Task instances with no state yet appear as no_status.
  • Links: each badge opens Task Instances filtered by the Dag, the counted run ids and the state. These are pattern filters, so another Dag whose id starts with this one and shares a run id can also show up.
  • Setting: "Show recent tasks" (on by default) hides the column and badges and skips the request entirely.

Unlike the run state badges from #67242, which count a Dag's runs by state, these count the task instances of its recent runs.

Query performance

The counts come from a single statement whose size does not grow with the number of running runs. Running runs are found through the partial idx_dag_run_running_dags index and their task instances through ti_dag_run, so the cost scales with the task instances actually counted. In a local benchmark (postgres 14, Airflow's indexes, 100 Dags × 1,050 runs × 30 tasks), it was roughly 40 to 75 times faster than counting with one UNION ALL branch per run once Dags had 50 running runs each. Absolute timings depend on the machine.

Demo

Screen.Recording.2026-10-05.at.10.06.37.PM.mov

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)
    • Claude Code (Opus 5.5)

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@boring-cyborg boring-cyborg Bot added area:API Airflow's REST/HTTP API area:translations area:UI Related to UI/UX. For Frontend Developers. translation:default labels Jul 8, 2026
@yuseok89
yuseok89 force-pushed the feature/66947-dag-list-latest-run-ti-state-counts branch 6 times, most recently from cb0a135 to 48872f8 Compare July 9, 2026 15:55
@yuseok89
yuseok89 marked this pull request as ready for review July 9, 2026 23:47
@potiuk potiuk added the ready for maintainer review Set by triage when all criteria pass, or by the fork CI reconciler when fork CI is green. label Jul 11, 2026
@bbovenzi

Copy link
Copy Markdown
Contributor

Thanks for opening this.

Let's make sure dags list performance issues are resolved first. Like in this PR: #69806. Only after that should we add any more complexity to the dags list

@yuseok89

yuseok89 commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for opening this.

Let's make sure dags list performance issues are resolved first. Like in this PR: #69806. Only after that should we add any more complexity to the dags list

Makes sense, thanks. I'll take a look at the dags list performance work too and see if there's anything I can help with there.

@yuseok89
yuseok89 force-pushed the feature/66947-dag-list-latest-run-ti-state-counts branch 2 times, most recently from 2972d54 to fc551db Compare August 5, 2026 14:22
@yuseok89

yuseok89 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Hi @bbovenzi.
The dags list performance work is now resolved (#69806 merged, #69609 closed).
So would this be a good time to pick it back up?

@pierrejeambrun pierrejeambrun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you benchmark this when there are millions of TI and hundred of thousand of runs in the DB?

I would like to double check performance, my feeling is that it will not scale way because of the subqueries

@bbovenzi

Copy link
Copy Markdown
Contributor

Let's just have it always be one line. I'd rather not maintain logic saying, "if this dag isnt running, then let it be two lines" that sounds very easy to mess up and break.

@yuseok89

yuseok89 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

I opened the single-line change for the existing columns separately in #74002, since it felt a bit different in scope from this PR. With that applied and the latest run tasks also kept on one line, the table could look like this.

Option 1 (only the states present in the run)

Screen.Recording.2026-10-01.at.8.14.28.PM.mov

Keeping everything on one line reminded me of Airflow 2, so I also tried listing every state in a fixed position the way Airflow 2 did, with the empty ones dimmed. Personally, I don't think it looks as good.

Option 2 (every state)

image

I'll go ahead with the first option and work on the toggle next.
Please let me know anytime if you see it differently.

@pedro-cf

pedro-cf commented Oct 1, 2026

Copy link
Copy Markdown

Would it be a problem/bad idea/anti-pattern if the icons were disabled the table view (and possibly card) ?

Also regarding the "Latest Run tasks", would it be possible to make it similar to Airflow 2 where it showed: "Status of tasks from all active DAG Runs or, if not currently active, from most recent run."

image

@yuseok89

yuseok89 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @pedro-cf!

About the icons, as far as I know the state badge hasn't been used without its icon since it was introduced, so it has been used much like a standard across the UI. If we dropped the icons only here, I wonder if this column would feel a bit out of tone with the rest of the UI.

About the description, I couldn't find a precedent for one on a table column header, but I'll give it a try.

@pedro-cf

pedro-cf commented Oct 1, 2026 •

Copy link
Copy Markdown

Thank you very much for your wonderful work @yuseok89

About the description, I couldn't find a precedent for one on a table column header, but I'll give it a try.

Regarding this, my concern is whether you are displaying only the tasks from the "Latest Run", rather than the "status of tasks from all active DAG Runs or, if not currently active, from the most recent run." If so, would it be possible to change it to the latter?

@yuseok89

yuseok89 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for clarifying!
Yes, it currently shows only the tasks from the latest run. I think I misunderstood what the Recent Tasks column showed in Airflow 2. I'll look into making it behave the same way. From the code, it doesn't look like it would cause performance issues, so I'll give it a try.

@yuseok89
yuseok89 force-pushed the feature/66947-dag-list-latest-run-ti-state-counts branch from a7c3770 to 25130a5 Compare October 3, 2026 00:19
# Conflicts:
#	airflow-core/src/airflow/ui/openapi-gen/requests/services.gen.ts
#	airflow-core/src/airflow/ui/src/constants/localStorage.ts
#	airflow-core/src/airflow/ui/src/pages/Settings/Settings.test.tsx
#	airflow-core/src/airflow/ui/src/pages/Settings/Settings.tsx
@yuseok89 yuseok89 changed the title Show task state counts for the latest Dag run on the Dags list page Show recent task states on the Dags list page Oct 5, 2026
@yuseok89

yuseok89 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Hi @bbovenzi @pedro-cf, I've addressed the feedback so far.

  • The task states in the table now always stay on a single line, with no logic that depends on whether the Dag is running. Keeping the other table columns on a single line is handled separately in UI: Keep Dags list table rows on a single line #74002, since it changes the existing columns rather than this feature.
  • A "Show recent tasks" toggle in the user settings turns the counts off entirely. When it's off, the UI doesn't send the request, so the query never runs.
  • Like the Recent Tasks column in Airflow 2, the counts now cover all running Dag runs, or the most recent run when none is running. The column is renamed to "Recent tasks", and an info tooltip next to its header explains what is counted and that it can be turned off in the user settings.
  • Updated the PR description and the demo video to match.

Could you take another look when you have a moment?

…ist-latest-run-ti-state-counts

# Conflicts:
#	airflow-core/src/airflow/ui/src/pages/DagsList/DagsList.test.tsx
#	airflow-core/src/airflow/ui/src/pages/DagsList/DagsList.tsx
@yuseok89

yuseok89 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Resolved the conflicts with main. After resolving them,DagsList.tsx went over the 500-line lint limit, so I moved the table columns into a new DagsListColumns.tsx in a separate commit. The moved code is unchanged, so that commit can be reviewed on its own.

@bbovenzi
bbovenzi merged commit 4699c48 into apache:main Oct 6, 2026
100 checks passed
@yuseok89

yuseok89 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @bbovenzi @pierrejeambrun @pedro-cf for the reviews. Your feedback helped me get this to a much better place than where it started, and I learned a lot along the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:translations area:UI Related to UI/UX. For Frontend Developers. ready for maintainer review Set by triage when all criteria pass, or by the fork CI reconciler when fork CI is green. translation:default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DAG list page: show task state counts for the most recent DAG run per DAG

7 participants