Persist AI panel router history stack across page reloads
What does this MR do and why?
Persists the AI panel's Vue Router (abstract mode) history stack to
sessionStorage so the in-panel "Go back" button continues to work
after a full page reload.
Before this MR, the panel's navigation history lived entirely in JS
memory; a hard refresh wiped it and router.canGoBack() returned
false until the user navigated at least twice in the panel again.
After this MR, every successful navigation serializes the stack to a
new duo_agents_platform_history_stack_{context} sessionStorage key,
and restoreLastRoute replays the stack on boot.
Behind the duo_panel_history_stack_persistence feature flag
(gitlab_com_derisk type, disabled by default).
The MR is structured as three commits so reviewers can take it a layer at a time:
- Register the feature flag — adds the flag YAML and pushes it
through
gon_helper.rbso the frontend can gate onwindow.gon.features.duoPanelHistoryStackPersistence. - Add history stack serialization helpers — three pure
functions (
saveHistoryStack,getHistoryStack,getHistoryStackKey) with 28 unit tests. Inert at this layer — no callers wired yet. - Wire history stack write and restore paths — registers a
router.afterEachinsiderestoreLastRouteto persist the stack on every navigation, and replays the persisted stack on panel init. Gated on the feature flag; falls back to the existing single-route restore when the flag is off.
A behavioral subtlety: when the flag is on, restoreLastRoute no
longer falls through to the legacy single-route fallback path on
empty or corrupt stacks. The flag-on branch owns its own navigation
policy and pushes a mode-aware default route on replay error. The
shouldShowBlockedState check was also hoisted above the FF branch
so blocked users land on the blocked route regardless of which path
is active.
Screenshots or screen recordings
How to set up and validate locally
- Enable the flag:
Feature.enable(:duo_panel_history_stack_persistence) - Open the AI panel from the navigation rail.
- Navigate Chat → Sessions tab → open any session detail.
- In devtools console:
You should see an array of
sessionStorage.getItem('duo_agents_platform_history_stack_side_panel'){name, params}route entries. - Hard reload the page (Cmd+Shift+R).
- Verify the panel restores to the session detail and the "Go back" button is visible. Click it — you should return to the sessions list.
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.