Preserve sessions index page when navigating back

What does this MR do and why?

When a user navigates from the sessions index to a session detail page and then back, the index component is unmounted and remounted, losing the pagination variables. The Apollo cache may still hold the data, but the query is re-issued with the default (first-page) variables, so the user lands on page 1 instead of the page they were on.

Fix: add a lightweight sessions_query_state.js module that stores the last-used query variables (sort, pagination, filters) in a module-level variable. Both UserAgentsPlatformIndex and ProjectAgentsPlatformIndex read the stored variables on mount and write them whenever the child emits query-variables-updated. Because the module is not part of the navigation_state.js import chain, it avoids the circular dependency that would otherwise arise.

References

https://gitlab.com/gitlab-org/gitlab/-/work_items/571496

Screenshots or screen recordings

Before After

How to set up and validate locally

  1. Navigate to the agent sessions index page (e.g. /group/-/agent-sessions).
  2. Page forward to page 2 or apply a filter/sort.
  3. Click into a session detail.
  4. Click the browser back button or the breadcrumb to return to the index.
  5. Before: lands on page 1 with default sort. After: lands on the same page/sort/filter as before.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Lindsey Shelton

Merge request reports

Loading
Loading