From dd5b8d7e92781aaaf2cf71133e8e2d96430adaba Mon Sep 17 00:00:00 2001 From: Zane Staggs Date: Thu, 21 Aug 2025 12:39:34 -0700 Subject: [PATCH 1/2] fix issue where app redirects to home after initialization but user has already started a chat --- ui/desktop/src/utils/appInitialization.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ui/desktop/src/utils/appInitialization.ts b/ui/desktop/src/utils/appInitialization.ts index 3313751cf824..8069352acd6e 100644 --- a/ui/desktop/src/utils/appInitialization.ts +++ b/ui/desktop/src/utils/appInitialization.ts @@ -95,8 +95,18 @@ export const initializeApp = async ({ } } } - window.location.hash = '#/'; - window.history.replaceState({}, '', '#/'); + + // Only redirect to home if we're still on the initial empty hash or root + // This prevents redirecting users who have already navigated elsewhere during initialization + const currentHash = window.location.hash; + const currentPathname = window.location.pathname; + const isOnRootRoute = + currentPathname === '/' && (!currentHash || currentHash === '#' || currentHash === '#/'); + + if (isOnRootRoute) { + window.location.hash = '#/'; + window.history.replaceState({}, '', '#/'); + } }; const initializeForSessionResume = async ({ From 338643c05ede6e7a1b483e59f64418a5cb2916f3 Mon Sep 17 00:00:00 2001 From: Zane Staggs Date: Thu, 21 Aug 2025 12:45:03 -0700 Subject: [PATCH 2/2] fix test --- ui/desktop/src/App.test.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/desktop/src/App.test.tsx b/ui/desktop/src/App.test.tsx index 338c1e9a1ff4..a4a9049f4ad5 100644 --- a/ui/desktop/src/App.test.tsx +++ b/ui/desktop/src/App.test.tsx @@ -15,6 +15,7 @@ Object.defineProperty(window, 'location', { search: '', href: 'http://localhost:3000', origin: 'http://localhost:3000', + pathname: '/', }, writable: true, }); @@ -196,6 +197,7 @@ describe('App Component - Brand New State', () => { vi.clearAllMocks(); window.location.hash = ''; window.location.search = ''; + window.location.pathname = '/'; window.sessionStorage.clear(); window.localStorage.clear(); });