safaehar opened a new pull request, #77025:
URL: https://github.com/apache/airflow/pull/77025
Follow-up to #76978, which adds route loaders for the Dag, run and task
pages. **This PR is stacked on #76978:** only the last commit (`UI: Prefetch
the Dashboard and the Grid's first page in route loaders`) is new here. I'll
rebase it onto `main` once #76978 is merged.
Two more sets of first requests still wait for the first render. This adds
them to the route loaders, using the same mechanism: the generated prefetch
helpers with the keys the pages' own queries build, no waiting, and no failures.
### Dashboard
- `/home`, and `/` when the user's landing page is the Dashboard, get a
loader for the Dashboard's queries:
- the history (`historical_metrics_data`) and asset events of the last 24
hours;
- Dag stats, health, favorite Dags, import errors, plugin import errors,
pools and plugins.
- The history and asset event queries carry a date range, which the
Dashboard used to create when it mounted. The loader now creates it
(`getDashboardRange`), and the Dashboard starts from the same range if it was
created in the last 10 seconds, so the keys match. Otherwise, the Dashboard
creates a new one, as before.
- On `/`, the loader reads the default landing page setting and does nothing
when it is the Dags list, which `/` redirects to.
### Grid's first page
The Dag, run and task loaders now also prefetch the Grid's first page of
runs, the request the Grid and `DetailsLayout` share (`limit + 1`, offset 0,
newest first):
- The limit comes from the URL's `limit`, else the Dag's stored limit, else
the default, read the same way `useDagRunsLimit` does. `useDagRunsLimit.ts` now
exports its default and URL reader for this.
- Skipped when the URL filters the runs (state, run type, run id, triggering
user, run-after range), since those change the key.
- Skipped in the Gantt view, whose limit also depends on the panel width,
and on Dag pages in the graph view, which renders no Grid there. On run and
task pages in the graph view, `DetailsLayout` still requests this page, so the
loader still prefetches it.
### Tests
- `routePrefetch.test.ts` (22 tests, 9 new), covering:
- the Grid's key with the default limit, the stored limit and the URL's
limit;
- no Grid prefetch with URL filters, in the Gantt view, and on Dag pages
in the graph view;
- the Grid prefetch on run pages in the graph view;
- the Dashboard's keys, including the shared range;
- the range being reused only within the window;
- `/` skipped when the landing page is the Dags list, but not `/home`.
- New default msw handlers for `historical_metrics_data`, `dag_stats` and
`monitor/health`. Tests that render the app root now send these requests
through the Dashboard loader, and the test setup fails on unhandled requests.
- The full UI suite passes (`pnpm test`, 2,437 tests), along with `pnpm
build`, `oxfmt`, `oxlint`, `eslint` and `tsc`. One unrelated test,
`UserSettingsButton` "counts the teams it does not list…", failed once in a
full run with a network error and passes when run alone, as noted on #76978.
### Measurements
I measured the Dashboard loader on an Airflow 3.3 deployment, as an
equivalent change. The A/B compared the same UI sources without and with the
loaders, with the JavaScript cached, against a real API server. A and B loads
alternated, 12 rounds. Medians:
| Home page | Without | With | Change |
|-|-|-|-|
| `historical_metrics_data` done | 593 ms | 458 ms | −135 ms |
| End of the first request burst | 626 ms | 532 ms | −94 ms |
| LCP | 560 ms | 438 ms | −122 ms |
There were no duplicate requests, so the shared range made the keys match. I
didn't measure the Grid prefetch separately: on run pages, the load ends with
the Grid's TI summaries, which the Grid requests only once it renders, so the
Grid prefetch mainly gets its runs, and the request for their summaries,
started earlier.
No visual change.
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes (please specify the tool below)
Generated-by: Claude Code (Claude Opus 5.5) following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
---
* Read the **[Pull Request
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#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](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
is needed.
* When adding dependency, check compliance with the [ASF 3rd Party License
Policy](https://www.apache.org/legal/resolved.html#category-x).
* For significant user-facing changes create newsfragment:
`{pr_number}.significant.rst`, in
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
You can add this file in a follow-up commit after the PR is created so you
know the PR number.
--
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]