Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ui/desktop/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Object.defineProperty(window, 'location', {
search: '',
href: 'http://localhost:3000',
origin: 'http://localhost:3000',
pathname: '/',
},
writable: true,
});
Expand Down Expand Up @@ -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();
});
Expand Down
14 changes: 12 additions & 2 deletions ui/desktop/src/utils/appInitialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({}, '', '#/');
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I dont understand this code and comment though - it seems like it says, redirect to root, but only if we are already on root?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's the fallback route to home, but we only want to trigger it if the user hasn't already navigated somewhere else by the time it hits this.

};

const initializeForSessionResume = async ({
Expand Down
Loading