Skip to content

Add option to collapse TaskGroups by default in Graph View #55305

Closed

Description

@rolfschleiss

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:

  1. A DAG-level parameter to set the default collapse state for all TaskGroups in that DAG.
  2. 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_collapsed as an optional argument in the DAG constructor (default = False).
  • collapsed as an optional argument in TaskGroup(...) (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)

Activity

  1. added
    kind:feature
    needs-triage
    on Sep 5, 2025
  2. vikrantkumar-max commented on Sep 12, 2025

    @vikrantkumar-max
    Contributor

    I would like to work on this ticket

  3. added
    area:UI
    and removed
    needs-triage
    on Sep 2, 2026
  4. bbovenzi commented on Sep 2, 2026

    @bbovenzi
    Contributor

    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.

  5. ucaeon commented on Sep 21, 2026

    @ucaeon
    Contributor

    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! ☺️

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:TaskGrouparea:UIkind:feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions