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.

⚑️ perf(skeleton): declare route skeletons per page and gate page loads on RouteLoading (#19244)

Innei16eb2b5611ea
diff --git a/.agents/skills/spa-routes/SKILL.md b/.agents/skills/spa-routes/SKILL.md
index 06c488a8db4..22b5749b08f 100644
--- a/.agents/skills/spa-routes/SKILL.md
+++ b/.agents/skills/spa-routes/SKILL.md
@@ -82,7 +82,7 @@ Each feature should:
- **Mobile-only flow:** use `mobileRouter.config.tsx`; mobile does not consume the shared desktop tree.
6. **Register a route skeleton (REQUIRED for every lazy route)**
- - Every lazy route inside the main area renders `RouteSegmentSkeleton` (`src/components/Skeleton/RouteSegment.tsx`) while its chunk loads. It resolves via `handle.meta.Skeleton` (deepest match wins, walking up through parent routes) and only then falls back to path-guessing β€” never rely on the guess.
+ - Every lazy route inside the main area renders `RouteSegmentSkeleton` (`src/components/Skeleton/RouteSegment.tsx`) while its chunk loads. It resolves via `handle.meta.Skeleton` only (deepest match wins, walking up through parent routes). Omitting `Skeleton` renders a blank pane β€” use `NoRouteSkeleton` when that is intentional.
- Pick the skeleton when adding or restructuring a route:
- A close-enough generic shape exists β†’ `Skeleton: createSurfaceSkeleton('list' | 'form' | 'grid' | 'editor' | 'detail')` from `@/components/Skeleton/Surface`.
- The page has a distinctive layout (dashboard, multi-panel, conversation) β†’ author a bespoke component under `src/components/Skeleton/` and register it (see `Home.tsx`, `Generation.tsx`, `Conversation/`).
diff --git a/src/components/Skeleton/CommunityHome.tsx b/src/components/Skeleton/CommunityHome.tsx
new file mode 100644
index 00000000000..c83182ff640
--- /dev/null
+++ b/src/components/Skeleton/CommunityHome.tsx
@@ -0,0 +1,39 @@
+'use client';
+
+import { Flexbox } from '@lobehub/ui';
+import { Skeleton } from '@lobehub/ui/base-ui';
+import { memo } from 'react';
+
+import type { RouteSkeletonProps } from '@/spa/router/routeMeta';
+
+import CommunityListSkeleton, { CommunityPageChrome } from './CommunityList';
+
+const SectionTitle = () => (
+ <Flexbox
+ horizontal
+ align={'center'}
+ height={41}
+ justify={'space-between'}
+ style={{ marginBlockStart: 10 }}
+ >
+ <Skeleton height={31} width={160} />
+ <Skeleton height={32} width={120} />
+ </Flexbox>
+);
+
+const CommunityHomeSkeleton = memo<RouteSkeletonProps>(({ chrome = 'page' }) => (
+ <CommunityPageChrome chrome={chrome}>
+ <Flexbox aria-busy gap={16} width={'100%'}>
+ <Skeleton height={150} style={{ borderRadius: 12 }} />
+ <SectionTitle />
+ <CommunityListSkeleton chrome={'body'} length={8} rows={4} />
+ <div />
+ <SectionTitle />
+ <CommunityListSkeleton chrome={'body'} length={8} rows={4} />
+ </Flexbox>
+ </CommunityPageChrome>
+));
+
+CommunityHomeSkeleton.displayName = 'CommunityHomeSkeleton';
+
+export default CommunityHomeSkeleton;
diff --git a/src/components/Skeleton/CommunityList.tsx b/src/components/Skeleton/CommunityList.tsx
index cf354f75688..675d233b279 100644
--- a/src/components/Skeleton/CommunityList.tsx
+++ b/src/components/Skeleton/CommunityList.tsx
@@ -3,9 +3,12 @@
import { Block, Flexbox, Grid } from '@lobehub/ui';
import { Skeleton } from '@lobehub/ui/base-ui';
import { createStaticStyles } from 'antd-style';
-import { memo } from 'react';
+import { memo, type ReactNode } from 'react';
-import type { RouteSkeletonProps } from '@/spa/router/routeMeta';
+import WideScreenContainer from '@/features/WideScreenContainer';
+import type { RouteSkeletonChrome, RouteSkeletonProps } from '@/spa/router/routeMeta';
+
+const COMMUNITY_MAX_WIDTH = 1440;
const styles = createStaticStyles(({ css, cssVar }) => ({
footer: css`
@@ -17,6 +20,45 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
`,
}));
+// Mirrors the community list layout (search header + centered wide-screen
+// container) for the fallback that paints before that layout has mounted.
+export const CommunityPageChrome = ({
+ children,
+ chrome,
+}: {
+ children: ReactNode;
+ chrome: RouteSkeletonChrome;
+}) => {
+ if (chrome === 'body') return children;
+
+ return (
+ <Flexbox aria-busy height={'100%'} width={'100%'}>
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={styles.toolbar}
+ flex={'none'}
+ gap={12}
+ height={56}
+ justify={'space-between'}
+ paddingInline={16}
+ >
+ <Skeleton height={20} width={280} />
+ <Skeleton height={28} width={132} />
+ </Flexbox>
+ <Flexbox height={'100%'} style={{ overflow: 'hidden' }} width={'100%'}>
+ <WideScreenContainer
+ gap={16}
+ minWidth={COMMUNITY_MAX_WIDTH}
+ style={{ paddingBottom: 56, paddingTop: 16 }}
+ >
+ {children}
+ </WideScreenContainer>
+ </Flexbox>
+ </Flexbox>
+ );
+};
+
export interface CommunityListSkeletonProps extends RouteSkeletonProps {
length?: number;
rows?: number;
@@ -29,48 +71,36 @@ export interface CommunityListSkeletonProps extends RouteSkeletonProps {
*/
const CommunityListSkeleton = memo<CommunityListSkeletonProps>(
({ rows = 3, length = 12, chrome = 'page' }) => (
- <Flexbox gap={16} width={'100%'}>
- {chrome !== 'body' && (
- <Flexbox
- horizontal
- align={'center'}
- className={styles.toolbar}
- gap={12}
- height={56}
- justify={'space-between'}
- paddingInline={16}
- >
- <Skeleton height={20} width={280} />
- <Skeleton height={28} width={132} />
- </Flexbox>
- )}
- <Grid rows={rows} width={'100%'}>
- {Array.from({ length }).map((_, index) => (
- <Block gap={12} key={index} padding={16} variant={'outlined'}>
- <Flexbox horizontal align={'center'} gap={12}>
- <Skeleton.Avatar shape="square" size={40} style={{ flex: 'none' }} />
- <Flexbox flex={1} gap={4}>
- <Skeleton height={20} width={'70%'} />
- <Skeleton height={14} width={'40%'} />
+ <CommunityPageChrome chrome={chrome}>
+ <Flexbox aria-busy gap={16} width={'100%'}>
+ <Grid rows={rows} width={'100%'}>
+ {Array.from({ length }).map((_, index) => (
+ <Block gap={12} key={index} padding={16} variant={'outlined'}>
+ <Flexbox horizontal align={'center'} gap={12}>
+ <Skeleton.Avatar shape="square" size={40} style={{ flex: 'none' }} />
+ <Flexbox flex={1} gap={4}>
+ <Skeleton height={20} width={'70%'} />
+ <Skeleton height={14} width={'40%'} />
+ </Flexbox>
</Flexbox>
- </Flexbox>
- <Skeleton.Text rows={3} style={{ marginBottom: 0 }} />
- <Flexbox horizontal gap={8}>
- <Skeleton height={20} width={60} />
- <Skeleton height={20} width={50} />
- </Flexbox>
- <Flexbox
- className={styles.footer}
- gap={4}
- padding={8}
- style={{ marginBottom: -16, marginInline: -16 }}
- >
- <Skeleton height={14} width={100} />
- </Flexbox>
- </Block>
- ))}
- </Grid>
- </Flexbox>
+ <Skeleton.Text rows={3} style={{ marginBottom: 0 }} />
+ <Flexbox horizontal gap={8}>
+ <Skeleton height={20} width={60} />
+ <Skeleton height={20} width={50} />
+ </Flexbox>
+ <Flexbox
+ className={styles.footer}
+ gap={4}
+ padding={8}
+ style={{ marginBottom: -16, marginInline: -16 }}
+ >
+ <Skeleton height={14} width={100} />
+ </Flexbox>
+ </Block>
+ ))}
+ </Grid>
+ </Flexbox>
+ </CommunityPageChrome>
),
);
diff --git a/src/components/Skeleton/Conversation/Container.tsx b/src/components/Skeleton/Conversation/Container.tsx
index 1efd68719e4..207230a5457 100644
--- a/src/components/Skeleton/Conversation/Container.tsx
+++ b/src/components/Skeleton/Conversation/Container.tsx
@@ -25,7 +25,7 @@ const ConversationSkeletonContainer = ({
const wideScreen = useGlobalStore(systemStatusSelectors.wideScreen);
return (
- <Flexbox flex={flex} height={height} style={{ minHeight: 0 }} width={'100%'}>
+ <Flexbox aria-busy flex={flex} height={height} style={{ minHeight: 0 }} width={'100%'}>
<Flexbox
className={cx(styles.container, className)}
flex={flex}
diff --git a/src/components/Skeleton/Delayed.tsx b/src/components/Skeleton/Delayed.tsx
index e99e1b9e343..aa9ac7e27ba 100644
--- a/src/components/Skeleton/Delayed.tsx
+++ b/src/components/Skeleton/Delayed.tsx
@@ -2,6 +2,8 @@
import { type ReactNode, useEffect, useState } from 'react';
+import { isSkeletonHandover } from './skeletonHandover';
+
/**
* Matches `BOOT_SHELL_DELAY`: below this, a placeholder is on screen for less
* time than it takes to read as one, so it registers as a flicker between two
@@ -20,12 +22,13 @@ interface DelayedFallbackProps {
* previous screen simply stays until the next one paints.
*/
const DelayedFallback = ({ children, delay = FALLBACK_DELAY }: DelayedFallbackProps) => {
- const [elapsed, setElapsed] = useState(false);
+ const [elapsed, setElapsed] = useState(() => isSkeletonHandover());
useEffect(() => {
+ if (elapsed) return;
const timer = setTimeout(() => setElapsed(true), delay);
return () => clearTimeout(timer);
- }, [delay]);
+ }, [delay, elapsed]);
return elapsed ? children : null;
};
diff --git a/src/components/Skeleton/Memory.tsx b/src/components/Skeleton/Memory.tsx
index bd7f742654d..93e399372b4 100644
--- a/src/components/Skeleton/Memory.tsx
+++ b/src/components/Skeleton/Memory.tsx
@@ -13,14 +13,16 @@ const MemorySkeleton = ({ chrome = 'page' }: RouteSkeletonProps) => (
{chrome !== 'body' && <NavHeader />}
<Flexbox height={'100%'} style={{ overflow: 'hidden' }} width={'100%'}>
<WideScreenContainer gap={32} paddingBlock={48}>
- <Flexbox align={'center'} gap={16} paddingBlock={'18vh 0'}>
- <SkeletonBar height={44} radius={'50%'} width={44} />
- <Flexbox align={'center'} gap={10} width={'min(520px, 80%)'}>
- <SkeletonBar height={24} width={132} />
- <SkeletonBar height={14} width={'88%'} />
- <SkeletonBar height={14} width={'64%'} />
- <SkeletonBar height={32} width={128} />
- </Flexbox>
+ <SkeletonBar height={400} radius={12} />
+ <Flexbox gap={16}>
+ <SkeletonBar height={32} width={120} />
+ <SkeletonBar height={64} radius={8} />
+ </Flexbox>
+ <Flexbox gap={16}>
+ <SkeletonBar height={44} width={160} />
+ <SkeletonBar height={16} />
+ <SkeletonBar height={16} width={'92%'} />
+ <SkeletonBar height={16} width={'60%'} />
</Flexbox>
</WideScreenContainer>
</Flexbox>
diff --git a/src/components/Skeleton/RouteSegment.tsx b/src/components/Skeleton/RouteSegment.tsx
index 0356a63b3b5..fa5138fcf64 100644
--- a/src/components/Skeleton/RouteSegment.tsx
+++ b/src/components/Skeleton/RouteSegment.tsx
@@ -1,61 +1,32 @@
'use client';
-import { useLocation } from 'react-router';
+import { useLayoutEffect } from 'react';
import { useRouteSkeletonChrome } from '@/spa/router/routeSkeletonChrome';
import { useRouteSkeleton } from '@/spa/router/useRouteSkeleton';
-import AppsSkeleton from './Apps';
-import ConversationLayoutSkeleton from './Conversation/Layout';
import DelayedFallback from './Delayed';
-import MemorySkeleton from './Memory';
-import SettingsPageSkeleton from './Settings/Page';
-import SurfaceSkeleton, { type SurfaceSkeletonVariant } from './Surface';
-
-const FORM_SEGMENTS = new Set(['permission', 'profile']);
-const GRID_SEGMENTS = new Set(['channel', 'statistics']);
-const LIST_SEGMENTS = new Set(['history', 'memory']);
-
-const getSurfaceVariant = (pathname: string): SurfaceSkeletonVariant => {
- const segments = pathname.split('/').filter(Boolean);
- const leaf = segments.at(-1) ?? '';
-
- if (segments[0] === 'page' || segments.includes('docs') || segments.includes('task')) {
- return 'editor';
- }
- if (FORM_SEGMENTS.has(leaf)) return 'form';
- if (GRID_SEGMENTS.has(leaf)) return 'grid';
- if (LIST_SEGMENTS.has(leaf)) return 'list';
-
- return 'list';
-};
-
-const isConversationPath = (pathname: string) => {
- const segments = pathname.split('/').filter(Boolean);
- if (segments[0] !== 'agent' && segments[0] !== 'group') return false;
- if (segments.length === 2) return true;
- return segments.length === 3 && segments[2].startsWith('tpc_');
-};
+import { markSkeletonVisible } from './skeletonHandover';
-const RouteSegmentContent = () => {
+// Same component the route Suspense fallback renders, so a page's data wait
+// continues the chunk wait's skeleton instead of swapping to a second one.
+export const RouteLoading = () => {
const Skeleton = useRouteSkeleton();
const chrome = useRouteSkeletonChrome();
- const { pathname } = useLocation();
- const segments = pathname.split('/').filter(Boolean);
- if (Skeleton) return <Skeleton chrome={chrome} />;
- // `settings` at any depth: workspace settings live at /:slug/settings/*
- if (segments.includes('settings')) return <SettingsPageSkeleton chrome={chrome} />;
- if (segments[0] === 'apps') return <AppsSkeleton />;
- if (isConversationPath(pathname)) return <ConversationLayoutSkeleton />;
- if (segments[0] === 'memory' && segments.length === 1) return <MemorySkeleton chrome={chrome} />;
+ useLayoutEffect(() => {
+ if (!Skeleton) return;
+ markSkeletonVisible();
+ return markSkeletonVisible;
+ }, [Skeleton]);
- return <SurfaceSkeleton header={chrome !== 'body'} variant={getSurfaceVariant(pathname)} />;
+ if (!Skeleton) return null;
+ return <Skeleton chrome={chrome} />;
};
const RouteSegmentSkeleton = () => (
<DelayedFallback>
- <RouteSegmentContent />
+ <RouteLoading />
</DelayedFallback>
);
diff --git a/src/components/Skeleton/index.ts b/src/components/Skeleton/index.ts
index 361737c2f9c..62f8d05053a 100644
--- a/src/components/Skeleton/index.ts
+++ b/src/components/Skeleton/index.ts
@@ -1,6 +1,7 @@
export { default as AppsSkeleton } from './Apps';
export { default as ArticleSkeleton } from './Article';
export { default as SkeletonBar } from './Bar';
+export { default as CommunityHomeSkeleton } from './CommunityHome';
export { default as CommunityListSkeleton, type CommunityListSkeletonProps } from './CommunityList';
export { default as ConversationLayoutSkeleton } from './Conversation/Layout';
export { default as ConversationListSkeleton } from './Conversation/List';
@@ -11,7 +12,7 @@ export {
NAV_SKELETON_SHAPES,
NavSideBarSkeleton,
} from './NavPanel/SideBar';
-export { default as RouteSegmentSkeleton } from './RouteSegment';
+export { RouteLoading, default as RouteSegmentSkeleton } from './RouteSegment';
export { default as SettingsPageSkeleton } from './Settings/Page';
export { default as SettingsProfileSkeleton } from './Settings/Profile';
export { default as SettingsSectionSkeleton } from './Settings/Section';
diff --git a/src/components/Skeleton/skeletonHandover.test.ts b/src/components/Skeleton/skeletonHandover.test.ts
new file mode 100644
index 00000000000..cc9eba8f44c
--- /dev/null
+++ b/src/components/Skeleton/skeletonHandover.test.ts
@@ -0,0 +1,19 @@
+import { describe, expect, it } from 'vitest';
+
+import { HANDOVER_WINDOW, isSkeletonHandover, markSkeletonVisible } from './skeletonHandover';
+
+describe('skeletonHandover', () => {
+ it('is not a handover before any skeleton was visible', () => {
+ expect(isSkeletonHandover(0)).toBe(false);
+ });
+
+ it('is a handover right after a skeleton was visible', () => {
+ markSkeletonVisible(10_000);
+ expect(isSkeletonHandover(10_100)).toBe(true);
+ });
+
+ it('is not a handover once the window has passed', () => {
+ markSkeletonVisible(20_000);
+ expect(isSkeletonHandover(20_000 + HANDOVER_WINDOW)).toBe(false);
+ });
+});
diff --git a/src/components/Skeleton/skeletonHandover.ts b/src/components/Skeleton/skeletonHandover.ts
new file mode 100644
index 00000000000..fb00180ff55
--- /dev/null
+++ b/src/components/Skeleton/skeletonHandover.ts
@@ -0,0 +1,14 @@
+// A nested boundary (layout chunk β†’ page chunk) mounts its fallback in the same
+// commit the parent's skeleton unmounts. Delaying it again blanks the pane the
+// user is already reading a skeleton in, so a fallback that follows one within
+// this window paints immediately.
+export const HANDOVER_WINDOW = 400;
+
+let lastSkeletonVisibleAt = -Infinity;
+
+export const markSkeletonVisible = (now = performance.now()) => {
+ lastSkeletonVisibleAt = now;
+};
+
+export const isSkeletonHandover = (now = performance.now()) =>
+ now - lastSkeletonVisibleAt < HANDOVER_WINDOW;
diff --git a/src/components/SuspenseRouteBoundary/index.tsx b/src/components/SuspenseRouteBoundary/index.tsx
deleted file mode 100644
index bd0a21fea0b..00000000000
--- a/src/components/SuspenseRouteBoundary/index.tsx
+++ /dev/null
@@ -1,91 +0,0 @@
-'use client';
-
-import { Component, type ErrorInfo, type ReactNode } from 'react';
-import { useLocation } from 'react-router';
-import { SWRConfig } from 'swr';
-
-import AsyncError, { type AsyncErrorVariant } from '@/components/AsyncError';
-
-import {
- resetOnLocationChange,
- type RouteBoundaryState,
- routeResetKey,
-} from './resetOnLocationChange';
-import { useRouteRetry } from './useRouteRetry';
-
-interface BoundaryProps {
- children: ReactNode;
- onReset: () => void;
- resetKey: string;
- variant: AsyncErrorVariant;
-}
-
-class Boundary extends Component<BoundaryProps, RouteBoundaryState> {
- state: RouteBoundaryState = { resetKey: this.props.resetKey };
-
- static getDerivedStateFromError(error: Error) {
- return { error };
- }
-
- static getDerivedStateFromProps(props: BoundaryProps, state: RouteBoundaryState) {
- return resetOnLocationChange(props.resetKey, state);
- }
-
- componentDidCatch(error: Error, info: ErrorInfo) {
- console.error('[SuspenseRouteBoundary]', error, info.componentStack);
- }
-
- retry = () => {
- this.setState({ error: undefined });
- this.props.onReset();
- };
-
- render() {
- const { error } = this.state;
- if (!error) return this.props.children;
-
- return <AsyncError error={error} variant={this.props.variant} onRetry={this.retry} />;
- }
-}
-
-/**
- * Pairs with the route skeleton: loading is the route's Suspense fallback,
- * failure is this boundary's Retry.
- *
- * Under `suspense`, SWR reports a failed fetch by throwing, so the four-state
- * gate `AsyncBoundary` used to run at the call site has to move above the
- * suspending component. Without it one failed request takes the whole route to
- * the router's error page and the user loses the Retry that used to sit inside
- * the surface.
- *
- * Two things the class boundary alone gets wrong, both because it is mounted in
- * a *persistent* area layout that outlives the route under it:
- *
- * - Its error state survives navigation, so a failure on one route keeps
- * covering the healthy sibling the user moves to. `resetKey` clears it as the
- * location changes.
- * - Reset has to clear the SWR entry that threw, but the error carries no key,
- * so the naive fix is to invalidate the whole cache β€” which refetches every
- * mounted consumer in the app for one route's Retry. `onError` records the
- * keys that actually failed and reset revalidates only those.
- */
-const SuspenseRouteBoundary = ({
- children,
- variant = 'page',
-}: {
- children: ReactNode;
- variant?: AsyncErrorVariant;
-}) => {
- const { onError, onReset } = useRouteRetry();
- const { pathname, search } = useLocation();
-
- return (
- <SWRConfig value={{ onError }}>
- <Boundary resetKey={routeResetKey(pathname, search)} variant={variant} onReset={onReset}>
- {children}
- </Boundary>
- </SWRConfig>
- );
-};
-
-export default SuspenseRouteBoundary;
diff --git a/src/components/SuspenseRouteBoundary/resetOnLocationChange.test.ts b/src/components/SuspenseRouteBoundary/resetOnLocationChange.test.ts
deleted file mode 100644
index e4f599ff1ab..00000000000
--- a/src/components/SuspenseRouteBoundary/resetOnLocationChange.test.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import { describe, expect, it } from 'vitest';
-
-import { resetOnLocationChange, routeResetKey } from './resetOnLocationChange';
-
-describe('routeResetKey', () => {
- it('separates two queries on the same path', () => {
- expect(routeResetKey('/community/skill', '?page=1')).not.toBe(
- routeResetKey('/community/skill', '?page=2'),
- );
- });
-});
-
-describe('resetOnLocationChange', () => {
- const error = new Error('boom');
-
- it('keeps the failure while the location is unchanged', () => {
- expect(resetOnLocationChange('/eval', { error, resetKey: '/eval' })).toBeNull();
- });
-
- it('clears the failure when the pathname changes', () => {
- expect(
- resetOnLocationChange('/community/model', { error, resetKey: '/community/agent' }),
- ).toEqual({ error: undefined, resetKey: '/community/model' });
- });
-
- it('clears the failure when only the query changes', () => {
- expect(
- resetOnLocationChange('/community/skill?page=2', {
- error,
- resetKey: '/community/skill?page=1',
- }),
- ).toEqual({ error: undefined, resetKey: '/community/skill?page=2' });
- });
-});
diff --git a/src/components/SuspenseRouteBoundary/resetOnLocationChange.ts b/src/components/SuspenseRouteBoundary/resetOnLocationChange.ts
deleted file mode 100644
index bb5d59bd715..00000000000
--- a/src/components/SuspenseRouteBoundary/resetOnLocationChange.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-export interface RouteBoundaryState {
- error?: Error;
- resetKey: string;
-}
-
-/**
- * The location identity the boundary resets on. Pathname alone is not enough:
- * the community lists derive their SWR keys from the query string, so a failed
- * page / filter / ordering request has to clear when the user moves to a
- * different query on the same path.
- */
-export const routeResetKey = (pathname: string, search: string) => `${pathname}${search}`;
-
-/**
- * Clear a stale failure when the route changes, without remounting the healthy
- * subtree β€” the boundary lives in a persistent area layout, so keying it would
- * throw away the scroll position and local state of every route it wraps.
- */
-export const resetOnLocationChange = (
- resetKey: string,
- state: RouteBoundaryState,
-): RouteBoundaryState | null => {
- if (resetKey === state.resetKey) return null;
-
- return { error: undefined, resetKey };
-};
diff --git a/src/components/SuspenseRouteBoundary/useRouteRetry.test.ts b/src/components/SuspenseRouteBoundary/useRouteRetry.test.ts
deleted file mode 100644
index a332eea7d70..00000000000
--- a/src/components/SuspenseRouteBoundary/useRouteRetry.test.ts
+++ /dev/null
@@ -1,85 +0,0 @@
-import { renderHook, waitFor } from '@testing-library/react';
-import { createElement, type ReactNode } from 'react';
-import useSWR, { SWRConfig } from 'swr';
-import { describe, expect, it, vi } from 'vitest';
-
-import { useRouteRetry } from './useRouteRetry';
-
-const wrapper = ({ children }: { children: ReactNode }) =>
- createElement(
- SWRConfig,
- {
- value: {
- dedupingInterval: 0,
- provider: () => new Map(),
- revalidateOnFocus: false,
- shouldRetryOnError: false,
- },
- },
- children,
- );
-
-describe('useRouteRetry', () => {
- it('revalidates only the keys that failed, leaving the rest of the cache alone', async () => {
- const shellFetcher = vi.fn().mockResolvedValue('shell');
- const routeFetcher = vi.fn().mockResolvedValue('route');
-
- const { result } = renderHook(
- () => ({
- retry: useRouteRetry(),
- route: useSWR('route-key', routeFetcher),
- shell: useSWR('shell-key', shellFetcher),
- }),
- { wrapper },
- );
-
- await waitFor(() => {
- expect(result.current.shell.data).toBe('shell');
- expect(result.current.route.data).toBe('route');
- });
- expect(shellFetcher).toHaveBeenCalledTimes(1);
- expect(routeFetcher).toHaveBeenCalledTimes(1);
-
- result.current.retry.onError(new Error('boom'), 'route-key');
- result.current.retry.onReset();
-
- await waitFor(() => expect(routeFetcher).toHaveBeenCalledTimes(2));
- expect(shellFetcher).toHaveBeenCalledTimes(1);
- });
-
- it('does nothing when no key has failed', async () => {
- const shellFetcher = vi.fn().mockResolvedValue('shell');
-
- const { result } = renderHook(
- () => ({ retry: useRouteRetry(), shell: useSWR('shell-key', shellFetcher) }),
- { wrapper },
- );
-
- await waitFor(() => expect(result.current.shell.data).toBe('shell'));
-
- result.current.retry.onReset();
-
- await new Promise((resolve) => setTimeout(resolve, 10));
- expect(shellFetcher).toHaveBeenCalledTimes(1);
- });
-
- it('clears the recorded keys so a later reset does not replay them', async () => {
- const routeFetcher = vi.fn().mockResolvedValue('route');
-
- const { result } = renderHook(
- () => ({ retry: useRouteRetry(), route: useSWR('route-key', routeFetcher) }),
- { wrapper },
- );
-
- await waitFor(() => expect(result.current.route.data).toBe('route'));
-
- result.current.retry.onError(new Error('boom'), 'route-key');
- result.current.retry.onReset();
- await waitFor(() => expect(routeFetcher).toHaveBeenCalledTimes(2));
-
- result.current.retry.onReset();
-
- await new Promise((resolve) => setTimeout(resolve, 10));
- expect(routeFetcher).toHaveBeenCalledTimes(2);
- });
-});
diff --git a/src/components/SuspenseRouteBoundary/useRouteRetry.ts b/src/components/SuspenseRouteBoundary/useRouteRetry.ts
deleted file mode 100644
index 5ed6cdbd1f5..00000000000
--- a/src/components/SuspenseRouteBoundary/useRouteRetry.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import { useCallback } from 'react';
-import { useSWRConfig } from 'swr';
-
-import { useSingleton } from '@/hooks/useSingleton';
-
-/**
- * A thrown SWR error carries no key, so the only way for the route's Retry to
- * revalidate what actually failed is to record the keys as they fail. Without
- * this the reset has to match the whole cache, and one route's Retry refetches
- * every mounted consumer in the app.
- */
-export const useRouteRetry = () => {
- const { mutate } = useSWRConfig();
- const failedKeys = useSingleton(() => new Set<string>());
-
- const onError = useCallback(
- (_error: unknown, key: string) => {
- failedKeys.add(key);
- },
- [failedKeys],
- );
-
- const onReset = useCallback(() => {
- if (failedKeys.size === 0) return;
- const keys = new Set(failedKeys);
- failedKeys.clear();
- mutate((key) => typeof key === 'string' && keys.has(key), undefined, { revalidate: true });
- }, [failedKeys, mutate]);
-
- return { onError, onReset };
-};
diff --git a/src/features/AgentDocumentPage/Layout/index.tsx b/src/features/AgentDocumentPage/Layout/index.tsx
index a03b1c8c35f..6bf505a503d 100644
--- a/src/features/AgentDocumentPage/Layout/index.tsx
+++ b/src/features/AgentDocumentPage/Layout/index.tsx
@@ -2,9 +2,7 @@
import { Flexbox } from '@lobehub/ui';
import { Outlet } from 'react-router';
-import { SWRConfig } from 'swr';
-import SuspenseRouteBoundary from '@/components/SuspenseRouteBoundary';
import { NavPanelPortal } from '@/features/NavPanel/NavPanelPortal';
import AgentDocumentSidebarContent from '../RightPanel';
@@ -22,11 +20,7 @@ const AgentDocumentLayout = () => (
width={'100%'}
>
<Flexbox flex={1} style={{ minHeight: 0, minWidth: 0 }}>
- <SWRConfig value={{ suspense: true }}>
- <SuspenseRouteBoundary>
- <Outlet />
- </SuspenseRouteBoundary>
- </SWRConfig>
+ <Outlet />
</Flexbox>
</Flexbox>
</>
diff --git a/src/features/AgentDocumentPage/index.tsx b/src/features/AgentDocumentPage/index.tsx
index 3186ee71eda..9aaea02b2e8 100644
--- a/src/features/AgentDocumentPage/index.tsx
+++ b/src/features/AgentDocumentPage/index.tsx
@@ -4,6 +4,8 @@ import { Flexbox } from '@lobehub/ui';
import { memo, useCallback, useEffect, useMemo } from 'react';
import { useParams } from 'react-router';
+import AsyncError from '@/components/AsyncError';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { type ComposerTarget, createComposerTarget } from '@/features/Conversation/types';
import FloatingChatPanel from '@/features/FloatingChatPanel';
import { useDocumentChatTopic } from '@/features/FloatingChatPanel/useDocumentChatTopic';
@@ -34,6 +36,7 @@ const AgentDocumentPage = memo<AgentDocumentPageProps>(({ documentId }) => {
const navigate = useWorkspaceAwareNavigate();
const {
error: itemError,
+ isLoading,
isNotFound,
item,
mutate,
@@ -117,6 +120,10 @@ const AgentDocumentPage = memo<AgentDocumentPageProps>(({ documentId }) => {
// a 404 for a doc that simply moved to the empty-state landing.
if (isNotFound) return null;
+ if (isLoading) return <RouteLoading />;
+ if (itemError && !item)
+ return <AsyncError error={itemError} variant={'page'} onRetry={() => void mutate()} />;
+
return (
<Flexbox
horizontal
diff --git a/src/features/AgentDocumentPage/useAgentDocumentItem.ts b/src/features/AgentDocumentPage/useAgentDocumentItem.ts
index 55aeecf4b30..12564ba2e6c 100644
--- a/src/features/AgentDocumentPage/useAgentDocumentItem.ts
+++ b/src/features/AgentDocumentPage/useAgentDocumentItem.ts
@@ -17,7 +17,7 @@ import {
* bundle rename.
*/
export const useAgentDocumentItem = (agentId: string | undefined, documentId: string) => {
- const { data, error, mutate } = useClientDataSWR(
+ const { data, error, isLoading, mutate } = useClientDataSWR(
agentId ? agentDocumentSWRKeys.documentsList(agentId) : null,
() => agentDocumentService.listDocuments({ agentId: agentId! }),
);
@@ -37,5 +37,5 @@ export const useAgentDocumentItem = (agentId: string | undefined, documentId: st
// the breadcrumb render a placeholder title over a 404 body.
const isNotFound = !!agentId && data !== undefined && !error && !item;
- return { error, isNotFound, item, mutate, skillBundle };
+ return { error, isLoading, isNotFound, item, mutate, skillBundle };
};
diff --git a/src/features/Eval/BenchmarkDetailLoading.tsx b/src/features/Eval/BenchmarkDetailLoading.tsx
deleted file mode 100644
index fa0d74cfca0..00000000000
--- a/src/features/Eval/BenchmarkDetailLoading.tsx
+++ /dev/null
@@ -1,128 +0,0 @@
-import { Flexbox } from '@lobehub/ui';
-import { Skeleton } from '@lobehub/ui/base-ui';
-import { Card } from 'antd';
-import { createStaticStyles, cssVar } from 'antd-style';
-
-const styles = createStaticStyles(({ css }) => ({
- header: css`
- min-height: 66px;
- `,
- hero: css`
- min-height: 106px;
- padding: 20px;
- border-radius: ${cssVar.borderRadiusLG};
- background: ${cssVar.colorFillQuaternary};
- `,
- runsSection: css`
- border-style: dashed;
- background: ${cssVar.colorFillQuaternary};
- `,
- section: css`
- flex-shrink: 0;
- align-items: center;
- justify-content: center;
-
- height: 287px;
- padding-block: 64px;
- padding-inline: 24px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadiusLG};
-
- text-align: center;
- `,
- sectionTitle: css`
- flex-shrink: 0;
- align-items: center;
- min-height: 25px;
- `,
- statCard: css`
- min-height: 146px;
- `,
-}));
-
-const BenchmarkDetailLoading = () => (
- <>
- <Flexbox className={styles.header} gap={16}>
- <Flexbox horizontal align="start" justify={'space-between'}>
- <Flexbox horizontal align="start" gap={12}>
- <Skeleton.Avatar
- shape="square"
- size={40}
- style={{ borderRadius: cssVar.borderRadiusLG }}
- />
- <Flexbox flex={1} gap={8}>
- <Skeleton height={24} width={200} />
- <Skeleton height={14} width={320} />
- </Flexbox>
- </Flexbox>
- <Flexbox horizontal gap={8}>
- <Skeleton height={28} width={72} />
- <Skeleton height={28} width={28} />
- </Flexbox>
- </Flexbox>
- </Flexbox>
-
- <Flexbox horizontal align={'center'} className={styles.hero} justify={'space-between'}>
- <Flexbox gap={8}>
- <Skeleton height={32} width={64} />
- <Skeleton height={14} width={144} />
- </Flexbox>
- </Flexbox>
-
- <Flexbox horizontal gap={12}>
- {[1, 2, 3, 4].map((i) => (
- <Card
- className={styles.statCard}
- key={i}
- styles={{ body: { padding: 16 } }}
- style={{
- border: `1px solid ${cssVar.colorBorderSecondary}`,
- borderRadius: cssVar.borderRadius,
- flex: 1,
- minWidth: 0,
- }}
- >
- <Flexbox gap={12}>
- <Flexbox horizontal align="center" gap={8}>
- <Skeleton.Avatar
- shape="square"
- size={36}
- style={{ borderRadius: cssVar.borderRadius }}
- />
- <Skeleton height={14} width={80} />
- </Flexbox>
- <Flexbox gap={4}>
- <Skeleton height={24} width={60} />
- <Skeleton height={12} width={100} />
- </Flexbox>
- </Flexbox>
- </Card>
- ))}
- </Flexbox>
-
- <Flexbox className={styles.sectionTitle}>
- <Skeleton height={18} width={80} />
- </Flexbox>
- <Flexbox className={styles.section} gap={16}>
- <Skeleton.Avatar shape={'square'} size={56} style={{ borderRadius: cssVar.borderRadiusLG }} />
- <Flexbox align={'center'} gap={6}>
- <Skeleton height={16} width={112} />
- <Skeleton height={12} width={216} />
- </Flexbox>
- <Skeleton height={28} width={112} />
- </Flexbox>
- <Flexbox className={styles.sectionTitle}>
- <Skeleton height={18} width={56} />
- </Flexbox>
- <Flexbox className={`${styles.section} ${styles.runsSection}`} gap={16}>
- <Skeleton.Avatar shape={'square'} size={56} style={{ borderRadius: cssVar.borderRadiusLG }} />
- <Flexbox align={'center'} gap={6}>
- <Skeleton height={16} width={96} />
- <Skeleton height={12} width={240} />
- </Flexbox>
- <Skeleton height={28} width={104} />
- </Flexbox>
- </>
-);
-
-export default BenchmarkDetailLoading;
diff --git a/src/features/Eval/index.ts b/src/features/Eval/index.ts
deleted file mode 100644
index 0611989cbb9..00000000000
--- a/src/features/Eval/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default as BenchmarkDetailLoading } from './BenchmarkDetailLoading';
diff --git a/src/features/FloatingChatPanel/index.test.tsx b/src/features/FloatingChatPanel/index.test.tsx
index e750945d56d..b49f3c9fbfa 100644
--- a/src/features/FloatingChatPanel/index.test.tsx
+++ b/src/features/FloatingChatPanel/index.test.tsx
@@ -1,25 +1,13 @@
import { act, fireEvent, render } from '@testing-library/react';
import type { ReactNode } from 'react';
-import { SWRConfig } from 'swr';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { __resetFloatingChatPanelRegistry } from './guard';
import FloatingChatPanel from './index';
-vi.mock('./ChatBody', async () => {
- const { useSWRConfig } = await import('swr');
- // Probe the effective SWR config so the suspense opt-out is testable: the
- // panel must shield its conversation subtree from suspense-mode hosts.
- const ChatBodyProbe = () => {
- const { suspense } = useSWRConfig();
- return (
- <div data-swr-suspense={String(suspense ?? false)} data-testid="chat-body">
- body
- </div>
- );
- };
- return { default: ChatBodyProbe };
-});
+vi.mock('./ChatBody', () => ({
+ default: () => <div data-testid="chat-body">body</div>,
+}));
const sheetHandlers = vi.hoisted(() => ({
current: {
@@ -324,21 +312,6 @@ describe('FloatingChatPanel', () => {
expect(queryByTestId('floating-chat-panel-collapse-button')).toBeNull();
});
- it('opts its subtree out of a suspense-mode SWRConfig host', () => {
- // The agent-doc layout wraps its whole outlet in SWRConfig{suspense:true}.
- // The panel's loading model is messagesInit gating, not suspense β€” without
- // the opt-out any conversation hook whose fetcher resolves undefined
- // (e.g. a missing model reasoning config) strands the panel on the host's
- // Suspense fallback forever.
- const { getByTestId } = render(
- <SWRConfig value={{ suspense: true }}>
- <FloatingChatPanel agentId="agent-1" mode="embedded" topicId="topic-1" />
- </SWRConfig>,
- );
-
- expect(getByTestId('chat-body').dataset.swrSuspense).toBe('false');
- });
-
it('binds the embedded toolbar topic selection to the conversation context', () => {
const { getByTestId, queryByTestId } = render(
<FloatingChatPanel agentId="agent-1" mode="embedded" topicId="topic-1" />,
diff --git a/src/features/FloatingChatPanel/index.tsx b/src/features/FloatingChatPanel/index.tsx
index 49f7ccda424..aab8bd2c81a 100644
--- a/src/features/FloatingChatPanel/index.tsx
+++ b/src/features/FloatingChatPanel/index.tsx
@@ -7,7 +7,6 @@ import { ChevronDown } from 'lucide-react';
import type { ReactNode } from 'react';
import { memo, useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { SWRConfig } from 'swr';
import {
type ActionsBarConfig,
@@ -131,7 +130,7 @@ export interface FloatingChatPanelProps {
*
* Single instance per page (see `./guard.ts`).
*/
-const FloatingChatPanelInner = memo<FloatingChatPanelProps>(
+const FloatingChatPanel = memo<FloatingChatPanelProps>(
({
agentId,
topicId,
@@ -306,22 +305,6 @@ const FloatingChatPanelInner = memo<FloatingChatPanelProps>(
},
);
-FloatingChatPanelInner.displayName = 'FloatingChatPanelInner';
-
-/**
- * The panel's loading model is `messagesInit` gating inside ChatList β€” it was
- * never designed for SWR suspense mode. Hosts that render under a
- * `SWRConfig {suspense: true}` layout (e.g. the agent-doc page) would otherwise
- * suspend the whole panel on any conversation-adjacent hook, and a fetcher that
- * legitimately resolves `undefined` (SWR suspense never settles on undefined
- * data) turns that into a permanent skeleton with an infinite refetch loop.
- */
-const FloatingChatPanel = memo<FloatingChatPanelProps>((props) => (
- <SWRConfig value={{ suspense: false }}>
- <FloatingChatPanelInner {...props} />
- </SWRConfig>
-));
-
FloatingChatPanel.displayName = 'FloatingChatPanel';
export default FloatingChatPanel;
diff --git a/src/features/Memory/isMemoryListPending.test.ts b/src/features/Memory/isMemoryListPending.test.ts
index 45f44dc30c7..a79e61c639b 100644
--- a/src/features/Memory/isMemoryListPending.test.ts
+++ b/src/features/Memory/isMemoryListPending.test.ts
@@ -33,4 +33,15 @@ describe('isMemoryListPending', () => {
isMemoryListPending({ error: new Error('failed'), initialized: true, loading: false }),
).toBe(false);
});
+
+ it('lets a settled error surface even if the reset flag is still set', () => {
+ expect(
+ isMemoryListPending({
+ error: new Error('failed'),
+ initialized: true,
+ loading: false,
+ resetting: true,
+ }),
+ ).toBe(false);
+ });
});
diff --git a/src/features/Memory/isMemoryListPending.ts b/src/features/Memory/isMemoryListPending.ts
index d9c61204635..85130caef0c 100644
--- a/src/features/Memory/isMemoryListPending.ts
+++ b/src/features/Memory/isMemoryListPending.ts
@@ -15,4 +15,4 @@ export const isMemoryListPending = ({
loading,
resetting,
}: MemoryListPendingContext) =>
- Boolean(resetting) || (!initialized && !error) || (Boolean(error) && loading);
+ Boolean(resetting && !error) || (!initialized && !error) || (Boolean(error) && loading);
diff --git a/src/features/Messenger/index.tsx b/src/features/Messenger/index.tsx
index ccf45675d2a..d8119455de1 100644
--- a/src/features/Messenger/index.tsx
+++ b/src/features/Messenger/index.tsx
@@ -1,7 +1,7 @@
'use client';
import { Flexbox } from '@lobehub/ui';
-import { Button, Text, toast } from '@lobehub/ui/base-ui';
+import { Button, Skeleton, Text, toast } from '@lobehub/ui/base-ui';
import { createStaticStyles } from 'antd-style';
import { memo, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -145,6 +145,8 @@ const MessengerSettings = memo(() => {
error={platformsSWR.error}
errorVariant={'block'}
isEmpty={platforms.length === 0}
+ isLoading={platformsSWR.isLoading}
+ loading={<Skeleton.Text rows={3} />}
empty={
<div className={styles.emptyState}>{t('messenger.noPlatformsConfigured')}</div>
}
diff --git a/src/features/Projects/Acceptance/index.tsx b/src/features/Projects/Acceptance/index.tsx
index e7fe6fc999a..d7532b09cba 100644
--- a/src/features/Projects/Acceptance/index.tsx
+++ b/src/features/Projects/Acceptance/index.tsx
@@ -1,28 +1,23 @@
'use client';
-import { Center } from '@lobehub/ui';
-
import AsyncError from '@/components/AsyncError';
-import NeuralNetworkLoading from '@/components/NeuralNetworkLoading';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { AcceptanceWorkspace } from '@/features/Acceptance';
import { useActiveRouteParams } from '@/hooks/useActiveRouteParams';
-import { useCurrentProjectDetail, useProjectStore } from '@/store/project';
+import { useProjectStore } from '@/store/project';
const ProjectAcceptance = () => {
const { projectId } = useActiveRouteParams<{ projectId: string }>();
- const detail = useCurrentProjectDetail(projectId);
- const detailSWR = useProjectStore((state) => state.useFetchProjectDetail)(projectId);
+ const { data, error, isLoading, mutate } = useProjectStore((s) => s.useFetchProjectDetail)(
+ projectId,
+ );
- if (detailSWR.error)
- return <AsyncError error={detailSWR.error} variant={'page'} onRetry={detailSWR.mutate} />;
- if (!detail)
- return (
- <Center height={'100%'} width={'100%'}>
- <NeuralNetworkLoading />
- </Center>
- );
+ if (isLoading && !data) return <RouteLoading />;
+ if (error && !data)
+ return <AsyncError error={error} variant={'page'} onRetry={() => void mutate()} />;
+ if (!data) return null;
- return <AcceptanceWorkspace projectId={detail.project.id} />;
+ return <AcceptanceWorkspace projectId={data.data.project.id} />;
};
export default ProjectAcceptance;
diff --git a/src/features/Projects/Goals/index.tsx b/src/features/Projects/Goals/index.tsx
index 41baab4a00d..e82717bb88d 100644
--- a/src/features/Projects/Goals/index.tsx
+++ b/src/features/Projects/Goals/index.tsx
@@ -1,16 +1,23 @@
'use client';
+import AsyncError from '@/components/AsyncError';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { AgentGoalsPage } from '@/features/AgentGoals';
import { useActiveRouteParams } from '@/hooks/useActiveRouteParams';
-import { useCurrentProjectDetail } from '@/store/project';
+import { useProjectStore } from '@/store/project';
const ProjectGoals = () => {
const { projectId } = useActiveRouteParams<{ projectId: string }>();
- const detail = useCurrentProjectDetail(projectId);
+ const { data, error, isLoading, mutate } = useProjectStore((s) => s.useFetchProjectDetail)(
+ projectId,
+ );
- if (!detail) return null;
+ if (isLoading && !data) return <RouteLoading />;
+ if (error && !data)
+ return <AsyncError error={error} variant={'page'} onRetry={() => void mutate()} />;
+ if (!data) return null;
- return <AgentGoalsPage projectId={detail.project.id} />;
+ return <AgentGoalsPage projectId={data.data.project.id} />;
};
export default ProjectGoals;
diff --git a/src/features/Projects/Layout/index.tsx b/src/features/Projects/Layout/index.tsx
index da891355167..0108019ae8c 100644
--- a/src/features/Projects/Layout/index.tsx
+++ b/src/features/Projects/Layout/index.tsx
@@ -3,9 +3,7 @@
import { Flexbox } from '@lobehub/ui';
import { memo } from 'react';
import { Outlet } from 'react-router';
-import { SWRConfig } from 'swr';
-import SuspenseRouteBoundary from '@/components/SuspenseRouteBoundary';
import ProjectDisabled from '@/features/Projects/ProjectDisabled';
import { useUserStore } from '@/store/user';
import { labPreferSelectors } from '@/store/user/selectors';
@@ -21,11 +19,7 @@ const ProjectLayout = memo(() => {
<>
<ProjectSidebar />
<Flexbox flex={1} height="100%" style={{ minWidth: 0 }}>
- <SWRConfig value={{ suspense: true }}>
- <SuspenseRouteBoundary>
- <Outlet />
- </SuspenseRouteBoundary>
- </SWRConfig>
+ <Outlet />
</Flexbox>
</>
);
diff --git a/src/features/ResourceHome/Layout/index.tsx b/src/features/ResourceHome/Layout/index.tsx
index 873ad7f8706..a45b05f274c 100644
--- a/src/features/ResourceHome/Layout/index.tsx
+++ b/src/features/ResourceHome/Layout/index.tsx
@@ -3,9 +3,6 @@
import { Flexbox } from '@lobehub/ui';
import { type FC } from 'react';
import { Outlet } from 'react-router';
-import { SWRConfig } from 'swr';
-
-import SuspenseRouteBoundary from '@/components/SuspenseRouteBoundary';
import Sidebar from './Sidebar';
import { styles } from './style';
@@ -15,11 +12,7 @@ const HomeLayout: FC = () => {
<>
<Sidebar />
<Flexbox className={styles.mainContainer} flex={1} height={'100%'}>
- <SWRConfig value={{ suspense: true }}>
- <SuspenseRouteBoundary>
- <Outlet />
- </SuspenseRouteBoundary>
- </SWRConfig>
+ <Outlet />
</Flexbox>
</>
);
diff --git a/src/features/ResourceLibrary/Layout/index.tsx b/src/features/ResourceLibrary/Layout/index.tsx
index 57a6af993c5..2b531dcaa8a 100644
--- a/src/features/ResourceLibrary/Layout/index.tsx
+++ b/src/features/ResourceLibrary/Layout/index.tsx
@@ -5,10 +5,8 @@ import { Button } from '@lobehub/ui/base-ui';
import { type FC } from 'react';
import { useTranslation } from 'react-i18next';
import { Outlet, useParams } from 'react-router';
-import { SWRConfig } from 'swr';
import AsyncError from '@/components/AsyncError';
-import SuspenseRouteBoundary from '@/components/SuspenseRouteBoundary';
import RegisterHotkeys from '@/features/ResourceLibrary/RegisterHotkeys';
import { useKnowledgeBaseItem } from '@/features/ResourceManager/hooks/useKnowledgeItem';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
@@ -47,11 +45,7 @@ const LibraryLayout: FC = () => {
<>
<Sidebar />
<Flexbox className={styles.mainContainer} flex={1} height={'100%'}>
- <SWRConfig value={{ suspense: true }}>
- <SuspenseRouteBoundary>
- <Outlet />
- </SuspenseRouteBoundary>
- </SWRConfig>
+ <Outlet />
</Flexbox>
<RegisterHotkeys />
</>
diff --git a/src/features/ResourceLibrary/Permission.tsx b/src/features/ResourceLibrary/Permission.tsx
index d0572bdd8c2..92b56dc329e 100644
--- a/src/features/ResourceLibrary/Permission.tsx
+++ b/src/features/ResourceLibrary/Permission.tsx
@@ -4,6 +4,7 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { useKnowledgeBaseItem } from '@/features/ResourceManager/hooks/useKnowledgeItem';
import ResourceAccessPage from '@/features/ResourcePermission/ResourceAccessPage';
@@ -18,9 +19,10 @@ const LibraryPermission = memo(() => {
const { id } = useParams<{ id: string }>();
// Managers can always browse, so the name fetch never 403s for a viewer of
// this page; a transient failure just falls back to the generic title.
- const { data } = useKnowledgeBaseItem(id || '');
+ const { data, isLoading } = useKnowledgeBaseItem(id || '');
if (!id) return null;
+ if (isLoading) return <RouteLoading />;
return (
<ResourceAccessPage
diff --git a/src/features/ResourceLibrary/index.tsx b/src/features/ResourceLibrary/index.tsx
index 254867650a4..754632caa27 100644
--- a/src/features/ResourceLibrary/index.tsx
+++ b/src/features/ResourceLibrary/index.tsx
@@ -6,6 +6,7 @@ import { useLocation, useParams } from 'react-router';
import NotFound from '@/components/404';
import AsyncError from '@/components/AsyncError';
import NProgress from '@/components/NProgress';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import Container from '@/features/ResourceLibrary/Container';
import ResourceManager from '@/features/ResourceManager';
import { useInitFileCheck } from '@/features/ResourceManager/hooks/useInitFileCheck';
@@ -53,7 +54,9 @@ const MainContent = memo(() => {
/>
);
- if (!isLoading && !data) return <NotFound />;
+ if (isLoading) return <RouteLoading />;
+
+ if (!data) return <NotFound />;
return <ResourceManager />;
});
diff --git a/src/features/ResourceManager/Layout/index.tsx b/src/features/ResourceManager/Layout/index.tsx
index b299b1bec7b..e169f43b1f2 100644
--- a/src/features/ResourceManager/Layout/index.tsx
+++ b/src/features/ResourceManager/Layout/index.tsx
@@ -2,20 +2,13 @@
import { type FC } from 'react';
import { Outlet } from 'react-router';
-import { SWRConfig } from 'swr';
-
-import SuspenseRouteBoundary from '@/components/SuspenseRouteBoundary';
import RegisterHotkeys from './RegisterHotkeys';
const ResourceLayout: FC = () => {
return (
<>
- <SWRConfig value={{ suspense: true }}>
- <SuspenseRouteBoundary>
- <Outlet />
- </SuspenseRouteBoundary>
- </SWRConfig>
+ <Outlet />
<RegisterHotkeys />
</>
);
diff --git a/src/features/ResourceManager/components/Explorer/useMasonryColumnCount.test.ts b/src/features/ResourceManager/components/Explorer/useMasonryColumnCount.test.ts
new file mode 100644
index 00000000000..72f828a833c
--- /dev/null
+++ b/src/features/ResourceManager/components/Explorer/useMasonryColumnCount.test.ts
@@ -0,0 +1,13 @@
+import { describe, expect, it } from 'vitest';
+
+import { resolveMasonryColumnCount } from './useMasonryColumnCount';
+
+describe('resolveMasonryColumnCount', () => {
+ it('maps viewport width to the masonry column count without a default guess', () => {
+ expect(resolveMasonryColumnCount(600)).toBe(2);
+ expect(resolveMasonryColumnCount(800)).toBe(3);
+ expect(resolveMasonryColumnCount(1200)).toBe(4);
+ expect(resolveMasonryColumnCount(1536)).toBe(5);
+ expect(resolveMasonryColumnCount(1920)).toBe(5);
+ });
+});
diff --git a/src/features/ResourceManager/components/Explorer/useMasonryColumnCount.ts b/src/features/ResourceManager/components/Explorer/useMasonryColumnCount.ts
index ea5a8167ae3..dbd0b7f2638 100644
--- a/src/features/ResourceManager/components/Explorer/useMasonryColumnCount.ts
+++ b/src/features/ResourceManager/components/Explorer/useMasonryColumnCount.ts
@@ -1,25 +1,21 @@
-import { useEffect, useState } from 'react';
+import { useLayoutEffect, useState } from 'react';
-/**
- * Hook to calculate responsive column count for masonry layout
- * @returns The current column count based on window width
- */
+export const resolveMasonryColumnCount = (width: number) => {
+ if (width < 768) return 2;
+ if (width < 1024) return 3;
+ if (width < 1536) return 4;
+ return 5;
+};
+
+// Resolved synchronously on the first render: a default column count that is
+// corrected in an effect re-lays out every masonry card one frame later.
export const useMasonryColumnCount = () => {
- const [columnCount, setColumnCount] = useState(4);
+ const [columnCount, setColumnCount] = useState(() =>
+ resolveMasonryColumnCount(typeof window === 'undefined' ? 1024 : window.innerWidth),
+ );
- useEffect(() => {
- const updateColumnCount = () => {
- const width = window.innerWidth;
- if (width < 768) {
- setColumnCount(2);
- } else if (width < 1024) {
- setColumnCount(3);
- } else if (width < 1536) {
- setColumnCount(4);
- } else {
- setColumnCount(5);
- }
- };
+ useLayoutEffect(() => {
+ const updateColumnCount = () => setColumnCount(resolveMasonryColumnCount(window.innerWidth));
updateColumnCount();
window.addEventListener('resize', updateColumnCount);
diff --git a/src/features/ServiceModel/ModelAssignmentsForm.tsx b/src/features/ServiceModel/ModelAssignmentsForm.tsx
index 419b7aa520e..b2c0ccfeaeb 100644
--- a/src/features/ServiceModel/ModelAssignmentsForm.tsx
+++ b/src/features/ServiceModel/ModelAssignmentsForm.tsx
@@ -2,13 +2,14 @@
import type { FormGroupItemType, FormItemProps } from '@lobehub/ui';
import { Flexbox, Form, InputNumber, TextArea, Tooltip } from '@lobehub/ui';
-import { Skeleton, Switch } from '@lobehub/ui/base-ui';
+import { Switch } from '@lobehub/ui/base-ui';
import isEqual from 'fast-deep-equal';
import { memo, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import AsyncError from '@/components/AsyncError';
import AutoSaveHint from '@/components/Editor/AutoSaveHint';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { FORM_STYLE } from '@/const/layoutTokens';
import ModelSelect from '@/features/ModelSelect';
import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
@@ -104,7 +105,7 @@ const ModelAssignmentsForm = memo(() => {
onRetry={() => refreshUserState()}
/>
);
- return <Skeleton.Text rows={8} />;
+ return <RouteLoading />;
}
const updateDefaultAgentModel = async ({
diff --git a/src/features/Settings/Layout/index.tsx b/src/features/Settings/Layout/index.tsx
index 30c5725fbee..8970d995202 100644
--- a/src/features/Settings/Layout/index.tsx
+++ b/src/features/Settings/Layout/index.tsx
@@ -3,9 +3,7 @@
import { Flexbox } from '@lobehub/ui';
import { type FC } from 'react';
import { Outlet } from 'react-router';
-import { SWRConfig } from 'swr';
-import SuspenseRouteBoundary from '@/components/SuspenseRouteBoundary';
import SideBar from '@/features/Settings/Layout/SideBar';
import { RouteSkeletonChromeProvider } from '@/spa/router/routeSkeletonChrome';
@@ -22,13 +20,9 @@ const Layout: FC = () => {
>
<SideBar />
<Flexbox className={styles.mainContainer} flex={1} height={'100%'}>
- <SWRConfig value={{ suspense: true }}>
- <SuspenseRouteBoundary>
- <RouteSkeletonChromeProvider>
- <Outlet />
- </RouteSkeletonChromeProvider>
- </SuspenseRouteBoundary>
- </SWRConfig>
+ <RouteSkeletonChromeProvider>
+ <Outlet />
+ </RouteSkeletonChromeProvider>
</Flexbox>
</SettingsContextProvider>
);
diff --git a/src/features/Settings/provider/features/ModelList/index.tsx b/src/features/Settings/provider/features/ModelList/index.tsx
index f67e1284715..185fbb290ab 100644
--- a/src/features/Settings/provider/features/ModelList/index.tsx
+++ b/src/features/Settings/provider/features/ModelList/index.tsx
@@ -46,7 +46,7 @@ const Content = memo<ContentProps>(({ id }) => {
const allModels = useAiInfraStore(aiModelSelectors.filteredAiProviderModelList, isEqual);
- const { error, mutate } = useFetchAiProviderModels(id);
+ const { isLoading, error, mutate } = useFetchAiProviderModels(id);
// Count models by type (for all models, not just enabled)
const modelCounts = useMemo(() => {
@@ -128,6 +128,8 @@ const Content = memo<ContentProps>(({ id }) => {
const availableTabKeys = tabs.map((tab) => tab.key);
const currentActiveTab = availableTabKeys.includes(activeTab) ? activeTab : 'all';
+ if (isLoading && isEmpty) return <SkeletonList />;
+
// Error before empty: a failed model-list fetch must not render as
// "no models yet" (EmptyModels) β€” surface the reason + Retry (ux Read Β§1.1).
if (error && isEmpty)
diff --git a/src/features/Settings/stats/index.tsx b/src/features/Settings/stats/index.tsx
index 4b528a43528..5e43e980259 100644
--- a/src/features/Settings/stats/index.tsx
+++ b/src/features/Settings/stats/index.tsx
@@ -9,7 +9,6 @@ import dayjs from 'dayjs';
import { Brain, UserIcon } from 'lucide-react';
import { memo, type ReactNode, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { SWRConfig } from 'swr';
import AsyncBoundary from '@/components/AsyncBoundary';
import SettingHeader from '@/features/Settings/features/SettingHeader';
@@ -51,7 +50,7 @@ interface StatsSettingProps {
showSettingHeader?: boolean;
}
-const StatsContent = memo<StatsSettingProps>(
+const StatsSetting = memo<StatsSettingProps>(
({ mobile, headerNode, enableUserDimension, resolveUser, showSettingHeader = true }) => {
const { t, i18n } = useTranslation('auth');
dayjs.locale(i18n.language);
@@ -176,19 +175,4 @@ const StatsContent = memo<StatsSettingProps>(
},
);
-/**
- * Every metric on this page fetches independently and gates itself with its own
- * `AsyncBoundary` + Retry β€” a failed token count must not take the healthy
- * message count down with it, and `errorVariant='metric'` exists so a failure
- * never reads as a confident zero. Route-wide `suspense` would turn all of that
- * into dead code by throwing to the route boundary instead, so the page opts
- * out. The opt-out has to sit *above* the hooks it covers, hence the wrapper
- * rather than an `SWRConfig` inside `StatsContent`.
- */
-const StatsSetting = memo<StatsSettingProps>((props) => (
- <SWRConfig value={{ suspense: false }}>
- <StatsContent {...props} />
- </SWRConfig>
-));
-
export default StatsSetting;
diff --git a/src/features/Workspace/WorkspaceSlugBoundary.tsx b/src/features/Workspace/WorkspaceSlugBoundary.tsx
index 3f33a97ab34..2ec646228c0 100644
--- a/src/features/Workspace/WorkspaceSlugBoundary.tsx
+++ b/src/features/Workspace/WorkspaceSlugBoundary.tsx
@@ -6,7 +6,7 @@ import { type FC } from 'react';
import { useTranslation } from 'react-i18next';
import { Outlet, useNavigate } from 'react-router';
-import RouteSegmentSkeleton from '@/components/Skeleton/RouteSegment';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { useWorkspaceFromSlug } from './useWorkspaceFromSlug';
@@ -28,10 +28,7 @@ const WorkspaceSlugBoundary: FC = () => {
const navigate = useNavigate();
const result = useWorkspaceFromSlug();
- // Workspaces are still being fetched. The parent layout has already resolved
- // by now, so returning null would blank the content area between the lazy
- // chunk's skeleton and the page's own β€” keep the same skeleton on screen.
- if (result.status === 'loading') return <RouteSegmentSkeleton />;
+ if (result.status === 'loading') return <RouteLoading />;
if (result.status === 'not-found') {
return (
diff --git a/src/features/WorkspaceSetting/AdminOnly.tsx b/src/features/WorkspaceSetting/AdminOnly.tsx
index 116cac867be..b66542fba2a 100644
--- a/src/features/WorkspaceSetting/AdminOnly.tsx
+++ b/src/features/WorkspaceSetting/AdminOnly.tsx
@@ -6,6 +6,7 @@ import { memo, type ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import { useIsWorkspaceLoading } from '@/business/client/hooks/useIsWorkspaceLoading';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { MAX_WIDTH } from '@/const/layoutTokens';
import { usePermission } from '@/hooks/usePermission';
@@ -49,7 +50,7 @@ const AdminOnly = memo<{ children: ReactNode }>(({ children }) => {
// Don't paint the 403 before workspace context resolves β€” `myRole` is `null`
// during bootstrap, which would briefly flash the forbidden screen for admins
// landing directly on the URL.
- if (isLoading) return null;
+ if (isLoading) return <RouteLoading />;
if (!canManageWorkspace) return <Forbidden />;
return <>{children}</>;
});
diff --git a/src/features/WorkspaceSetting/Layout.tsx b/src/features/WorkspaceSetting/Layout.tsx
index c4fb100cc76..e9df6296021 100644
--- a/src/features/WorkspaceSetting/Layout.tsx
+++ b/src/features/WorkspaceSetting/Layout.tsx
@@ -3,9 +3,7 @@
import { Text } from '@lobehub/ui/base-ui';
import { type FC, memo } from 'react';
import { Outlet, useMatch } from 'react-router';
-import { SWRConfig } from 'swr';
-import SuspenseRouteBoundary from '@/components/SuspenseRouteBoundary';
import NavHeader from '@/features/NavHeader';
import { RouteSkeletonChromeProvider } from '@/spa/router/routeSkeletonChrome';
import { WorkspaceSettingsTabs } from '@/types/workspaceSettings';
@@ -40,13 +38,9 @@ const WorkspaceSettingsLayout: FC = () => {
return (
<>
<SideBar />
- <SWRConfig value={{ suspense: true }}>
- <SuspenseRouteBoundary>
- <RouteSkeletonChromeProvider>
- <Outlet />
- </RouteSkeletonChromeProvider>
- </SuspenseRouteBoundary>
- </SWRConfig>
+ <RouteSkeletonChromeProvider>
+ <Outlet />
+ </RouteSkeletonChromeProvider>
</>
);
};
diff --git a/src/routes/(main)/community/(detail)/_layout/index.tsx b/src/routes/(main)/community/(detail)/_layout/index.tsx
index 6d70c6c5466..5818525d83d 100644
--- a/src/routes/(main)/community/(detail)/_layout/index.tsx
+++ b/src/routes/(main)/community/(detail)/_layout/index.tsx
@@ -3,9 +3,7 @@
import { Flexbox } from '@lobehub/ui';
import { memo } from 'react';
import { Outlet } from 'react-router';
-import { SWRConfig } from 'swr';
-import SuspenseRouteBoundary from '@/components/SuspenseRouteBoundary';
import Footer from '@/features/Setting/Footer';
import WideScreenContainer from '@/features/WideScreenContainer';
import { RouteSkeletonChromeProvider } from '@/spa/router/routeSkeletonChrome';
@@ -38,13 +36,9 @@ const DesktopDiscoverDetailLayout = memo(() => {
position: 'relative',
}}
>
- <SWRConfig value={{ suspense: true }}>
- <SuspenseRouteBoundary>
- <RouteSkeletonChromeProvider>
- <Outlet />
- </RouteSkeletonChromeProvider>
- </SuspenseRouteBoundary>
- </SWRConfig>
+ <RouteSkeletonChromeProvider>
+ <Outlet />
+ </RouteSkeletonChromeProvider>
<div className={styles.spacer} />
<Footer />
</WideScreenContainer>
diff --git a/src/routes/(main)/community/(detail)/agent/index.tsx b/src/routes/(main)/community/(detail)/agent/index.tsx
index 7e446b129b8..f6551fb8ad0 100644
--- a/src/routes/(main)/community/(detail)/agent/index.tsx
+++ b/src/routes/(main)/community/(detail)/agent/index.tsx
@@ -4,6 +4,8 @@ import { Flexbox } from '@lobehub/ui';
import { memo } from 'react';
import { useParams } from 'react-router';
+import AsyncError from '@/components/AsyncError';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { useQuery } from '@/hooks/useQuery';
import { useDiscoverStore } from '@/store/discover';
import { type AssistantMarketSource } from '@/types/discover';
@@ -25,10 +27,12 @@ const AssistantDetailPage = memo<AssistantDetailPageProps>(({ mobile }) => {
const { version, source } = useQuery() as { source?: AssistantMarketSource; version?: string };
const useAssistantDetail = useDiscoverStore((s) => s.useAssistantDetail);
- const { data } = useAssistantDetail({ identifier, source, version });
- if (!data) return <NotFound />;
-
- // Check assistant status
+ const { data, error, isLoading, mutate } = useAssistantDetail({ identifier, source, version });
+ if (data === undefined) {
+ if (isLoading) return <RouteLoading />;
+ if (error) return <AsyncError error={error} variant={'page'} onRetry={() => void mutate()} />;
+ return <NotFound />;
+ }
const status = (data as any)?.status;
if (status === 'unpublished' || status === 'archived' || status === 'deprecated') {
return <StatusPage status={status} />;
diff --git a/src/routes/(main)/community/(detail)/group_agent/index.tsx b/src/routes/(main)/community/(detail)/group_agent/index.tsx
index 5a8fca5429e..8b4fa0f40e1 100644
--- a/src/routes/(main)/community/(detail)/group_agent/index.tsx
+++ b/src/routes/(main)/community/(detail)/group_agent/index.tsx
@@ -4,6 +4,8 @@ import { Flexbox } from '@lobehub/ui';
import { memo } from 'react';
import { useParams } from 'react-router';
+import AsyncError from '@/components/AsyncError';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { useQuery } from '@/hooks/useQuery';
import { useDiscoverStore } from '@/store/discover';
@@ -25,11 +27,13 @@ const GroupAgentDetailPage = memo<GroupAgentDetailPageProps>(({ mobile }) => {
// Fetch group agent detail
const useGroupAgentDetail = useDiscoverStore((s) => s.useGroupAgentDetail);
- const { data } = useGroupAgentDetail({ identifier, version });
+ const { data, error, isLoading, mutate } = useGroupAgentDetail({ identifier, version });
- if (!data) return <NotFound />;
-
- // Check status and show appropriate page
+ if (data === undefined) {
+ if (isLoading) return <RouteLoading />;
+ if (error) return <AsyncError error={error} variant={'page'} onRetry={() => void mutate()} />;
+ return <NotFound />;
+ }
const status = (data as any)?.group?.status || (data as any)?.status;
if (status === 'unpublished' || status === 'archived' || status === 'deprecated') {
return <StatusPage status={status} />;
diff --git a/src/routes/(main)/community/(detail)/mcp/index.tsx b/src/routes/(main)/community/(detail)/mcp/index.tsx
index 7ab0c2e5948..c7119d5e317 100644
--- a/src/routes/(main)/community/(detail)/mcp/index.tsx
+++ b/src/routes/(main)/community/(detail)/mcp/index.tsx
@@ -4,6 +4,8 @@ import { Flexbox } from '@lobehub/ui';
import { memo } from 'react';
import { useParams } from 'react-router';
+import AsyncError from '@/components/AsyncError';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { DetailProvider } from '@/features/MCPPluginDetail/DetailProvider';
import Header from '@/features/MCPPluginDetail/Header';
import { useFetchInstalledPlugins } from '@/hooks/useFetchInstalledPlugins';
@@ -24,10 +26,14 @@ const McpDetailPage = memo<McpDetailPageProps>(({ mobile }) => {
const { version } = useQuery() as { version?: string };
const useMcpDetail = useDiscoverStore((s) => s.useFetchMcpDetail);
- const { data } = useMcpDetail({ identifier, version });
+ const { data, error, isLoading, mutate } = useMcpDetail({ identifier, version });
useFetchInstalledPlugins();
- if (!data) return <NotFound />;
+ if (data === undefined) {
+ if (isLoading) return <RouteLoading />;
+ if (error) return <AsyncError error={error} variant={'page'} onRetry={() => void mutate()} />;
+ return <NotFound />;
+ }
return (
<TocProvider>
diff --git a/src/routes/(main)/community/(detail)/model/index.tsx b/src/routes/(main)/community/(detail)/model/index.tsx
index 83e1ddec806..18fec8cc908 100644
--- a/src/routes/(main)/community/(detail)/model/index.tsx
+++ b/src/routes/(main)/community/(detail)/model/index.tsx
@@ -4,6 +4,8 @@ import { Flexbox } from '@lobehub/ui';
import { memo } from 'react';
import { useParams } from 'react-router';
+import AsyncError from '@/components/AsyncError';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { useDiscoverStore } from '@/store/discover';
import NotFound from '../components/NotFound';
@@ -20,8 +22,12 @@ const ModelDetailPage = memo<ModelDetailPageProps>(({ mobile }) => {
const identifier = decodeURIComponent(params.slug ?? '');
const useModelDetail = useDiscoverStore((s) => s.useModelDetail);
- const { data } = useModelDetail({ identifier });
- if (!data) return <NotFound />;
+ const { data, error, isLoading, mutate } = useModelDetail({ identifier });
+ if (data === undefined) {
+ if (isLoading) return <RouteLoading />;
+ if (error) return <AsyncError error={error} variant={'page'} onRetry={() => void mutate()} />;
+ return <NotFound />;
+ }
return (
<DetailProvider config={data}>
diff --git a/src/routes/(main)/community/(detail)/organization/index.tsx b/src/routes/(main)/community/(detail)/organization/index.tsx
index d9b850e051f..3c17a98e82a 100644
--- a/src/routes/(main)/community/(detail)/organization/index.tsx
+++ b/src/routes/(main)/community/(detail)/organization/index.tsx
@@ -4,6 +4,8 @@ import { memo, useEffect, useMemo } from 'react';
import { useLocation, useParams } from 'react-router';
import { useCommunityWorkspaceProfile } from '@/business/client/hooks/useCommunityWorkspaceProfile';
+import AsyncError from '@/components/AsyncError';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useDiscoverStore } from '@/store/discover';
@@ -25,7 +27,7 @@ const OrganizationDetailPage = memo<OrganizationDetailPageProps>(({ mobile }) =>
const { isWorkspaceScope } = useCommunityWorkspaceProfile();
const useUserProfile = useDiscoverStore((s) => s.useUserProfile);
- const { data } = useUserProfile({ username });
+ const { data, error, isLoading, mutate } = useUserProfile({ username });
useEffect(() => {
const redirectTo = resolveWorkspaceCommunityProfileRedirect({
@@ -53,6 +55,10 @@ const OrganizationDetailPage = memo<OrganizationDetailPageProps>(({ mobile }) =>
user,
};
}, [data, mobile]);
+ if (data === undefined) {
+ if (isLoading) return <RouteLoading />;
+ if (error) return <AsyncError error={error} variant={'page'} onRetry={() => void mutate()} />;
+ }
if (!contextConfig) return <NotFound />;
return (
diff --git a/src/routes/(main)/community/(detail)/provider/index.tsx b/src/routes/(main)/community/(detail)/provider/index.tsx
index 3fdb6066e70..9d4142c7f50 100644
--- a/src/routes/(main)/community/(detail)/provider/index.tsx
+++ b/src/routes/(main)/community/(detail)/provider/index.tsx
@@ -4,6 +4,8 @@ import { Flexbox } from '@lobehub/ui';
import { memo } from 'react';
import { useParams } from 'react-router';
+import AsyncError from '@/components/AsyncError';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { useDiscoverStore } from '@/store/discover';
import NotFound from '../components/NotFound';
@@ -20,8 +22,12 @@ const ProviderDetailPage = memo<ProviderDetailPageProps>(({ mobile }) => {
const identifier = decodeURIComponent(params.slug ?? '');
const useProviderDetail = useDiscoverStore((s) => s.useProviderDetail);
- const { data } = useProviderDetail({ identifier, withReadme: true });
- if (!data) return <NotFound />;
+ const { data, error, isLoading, mutate } = useProviderDetail({ identifier, withReadme: true });
+ if (data === undefined) {
+ if (isLoading) return <RouteLoading />;
+ if (error) return <AsyncError error={error} variant={'page'} onRetry={() => void mutate()} />;
+ return <NotFound />;
+ }
return (
<DetailProvider config={data}>
diff --git a/src/routes/(main)/community/(detail)/skill/index.tsx b/src/routes/(main)/community/(detail)/skill/index.tsx
index e82223f84bc..ef1429ce202 100644
--- a/src/routes/(main)/community/(detail)/skill/index.tsx
+++ b/src/routes/(main)/community/(detail)/skill/index.tsx
@@ -4,6 +4,8 @@ import { Flexbox } from '@lobehub/ui';
import { memo, useCallback } from 'react';
import { useParams, useSearchParams } from 'react-router';
+import AsyncError from '@/components/AsyncError';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { SkillDetailView, SkillNavKey } from '@/features/CommunitySkillDetail';
import { useQuery } from '@/hooks/useQuery';
import { useDiscoverStore } from '@/store/discover';
@@ -48,8 +50,12 @@ const SkillDetailPage = memo<SkillDetailPageProps>(({ mobile }) => {
);
const useSkillDetail = useDiscoverStore((s) => s.useFetchSkillDetail);
- const { data } = useSkillDetail({ identifier, version });
- if (!data) return <NotFound />;
+ const { data, error, isLoading, mutate } = useSkillDetail({ identifier, version });
+ if (data === undefined) {
+ if (isLoading) return <RouteLoading />;
+ if (error) return <AsyncError error={error} variant={'page'} onRetry={() => void mutate()} />;
+ return <NotFound />;
+ }
return (
<Flexbox data-testid="skill-detail-content" gap={16}>
diff --git a/src/routes/(main)/community/(detail)/user/index.tsx b/src/routes/(main)/community/(detail)/user/index.tsx
index f8942510479..6a679770d67 100644
--- a/src/routes/(main)/community/(detail)/user/index.tsx
+++ b/src/routes/(main)/community/(detail)/user/index.tsx
@@ -4,6 +4,8 @@ import { memo, useCallback, useEffect, useMemo, useRef } from 'react';
import { useLocation, useParams } from 'react-router';
import { useCommunityWorkspaceProfile } from '@/business/client/hooks/useCommunityWorkspaceProfile';
+import AsyncError from '@/components/AsyncError';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useMarketAuth, useMarketUserProfile } from '@/layout/AuthProvider/MarketAuth';
import { type MarketUserProfile } from '@/layout/AuthProvider/MarketAuth/types';
@@ -31,7 +33,7 @@ const UserDetailPage = memo<UserDetailPageProps>(({ mobile }) => {
useMarketAuth();
const useUserProfile = useDiscoverStore((s) => s.useUserProfile);
- const { data, mutate } = useUserProfile({ username });
+ const { data, error, isLoading, mutate } = useUserProfile({ username });
// When inside a workspace scope, /community/user/:slug and /community/org/:slug are not the
// right surface β€” redirect to the dedicated workspace community page.
@@ -118,6 +120,10 @@ const UserDetailPage = memo<UserDetailPageProps>(({ mobile }) => {
user,
};
}, [data, handleEditProfile, handleStatusChange, isOwner, mobile]);
+ if (data === undefined) {
+ if (isLoading) return <RouteLoading />;
+ if (error) return <AsyncError error={error} variant={'page'} onRetry={() => void mutate()} />;
+ }
if (!contextConfig) return <NotFound />;
return (
diff --git a/src/routes/(main)/community/(detail)/workspace/index.tsx b/src/routes/(main)/community/(detail)/workspace/index.tsx
index b0a5b85dbd6..34bd4383f47 100644
--- a/src/routes/(main)/community/(detail)/workspace/index.tsx
+++ b/src/routes/(main)/community/(detail)/workspace/index.tsx
@@ -5,6 +5,7 @@ import { memo, useCallback, useMemo } from 'react';
import { useCommunityWorkspaceProfile } from '@/business/client/hooks/useCommunityWorkspaceProfile';
import AsyncError from '@/components/AsyncError';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useDiscoverStore } from '@/store/discover';
import type { DiscoverUserProfile } from '@/types/discover';
@@ -18,7 +19,6 @@ import {
} from './features/resolveWorkspaceProfileEdit';
import WorkspaceContent from './features/WorkspaceContent';
import { openWorkspaceProfileModal } from './features/WorkspaceProfileModal';
-import Loading from './loading';
interface WorkspaceDetailPageProps {
mobile?: boolean;
@@ -151,7 +151,8 @@ const WorkspaceDetailPage = memo<WorkspaceDetailPageProps>(({ mobile }) => {
profileData,
]);
- if ((isWorkspaceProfileLoading || isUserProfileLoading) && !fallbackProfile) return <Loading />;
+ if ((isWorkspaceProfileLoading || isUserProfileLoading) && !fallbackProfile)
+ return <RouteLoading />;
if (!contextConfig) {
// A transient profile fetch failure must not masquerade as "workspace not
// found" β€” offer Reload. Only a resolved-empty profile is a real 404
diff --git a/src/routes/(main)/community/(detail)/workspace/loading.tsx b/src/routes/(main)/community/(detail)/workspace/loading.tsx
deleted file mode 100644
index d2048161ea2..00000000000
--- a/src/routes/(main)/community/(detail)/workspace/loading.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-'use client';
-
-import { Flexbox } from '@lobehub/ui';
-import { Skeleton } from '@lobehub/ui/base-ui';
-import { cssVar } from 'antd-style';
-import { memo } from 'react';
-
-import { ArticleSkeleton } from '@/components/Skeleton';
-import ListLoading from '@/routes/(main)/community/components/ListLoading';
-
-import Banner from './features/Header/Banner';
-
-const Loading = memo(() => {
- return (
- <Flexbox gap={24} width={'100%'}>
- <Banner />
- <Flexbox gap={16}>
- <Skeleton.Avatar
- shape={'square'}
- size={64}
- style={{ boxShadow: `0 0 0 4px ${cssVar.colorBgContainer}`, flexShrink: 0 }}
- />
- <ArticleSkeleton rows={1} />
- </Flexbox>
-
- <ListLoading length={4} rows={4} />
- </Flexbox>
- );
-});
-
-export default Loading;
diff --git a/src/routes/(main)/community/(list)/(home)/index.tsx b/src/routes/(main)/community/(list)/(home)/index.tsx
index 3ad2b5ff1bd..d5161f26d0a 100644
--- a/src/routes/(main)/community/(list)/(home)/index.tsx
+++ b/src/routes/(main)/community/(list)/(home)/index.tsx
@@ -2,7 +2,6 @@
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-import { SWRConfig } from 'swr';
import AsyncBoundary from '@/components/AsyncBoundary';
import { useDiscoverStore } from '@/store/discover';
@@ -14,7 +13,7 @@ import AssistantList from '../agent/features/List';
import McpList from '../mcp/features/List';
import CreatorRewardBanner from './features/CreatorRewardBanner';
-const HomeSections = memo(() => {
+const HomePage = memo(() => {
const { t } = useTranslation('discover');
const useAssistantList = useDiscoverStore((s) => s.useAssistantList);
const useMcpList = useDiscoverStore((s) => s.useFetchMcpList);
@@ -41,12 +40,6 @@ const HomeSections = memo(() => {
sort: McpSorts.Recommended,
});
- // Gate each section independently so a failure in one featured list surfaces a
- // Retry there instead of leaving the whole page on a permanent skeleton
- //
- // The two featured lists are gated independently (see AsyncBoundary), so this
- // page opts out of the subtree's suspense: a failing list must surface its own
- // Retry instead of throwing the whole page to the route error boundary.
return (
<>
<CreatorRewardBanner />
@@ -79,18 +72,6 @@ const HomeSections = memo(() => {
);
});
-HomeSections.displayName = 'CommunityHomeSections';
-
-/**
- * The two featured lists are gated independently (see `AsyncBoundary`), so this
- * page opts out of the subtree's suspense: a list that fails must surface its own
- * Retry instead of throwing the whole page to the route error boundary. The
- * sections live in a child because `SWRConfig` only reaches hooks below it.
- */
-const HomePage = memo(() => (
- <SWRConfig value={{ suspense: false }}>
- <HomeSections />
- </SWRConfig>
-));
+HomePage.displayName = 'CommunityHomePage';
export default HomePage;
diff --git a/src/routes/(main)/community/(list)/_layout/index.tsx b/src/routes/(main)/community/(list)/_layout/index.tsx
index ab4d28246b8..cf00505710e 100644
--- a/src/routes/(main)/community/(list)/_layout/index.tsx
+++ b/src/routes/(main)/community/(list)/_layout/index.tsx
@@ -1,8 +1,6 @@
import { Flexbox } from '@lobehub/ui';
import { Outlet } from 'react-router';
-import { SWRConfig } from 'swr';
-import SuspenseRouteBoundary from '@/components/SuspenseRouteBoundary';
import WideScreenContainer from '@/features/WideScreenContainer';
import { RouteSkeletonChromeProvider } from '@/spa/router/routeSkeletonChrome';
@@ -27,13 +25,9 @@ const Layout = () => {
}}
>
<Flexbox gap={16} style={{ paddingBlockEnd: 40 }} width={'100%'}>
- <SWRConfig value={{ suspense: true }}>
- <SuspenseRouteBoundary>
- <RouteSkeletonChromeProvider>
- <Outlet />
- </RouteSkeletonChromeProvider>
- </SuspenseRouteBoundary>
- </SWRConfig>
+ <RouteSkeletonChromeProvider>
+ <Outlet />
+ </RouteSkeletonChromeProvider>
</Flexbox>
<div className={styles.spacer} />
<Footer />
diff --git a/src/routes/(main)/community/(list)/agent/index.tsx b/src/routes/(main)/community/(list)/agent/index.tsx
index 02e2adcdf08..e60c7344d14 100644
--- a/src/routes/(main)/community/(list)/agent/index.tsx
+++ b/src/routes/(main)/community/(list)/agent/index.tsx
@@ -4,6 +4,7 @@ import { Flexbox } from '@lobehub/ui';
import { memo } from 'react';
import AsyncBoundary from '@/components/AsyncBoundary';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { buildAssistantListQuery } from '@/features/CommunityAgentList/assistantListQuery';
import { useQuery } from '@/hooks/useQuery';
import { useDiscoverStore } from '@/store/discover';
@@ -17,7 +18,7 @@ import List from './features/List';
const AssistantPage = memo(() => {
const query = useQuery() as AssistantQueryParams;
const useAssistantList = useDiscoverStore((s) => s.useAssistantList);
- const { data, error, mutate } = useAssistantList(buildAssistantListQuery(query));
+ const { data, error, isLoading, mutate } = useAssistantList(buildAssistantListQuery(query));
const items = data?.items ?? [];
@@ -28,6 +29,8 @@ const AssistantPage = memo(() => {
error={error}
errorVariant={'page'}
isEmpty={items.length === 0}
+ isLoading={isLoading}
+ loading={<RouteLoading />}
onRetry={() => mutate()}
>
{data && (
diff --git a/src/routes/(main)/community/(list)/mcp/index.tsx b/src/routes/(main)/community/(list)/mcp/index.tsx
index f6badbff338..52da140bd64 100644
--- a/src/routes/(main)/community/(list)/mcp/index.tsx
+++ b/src/routes/(main)/community/(list)/mcp/index.tsx
@@ -4,6 +4,7 @@ import { Flexbox } from '@lobehub/ui';
import { memo } from 'react';
import AsyncBoundary from '@/components/AsyncBoundary';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { useQuery } from '@/hooks/useQuery';
import { useDiscoverStore } from '@/store/discover';
import { type McpQueryParams } from '@/types/discover';
@@ -16,7 +17,7 @@ import List from './features/List';
const McpPage = memo(() => {
const { q, page, category, sort, order } = useQuery() as McpQueryParams;
const useMcpList = useDiscoverStore((s) => s.useFetchMcpList);
- const { data, error, mutate } = useMcpList({
+ const { data, error, isLoading, mutate } = useMcpList({
category,
order,
page,
@@ -34,6 +35,8 @@ const McpPage = memo(() => {
error={error}
errorVariant={'page'}
isEmpty={items.length === 0}
+ isLoading={isLoading}
+ loading={<RouteLoading />}
onRetry={() => mutate()}
>
{data && (
diff --git a/src/routes/(main)/community/(list)/model/index.tsx b/src/routes/(main)/community/(list)/model/index.tsx
index 30462a995bf..9bc3ae1fb4b 100644
--- a/src/routes/(main)/community/(list)/model/index.tsx
+++ b/src/routes/(main)/community/(list)/model/index.tsx
@@ -4,6 +4,7 @@ import { Flexbox } from '@lobehub/ui';
import { memo } from 'react';
import AsyncBoundary from '@/components/AsyncBoundary';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { useQuery } from '@/hooks/useQuery';
import { useDiscoverStore } from '@/store/discover';
import { type ModelQueryParams } from '@/types/discover';
@@ -16,7 +17,7 @@ import List from './features/List';
const ModelPage = memo<{ mobile?: boolean }>(() => {
const { q, page, category, sort, order } = useQuery() as ModelQueryParams;
const useModelList = useDiscoverStore((s) => s.useModelList);
- const { data, error, mutate } = useModelList({
+ const { data, error, isLoading, mutate } = useModelList({
category,
order,
page,
@@ -34,6 +35,8 @@ const ModelPage = memo<{ mobile?: boolean }>(() => {
error={error}
errorVariant={'page'}
isEmpty={items.length === 0}
+ isLoading={isLoading}
+ loading={<RouteLoading />}
onRetry={() => mutate()}
>
{data && (
diff --git a/src/routes/(main)/community/(list)/provider/index.tsx b/src/routes/(main)/community/(list)/provider/index.tsx
index 384e95878d7..799e8bcfd98 100644
--- a/src/routes/(main)/community/(list)/provider/index.tsx
+++ b/src/routes/(main)/community/(list)/provider/index.tsx
@@ -4,6 +4,7 @@ import { Flexbox } from '@lobehub/ui';
import { memo } from 'react';
import AsyncBoundary from '@/components/AsyncBoundary';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { useQuery } from '@/hooks/useQuery';
import { useDiscoverStore } from '@/store/discover';
import { type ProviderQueryParams } from '@/types/discover';
@@ -16,7 +17,7 @@ import List from './features/List';
const ProviderPage = memo(() => {
const { q, page, sort, order } = useQuery() as ProviderQueryParams;
const useProviderList = useDiscoverStore((s) => s.useProviderList);
- const { data, error, mutate } = useProviderList({
+ const { data, error, isLoading, mutate } = useProviderList({
order,
page,
pageSize: 21,
@@ -33,6 +34,8 @@ const ProviderPage = memo(() => {
error={error}
errorVariant={'page'}
isEmpty={items.length === 0}
+ isLoading={isLoading}
+ loading={<RouteLoading />}
onRetry={() => mutate()}
>
{data && (
diff --git a/src/routes/(main)/community/(list)/skill/index.tsx b/src/routes/(main)/community/(list)/skill/index.tsx
index 3cd154a0d9f..7c8a55ced11 100644
--- a/src/routes/(main)/community/(list)/skill/index.tsx
+++ b/src/routes/(main)/community/(list)/skill/index.tsx
@@ -4,6 +4,7 @@ import { Flexbox } from '@lobehub/ui';
import { memo } from 'react';
import AsyncBoundary from '@/components/AsyncBoundary';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { useQuery } from '@/hooks/useQuery';
import { useDiscoverStore } from '@/store/discover';
import { type SkillQueryParams } from '@/types/discover';
@@ -16,7 +17,7 @@ import List from './features/List';
const SkillPage = memo(() => {
const { q, page, category, sort, order } = useQuery() as SkillQueryParams;
const useSkillList = useDiscoverStore((s) => s.useFetchSkillList);
- const { data, error, mutate } = useSkillList({
+ const { data, error, isLoading, mutate } = useSkillList({
category,
order,
page,
@@ -34,6 +35,8 @@ const SkillPage = memo(() => {
error={error}
errorVariant={'page'}
isEmpty={items.length === 0}
+ isLoading={isLoading}
+ loading={<RouteLoading />}
onRetry={() => mutate()}
>
{data && (
diff --git a/src/routes/(main)/eval/_layout/Sidebar/Content.tsx b/src/routes/(main)/eval/_layout/Sidebar/Content.tsx
index e927db26623..11a47e4c7a5 100644
--- a/src/routes/(main)/eval/_layout/Sidebar/Content.tsx
+++ b/src/routes/(main)/eval/_layout/Sidebar/Content.tsx
@@ -1,22 +1,10 @@
'use client';
-import { SWRConfig } from 'swr';
-
import SideBarLayout from '@/features/NavPanel/SideBarLayout';
import Body from './Body';
import Header from './Header';
-/**
- * The sidebar is persistent chrome, not route content: it outlives every route
- * under it and its lists carry their own Retry. Route-wide `suspense` would let
- * one failing list throw past them to the route boundary and blank the whole
- * eval workspace, so the sidebar opts out.
- */
-const EvalSidebarContent = () => (
- <SWRConfig value={{ suspense: false }}>
- <SideBarLayout body={<Body />} header={<Header />} />
- </SWRConfig>
-);
+const EvalSidebarContent = () => <SideBarLayout body={<Body />} header={<Header />} />;
export default EvalSidebarContent;
diff --git a/src/routes/(main)/eval/_layout/index.tsx b/src/routes/(main)/eval/_layout/index.tsx
index e01d0e2b262..671b66d9241 100644
--- a/src/routes/(main)/eval/_layout/index.tsx
+++ b/src/routes/(main)/eval/_layout/index.tsx
@@ -2,18 +2,7 @@
import { type FC } from 'react';
import { Outlet } from 'react-router';
-import { SWRConfig } from 'swr';
-import SuspenseRouteBoundary from '@/components/SuspenseRouteBoundary';
-
-const EvalLayout: FC = () => {
- return (
- <SWRConfig value={{ suspense: true }}>
- <SuspenseRouteBoundary>
- <Outlet />
- </SuspenseRouteBoundary>
- </SWRConfig>
- );
-};
+const EvalLayout: FC = () => <Outlet />;
export default EvalLayout;
diff --git a/src/routes/(main)/eval/bench/[benchmarkId]/index.tsx b/src/routes/(main)/eval/bench/[benchmarkId]/index.tsx
index 9b41275f05a..dff1fc74acc 100644
--- a/src/routes/(main)/eval/bench/[benchmarkId]/index.tsx
+++ b/src/routes/(main)/eval/bench/[benchmarkId]/index.tsx
@@ -19,7 +19,8 @@ import { memo, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router';
-import { BenchmarkDetailLoading } from '@/features/Eval';
+import AsyncError from '@/components/AsyncError';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { runSelectors, useEvalStore } from '@/store/eval';
import BenchmarkHeader from './features/BenchmarkHeader';
@@ -89,7 +90,7 @@ const BenchmarkDetail = memo(() => {
const useFetchRuns = useEvalStore((s) => s.useFetchRuns);
const runList = useEvalStore(runSelectors.runList);
- useFetchBenchmarkDetail(benchmarkId);
+ const { error, isLoading, mutate } = useFetchBenchmarkDetail(benchmarkId);
useFetchDatasets(benchmarkId);
const handleRefreshDatasets = useCallback(async () => {
@@ -111,12 +112,10 @@ const BenchmarkDetail = memo(() => {
const totalCases = datasets.reduce((sum, ds) => sum + (ds.testCaseCount || 0), 0);
- if (!benchmark)
- return (
- <Flexbox aria-busy className={styles.container} gap={24} height="100%" width="100%">
- <BenchmarkDetailLoading />
- </Flexbox>
- );
+ if (!benchmark) {
+ if (isLoading || !error) return <RouteLoading />;
+ return <AsyncError error={error} variant={'page'} onRetry={() => void mutate()} />;
+ }
return (
<Flexbox className={styles.container} gap={24} height="100%" width="100%">
diff --git a/src/routes/(main)/eval/bench/[benchmarkId]/runs/[runId]/cases/[caseId]/index.tsx b/src/routes/(main)/eval/bench/[benchmarkId]/runs/[runId]/cases/[caseId]/index.tsx
index ccdf01d8a00..0a6cdf169d8 100644
--- a/src/routes/(main)/eval/bench/[benchmarkId]/runs/[runId]/cases/[caseId]/index.tsx
+++ b/src/routes/(main)/eval/bench/[benchmarkId]/runs/[runId]/cases/[caseId]/index.tsx
@@ -9,6 +9,7 @@ import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router';
import AsyncBoundary from '@/components/AsyncBoundary';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { runSelectors, useEvalStore } from '@/store/eval';
@@ -36,6 +37,7 @@ const CaseDetail = memo(() => {
const {
data: resultsData,
error: resultsError,
+ isLoading: isLoadingResults,
mutate: mutateResults,
} = useFetchRunResults(runId!, pollingConfig);
@@ -99,6 +101,8 @@ const CaseDetail = memo(() => {
error={resultsError}
errorVariant={'page'}
isEmpty={!caseResult}
+ isLoading={isLoadingResults}
+ loading={<RouteLoading />}
onRetry={() => mutateResults()}
>
{caseResult && (
diff --git a/src/routes/(main)/eval/bench/[benchmarkId]/runs/[runId]/index.tsx b/src/routes/(main)/eval/bench/[benchmarkId]/runs/[runId]/index.tsx
index 160dc9ec2e8..5c629ab60fb 100644
--- a/src/routes/(main)/eval/bench/[benchmarkId]/runs/[runId]/index.tsx
+++ b/src/routes/(main)/eval/bench/[benchmarkId]/runs/[runId]/index.tsx
@@ -10,6 +10,7 @@ import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router';
import AsyncBoundary from '@/components/AsyncBoundary';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { runSelectors, useEvalStore } from '@/store/eval';
import { createBatchResumeModal } from './features/BatchResumeModal';
@@ -78,7 +79,7 @@ const RunDetail = memo(() => {
const pollingConfig = { refreshInterval: isActive ? POLLING_INTERVAL : 0 };
- const { error, mutate } = useFetchRunDetail(runId!, pollingConfig);
+ const { error, isLoading, mutate } = useFetchRunDetail(runId!, pollingConfig);
useFetchRunResults(runId!, pollingConfig);
const hasResults = !!runResults?.results?.length;
@@ -109,6 +110,8 @@ const RunDetail = memo(() => {
error={error}
errorVariant={'page'}
isEmpty={!runDetail}
+ isLoading={isLoading}
+ loading={<RouteLoading />}
onRetry={() => mutate()}
>
{runDetail && (
diff --git a/src/routes/(main)/eval/cases/[caseId]/index.tsx b/src/routes/(main)/eval/cases/[caseId]/index.tsx
index ae81ece9121..905065e0ac2 100644
--- a/src/routes/(main)/eval/cases/[caseId]/index.tsx
+++ b/src/routes/(main)/eval/cases/[caseId]/index.tsx
@@ -7,6 +7,7 @@ import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router';
import AsyncBoundary from '@/components/AsyncBoundary';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { useEvalStore } from '@/store/eval';
import { isTrpcErrorCode } from '@/utils/trpcError';
@@ -18,7 +19,7 @@ const Page = memo(() => {
const useFetchTestCase = useEvalStore((s) => s.useFetchTestCase);
const useFetchDatasetDetail = useEvalStore((s) => s.useFetchDatasetDetail);
- const { data: testCase, error, mutate } = useFetchTestCase(caseId);
+ const { data: testCase, error, isLoading, mutate } = useFetchTestCase(caseId);
const { data: dataset } = useFetchDatasetDetail(testCase?.datasetId);
// A deleted or mistyped case id is an absent resource, not a failed request:
@@ -33,6 +34,8 @@ const Page = memo(() => {
error={isMissing ? undefined : error}
errorVariant={'page'}
isEmpty={isMissing || !testCase}
+ isLoading={isLoading}
+ loading={<RouteLoading />}
empty={
<Center flex={1}>
<Text type="secondary">{t('testCaseDetail.notFound')}</Text>
diff --git a/src/routes/(main)/eval/datasets/[datasetId]/index.tsx b/src/routes/(main)/eval/datasets/[datasetId]/index.tsx
index 65d8fd727e6..148433f9f6f 100644
--- a/src/routes/(main)/eval/datasets/[datasetId]/index.tsx
+++ b/src/routes/(main)/eval/datasets/[datasetId]/index.tsx
@@ -9,6 +9,7 @@ import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router';
import AsyncBoundary from '@/components/AsyncBoundary';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
import { agentEvalService } from '@/services/agentEval';
@@ -107,7 +108,7 @@ const DatasetDetail = memo(() => {
const refreshTestCases = useEvalStore((s) => s.refreshTestCases);
const refreshDatasetDetail = useEvalStore((s) => s.refreshDatasetDetail);
- const { data: dataset, error, mutate } = useFetchDatasetDetail(datasetId);
+ const { data: dataset, error, isLoading, mutate } = useFetchDatasetDetail(datasetId);
// Nullable: a dataset accumulated from captured cases belongs to no benchmark.
const benchmarkId: string | null =
(dataset as { benchmarkId?: string | null })?.benchmarkId ?? null;
@@ -209,6 +210,8 @@ const DatasetDetail = memo(() => {
error={error}
errorVariant={'page'}
isEmpty={!dataset}
+ isLoading={isLoading}
+ loading={<RouteLoading />}
onRetry={() => mutate()}
>
{dataset && (
diff --git a/src/routes/(main)/eval/features/Experiments/ExperimentDetailPage.tsx b/src/routes/(main)/eval/features/Experiments/ExperimentDetailPage.tsx
index 24aa924d564..2686743286c 100644
--- a/src/routes/(main)/eval/features/Experiments/ExperimentDetailPage.tsx
+++ b/src/routes/(main)/eval/features/Experiments/ExperimentDetailPage.tsx
@@ -1,13 +1,12 @@
'use client';
import { Flexbox } from '@lobehub/ui';
-import { Skeleton } from '@lobehub/ui/base-ui';
import { createStaticStyles } from 'antd-style';
import { memo } from 'react';
import { useParams } from 'react-router';
-import AsyncBoundary from '@/components/AsyncBoundary';
-import { ArticleSkeleton } from '@/components/Skeleton';
+import AsyncError from '@/components/AsyncError';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { experimentSelectors, useEvalStore } from '@/store/eval';
import BenchmarksSection from './BenchmarksSection';
@@ -39,33 +38,18 @@ const ExperimentDetailPage = memo(() => {
const actions = useExperimentActions(experiment);
- // Error (including a deleted / unknown experiment) must gate before the
- // skeleton β€” otherwise a failed first load hangs on it forever (ux Feedback).
+ if (!experiment) {
+ if (isLoading || !error) return <RouteLoading />;
+ return <AsyncError error={error} variant={'page'} onRetry={() => void mutate()} />;
+ }
+
return (
<Flexbox className={styles.container} gap={24} height="100%" width="100%">
- <AsyncBoundary
- data={experiment}
- error={error}
- errorVariant={'block'}
- isLoading={isLoading && !experiment}
- loading={
- <>
- <ArticleSkeleton rows={2} title={240} />
- <Skeleton.Text rows={6} />
- </>
- }
- onRetry={() => mutate()}
- >
- {experiment && (
- <>
- <ExperimentHeader experiment={experiment} />
- <ExperimentStats datasetCount={experiment.datasets.length} experiment={experiment} />
- <BenchmarksSection actions={actions} experiment={experiment} />
- <ScopedDatasetsSection actions={actions} />
- <RunsSection actions={actions} experiment={experiment} />
- </>
- )}
- </AsyncBoundary>
+ <ExperimentHeader experiment={experiment} />
+ <ExperimentStats datasetCount={experiment.datasets.length} experiment={experiment} />
+ <BenchmarksSection actions={actions} experiment={experiment} />
+ <ScopedDatasetsSection actions={actions} />
+ <RunsSection actions={actions} experiment={experiment} />
</Flexbox>
);
});
diff --git a/src/routes/(main)/eval/index.tsx b/src/routes/(main)/eval/index.tsx
index 5e81db2f67e..18dc365dbdc 100644
--- a/src/routes/(main)/eval/index.tsx
+++ b/src/routes/(main)/eval/index.tsx
@@ -6,7 +6,6 @@ import { createStaticStyles, cssVar } from 'antd-style';
import { Database, FlaskConical, Plus } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-import { SWRConfig } from 'swr';
import AsyncBoundary from '@/components/AsyncBoundary';
import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
@@ -89,7 +88,7 @@ const SkeletonGrid = memo(() => (
</div>
));
-const EvalOverviewContent = memo(() => {
+const EvalOverview = memo(() => {
const { t } = useTranslation('eval');
const benchmarkList = useEvalStore((s) => s.benchmarkList);
const useFetchBenchmarks = useEvalStore((s) => s.useFetchBenchmarks);
@@ -269,17 +268,4 @@ const EvalOverviewContent = memo(() => {
);
});
-/**
- * The overview holds three independently gated sections β€” experiments,
- * benchmarks and datasets β€” each with its own `AsyncBoundary` and Retry. Under
- * route-wide `suspense` the first failing fetch throws past all of them and
- * replaces the healthy sections with a page-wide error, so the overview opts
- * out. The opt-out has to sit *above* the hooks it covers, hence the wrapper.
- */
-const EvalOverview = memo(() => (
- <SWRConfig value={{ suspense: false }}>
- <EvalOverviewContent />
- </SWRConfig>
-));
-
export default EvalOverview;
diff --git a/src/routes/(main)/group/_layout/index.tsx b/src/routes/(main)/group/_layout/index.tsx
index 8ce8e75d459..f05baace3b9 100644
--- a/src/routes/(main)/group/_layout/index.tsx
+++ b/src/routes/(main)/group/_layout/index.tsx
@@ -1,9 +1,7 @@
import { Flexbox } from '@lobehub/ui';
import { type FC } from 'react';
import { Outlet } from 'react-router';
-import { SWRConfig } from 'swr';
-import SuspenseRouteBoundary from '@/components/SuspenseRouteBoundary';
import { isDesktop } from '@/const/version';
import { GroupNotFoundGuard } from '@/features/GroupNotFound';
import ProtocolUrlHandler from '@/features/ProtocolUrlHandler';
@@ -24,11 +22,7 @@ const Layout: FC = () => {
{/* Keep the sidebar interactive when the routed group is gone (deleted
or made private) β€” only the content area collapses to the 404 card. */}
<GroupNotFoundGuard>
- <SWRConfig value={{ suspense: true }}>
- <SuspenseRouteBoundary>
- <Outlet />
- </SuspenseRouteBoundary>
- </SWRConfig>
+ <Outlet />
</GroupNotFoundGuard>
</Flexbox>
<RegisterHotkeys />
diff --git a/src/routes/(main)/memory/(home)/index.tsx b/src/routes/(main)/memory/(home)/index.tsx
index 06086b7eac5..2708aefc652 100644
--- a/src/routes/(main)/memory/(home)/index.tsx
+++ b/src/routes/(main)/memory/(home)/index.tsx
@@ -3,6 +3,8 @@ import { Flexbox } from '@lobehub/ui';
import { type FC } from 'react';
import AsyncBoundary from '@/components/AsyncBoundary';
+import SkeletonBar from '@/components/Skeleton/Bar';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import NavHeader from '@/features/NavHeader';
import WideScreenContainer from '@/features/WideScreenContainer';
import WideScreenButton from '@/features/WideScreenContainer/WideScreenButton';
@@ -22,8 +24,12 @@ const Home: FC = () => {
const roles = useUserMemoryStore((s) => s.roles);
const persona = useUserMemoryStore((s) => s.persona);
- const { error: tagsError, mutate: mutateTags } = useFetchTags();
- const { error: personaError, mutate: mutatePersona } = useFetchPersona();
+ const { error: tagsError, isLoading: tagsLoading, mutate: mutateTags } = useFetchTags();
+ const {
+ error: personaError,
+ isLoading: personaLoading,
+ mutate: mutatePersona,
+ } = useFetchPersona();
// const { EditorModalElement, openEditor } = usePersonaEditor();
// Persona / tags feed the store, so a failed fetch left the render falling
@@ -35,6 +41,8 @@ const Home: FC = () => {
// whole page β€” and it already offers the analyse action inline.
const isEmpty = !hasData && !error;
+ if ((tagsLoading || personaLoading) && !hasData) return <RouteLoading />;
+
return (
<Flexbox flex={1} height={'100%'}>
<NavHeader
@@ -72,7 +80,11 @@ const Home: FC = () => {
mutatePersona();
}}
>
- {roles?.length > 0 && <RoleTagCloud tags={roles} />}
+ {roles?.length > 0 ? (
+ <RoleTagCloud tags={roles} />
+ ) : (
+ tagsLoading && <SkeletonBar height={400} radius={12} />
+ )}
{persona && (
<>
<PersonaHeader />
diff --git a/src/routes/(main)/memory/_layout/index.tsx b/src/routes/(main)/memory/_layout/index.tsx
index 4526c007cc4..14482932b92 100644
--- a/src/routes/(main)/memory/_layout/index.tsx
+++ b/src/routes/(main)/memory/_layout/index.tsx
@@ -3,9 +3,7 @@
import { Flexbox } from '@lobehub/ui';
import { type FC } from 'react';
import { Outlet } from 'react-router';
-import { SWRConfig } from 'swr';
-import SuspenseRouteBoundary from '@/components/SuspenseRouteBoundary';
import { RouteSkeletonChromeProvider } from '@/spa/router/routeSkeletonChrome';
import Sidebar from './Sidebar';
@@ -16,13 +14,9 @@ const DesktopMemoryLayout: FC = () => {
<>
<Sidebar />
<Flexbox className={styles.mainContainer} flex={1} height={'100%'}>
- <SWRConfig value={{ suspense: true }}>
- <SuspenseRouteBoundary>
- <RouteSkeletonChromeProvider>
- <Outlet />
- </RouteSkeletonChromeProvider>
- </SuspenseRouteBoundary>
- </SWRConfig>
+ <RouteSkeletonChromeProvider>
+ <Outlet />
+ </RouteSkeletonChromeProvider>
</Flexbox>
</>
);
diff --git a/src/routes/(main)/memory/identities/index.tsx b/src/routes/(main)/memory/identities/index.tsx
index 4b5b6f53788..97b10b40ef9 100644
--- a/src/routes/(main)/memory/identities/index.tsx
+++ b/src/routes/(main)/memory/identities/index.tsx
@@ -4,6 +4,7 @@ import { BrainCircuitIcon } from 'lucide-react';
import { type FC } from 'react';
import { memo, useCallback, useEffect, useState } from 'react';
+import { MemoryListBoundary } from '@/features/Memory';
import NavHeader from '@/features/NavHeader';
import WideScreenContainer from '@/features/WideScreenContainer';
import WideScreenButton from '@/features/WideScreenContainer/WideScreenButton';
@@ -46,7 +47,7 @@ const IdentitiesArea = memo(() => {
}, [searchValue, typeFilter]);
// Call SWR hook to fetch data
- const { isLoading } = useFetchIdentities({
+ const { data, error, isLoading, mutate } = useFetchIdentities({
page: identitiesPage,
pageSize: 12,
q: searchValue || undefined,
@@ -68,9 +69,6 @@ const IdentitiesArea = memo(() => {
[setTypeFilterRaw],
);
- // Show loading: during search/reset or initial load
- const showLoading = identitiesSearchLoading || !identitiesInit;
-
// Action bar, type tabs and search are controls over nothing on an empty
// collection, so they only render once there is something to act on.
const showControls = showIdentityControls({
@@ -110,11 +108,17 @@ const IdentitiesArea = memo(() => {
<CommonFilterBar searchValue={searchValue} onSearch={handleSearch} />
</Flexbox>
)}
- {showLoading ? (
- <Loading viewMode={viewMode} />
- ) : (
+ <MemoryListBoundary
+ data={data}
+ error={error}
+ isInitialized={identitiesInit}
+ isLoading={isLoading}
+ isResetting={identitiesSearchLoading}
+ loading={<Loading viewMode={viewMode} />}
+ onRetry={() => void mutate()}
+ >
<List isLoading={isLoading} searchValue={searchValue} viewMode={viewMode} />
- )}
+ </MemoryListBoundary>
</WideScreenContainer>
</Flexbox>
</Flexbox>
diff --git a/src/routes/(main)/project/[projectId]/tasks/index.tsx b/src/routes/(main)/project/[projectId]/tasks/index.tsx
index aae9a43f57e..3f2e6a565c4 100644
--- a/src/routes/(main)/project/[projectId]/tasks/index.tsx
+++ b/src/routes/(main)/project/[projectId]/tasks/index.tsx
@@ -1,16 +1,23 @@
'use client';
+import AsyncError from '@/components/AsyncError';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { AgentTasksPage } from '@/features/AgentTasks';
import { useActiveRouteParams } from '@/hooks/useActiveRouteParams';
-import { useCurrentProjectDetail } from '@/store/project';
+import { useProjectStore } from '@/store/project';
const ProjectTasks = () => {
const { projectId } = useActiveRouteParams<{ projectId: string }>();
- const detail = useCurrentProjectDetail(projectId);
+ const { data, error, isLoading, mutate } = useProjectStore((s) => s.useFetchProjectDetail)(
+ projectId,
+ );
- if (!detail) return null;
+ if (isLoading && !data) return <RouteLoading />;
+ if (error && !data)
+ return <AsyncError error={error} variant={'page'} onRetry={() => void mutate()} />;
+ if (!data) return null;
- return <AgentTasksPage projectId={detail.project.id} />;
+ return <AgentTasksPage projectId={data.data.project.id} />;
};
export default ProjectTasks;
diff --git a/src/routes/(mobile)/community/(detail)/_layout/index.tsx b/src/routes/(mobile)/community/(detail)/_layout/index.tsx
index 4446b2d2d70..7dd0754e778 100644
--- a/src/routes/(mobile)/community/(detail)/_layout/index.tsx
+++ b/src/routes/(mobile)/community/(detail)/_layout/index.tsx
@@ -1,21 +1,18 @@
import { Outlet } from 'react-router';
-import { SWRConfig } from 'swr';
import MobileContentLayout from '@/components/server/MobileNavLayout';
-import SuspenseRouteBoundary from '@/components/SuspenseRouteBoundary';
import Footer from '@/features/Setting/Footer';
import { SCROLL_PARENT_ID } from '@/routes/(main)/community/features/const';
+import { RouteSkeletonChromeProvider } from '@/spa/router/routeSkeletonChrome';
import Header from './Header';
const Layout = () => {
return (
<MobileContentLayout gap={16} header={<Header />} id={SCROLL_PARENT_ID} padding={16}>
- <SWRConfig value={{ suspense: true }}>
- <SuspenseRouteBoundary>
- <Outlet />
- </SuspenseRouteBoundary>
- </SWRConfig>
+ <RouteSkeletonChromeProvider>
+ <Outlet />
+ </RouteSkeletonChromeProvider>
<div />
<Footer />
</MobileContentLayout>
diff --git a/src/routes/(mobile)/community/(list)/_layout/index.tsx b/src/routes/(mobile)/community/(list)/_layout/index.tsx
index 5cd54050a75..3880f646bfb 100644
--- a/src/routes/(mobile)/community/(list)/_layout/index.tsx
+++ b/src/routes/(mobile)/community/(list)/_layout/index.tsx
@@ -1,9 +1,8 @@
import { Outlet } from 'react-router';
-import { SWRConfig } from 'swr';
import MobileContentLayout from '@/components/server/MobileNavLayout';
-import SuspenseRouteBoundary from '@/components/SuspenseRouteBoundary';
import Footer from '@/features/Setting/Footer';
+import { RouteSkeletonChromeProvider } from '@/spa/router/routeSkeletonChrome';
import { SCROLL_PARENT_ID } from '../../../../(main)/community/features/const';
import Header from './Header';
@@ -18,11 +17,9 @@ const Layout = () => {
header={<Header />}
id={SCROLL_PARENT_ID}
>
- <SWRConfig value={{ suspense: true }}>
- <SuspenseRouteBoundary>
- <Outlet />
- </SuspenseRouteBoundary>
- </SWRConfig>
+ <RouteSkeletonChromeProvider>
+ <Outlet />
+ </RouteSkeletonChromeProvider>
<div />
<Footer />
</MobileContentLayout>
diff --git a/src/spa/router/desktopRouter.shared.tsx b/src/spa/router/desktopRouter.shared.tsx
index 8f3fe9547f2..57d071890ef 100644
--- a/src/spa/router/desktopRouter.shared.tsx
+++ b/src/spa/router/desktopRouter.shared.tsx
@@ -34,6 +34,7 @@ import {
import BrandTextLoading from '@/components/Loading/BrandTextLoading';
import AgentShareVisitorSkeleton from '@/components/Skeleton/AgentShareVisitor';
import AppsSkeleton from '@/components/Skeleton/Apps';
+import CommunityHomeSkeleton from '@/components/Skeleton/CommunityHome';
import CommunityListSkeleton from '@/components/Skeleton/CommunityList';
import ConversationLayoutSkeleton from '@/components/Skeleton/Conversation/Layout';
import ConversationSegmentSkeleton from '@/components/Skeleton/Conversation/Segment';
@@ -167,6 +168,7 @@ export const sharedMainAreaChildren: RouteObject[] = [
() => import('@/routes/(main)/agent/docs'),
'Desktop > Chat > DocumentsIndex',
),
+ handle: { meta: routeMeta({ Skeleton: NoRouteSkeleton }) },
index: true,
},
{
@@ -308,6 +310,7 @@ export const sharedMainAreaChildren: RouteObject[] = [
() => import('@/routes/(main)/agent/self-learning/[domainId]/rules/[lessonId]'),
'Desktop > Chat > Self Learning > Domain > Legacy Rule',
),
+ handle: { meta: routeMeta({ Skeleton: NoRouteSkeleton }) },
path: 'rules/:lessonId',
},
],
@@ -319,6 +322,7 @@ export const sharedMainAreaChildren: RouteObject[] = [
() => import('@/routes/(main)/agent/self-learning/legacy'),
'Desktop > Chat > Legacy Self Learning Redirect',
),
+ handle: { meta: routeMeta({ Skeleton: NoRouteSkeleton }) },
path: 'self-learning/*',
},
{
@@ -414,6 +418,7 @@ export const sharedMainAreaChildren: RouteObject[] = [
() => import('@/routes/(main)/community/(detail)/workspace/settings'),
'Desktop > Discover > Workspace > Settings',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('form') }) },
path: 'workspace/settings',
},
// List routes (with ListLayout)
@@ -513,6 +518,7 @@ export const sharedMainAreaChildren: RouteObject[] = [
() => import('@/routes/(main)/community/(detail)/workspace'),
'Desktop > Discover > List > Workspace',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('detail') }) },
path: 'workspace',
},
{
@@ -522,7 +528,11 @@ export const sharedMainAreaChildren: RouteObject[] = [
{ preloadId: 'community' },
),
handle: {
- meta: routeMeta({ icon: ShapesIcon, titleKey: 'navigation.discover' }),
+ meta: routeMeta({
+ icon: ShapesIcon,
+ Skeleton: CommunityHomeSkeleton,
+ titleKey: 'navigation.discover',
+ }),
},
index: true,
},
@@ -901,6 +911,7 @@ export const sharedMainAreaChildren: RouteObject[] = [
() => import('@/routes/(main)/eval/bench/[benchmarkId]'),
'Desktop > Eval > Benchmark Detail',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('detail') }) },
index: true,
},
{
@@ -1242,6 +1253,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/provider'),
'Desktop > Workspace > Settings > Provider',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('list') }) },
path: 'provider',
},
// Path-shaped provider deep-links (`/:slug/settings/provider/:id`)
@@ -1259,6 +1271,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
'Desktop > Workspace > Settings > Skill',
{ preloadId: 'settings' },
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('list') }) },
path: 'skill',
},
{
@@ -1267,6 +1280,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
'Desktop > Workspace > Settings > Connector',
{ preloadId: 'settings' },
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('list') }) },
path: 'connector',
},
// Padded tabs share a centered, max-width container layout.
@@ -1277,6 +1291,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/general'),
'Desktop > Workspace > Settings > General',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('form') }) },
path: 'general',
},
{
@@ -1284,6 +1299,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/members'),
'Desktop > Workspace > Settings > Members',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('list') }) },
path: 'members',
},
{
@@ -1291,6 +1307,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/notification'),
'Desktop > Workspace > Settings > Notification',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('form') }) },
path: 'notification',
},
// Channel detail level of the two-level notification settings β€”
@@ -1300,6 +1317,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/notification'),
'Desktop > Workspace > Settings > Notification > Channel',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('form') }) },
path: 'notification/:sub',
},
{
@@ -1307,6 +1325,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/statistics'),
'Desktop > Workspace > Settings > Statistics',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('grid') }) },
path: 'statistics',
},
// Legacy `/:slug/settings/stats` URLs β€” kept for deep-links.
@@ -1319,6 +1338,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/plans'),
'Desktop > Workspace > Settings > Plans',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('detail') }) },
path: 'plans',
},
{
@@ -1326,6 +1346,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/billing'),
'Desktop > Workspace > Settings > Billing',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('detail') }) },
path: 'billing',
},
{
@@ -1333,6 +1354,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/budget'),
'Desktop > Workspace > Settings > Budget',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('detail') }) },
path: 'budget',
},
{
@@ -1340,6 +1362,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/credits'),
'Desktop > Workspace > Settings > Credits',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('detail') }) },
path: 'credits',
},
{
@@ -1347,6 +1370,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/usage'),
'Desktop > Workspace > Settings > Usage',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('grid') }) },
path: 'usage',
},
{
@@ -1354,6 +1378,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/service-model'),
'Desktop > Workspace > Settings > Service Model',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('form') }) },
path: 'service-model',
},
{
@@ -1361,6 +1386,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/credential'),
'Desktop > Workspace > Settings > Credential',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('form') }) },
path: 'credential',
},
// Legacy `/:slug/settings/creds` URLs β€” kept for deep-links.
@@ -1373,6 +1399,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/apikey'),
'Desktop > Workspace > Settings > API Key',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('list') }) },
path: 'apikey',
},
{
@@ -1380,6 +1407,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/oauth-apps'),
'Desktop > Workspace > Settings > OAuth Apps',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('list') }) },
path: 'oauth-apps',
},
{
@@ -1387,6 +1415,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/oauth-apps'),
'Desktop > Workspace > Settings > OAuth App Detail',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('list') }) },
path: 'oauth-apps/:sub',
},
{
@@ -1394,6 +1423,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/audit-log'),
'Desktop > Workspace > Settings > Audit Log',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('list') }) },
path: 'audit-log',
},
{
@@ -1401,6 +1431,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/labels'),
'Desktop > Workspace > Settings > Labels',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('list') }) },
path: 'labels',
},
{
@@ -1408,6 +1439,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/storage'),
'Desktop > Workspace > Settings > Storage',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('list') }) },
path: 'storage',
},
{
@@ -1415,6 +1447,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/devices'),
'Desktop > Workspace > Settings > Devices',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('list') }) },
path: 'devices',
},
],
diff --git a/src/spa/router/desktopRouter.sync.test.tsx b/src/spa/router/desktopRouter.sync.test.tsx
index 0d99f175180..6c3b0efa9f8 100644
--- a/src/spa/router/desktopRouter.sync.test.tsx
+++ b/src/spa/router/desktopRouter.sync.test.tsx
@@ -1,7 +1,7 @@
import { readFile } from 'node:fs/promises';
import path from 'node:path';
-import type { ReactElement } from 'react';
+import { isValidElement, type ReactElement, Suspense } from 'react';
import type { RouteObject } from 'react-router';
import { matchRoutes } from 'react-router';
import { describe, expect, it, vi } from 'vitest';
@@ -384,6 +384,28 @@ describe('desktop router shared definition', () => {
},
);
+ it.each([
+ ['Web', () => webDesktopRoutes.find((route) => route.path === '/')?.children ?? []],
+ ['Electron', () => createTabRouter('/').routes[0]?.children ?? []],
+ ])('%s declares a skeleton on every lazy main-area page', (_, getRoutes) => {
+ const undeclared: string[] = [];
+ const walk = (routes: RouteObject[], base: string, chain: RouteObject[]) => {
+ for (const route of routes) {
+ const pathname = route.index ? `${base}/(index)` : `${base}/${route.path ?? ''}`;
+ const nextChain = [...chain, route];
+ if (route.children?.length) {
+ walk(route.children, route.index ? base : pathname, nextChain);
+ continue;
+ }
+ const isLazyPage = isValidElement(route.element) && route.element.type === Suspense;
+ if (isLazyPage && !resolveRouteSkeleton(nextChain)) undeclared.push(pathname);
+ }
+ };
+ walk(getRoutes(), '', []);
+
+ expect(undeclared).toEqual([]);
+ });
+
it.each([
['Web', (_pathname: string) => webDesktopRoutes],
['Electron', (pathname: string) => createTabRouter(pathname).routes],
diff --git a/src/spa/router/mobileRouter.config.tsx b/src/spa/router/mobileRouter.config.tsx
index ea26c5a12e5..35de285cb70 100644
--- a/src/spa/router/mobileRouter.config.tsx
+++ b/src/spa/router/mobileRouter.config.tsx
@@ -8,7 +8,9 @@ import {
} from '@/business/client/BusinessMobileRoutes';
import AgentShareVisitorSkeleton from '@/components/Skeleton/AgentShareVisitor';
import AppsSkeleton from '@/components/Skeleton/Apps';
+import CommunityListSkeleton from '@/components/Skeleton/CommunityList';
import { delayed } from '@/components/Skeleton/Delayed';
+import { createSurfaceSkeleton } from '@/components/Skeleton/Surface';
import { acceptanceRouteMeta } from '@/features/Acceptance/routeMeta';
import { agentShareVisitorRouteMeta } from '@/features/AgentShareVisitor/routeMeta';
import { AGENT_SHARE_VISITOR_PATH } from '@/features/AgentShareVisitor/visitorPath';
@@ -16,6 +18,7 @@ import { mobileAgentSettingsRouteMeta } from '@/features/RouteMeta/mobileRouteMe
import WorkspaceProviderRedirect from '@/features/WorkspaceSetting/ProviderRedirect';
import { agentRouteMeta } from '@/routes/(main)/agent/features/routeMeta';
import { loadRouteWithBuiltinToolSurfaces } from '@/spa/initialize/toolSurfaces';
+import { routeMeta } from '@/spa/router/routeMeta';
import { dynamicElement, dynamicLayout, ErrorBoundary, redirectElement } from '@/utils/router';
const mobileChatElement = dynamicElement(
@@ -139,6 +142,7 @@ export const sharedMainAreaChildren: RouteObject[] = [
),
'Mobile > Discover > List > Workspace',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('detail') }) },
path: 'workspace',
},
],
@@ -147,6 +151,7 @@ export const sharedMainAreaChildren: RouteObject[] = [
'Mobile > Discover > List > Layout',
{ preloadId: 'mobile-community' },
),
+ handle: { meta: routeMeta({ Skeleton: CommunityListSkeleton }) },
},
// Detail routes (with DetailLayout)
{
@@ -211,6 +216,7 @@ export const sharedMainAreaChildren: RouteObject[] = [
() => import('@/routes/(mobile)/community/(detail)/_layout'),
'Mobile > Discover > Detail > Layout',
),
+ handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('detail') }) },
},
],
element: dynamicElement(
diff --git a/src/spa/router/mobileRouter.test.tsx b/src/spa/router/mobileRouter.test.tsx
index 821ab49ffe3..b9d4e2e2ca5 100644
--- a/src/spa/router/mobileRouter.test.tsx
+++ b/src/spa/router/mobileRouter.test.tsx
@@ -5,6 +5,7 @@ import { matchRoutes } from 'react-router';
import { describe, expect, it } from 'vitest';
import { mobileRoutes } from './mobileRouter.config';
+import { getRouteMetaFromHandle } from './routeMeta';
describe('mobileRouter agent share route', () => {
it('serves the agent-share visitor page on /a/:slugOrId outside the main layout', () => {
@@ -64,7 +65,7 @@ describe('mobileRouter workspace provider routes', () => {
});
describe('mobile community route layouts', () => {
- it('wraps shared community list and detail pages in SWR suspense boundaries', async () => {
+ it('renders community list and detail pages without layout-level SWR suspense', async () => {
const readLayout = (layoutPath: string) =>
readFile(path.join(process.cwd(), layoutPath), 'utf8');
@@ -74,13 +75,22 @@ describe('mobile community route layouts', () => {
]);
for (const source of [listLayout, detailLayout]) {
- expect(source).toContain("import { SWRConfig } from 'swr'");
- expect(source).toContain(
- "import SuspenseRouteBoundary from '@/components/SuspenseRouteBoundary'",
- );
- expect(source).toContain('<SWRConfig value={{ suspense: true }}>');
- expect(source).toContain('<SuspenseRouteBoundary>');
+ expect(source).not.toContain('SWRConfig');
+ expect(source).not.toContain('SuspenseRouteBoundary');
+ expect(source).toContain('<RouteSkeletonChromeProvider>');
expect(source).toContain('<Outlet />');
}
});
+
+ it('declares a route skeleton for the community list and detail layouts', () => {
+ const listMatches = matchRoutes(mobileRoutes, '/community/agent');
+ const detailMatches = matchRoutes(mobileRoutes, '/community/agent/my-agent');
+
+ expect(listMatches?.some((match) => getRouteMetaFromHandle(match.route.handle)?.Skeleton)).toBe(
+ true,
+ );
+ expect(
+ detailMatches?.some((match) => getRouteMetaFromHandle(match.route.handle)?.Skeleton),
+ ).toBe(true);
+ });
});
diff --git a/src/spa/router/routeMeta.ts b/src/spa/router/routeMeta.ts
index 90cc076b503..0ed149fc3c3 100644
--- a/src/spa/router/routeMeta.ts
+++ b/src/spa/router/routeMeta.ts
@@ -46,8 +46,8 @@ export interface ResolvedRouteMeta {
/**
* For a route whose surface is mounted outside the router outlet, or that
* paints fast enough that any placeholder is pure flicker. Declared rather than
- * omitted: an absent `Skeleton` falls through to `RouteSegmentSkeleton`'s
- * path heuristics, which would guess a generic surface shape instead.
+ * omitted: an absent `Skeleton` makes `RouteLoading` render nothing, so the
+ * chunk wait is a blank pane.
*/
export const NoRouteSkeleton = () => null;
diff --git a/src/store/aiInfra/slices/aiModel/action.test.ts b/src/store/aiInfra/slices/aiModel/action.test.ts
index 2e0016564d5..fad07736670 100644
--- a/src/store/aiInfra/slices/aiModel/action.test.ts
+++ b/src/store/aiInfra/slices/aiModel/action.test.ts
@@ -1054,8 +1054,8 @@ describe('AiModelAction', () => {
describe('useFetchAiModelReasoningConfig', () => {
it('resolves a missing config as null so SWR data is never undefined', async () => {
// The server legitimately returns nothing when the user never customized
- // this model's reasoning params. SWR suspense mode can only settle on
- // defined data, so the fetcher must normalize that to null.
+ // this model's reasoning params; `null` keeps that distinguishable from a
+ // fetch that has not settled yet.
vi.spyOn(aiModelService, 'getAiModelReasoningConfig').mockResolvedValue(undefined);
const { result } = renderHook(
diff --git a/src/store/aiInfra/slices/aiModel/action.ts b/src/store/aiInfra/slices/aiModel/action.ts
index 4d6586f3b2d..d3e0829c8a5 100644
--- a/src/store/aiInfra/slices/aiModel/action.ts
+++ b/src/store/aiInfra/slices/aiModel/action.ts
@@ -292,11 +292,6 @@ export class AiModelActionImpl {
): SWRResponse<AiModelReasoningConfig | null> => {
return useClientDataSWR<AiModelReasoningConfig | null>(
id && provider ? aiModelKeys.reasoningConfig(provider, id) : null,
- // A model without a personalized config legitimately resolves to nothing.
- // That MUST land as `null`, not `undefined`: SWR suspense mode treats
- // undefined data as "not loaded yet" and refetches forever, so a
- // suspense-wrapped host (e.g. the agent-doc layout) would hang on its
- // Suspense fallback while hammering this endpoint.
async ([, provider, id]) =>
(await aiModelService.getAiModelReasoningConfig(id as string, provider as string)) ?? null,
{
diff --git a/src/store/discover/slices/assistant/action.test.ts b/src/store/discover/slices/assistant/action.test.ts
index 7cbe0718c7c..b6cc2dae8ae 100644
--- a/src/store/discover/slices/assistant/action.test.ts
+++ b/src/store/discover/slices/assistant/action.test.ts
@@ -99,6 +99,40 @@ describe('AssistantAction', () => {
expect(globalHelpers.getCurrentLanguage).toHaveBeenCalled();
});
+
+ it('should drop previous detail data when the identifier changes', async () => {
+ const first = { identifier: 'assistant-a', name: 'A' };
+ const second = { identifier: 'assistant-b', name: 'B' };
+ let resolveSecond!: (value: typeof second) => void;
+ const secondRequest = new Promise<typeof second>((resolve) => {
+ resolveSecond = resolve;
+ });
+ vi.spyOn(discoverService, 'getAssistantDetail').mockImplementation(async (params) =>
+ params?.identifier === 'assistant-b' ? secondRequest : (first as any),
+ );
+ vi.spyOn(globalHelpers, 'getCurrentLanguage').mockReturnValue('en-US');
+
+ const { result, rerender } = renderHook(
+ ({ identifier }) => useStore.getState().useAssistantDetail({ identifier }),
+ { initialProps: { identifier: 'assistant-a' } },
+ );
+
+ await waitFor(() => {
+ expect(result.current.data).toEqual(first);
+ });
+
+ rerender({ identifier: 'assistant-b' });
+
+ await waitFor(() => {
+ expect(result.current.data).toBeUndefined();
+ });
+
+ resolveSecond(second);
+
+ await waitFor(() => {
+ expect(result.current.data).toEqual(second);
+ });
+ });
});
describe('useAssistantIdentifiers', () => {
diff --git a/src/store/electron/actions/gateway.ts b/src/store/electron/actions/gateway.ts
index 3878bf3e5de..654cd508917 100644
--- a/src/store/electron/actions/gateway.ts
+++ b/src/store/electron/actions/gateway.ts
@@ -56,9 +56,7 @@ export class ElectronGatewayActionImpl {
useFetchGatewayDeviceInfo = (): SWRResponse<GatewayDeviceInfo> => {
return useSWR<GatewayDeviceInfo>(
- // Desktop-only IPC: on web there is no electronAPI, and under a
- // suspense-mode SWRConfig a rejected fetch throws into the route
- // boundary instead of staying in `error` β€” so never fetch off-desktop.
+ // Desktop-only IPC: on web there is no electronAPI, so never fetch off-desktop.
isDesktop ? electronKeys.gatewayDeviceInfo() : null,
async () => gatewayConnectionService.getDeviceInfo() as Promise<GatewayDeviceInfo>,
{
diff --git a/src/store/electron/actions/settings.ts b/src/store/electron/actions/settings.ts
index 54d48c10fe3..0d2492b4a4e 100644
--- a/src/store/electron/actions/settings.ts
+++ b/src/store/electron/actions/settings.ts
@@ -77,9 +77,7 @@ export class ElectronSettingsActionImpl {
useFetchDesktopHotkeys = (): SWRResponse => {
return useSWR<Record<string, string>>(
- // Desktop-only IPC: on web there is no electronAPI, and under a
- // suspense-mode SWRConfig a rejected fetch throws into the route
- // boundary instead of staying in `error` β€” so never fetch off-desktop.
+ // Desktop-only IPC: on web there is no electronAPI, so never fetch off-desktop.
isDesktop ? electronKeys.desktopHotkeys() : null,
async () => desktopSettingsService.getDesktopHotkeys(),
{
diff --git a/src/store/electron/actions/sync.ts b/src/store/electron/actions/sync.ts
index b1359a0e361..c4021df3790 100644
--- a/src/store/electron/actions/sync.ts
+++ b/src/store/electron/actions/sync.ts
@@ -111,9 +111,7 @@ export class ElectronRemoteServerActionImpl {
useDataSyncConfig = (): SWRResponse => {
return useSWR<DataSyncConfig>(
- // Desktop-only IPC: on web there is no electronAPI, and under a
- // suspense-mode SWRConfig a rejected fetch throws into the route
- // boundary instead of staying in `error` β€” so never fetch off-desktop.
+ // Desktop-only IPC: on web there is no electronAPI, so never fetch off-desktop.
isDesktop ? electronKeys.remoteServerConfig() : null,
async () => {
try {
@@ -141,7 +139,6 @@ export class ElectronRemoteServerActionImpl {
this.#set({ dataSyncConfig: data, isInitRemoteServerConfig: true });
},
- suspense: false,
},
);
};