fix: close module access lifecycle gaps

This commit is contained in:
2026-08-17 09:15:37 +08:00
parent d16922f18c
commit ebe55ba17a
8 changed files with 289 additions and 19 deletions

View File

@@ -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;