Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(layout): render DevDockLayout inside CacheHydrationGate (#17967)

Innei1462660e099d
diff --git a/src/layout/SPAGlobalProvider/index.test.tsx b/src/layout/SPAGlobalProvider/index.test.tsx
index 067574eea88..1b2b8a84a2e 100644
--- a/src/layout/SPAGlobalProvider/index.test.tsx
+++ b/src/layout/SPAGlobalProvider/index.test.tsx
@@ -13,7 +13,8 @@ import { type DevDockLayout as DevDockLayoutComponent } from './index';
let SPAGlobalProvider: typeof SPAGlobalProviderComponent;
let DevDockLayout: typeof DevDockLayoutComponent;
-const { canAccessDevDock, devDockRenderError } = vi.hoisted(() => ({
+const { cacheGateReleased, canAccessDevDock, devDockRenderError } = vi.hoisted(() => ({
+ cacheGateReleased: { current: true },
canAccessDevDock: vi.fn(() => false),
devDockRenderError: { current: null as Error | null },
}));
@@ -124,7 +125,7 @@ vi.mock('@/layout/GlobalProvider/CacheHydrationGate', async () => {
return {
default: ({ children }: { children?: ReactNode }) =>
- React.createElement(React.Fragment, null, children),
+ cacheGateReleased.current ? React.createElement(React.Fragment, null, children) : null,
};
});
@@ -198,6 +199,7 @@ describe('SPAGlobalProvider', () => {
});
beforeEach(() => {
+ cacheGateReleased.current = true;
canAccessDevDock.mockReturnValue(false);
devDockRenderError.current = null;
setDevDockUnlocked(false);
diff --git a/src/layout/SPAGlobalProvider/index.tsx b/src/layout/SPAGlobalProvider/index.tsx
index 67f79454f2c..fbed5c5c2bb 100644
--- a/src/layout/SPAGlobalProvider/index.tsx
+++ b/src/layout/SPAGlobalProvider/index.tsx
@@ -97,7 +97,9 @@ const SPAGlobalProvider = memo<PropsWithChildren>(({ children }) => {
<TooltipGroup layoutAnimation={false}>
<StyleProvider speedy={import.meta.env.PROD}>
<LobeAnalyticsProviderWrapper>
- <CacheHydrationGate>{children}</CacheHydrationGate>
+ <CacheHydrationGate>
+ <DevDockLayout>{children}</DevDockLayout>
+ </CacheHydrationGate>
</LobeAnalyticsProviderWrapper>
</StyleProvider>
</TooltipGroup>
@@ -124,9 +126,7 @@ const SPAGlobalProvider = memo<PropsWithChildren>(({ children }) => {
isMobile={isMobile}
serverConfig={serverConfig?.config}
>
- <QueryProvider>
- <DevDockLayout>{content}</DevDockLayout>
- </QueryProvider>
+ <QueryProvider>{content}</QueryProvider>
</ServerConfigStoreProvider>
</AppTheme>
</Locale>