From 38d7da93e2e345b1480ae501a799aa1c541c8497 Mon Sep 17 00:00:00 2001 From: Vadym Samoilenko Date: Wed, 13 May 2026 14:14:27 +0100 Subject: [PATCH] fix(auth): restore session before registering router to prevent refresh redirect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move app.use(router) after await authStore.init() so the beforeEach guard sees the correct isAuthenticated state on page load - Fix backfill_session_costs._root_prefix: remove underscore→dash replacement that caused paths like /Users/ai_leed/... to not match ~/.claude/projects/ folders Co-Authored-By: Claude Sonnet 4.6 --- scripts/backfill_session_costs.py | 2 +- web/src/main.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/backfill_session_costs.py b/scripts/backfill_session_costs.py index 0ec14a5..88817ba 100644 --- a/scripts/backfill_session_costs.py +++ b/scripts/backfill_session_costs.py @@ -51,7 +51,7 @@ def _get_pricing(model: str) -> tuple[float, float, float, float]: def _root_prefix(root_path: str) -> str: - return root_path.rstrip("/").replace("/", "-").replace("_", "-") + return root_path.rstrip("/").replace("/", "-") def _match_root(folder_key: str) -> str | None: diff --git a/web/src/main.ts b/web/src/main.ts index 9c35892..9cfed91 100644 --- a/web/src/main.ts +++ b/web/src/main.ts @@ -14,7 +14,6 @@ initMsal().then(async () => { const pinia = createPinia() app.use(pinia) - app.use(router) app.use(VueQueryPlugin) const authStore = useAuthStore() @@ -27,8 +26,10 @@ initMsal().then(async () => { (token) => authStore.setToken(token), ) - // Restore session from HttpOnly refresh cookie before mounting + // Restore session BEFORE registering router so the beforeEach guard + // sees the correct isAuthenticated state on initial navigation await authStore.init() + app.use(router) app.mount('#app') })