Skip to content

Conversation

@RoyLee1224
Copy link
Contributor

@RoyLee1224 RoyLee1224 commented Dec 1, 2025

Related

closes: #57625

What

Refactors tab preservation logic to use Entity-based LocalStorage.

  • Introduces 6 entity-type storage keys (DAG, RUN, TASK, TASK_INSTANCE, MAPPED_TASK_INSTANCE, TASK_GROUP) instead of per-URL keys
  • Refactors useTabMemory hook to accept storageKey parameter with options object pattern
  • Adds getTaskAdditionalPath for Task page navigation
  • Updates getTaskInstanceAdditionalPath to only handle TaskInstance pages (with /runs/)

Screenshots

preserve_tabs.mp4

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@pierrejeambrun pierrejeambrun added the backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch label Dec 2, 2025
@pierrejeambrun pierrejeambrun added this to the Airflow 3.1.4 milestone Dec 2, 2025
Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

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

The problem with this approach is that it will not recall the tabs if we start switching from a TI to a DagRun back and forth. Only from TI to TI and Runs to Runs. Which is still a regression from 2.x.

In 2.x to achieve that, we would persist the active tabs in the local storage. To not have a multitude of storage entries. We could imagine 1 entry per 'type' of entities (that has specific tabs layout).

For instance, TI, Mapped TI, Task Group, Task, Run and DAG. And persist the active tab in the storage. Then everytime we redirect somewhere, read the appropriate value from the storage (depending on our current entity type), and default redirect to that if defined.

This will also have the advantage of persisting the tab accross different dags. (all groups will default to something, all Runs will default to something, etc.)

@RoyLee1224
Copy link
Contributor Author

@pierrejeambrun Thanks for the review, the localStorage approach makes much more sense. I'll update to support that. 🚀

@eladkal
Copy link
Contributor

eladkal commented Jan 22, 2026

@RoyLee1224 are you still working on this PR?

@RoyLee1224
Copy link
Contributor Author

Hi, yes! I'll be wrapping up the remaining this week.

@RoyLee1224
Copy link
Contributor Author

@pierrejeambrun I have updated the PR to use the Entity-based LocalStorage approach you recommended. This fixes the persistence issues across different Dags and simplifies the logic significantly. Ready for your review!

Copy link
Member

@guan404ming guan404ming left a comment

Choose a reason for hiding this comment

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

Looks nice, just left some nit!

return "";
};

export const getTaskAdditionalPath = (pathname: string): string => {
Copy link
Member

Choose a reason for hiding this comment

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

getTaskInstanceAdditionalPath validates against taskInstanceRoutes and plugin prefixes. Would it be worth adding a similar check and also with more tests?

refetchInterval: isStatePending(taskInstance?.state) ? refetchInterval : false,
});

const storageKey =
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should consider defaulting based on URL shape (e.g., checking for /mapped/ in the path) rather than waiting for API data, which may cause a redirect during the async call

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

Labels

backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dag view does not remember tab when switching between dags

6 participants