diff --git a/components/layout/account-switcher.tsx b/components/layout/account-switcher.tsx index 8e044514..6cf3573a 100644 --- a/components/layout/account-switcher.tsx +++ b/components/layout/account-switcher.tsx @@ -40,8 +40,11 @@ export function AccountSwitcher({ variant = "rail", className }: AccountSwitcher const [popoverStyle, setPopoverStyle] = useState({}); const accounts = useAccountStore((s) => s.accounts); - const activeAccountId = useAccountStore((s) => s.activeAccountId); const setDefaultAccount = useAccountStore((s) => s.setDefaultAccount); + // Read activeAccountId from authStore so the selector matches the actually-loaded + // session (primaryIdentity, JMAP client). accountStore.activeAccountId is a separate + // persisted copy that can drift out of sync across hydration / partial persist writes. + const activeAccountId = useAuthStore((s) => s.activeAccountId); const activeAccount = accounts.find((a) => a.id === activeAccountId); const switchAccount = useAuthStore((s) => s.switchAccount); const logout = useAuthStore((s) => s.logout); diff --git a/components/layout/navigation-rail.tsx b/components/layout/navigation-rail.tsx index ea94803f..ad0594e7 100644 --- a/components/layout/navigation-rail.tsx +++ b/components/layout/navigation-rail.tsx @@ -184,7 +184,9 @@ export function NavigationRail({ // Account list for rail const accounts = useAccountStore((s) => s.accounts); - const activeAccountId = useAccountStore((s) => s.activeAccountId); + // Read activeAccountId from authStore so the rail's account row matches the actually-loaded + // session — accountStore has its own persisted copy that can drift out of sync. + const activeAccountId = useAuthStore((s) => s.activeAccountId); const switchAccount = useAuthStore((s) => s.switchAccount); const logout = useAuthStore((s) => s.logout); const logoutAll = useAuthStore((s) => s.logoutAll);