Repository navigation
Closed
Labels
Description
Description
In the current Airflow Graph View, all TaskGroups are expanded by default when a DAG is opened.
For very large DAGs, this makes the view cluttered and difficult to navigate.
For smaller DAGs or selected TaskGroups, it is convenient to see the details immediately.
It would be very helpful to have:
- A DAG-level parameter to set the default collapse state for all TaskGroups in that DAG.
- A TaskGroup-level parameter to override the default for specific groups.
Use case/motivation
- Large DAGs: collapsing TaskGroups by default improves readability and reduces visual clutter.
- Mixed DAGs: some TaskGroups should start collapsed (big ones), while others should stay expanded (small utility groups).
- This dual control (global default + per-group override) gives DAG authors maximum flexibility.
Proposed solution
Introduce:
taskgroup_collapsedas an optional argument in the DAG constructor (default = False).collapsedas an optional argument inTaskGroup(...)(default = None → inherit from DAG setting).
Example
from airflow import DAG
from airflow.utils.task_group import TaskGroup
from airflow.operators.empty import EmptyOperator
from datetime import datetime
with DAG(
dag_id="my_dag",
default_args={"owner": "airflow"},
start_date=datetime(2025, 1, 1),
schedule_interval="@daily",
taskgroup_collapsed=True, # NEW DAG-level default
) as dag:
# This group will be collapsed by default (inherits from DAG)
with TaskGroup(group_id="processing", tooltip="Data processing") as processing:
t1 = EmptyOperator(task_id="start")
t2 = EmptyOperator(task_id="end")
t1 >> t2
# This group explicitly overrides the default
with TaskGroup(group_id="small", tooltip="Tiny group", collapsed=False) as small_group:
EmptyOperator(task_id="only_task")
### Related issues
[AIP-38: Add Expand/Collapse all task groups button](https://github.com/apache/airflow/issues/47429?utm_source=chatgpt.com)
– request for a global toggle in the UI.
[Task expand/collapse is intermittently available in grid view](https://github.com/apache/airflow/issues/53919?utm_source=chatgpt.com)
– describes inconsistent collapse/expand behavior.
[Add UI collapse property to TaskGroups](https://github.com/apache/airflow/issues/19773?utm_source=chatgpt.com)
– earlier proposal for a collapse initial state (closed but highly relevant).
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)Reacted by ict-sbsshu
Activity
vikrantkumar-max commentedon Sep 12, 2025
I would like to work on this ticket
bbovenzi commentedon Sep 2, 2026
We persist the dag's open groups in the browser's localStorage. We should keep it there and not define it via dag code. We have a new user settings page if you want a setting for all task groups for all dags.
ucaeon commentedon Sep 21, 2026
I've picked this up and implemented the user-settings approach suggested above.☺️
It adds a browser-local preference to expand task groups by default while preserving existing per-Dag selections.
Local tests are passing, and I'll open a PR shortly with before/after screenshots!