fix: close module access lifecycle gaps
This commit is contained in:
25
src/App.tsx
25
src/App.tsx
@@ -35,6 +35,7 @@ import {
|
||||
AI_MODULE_SELECTION_PATH,
|
||||
getGuardedAiModuleForPath,
|
||||
isAiModuleAllowed,
|
||||
isProgrammingProviderRoute,
|
||||
} from './lib/ai-modules';
|
||||
import { useUserSyncStore } from './stores/user-sync';
|
||||
import { flushPendingAgentSessionSync } from '@/lib/agent-session-sync';
|
||||
@@ -122,10 +123,6 @@ function getReturnPath(location: ReturnType<typeof useLocation>): string {
|
||||
return `${location.pathname}${location.search}`;
|
||||
}
|
||||
|
||||
function isProgrammingRoute(pathname: string): boolean {
|
||||
return getGuardedAiModuleForPath(pathname) === 'programming';
|
||||
}
|
||||
|
||||
function ProtectedLayout({
|
||||
authReady,
|
||||
authRequired,
|
||||
@@ -321,10 +318,24 @@ function App() {
|
||||
useEffect(() => {
|
||||
if (rendererOnlyPreview) return;
|
||||
if (!setupReady) return;
|
||||
if (!programmingModuleAllowed) return;
|
||||
if (!isProgrammingRoute(location.pathname)) return;
|
||||
if (authRequired && !authInitialized) return;
|
||||
if (authRequired && !authenticated) return;
|
||||
if (!isProgrammingProviderRoute(location.pathname)) return;
|
||||
if (
|
||||
getGuardedAiModuleForPath(location.pathname) === 'programming'
|
||||
&& !programmingModuleAllowed
|
||||
) return;
|
||||
initProviders();
|
||||
}, [initProviders, location.pathname, programmingModuleAllowed, rendererOnlyPreview, setupReady]);
|
||||
}, [
|
||||
authInitialized,
|
||||
authRequired,
|
||||
authenticated,
|
||||
initProviders,
|
||||
location.pathname,
|
||||
programmingModuleAllowed,
|
||||
rendererOnlyPreview,
|
||||
setupReady,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
if (rendererOnlyPreview) return;
|
||||
|
||||
Reference in New Issue
Block a user