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.

💄 style(skeleton): replace branded loading states with contextual skeletons (#18192)

Innei3aee848b9402
diff --git a/src/components/Skeleton/Bar.tsx b/src/components/Skeleton/Bar.tsx
new file mode 100644
index 00000000000..104f0eae7d6
--- /dev/null
+++ b/src/components/Skeleton/Bar.tsx
@@ -0,0 +1,31 @@
+'use client';
+
+import { Skeleton } from '@lobehub/ui';
+import { cssVar } from 'antd-style';
+
+export interface SkeletonBarProps {
+ height: number;
+ radius?: number | string;
+ width?: number | string;
+}
+
+const SkeletonBar = ({ height, width = '100%', radius }: SkeletonBarProps) => (
+ <Skeleton.Button
+ active
+ block
+ size={'small'}
+ style={{
+ borderRadius: radius ?? cssVar.borderRadius,
+ height,
+ margin: 0,
+ maxHeight: height,
+ maxWidth: width,
+ minHeight: height,
+ minWidth: width,
+ padding: 0,
+ width,
+ }}
+ />
+);
+
+export default SkeletonBar;
diff --git a/src/components/Skeleton/Conversation/Container.tsx b/src/components/Skeleton/Conversation/Container.tsx
new file mode 100644
index 00000000000..1efd68719e4
--- /dev/null
+++ b/src/components/Skeleton/Conversation/Container.tsx
@@ -0,0 +1,43 @@
+'use client';
+
+import { type FlexboxProps } from '@lobehub/ui';
+import { Flexbox } from '@lobehub/ui';
+import { createStaticStyles, cx } from 'antd-style';
+
+import { CONVERSATION_MIN_WIDTH } from '@/const/layoutTokens';
+import { useGlobalStore } from '@/store/global';
+import { systemStatusSelectors } from '@/store/global/selectors';
+
+const styles = createStaticStyles(({ css }) => ({
+ container: css`
+ flex-grow: 1;
+ align-self: center;
+ `,
+}));
+
+const ConversationSkeletonContainer = ({
+ children,
+ className,
+ flex,
+ height,
+ ...rest
+}: FlexboxProps) => {
+ const wideScreen = useGlobalStore(systemStatusSelectors.wideScreen);
+
+ return (
+ <Flexbox flex={flex} height={height} style={{ minHeight: 0 }} width={'100%'}>
+ <Flexbox
+ className={cx(styles.container, className)}
+ flex={flex}
+ height={height}
+ paddingInline={16}
+ width={wideScreen ? '100%' : `min(${CONVERSATION_MIN_WIDTH}px, 100%)`}
+ {...rest}
+ >
+ {children}
+ </Flexbox>
+ </Flexbox>
+ );
+};
+
+export default ConversationSkeletonContainer;
diff --git a/src/components/Skeleton/Conversation/Layout.tsx b/src/components/Skeleton/Conversation/Layout.tsx
new file mode 100644
index 00000000000..96ab685e6bd
--- /dev/null
+++ b/src/components/Skeleton/Conversation/Layout.tsx
@@ -0,0 +1,25 @@
+'use client';
+
+import { Flexbox } from '@lobehub/ui';
+
+import SkeletonBar from '../Bar';
+import ConversationSegmentSkeleton from './Segment';
+
+const ConversationLayoutSkeleton = () => (
+ <Flexbox aria-busy flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
+ <Flexbox
+ horizontal
+ align={'center'}
+ flex={'none'}
+ height={44}
+ justify={'space-between'}
+ paddingInline={12}
+ >
+ <SkeletonBar height={24} width={144} />
+ <SkeletonBar height={28} width={72} />
+ </Flexbox>
+ <ConversationSegmentSkeleton />
+ </Flexbox>
+);
+
+export default ConversationLayoutSkeleton;
diff --git a/src/components/Skeleton/Conversation/List.tsx b/src/components/Skeleton/Conversation/List.tsx
new file mode 100644
index 00000000000..b600e693b64
--- /dev/null
+++ b/src/components/Skeleton/Conversation/List.tsx
@@ -0,0 +1,28 @@
+'use client';
+
+import { Flexbox, Skeleton } from '@lobehub/ui';
+
+import ConversationSkeletonContainer from './Container';
+
+const ConversationListSkeleton = () => (
+ <ConversationSkeletonContainer
+ flex={1}
+ gap={36}
+ height={'100%'}
+ padding={12}
+ style={{ marginTop: 24 }}
+ >
+ <Flexbox gap={8} style={{ paddingLeft: '25%' }} width={'100%'}>
+ <Skeleton.Paragraph active rows={3} style={{ alignItems: 'flex-end' }} />
+ </Flexbox>
+ {Array.from({ length: 2 }).map((_, index) => (
+ <Flexbox gap={8} key={index} width={'100%'}>
+ <Skeleton active avatar={{ shape: 'square', size: 28 }} paragraph={false} />
+ <Skeleton.Paragraph />
+ <Skeleton.Tags count={2} />
+ </Flexbox>
+ ))}
+ </ConversationSkeletonContainer>
+);
+
+export default ConversationListSkeleton;
diff --git a/src/components/Skeleton/Conversation/Segment.tsx b/src/components/Skeleton/Conversation/Segment.tsx
new file mode 100644
index 00000000000..d00ae3022a7
--- /dev/null
+++ b/src/components/Skeleton/Conversation/Segment.tsx
@@ -0,0 +1,52 @@
+'use client';
+
+import { Flexbox } from '@lobehub/ui';
+import { createStaticStyles, cssVar } from 'antd-style';
+
+import SkeletonBar from '../Bar';
+import ConversationSkeletonContainer from './Container';
+import ConversationListSkeleton from './List';
+
+const styles = createStaticStyles(({ css }) => ({
+ composer: css`
+ overflow: hidden;
+
+ height: 106px;
+ border: 1px solid ${cssVar.colorFill};
+ border-radius: ${cssVar.borderRadiusLG};
+
+ background: ${cssVar.colorBgElevated};
+ box-shadow: 0 4px 4px color-mix(in srgb, #000 4%, transparent);
+ `,
+}));
+
+const ComposerSkeleton = () => (
+ <ConversationSkeletonContainer flex={'none'} paddingBlock={'0 8px'}>
+ <Flexbox className={styles.composer} data-testid={'conversation-composer-skeleton'}>
+ <Flexbox flex={1} paddingBlock={'12px 8px'} paddingInline={12}>
+ <SkeletonBar height={14} width={'38%'} />
+ </Flexbox>
+ <Flexbox horizontal align={'center'} height={40} justify={'space-between'} paddingInline={8}>
+ <Flexbox horizontal gap={6}>
+ <SkeletonBar height={28} radius={'50%'} width={28} />
+ <SkeletonBar height={28} radius={'50%'} width={28} />
+ </Flexbox>
+ <SkeletonBar height={32} radius={16} width={64} />
+ </Flexbox>
+ </Flexbox>
+ <Flexbox horizontal align={'center'} gap={8} height={36} paddingInline={4}>
+ <SkeletonBar height={22} radius={11} width={72} />
+ <SkeletonBar height={22} radius={11} width={104} />
+ <SkeletonBar height={22} radius={11} width={88} />
+ </Flexbox>
+ </ConversationSkeletonContainer>
+);
+
+const ConversationSegmentSkeleton = () => (
+ <Flexbox aria-busy flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
+ <ConversationListSkeleton />
+ <ComposerSkeleton />
+ </Flexbox>
+);
+
+export default ConversationSegmentSkeleton;
diff --git a/src/components/Skeleton/NavPanel/List.tsx b/src/components/Skeleton/NavPanel/List.tsx
new file mode 100644
index 00000000000..e456c81486c
--- /dev/null
+++ b/src/components/Skeleton/NavPanel/List.tsx
@@ -0,0 +1,43 @@
+'use client';
+
+import { type FlexboxProps } from '@lobehub/ui';
+import { Flexbox } from '@lobehub/ui';
+
+import SkeletonBar from '../Bar';
+
+export const SkeletonItem = ({
+ padding = 6,
+ height = 36,
+ style,
+ avatarSize = 28,
+ ...rest
+}: { avatarSize?: number } & Omit<FlexboxProps, 'children'>) => (
+ <Flexbox
+ horizontal
+ align={'center'}
+ flex={1}
+ gap={8}
+ height={height}
+ padding={padding}
+ style={style}
+ {...rest}
+ >
+ <SkeletonBar height={avatarSize} width={avatarSize} />
+ <Flexbox flex={1} height={16}>
+ <SkeletonBar height={16} />
+ </Flexbox>
+ </Flexbox>
+);
+
+export const SkeletonList = ({
+ rows = 3,
+ ...rest
+}: { rows?: number } & Omit<FlexboxProps, 'children'>) => (
+ <Flexbox gap={2} {...rest}>
+ {Array.from({ length: rows }).map((_, index) => (
+ <SkeletonItem key={index} />
+ ))}
+ </Flexbox>
+);
+
+export default SkeletonList;
diff --git a/src/components/Skeleton/NavPanel/SideBar.tsx b/src/components/Skeleton/NavPanel/SideBar.tsx
new file mode 100644
index 00000000000..6a1c00d4f9a
--- /dev/null
+++ b/src/components/Skeleton/NavPanel/SideBar.tsx
@@ -0,0 +1,154 @@
+'use client';
+
+import { Center, Flexbox } from '@lobehub/ui';
+import { cssVar } from 'antd-style';
+
+import { isDesktop } from '@/const/version';
+import { isMacOS } from '@/utils/platform';
+
+import SkeletonBar from '../Bar';
+
+const isMacDesktop = isDesktop && isMacOS();
+
+export type SideBarHeaderVariant = 'breadcrumb' | 'title';
+
+const headerContentHeight = (variant: SideBarHeaderVariant) => {
+ if (variant === 'title') return 32;
+ return isMacDesktop ? 22 : 28;
+};
+
+export const SideBarHeaderSkeleton = ({
+ variant = 'breadcrumb',
+}: {
+ variant?: SideBarHeaderVariant;
+}) => (
+ <Flexbox horizontal align={'center'} flex={'none'} padding={'8px 6px'}>
+ <Flexbox flex={1} height={headerContentHeight(variant)} justify={'center'} paddingInline={6}>
+ <SkeletonBar height={variant === 'title' ? 18 : 14} width={variant === 'title' ? 96 : 72} />
+ </Flexbox>
+ </Flexbox>
+);
+
+const SkeletonNavItem = ({ width }: { width: string }) => (
+ <Flexbox horizontal align={'center'} flex={'none'} gap={8} height={36} paddingInline={4}>
+ <Center flex={'none'} height={28} width={28}>
+ <SkeletonBar height={18} radius={cssVar.borderRadiusSM} width={18} />
+ </Center>
+ <Flexbox flex={1}>
+ <SkeletonBar height={14} width={width} />
+ </Flexbox>
+ </Flexbox>
+);
+
+const TITLE_WIDTHS = [56, 72, 48, 64];
+const ITEM_WIDTHS = ['62%', '44%', '70%', '52%', '66%', '48%', '58%', '74%'];
+
+const SkeletonRows = ({
+ count,
+ seed = 0,
+ paddingBlock = 1,
+ gap = 1,
+}: {
+ count: number;
+ gap?: number;
+ paddingBlock?: number;
+ seed?: number;
+}) => (
+ <Flexbox gap={gap} paddingBlock={paddingBlock}>
+ {Array.from({ length: count }).map((_, index) => (
+ <SkeletonNavItem key={index} width={ITEM_WIDTHS[(seed * 3 + index) % ITEM_WIDTHS.length]} />
+ ))}
+ </Flexbox>
+);
+
+export interface NavSkeletonShape {
+ bodyGap?: number;
+ bodyPaddingBlock?: number;
+ groups?: number[];
+ groupTitleHeight?: number;
+ headerVariant?: SideBarHeaderVariant;
+ leadingRows?: number;
+ navGap?: number;
+ navRows?: number;
+ search?: boolean;
+}
+
+export const NavSideBarSkeleton = ({
+ bodyGap = 0,
+ bodyPaddingBlock = 0,
+ groups,
+ groupTitleHeight = 32,
+ headerVariant = 'breadcrumb',
+ leadingRows = 0,
+ navGap = 1,
+ navRows = 0,
+ search = false,
+}: NavSkeletonShape) => {
+ const hasBody = search || leadingRows > 0 || !!groups?.length;
+
+ return (
+ <Flexbox data-testid={'nav-sidebar-skeleton'} gap={1} style={{ height: '100%' }}>
+ <SideBarHeaderSkeleton variant={headerVariant} />
+ {navRows > 0 && (
+ <Flexbox data-testid={'nav-sidebar-skeleton-nav'} flex={'none'} paddingInline={4}>
+ <SkeletonRows count={navRows} gap={navGap} paddingBlock={0} />
+ </Flexbox>
+ )}
+ {hasBody && (
+ <Flexbox
+ gap={bodyGap}
+ paddingBlock={bodyPaddingBlock}
+ paddingInline={4}
+ style={{ overflow: 'hidden' }}
+ >
+ {search && (
+ <Flexbox data-testid={'nav-sidebar-skeleton-search'} paddingInline={4}>
+ <SkeletonBar height={36} />
+ </Flexbox>
+ )}
+ {leadingRows > 0 && <SkeletonRows count={leadingRows} paddingBlock={0} />}
+ {!!groups?.length && (
+ <Flexbox gap={8}>
+ {groups.map((rows, groupIndex) => (
+ <Flexbox key={groupIndex}>
+ <Flexbox
+ flex={'none'}
+ height={groupTitleHeight}
+ justify={'center'}
+ paddingBlock={4}
+ paddingInline={'8px 4px'}
+ >
+ <SkeletonBar
+ height={12}
+ width={TITLE_WIDTHS[groupIndex % TITLE_WIDTHS.length]}
+ />
+ </Flexbox>
+ {rows > 0 && <SkeletonRows count={rows} seed={groupIndex} />}
+ </Flexbox>
+ ))}
+ </Flexbox>
+ )}
+ </Flexbox>
+ )}
+ </Flexbox>
+ );
+};
+
+export const NAV_SKELETON_SHAPES: Record<string, NavSkeletonShape> = {
+ 'agent': { groups: [0, 12], headerVariant: 'title', navRows: 5 },
+ 'discover': { navRows: 6 },
+ 'eval': { bodyGap: 8, groups: [3, 3], groupTitleHeight: 27, leadingRows: 1 },
+ 'evalBench': { bodyGap: 8, groups: [3, 3], groupTitleHeight: 27, leadingRows: 1 },
+ 'group': { groups: [3, 8], headerVariant: 'title' },
+ 'home': { bodyGap: 1, groups: [5, 7, 3], headerVariant: 'title', leadingRows: 2, navRows: 2 },
+ 'image': { bodyGap: 1, groups: [4], groupTitleHeight: 40, navGap: 0, navRows: 2 },
+ 'memory': { navRows: 7 },
+ 'page': { bodyGap: 1, groups: [12], headerVariant: 'title', navRows: 1 },
+ 'resource': { bodyPaddingBlock: 8, groups: [5], navRows: 6 },
+ 'resourceLibrary': { bodyPaddingBlock: 8, groups: [6] },
+ 'settings': { bodyGap: 4, groups: [6, 5, 8, 3], groupTitleHeight: 27, search: true },
+ 'video': { bodyGap: 1, groups: [4], groupTitleHeight: 40, navGap: 0, navRows: 2 },
+ 'workspace-settings': { groups: [5, 5, 6, 3], groupTitleHeight: 27 },
+};
+
+export const DEFAULT_NAV_SKELETON_SHAPE: NavSkeletonShape = { groups: [6, 4] };
diff --git a/src/components/Skeleton/RouteSegment.tsx b/src/components/Skeleton/RouteSegment.tsx
new file mode 100644
index 00000000000..a2c90d779b3
--- /dev/null
+++ b/src/components/Skeleton/RouteSegment.tsx
@@ -0,0 +1,50 @@
+'use client';
+
+import { useLocation } from 'react-router';
+
+import ConversationLayoutSkeleton from './Conversation/Layout';
+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', 'topics']);
+
+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_');
+};
+
+/**
+ * Structural fallback shared by nested route boundaries.
+ *
+ * It deliberately maps URLs to settled surface families instead of drawing one
+ * universal placeholder. This keeps parent and leaf Suspense boundaries on the
+ * same visual structure while their chunks resolve at different times.
+ */
+const RouteSegmentSkeleton = () => {
+ const { pathname } = useLocation();
+
+ if (pathname.startsWith('/settings/')) return <SettingsPageSkeleton />;
+ if (isConversationPath(pathname)) return <ConversationLayoutSkeleton />;
+
+ return <SurfaceSkeleton variant={getSurfaceVariant(pathname)} />;
+};
+
+export default RouteSegmentSkeleton;
diff --git a/src/components/Skeleton/Settings/Page.tsx b/src/components/Skeleton/Settings/Page.tsx
new file mode 100644
index 00000000000..f8fa846d603
--- /dev/null
+++ b/src/components/Skeleton/Settings/Page.tsx
@@ -0,0 +1,30 @@
+'use client';
+
+import { Flexbox } from '@lobehub/ui';
+import { useLocation } from 'react-router';
+
+import NavHeader from '@/features/NavHeader';
+import SettingContainer from '@/features/Setting/SettingContainer';
+
+import SkeletonBar from '../Bar';
+import SettingsProfileSkeleton from './Profile';
+import SettingsSectionSkeleton from './Section';
+
+const SettingsPageSkeleton = () => {
+ const { pathname } = useLocation();
+ const tab = pathname.match(/\/settings\/([^/]+)/)?.[1] ?? 'profile';
+ const profile = tab === 'profile';
+
+ return (
+ <Flexbox aria-busy flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
+ <NavHeader styles={{ center: { alignItems: 'center' } }}>
+ <SkeletonBar height={16} width={profile ? 52 : 88} />
+ </NavHeader>
+ <SettingContainer maxWidth={1024} paddingBlock={'24px 128px'} paddingInline={24}>
+ {profile ? <SettingsProfileSkeleton /> : <SettingsSectionSkeleton />}
+ </SettingContainer>
+ </Flexbox>
+ );
+};
+
+export default SettingsPageSkeleton;
diff --git a/src/components/Skeleton/Settings/Profile.tsx b/src/components/Skeleton/Settings/Profile.tsx
new file mode 100644
index 00000000000..ff8de6d2e8d
--- /dev/null
+++ b/src/components/Skeleton/Settings/Profile.tsx
@@ -0,0 +1,157 @@
+'use client';
+
+import { Flexbox, FormGroup } from '@lobehub/ui';
+import { createStaticStyles, cssVar } from 'antd-style';
+import { type ReactNode } from 'react';
+
+import { useServerConfigStore } from '@/store/serverConfig';
+import { serverConfigSelectors } from '@/store/serverConfig/selectors';
+import { useToolStore } from '@/store/tool';
+import { ComposioServerStatus } from '@/store/tool/slices/composioStore';
+import { useUserStore } from '@/store/user';
+import { authSelectors, userProfileSelectors } from '@/store/user/selectors';
+
+import SkeletonBar from '../Bar';
+
+const styles = createStaticStyles(({ css, responsive }) => ({
+ action: css`
+ flex-shrink: 0;
+ margin-inline-start: auto;
+ `,
+ body: css`
+ display: flex;
+ flex: 1;
+ gap: 12px;
+ align-items: center;
+ justify-content: space-between;
+
+ min-width: 0;
+ `,
+ divider: css`
+ width: 100%;
+ height: 1px;
+ background: ${cssVar.colorBorderSecondary};
+ `,
+ label: css`
+ flex: 0 0 160px;
+
+ ${responsive.md} {
+ flex: 0 0 auto;
+ }
+ `,
+ row: css`
+ display: flex;
+ gap: 24px;
+ align-items: center;
+
+ min-height: 48px;
+ padding-block: 16px;
+
+ ${responsive.md} {
+ flex-direction: column;
+ gap: 12px;
+ align-items: stretch;
+ }
+ `,
+}));
+
+interface SettingsProfileRowSkeletonProps {
+ action?: boolean;
+ actionNode?: ReactNode;
+ body?: ReactNode;
+ bodyWidth?: number;
+ height?: number;
+ labelWidth?: number;
+}
+
+export const SettingsProfileRowSkeleton = ({
+ action = true,
+ actionNode,
+ body,
+ bodyWidth = 160,
+ height,
+ labelWidth = 80,
+}: SettingsProfileRowSkeletonProps) => (
+ <div className={styles.row} style={height ? { minHeight: height } : undefined}>
+ <div className={styles.label}>
+ <SkeletonBar height={22} width={labelWidth} />
+ </div>
+ <div className={styles.body}>
+ {body === undefined ? <SkeletonBar height={22} width={bodyWidth} /> : body}
+ {action && (
+ <div className={styles.action}>{actionNode ?? <SkeletonBar height={22} width={80} />}</div>
+ )}
+ </div>
+ </div>
+);
+
+const INTEREST_WIDTHS = [
+ 128, 188, 152, 148, 148, 164, 164, 188, 148, 100, 120, 136, 144, 144, 120, 128, 104, 104,
+];
+
+const InterestsSkeleton = () => (
+ <Flexbox horizontal gap={8} style={{ width: '100%' }} wrap={'wrap'}>
+ {INTEREST_WIDTHS.map((width, index) => (
+ <SkeletonBar height={34} key={index} radius={cssVar.borderRadius} width={width} />
+ ))}
+ </Flexbox>
+);
+
+const SettingsProfileSkeleton = () => {
+ const isLogin = useUserStore(authSelectors.isLogin);
+ const email = useUserStore(userProfileSelectors.email);
+ const enableComposio = useServerConfigStore(serverConfigSelectors.enableComposio);
+ const [hasConnectedServers, isServersInit] = useToolStore((state) => [
+ state.composioServers.some((server) => server.status === ComposioServerStatus.ACTIVE),
+ state.isComposioServersInit,
+ ]);
+
+ return (
+ <FormGroup
+ aria-busy
+ collapsible={false}
+ data-testid={'settings-profile-skeleton'}
+ gap={16}
+ title={<SkeletonBar height={18} width={80} />}
+ variant={'filled'}
+ >
+ <Flexbox>
+ <SettingsProfileRowSkeleton
+ actionNode={<SkeletonBar height={46} radius={cssVar.borderRadius} width={46} />}
+ body={null}
+ height={78}
+ />
+ <div className={styles.divider} />
+ <SettingsProfileRowSkeleton action={false} bodyWidth={194} height={68} labelWidth={72} />
+ <div className={styles.divider} />
+ <SettingsProfileRowSkeleton action={false} bodyWidth={194} height={68} labelWidth={88} />
+ <div className={styles.divider} />
+ <SettingsProfileRowSkeleton
+ action={false}
+ body={<InterestsSkeleton />}
+ height={210}
+ labelWidth={64}
+ />
+ {isLogin && email && (
+ <>
+ <div className={styles.divider} />
+ <SettingsProfileRowSkeleton bodyWidth={184} height={54} labelWidth={96} />
+ </>
+ )}
+ {enableComposio && isServersInit && hasConnectedServers && (
+ <>
+ <div className={styles.divider} />
+ <SettingsProfileRowSkeleton
+ action={false}
+ bodyWidth={184}
+ height={54}
+ labelWidth={136}
+ />
+ </>
+ )}
+ </Flexbox>
+ </FormGroup>
+ );
+};
+
+export default SettingsProfileSkeleton;
diff --git a/src/components/Skeleton/Settings/Section.tsx b/src/components/Skeleton/Settings/Section.tsx
new file mode 100644
index 00000000000..f0ca12d1b9a
--- /dev/null
+++ b/src/components/Skeleton/Settings/Section.tsx
@@ -0,0 +1,59 @@
+'use client';
+
+import { Flexbox, FormGroup } from '@lobehub/ui';
+import { createStaticStyles, cssVar } from 'antd-style';
+
+import SkeletonBar from '../Bar';
+
+const styles = createStaticStyles(({ css }) => ({
+ divider: css`
+ width: 100%;
+ height: 1px;
+ background: ${cssVar.colorBorderSecondary};
+ `,
+ row: css`
+ display: flex;
+ gap: 24px;
+ align-items: center;
+ justify-content: space-between;
+
+ min-height: 64px;
+ padding-block: 16px;
+ `,
+}));
+
+const Row = ({ index }: { index: number }) => (
+ <div className={styles.row}>
+ <Flexbox gap={8}>
+ <SkeletonBar height={16} width={112 + (index % 2) * 40} />
+ <SkeletonBar height={12} width={224 + (index % 3) * 36} />
+ </Flexbox>
+ <SkeletonBar height={32} width={index % 2 ? 152 : 88} />
+ </div>
+);
+
+const Group = ({ rows, titleWidth }: { rows: number; titleWidth: number }) => (
+ <FormGroup
+ collapsible={false}
+ title={<SkeletonBar height={18} width={titleWidth} />}
+ variant={'filled'}
+ >
+ <Flexbox>
+ {Array.from({ length: rows }).map((_, index) => (
+ <Flexbox key={index}>
+ {index > 0 && <div className={styles.divider} />}
+ <Row index={index} />
+ </Flexbox>
+ ))}
+ </Flexbox>
+ </FormGroup>
+);
+
+const SettingsSectionSkeleton = () => (
+ <Flexbox aria-busy data-testid={'settings-section-skeleton'} gap={36}>
+ <Group rows={2} titleWidth={104} />
+ <Group rows={3} titleWidth={136} />
+ </Flexbox>
+);
+
+export default SettingsSectionSkeleton;
diff --git a/src/components/Skeleton/Surface.tsx b/src/components/Skeleton/Surface.tsx
new file mode 100644
index 00000000000..4db83458636
--- /dev/null
+++ b/src/components/Skeleton/Surface.tsx
@@ -0,0 +1,138 @@
+'use client';
+
+import { Flexbox, FormGroup, Grid } from '@lobehub/ui';
+import { createStaticStyles, cssVar } from 'antd-style';
+
+import SkeletonBar from './Bar';
+
+export type SurfaceSkeletonVariant = 'editor' | 'form' | 'grid' | 'list';
+
+interface SurfaceSkeletonProps {
+ header?: boolean;
+ variant?: SurfaceSkeletonVariant;
+}
+
+const styles = createStaticStyles(({ css }) => ({
+ card: css`
+ border-radius: ${cssVar.borderRadiusLG};
+ background: ${cssVar.colorFillQuaternary};
+ `,
+ divider: css`
+ width: 100%;
+ height: 1px;
+ background: ${cssVar.colorBorderSecondary};
+ `,
+ editor: css`
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: ${cssVar.borderRadiusLG};
+ background: ${cssVar.colorBgContainer};
+ `,
+ row: css`
+ min-height: 64px;
+ padding-block: 16px;
+ `,
+}));
+
+const HeaderSkeleton = () => (
+ <Flexbox
+ horizontal
+ align={'center'}
+ flex={'none'}
+ height={44}
+ justify={'space-between'}
+ paddingInline={16}
+ >
+ <SkeletonBar height={20} width={144} />
+ <SkeletonBar height={28} width={72} />
+ </Flexbox>
+);
+
+const ListSkeleton = () => (
+ <Flexbox gap={12} padding={16}>
+ {Array.from({ length: 5 }).map((_, index) => (
+ <Flexbox className={styles.card} gap={10} key={index} padding={16}>
+ <Flexbox horizontal align={'center'} gap={8}>
+ <SkeletonBar height={24} radius={'50%'} width={24} />
+ <SkeletonBar height={14} width={96 + (index % 3) * 24} />
+ </Flexbox>
+ <SkeletonBar height={12} width={`${58 + (index % 3) * 12}%`} />
+ <SkeletonBar height={12} width={`${42 + (index % 2) * 16}%`} />
+ </Flexbox>
+ ))}
+ </Flexbox>
+);
+
+const FormSkeleton = () => (
+ <Flexbox align={'center'} padding={24}>
+ <FormGroup
+ collapsible={false}
+ style={{ width: 'min(800px, 100%)' }}
+ title={<SkeletonBar height={18} width={112} />}
+ variant={'filled'}
+ >
+ <Flexbox>
+ {Array.from({ length: 3 }).map((_, index) => (
+ <Flexbox key={index}>
+ {index > 0 && <div className={styles.divider} />}
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={styles.row}
+ gap={24}
+ justify={'space-between'}
+ >
+ <Flexbox gap={8}>
+ <SkeletonBar height={16} width={112 + index * 24} />
+ <SkeletonBar height={12} width={220 + index * 28} />
+ </Flexbox>
+ <SkeletonBar height={32} width={index % 2 ? 152 : 88} />
+ </Flexbox>
+ </Flexbox>
+ ))}
+ </Flexbox>
+ </FormGroup>
+ </Flexbox>
+);
+
+const GridSkeleton = () => (
+ <Grid gap={16} maxItemWidth={320} padding={16} rows={3}>
+ {Array.from({ length: 6 }).map((_, index) => (
+ <Flexbox gap={12} key={index} padding={16}>
+ <SkeletonBar height={120} radius={cssVar.borderRadiusLG} />
+ <SkeletonBar height={16} width={'72%'} />
+ <SkeletonBar height={12} width={'48%'} />
+ </Flexbox>
+ ))}
+ </Grid>
+);
+
+const EditorSkeleton = () => (
+ <Flexbox align={'center'} flex={1} padding={'32px 24px'}>
+ <Flexbox
+ className={styles.editor}
+ gap={20}
+ padding={'32px 40px 96px'}
+ width={'min(760px, 100%)'}
+ >
+ <SkeletonBar height={28} width={'54%'} />
+ <SkeletonBar height={14} width={'92%'} />
+ <SkeletonBar height={14} width={'86%'} />
+ <SkeletonBar height={14} width={'64%'} />
+ <SkeletonBar height={180} radius={12} />
+ </Flexbox>
+ </Flexbox>
+);
+
+const SurfaceSkeleton = ({ header = true, variant = 'list' }: SurfaceSkeletonProps) => (
+ <Flexbox aria-busy flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
+ {header && <HeaderSkeleton />}
+ <Flexbox flex={1} style={{ minHeight: 0, overflow: 'hidden' }}>
+ {variant === 'list' && <ListSkeleton />}
+ {variant === 'form' && <FormSkeleton />}
+ {variant === 'grid' && <GridSkeleton />}
+ {variant === 'editor' && <EditorSkeleton />}
+ </Flexbox>
+ </Flexbox>
+);
+
+export default SurfaceSkeleton;
diff --git a/src/components/Skeleton/index.ts b/src/components/Skeleton/index.ts
index 52dafd03f26..5ddf1978490 100644
--- a/src/components/Skeleton/index.ts
+++ b/src/components/Skeleton/index.ts
@@ -1,2 +1,17 @@
+export { default as SkeletonBar } from './Bar';
+export { default as ConversationLayoutSkeleton } from './Conversation/Layout';
+export { default as ConversationListSkeleton } from './Conversation/List';
+export { default as ConversationSegmentSkeleton } from './Conversation/Segment';
+export { default as NavPanelSkeletonList } from './NavPanel/List';
+export {
+ DEFAULT_NAV_SKELETON_SHAPE,
+ NAV_SKELETON_SHAPES,
+ NavSideBarSkeleton,
+} from './NavPanel/SideBar';
+export { 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';
export * from './SkeletonInput';
export * from './SkeletonSwitch';
+export { default as SurfaceSkeleton, type SurfaceSkeletonVariant } from './Surface';
diff --git a/src/features/AgentBuilder/index.tsx b/src/features/AgentBuilder/index.tsx
index c0f8a699391..9cc2c8ac853 100644
--- a/src/features/AgentBuilder/index.tsx
+++ b/src/features/AgentBuilder/index.tsx
@@ -1,7 +1,7 @@
import { BUILTIN_AGENT_SLUGS } from '@lobechat/builtin-agents';
import { memo } from 'react';
-import Loading from '@/components/Loading/BrandTextLoading';
+import ConversationSegmentSkeleton from '@/components/Skeleton/Conversation/Segment';
import RightPanel from '@/features/RightPanel';
import { useAgentStore } from '@/store/agent';
import { builtinAgentSelectors } from '@/store/agent/selectors';
@@ -45,7 +45,7 @@ const AgentBuilder = memo(() => {
<AgentBuilderConversation agentId={agentBuilderId} />
</AgentBuilderProvider>
) : (
- <Loading debugId="AgentBuilder > Init" />
+ <ConversationSegmentSkeleton />
)}
</RightPanel>
);
diff --git a/src/features/AgentGoals/GoalDetailPage.tsx b/src/features/AgentGoals/GoalDetailPage.tsx
index 1aaf70dfa93..c8d2073e05a 100644
--- a/src/features/AgentGoals/GoalDetailPage.tsx
+++ b/src/features/AgentGoals/GoalDetailPage.tsx
@@ -12,7 +12,7 @@ import { useTranslation } from 'react-i18next';
import NotFound from '@/components/404';
import AsyncError from '@/components/AsyncError';
import { TASK_STATUS_VISUALS } from '@/components/ExecutionStatus';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import AgentBreadcrumb from '@/features/AgentBreadcrumb';
import { useActiveTaskDetail } from '@/features/AgentTasks/AgentTaskDetail';
import TaskDetailTitleInput from '@/features/AgentTasks/AgentTaskDetail/TaskDetailTitleInput';
@@ -190,7 +190,7 @@ const GoalDetailPage = memo<GoalDetailPageProps>(({ agentId, goalId }) => {
<Flexbox flex={1} style={{ overflowY: 'auto' }}>
<WideScreenContainer gap={20} paddingBlock={16}>
{isInitialLoading || !task ? (
- <Loading debugId={'GoalDetail'} />
+ <SurfaceSkeleton header={false} variant={'editor'} />
) : (
<>
<Flexbox className={styles.header} gap={8}>
diff --git a/src/features/AgentPermission/index.tsx b/src/features/AgentPermission/index.tsx
index 4549a91cf41..83eac87c14b 100644
--- a/src/features/AgentPermission/index.tsx
+++ b/src/features/AgentPermission/index.tsx
@@ -5,7 +5,7 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import AsyncBoundary from '@/components/AsyncBoundary';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import AgentBreadcrumb from '@/features/AgentBreadcrumb';
import NavHeader from '@/features/NavHeader';
import WideScreenContainer from '@/features/WideScreenContainer';
@@ -51,7 +51,7 @@ const AgentPermission = memo(() => {
error={configError}
errorVariant={'page'}
isLoading={isAgentConfigLoading && !configError}
- loading={<Loading debugId="AgentPermission" />}
+ loading={<SurfaceSkeleton header={false} variant={'form'} />}
onRetry={() => retryAgentConfigFetch()}
>
<PermissionForm agentId={activeAgentId ?? ''} />
diff --git a/src/features/AgentTaskManager/TaskAgentProvider.test.tsx b/src/features/AgentTaskManager/TaskAgentProvider.test.tsx
index 42b9f6b638d..dae33d6b933 100644
--- a/src/features/AgentTaskManager/TaskAgentProvider.test.tsx
+++ b/src/features/AgentTaskManager/TaskAgentProvider.test.tsx
@@ -42,8 +42,8 @@ const mocks = vi.hoisted(() => {
};
});
-vi.mock('@/components/Loading/BrandTextLoading', () => ({
- default: ({ debugId }: { debugId: string }) => <div data-testid="loading">{debugId}</div>,
+vi.mock('@/components/Skeleton/Conversation/Segment', () => ({
+ default: () => <div data-testid="loading" />,
}));
vi.mock('@/features/Conversation', () => ({
diff --git a/src/features/AgentTaskManager/TaskAgentProvider.tsx b/src/features/AgentTaskManager/TaskAgentProvider.tsx
index cc50b1ffcf2..9c73570f853 100644
--- a/src/features/AgentTaskManager/TaskAgentProvider.tsx
+++ b/src/features/AgentTaskManager/TaskAgentProvider.tsx
@@ -5,7 +5,7 @@ import type { ReactNode } from 'react';
import { createContext, memo, use, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useMatch, useSearchParams } from 'react-router';
-import Loading from '@/components/Loading/BrandTextLoading';
+import ConversationSegmentSkeleton from '@/components/Skeleton/Conversation/Segment';
import { ConversationProvider } from '@/features/Conversation';
import { useInitBuiltinAgent } from '@/hooks/useInitBuiltinAgent';
import { useOperationState } from '@/hooks/useOperationState';
@@ -103,7 +103,7 @@ export const TaskAgentProvider = memo<TaskAgentProviderProps>(({ children }) =>
const messages = useChatStore((s) => s.dbMessagesMap[chatKey]);
const operationState = useOperationState(context);
- if (!taskAgentId) return <Loading debugId="TaskAgentProvider" />;
+ if (!taskAgentId) return <ConversationSegmentSkeleton />;
return (
<TaskAgentSelectionContext value={selectTaskAgent}>
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskDetailPage.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskDetailPage.tsx
index 8fd39cee604..af78e084bad 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskDetailPage.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskDetailPage.tsx
@@ -7,7 +7,7 @@ import { Link } from 'react-router';
import NotFound from '@/components/404';
import AsyncError from '@/components/AsyncError';
import AutoSaveHint from '@/components/Editor/AutoSaveHint';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import NavHeader from '@/features/NavHeader';
import ToggleRightPanelButton from '@/features/RightPanel/ToggleRightPanelButton';
import WideScreenContainer from '@/features/WideScreenContainer';
@@ -105,7 +105,11 @@ const TaskDetailPage = memo<TaskDetailPageProps>(({ taskId, showTaskAgentPanelTo
/>
<Flexbox flex={1} style={{ minHeight: 0, overflowY: 'auto' }}>
<WideScreenContainer>
- {isInitialLoading ? <Loading debugId="TaskDetail" /> : <TaskDetailSections />}
+ {isInitialLoading ? (
+ <SurfaceSkeleton header={false} variant={'editor'} />
+ ) : (
+ <TaskDetailSections />
+ )}
</WideScreenContainer>
</Flexbox>
<TopicChatDrawer />
diff --git a/src/features/AgentTopicManager/index.tsx b/src/features/AgentTopicManager/index.tsx
index c3291187b19..8fd92e17410 100644
--- a/src/features/AgentTopicManager/index.tsx
+++ b/src/features/AgentTopicManager/index.tsx
@@ -10,7 +10,7 @@ import { memo, useEffect, useMemo, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import AsyncError from '@/components/AsyncError';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import { useChatStore } from '@/store/chat';
import { topicSelectors } from '@/store/chat/selectors';
import { shinyTextStyles } from '@/styles/loading';
@@ -200,7 +200,7 @@ const AgentTopicManager = memo(() => {
return () => observer.disconnect();
}, [hasMore, isLoadingMore, isSearchMode, loadMoreAgentTopicsView, loadMoreError]);
- if (!activeAgentId) return <Loading debugId="AgentTopicManager" />;
+ if (!activeAgentId) return <SurfaceSkeleton variant={'list'} />;
return (
<Flexbox flex={1} height={'100%'} style={{ overflow: 'hidden' }}>
diff --git a/src/features/Conversation/components/SkeletonList.tsx b/src/features/Conversation/components/SkeletonList.tsx
index 60790d11d59..feac8da0be9 100644
--- a/src/features/Conversation/components/SkeletonList.tsx
+++ b/src/features/Conversation/components/SkeletonList.tsx
@@ -1,59 +1 @@
-'use client';
-
-import { Flexbox, Skeleton } from '@lobehub/ui';
-import { memo } from 'react';
-
-import WideScreenContainer from '../../WideScreenContainer';
-
-const SkeletonList = memo(() => {
- return (
- <WideScreenContainer flex={1} gap={36} height={'100%'} padding={12} style={{ marginTop: 24 }}>
- {/* User Message */}
- <Flexbox
- gap={8}
- width={'100%'}
- style={{
- paddingLeft: '25%',
- }}
- >
- <Skeleton.Paragraph
- active
- rows={3}
- style={{
- alignItems: 'flex-end',
- }}
- />
- </Flexbox>
-
- {/* Assistant Message */}
- <Flexbox gap={8} width={'100%'}>
- <Skeleton
- active
- paragraph={false}
- avatar={{
- shape: 'square',
- size: 28,
- }}
- />
- <Skeleton.Paragraph />
- <Skeleton.Tags count={2} />
- </Flexbox>
-
- {/* Assistant Message */}
- <Flexbox gap={8} width={'100%'}>
- <Skeleton
- active
- paragraph={false}
- avatar={{
- shape: 'square',
- size: 28,
- }}
- />
- <Skeleton.Paragraph />
- <Skeleton.Tags count={2} />
- </Flexbox>
- </WideScreenContainer>
- );
-});
-
-export default SkeletonList;
+export { default } from '@/components/Skeleton/Conversation/List';
diff --git a/src/features/GroupPermission/index.tsx b/src/features/GroupPermission/index.tsx
index b59f330e57a..fc35218b5e2 100644
--- a/src/features/GroupPermission/index.tsx
+++ b/src/features/GroupPermission/index.tsx
@@ -5,7 +5,7 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import AsyncBoundary from '@/components/AsyncBoundary';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import NavHeader from '@/features/NavHeader';
import WideScreenContainer from '@/features/WideScreenContainer';
import { useAgentGroupStore } from '@/store/agentGroup';
@@ -47,7 +47,7 @@ const GroupPermission = memo(() => {
<AsyncBoundary
data={isGroupLoading ? undefined : true}
isLoading={isGroupLoading}
- loading={<Loading debugId="GroupPermission" />}
+ loading={<SurfaceSkeleton header={false} variant={'form'} />}
>
<PermissionForm groupId={activeGroupId ?? ''} />
</AsyncBoundary>
diff --git a/src/features/NavPanel/components/SideBarSkeleton.tsx b/src/features/NavPanel/components/SideBarSkeleton.tsx
index f464b4807b4..426c8bb71a4 100644
--- a/src/features/NavPanel/components/SideBarSkeleton.tsx
+++ b/src/features/NavPanel/components/SideBarSkeleton.tsx
@@ -1,185 +1,8 @@
-'use client';
-
-import { Center, Flexbox, Skeleton } from '@lobehub/ui';
-import { cssVar } from 'antd-style';
-import { memo } from 'react';
-
-import { isMacDesktop } from '../ToggleLeftPanelButton';
-
-interface SkeletonBarProps {
- height: number;
- radius?: number | string;
- width?: number | string;
-}
-
-const SkeletonBar = memo<SkeletonBarProps>(({ height, width = '100%', radius }) => (
- <Skeleton.Button
- active
- block
- size={'small'}
- style={{
- borderRadius: radius ?? cssVar.borderRadius,
- height,
- margin: 0,
- maxHeight: height,
- maxWidth: width,
- minHeight: height,
- minWidth: width,
- opacity: 0.5,
- padding: 0,
- width,
- }}
- />
-));
-
-export type SideBarHeaderVariant = 'breadcrumb' | 'title';
-
-// The real header's height comes from its tallest child. A breadcrumb header holds
-// a 22px trail plus a 28px action icon — and ToggleLeftPanelButton renders nothing
-// on macOS desktop, so 22 wins there. A title header (agent / page / home) carries
-// a 16px title beside a back button and settles at 32.
-const headerContentHeight = (variant: SideBarHeaderVariant) => {
- if (variant === 'title') return 32;
- return isMacDesktop ? 22 : 28;
-};
-
-export const SideBarHeaderSkeleton = memo<{ variant?: SideBarHeaderVariant }>(
- ({ variant = 'breadcrumb' }) => (
- <Flexbox horizontal align={'center'} flex={'none'} padding={'8px 6px'}>
- <Flexbox flex={1} height={headerContentHeight(variant)} justify={'center'} paddingInline={6}>
- <SkeletonBar height={variant === 'title' ? 18 : 14} width={variant === 'title' ? 96 : 72} />
- </Flexbox>
- </Flexbox>
- ),
-);
-
-const SkeletonNavItem = memo<{ width: string }>(({ width }) => (
- <Flexbox horizontal align={'center'} flex={'none'} gap={8} height={36} paddingInline={4}>
- <Center flex={'none'} height={28} width={28}>
- <SkeletonBar height={18} radius={cssVar.borderRadiusSM} width={18} />
- </Center>
- <Flexbox flex={1}>
- <SkeletonBar height={14} width={width} />
- </Flexbox>
- </Flexbox>
-));
-
-const TITLE_WIDTHS = [56, 72, 48, 64];
-const ITEM_WIDTHS = ['62%', '44%', '70%', '52%', '66%', '48%', '58%', '74%'];
-
-// `paddingBlock` mirrors the accordion content wrapper; the header-slot nav list has
-// no such padding, so passing 0 there keeps the skeleton 2px shorter and on target.
-const SkeletonRows = memo<{ count: number; gap?: number; paddingBlock?: number; seed?: number }>(
- ({ count, seed = 0, paddingBlock = 1, gap = 1 }) => (
- <Flexbox gap={gap} paddingBlock={paddingBlock}>
- {Array.from({ length: count }).map((_, index) => (
- <SkeletonNavItem key={index} width={ITEM_WIDTHS[(seed * 3 + index) % ITEM_WIDTHS.length]} />
- ))}
- </Flexbox>
- ),
-);
-
-export interface NavSkeletonShape {
- /** `gap` of the body flex column, matching the real sidebar's body wrapper. */
- bodyGap?: number;
- bodyPaddingBlock?: number;
- /** Row count per accordion group; 0 renders a collapsed group (title only). */
- groups?: number[];
- /** Accordion header height: 27 with `paddingBlock={4}`, 32 by default, 40 with a toolbar. */
- groupTitleHeight?: number;
- headerVariant?: SideBarHeaderVariant;
- /** Rows inside the body that sit above the first group. */
- leadingRows?: number;
- /** `gap` between the header-slot nav rows. */
- navGap?: number;
- /** Fixed rows rendered in the header slot, above the scroll area. */
- navRows?: number;
- /** A search box placeholder inside the body (settings only). */
- search?: boolean;
-}
-
-export const NavSideBarSkeleton = memo<NavSkeletonShape>(
- ({
- bodyGap = 0,
- bodyPaddingBlock = 0,
- groups,
- groupTitleHeight = 32,
- headerVariant = 'breadcrumb',
- leadingRows = 0,
- navGap = 1,
- navRows = 0,
- search = false,
- }) => {
- const hasBody = search || leadingRows > 0 || !!groups?.length;
-
- return (
- <Flexbox data-testid={'nav-sidebar-skeleton'} gap={1} style={{ height: '100%' }}>
- <SideBarHeaderSkeleton variant={headerVariant} />
- {navRows > 0 && (
- <Flexbox data-testid={'nav-sidebar-skeleton-nav'} flex={'none'} paddingInline={4}>
- <SkeletonRows count={navRows} gap={navGap} paddingBlock={0} />
- </Flexbox>
- )}
- {hasBody && (
- <Flexbox
- gap={bodyGap}
- paddingBlock={bodyPaddingBlock}
- paddingInline={4}
- style={{ overflow: 'hidden' }}
- >
- {search && (
- <Flexbox data-testid={'nav-sidebar-skeleton-search'} paddingInline={4}>
- <SkeletonBar height={36} />
- </Flexbox>
- )}
- {leadingRows > 0 && <SkeletonRows count={leadingRows} paddingBlock={0} />}
- {!!groups?.length && (
- <Flexbox gap={8}>
- {groups.map((rows, groupIndex) => (
- <Flexbox key={groupIndex}>
- <Flexbox
- flex={'none'}
- height={groupTitleHeight}
- justify={'center'}
- paddingBlock={4}
- paddingInline={'8px 4px'}
- >
- <SkeletonBar
- height={12}
- width={TITLE_WIDTHS[groupIndex % TITLE_WIDTHS.length]}
- />
- </Flexbox>
- {rows > 0 && <SkeletonRows count={rows} seed={groupIndex} />}
- </Flexbox>
- ))}
- </Flexbox>
- )}
- </Flexbox>
- )}
- </Flexbox>
- );
- },
-);
-
-// Every shape below was measured against its settled sidebar in the desktop shell
-// (301px panel): header slot height, body gap/padding, accordion header height, and
-// group composition. A shape that drifts from its sidebar shifts the whole list at
-// the moment the route chunk resolves, which is the defect this file exists to avoid.
-export const NAV_SKELETON_SHAPES: Record<string, NavSkeletonShape> = {
- 'agent': { groups: [0, 12], headerVariant: 'title', navRows: 5 },
- 'discover': { navRows: 6 },
- 'eval': { bodyGap: 8, groups: [3, 3], groupTitleHeight: 27, leadingRows: 1 },
- 'evalBench': { bodyGap: 8, groups: [3, 3], groupTitleHeight: 27, leadingRows: 1 },
- 'group': { groups: [3, 8], headerVariant: 'title' },
- 'home': { bodyGap: 1, groups: [5, 7, 3], headerVariant: 'title', leadingRows: 2, navRows: 2 },
- 'image': { bodyGap: 1, groups: [4], groupTitleHeight: 40, navGap: 0, navRows: 2 },
- 'memory': { navRows: 7 },
- 'page': { bodyGap: 1, groups: [12], headerVariant: 'title', navRows: 1 },
- 'resource': { bodyPaddingBlock: 8, groups: [5], navRows: 6 },
- 'resourceLibrary': { bodyPaddingBlock: 8, groups: [6] },
- 'settings': { bodyGap: 4, groups: [6, 5, 8, 3], groupTitleHeight: 27, search: true },
- 'video': { bodyGap: 1, groups: [4], groupTitleHeight: 40, navGap: 0, navRows: 2 },
- 'workspace-settings': { groups: [5, 5, 6, 3], groupTitleHeight: 27 },
-};
-
-export const DEFAULT_NAV_SKELETON_SHAPE: NavSkeletonShape = { groups: [6, 4] };
+export {
+ DEFAULT_NAV_SKELETON_SHAPE,
+ NAV_SKELETON_SHAPES,
+ NavSideBarSkeleton,
+ type NavSkeletonShape,
+ SideBarHeaderSkeleton,
+ type SideBarHeaderVariant,
+} from '@/components/Skeleton/NavPanel/SideBar';
diff --git a/src/features/NavPanel/components/SkeletonList.tsx b/src/features/NavPanel/components/SkeletonList.tsx
index 5173ac396d0..7d641144f90 100644
--- a/src/features/NavPanel/components/SkeletonList.tsx
+++ b/src/features/NavPanel/components/SkeletonList.tsx
@@ -1,63 +1 @@
-'use client';
-
-import { type FlexboxProps } from '@lobehub/ui';
-import { Flexbox, Skeleton } from '@lobehub/ui';
-import { cssVar } from 'antd-style';
-import { memo } from 'react';
-
-export const SkeletonItem = memo<{ avatarSize?: number } & Omit<FlexboxProps, 'children'>>(
- ({ padding = 6, height = 36, style, avatarSize = 28, ...rest }) => {
- return (
- <Flexbox
- horizontal
- align={'center'}
- flex={1}
- gap={8}
- height={height}
- padding={padding}
- style={style}
- {...rest}
- >
- <Skeleton.Button
- size={'small'}
- style={{
- borderRadius: cssVar.borderRadius,
- height: avatarSize,
- maxHeight: avatarSize,
- maxWidth: avatarSize,
- minWidth: avatarSize,
- }}
- />
- <Flexbox flex={1} height={16}>
- <Skeleton.Button
- active
- block
- size={'small'}
- style={{
- borderRadius: cssVar.borderRadius,
- height: 16,
- margin: 0,
- maxHeight: 16,
- opacity: 0.5,
- padding: 0,
- }}
- />
- </Flexbox>
- </Flexbox>
- );
- },
-);
-
-export const SkeletonList = memo<{ rows?: number } & Omit<FlexboxProps, 'children'>>(
- ({ rows = 3, ...rest }) => {
- return (
- <Flexbox gap={2} {...rest}>
- {Array.from({ length: rows }).map((_, i) => (
- <SkeletonItem key={i} />
- ))}
- </Flexbox>
- );
- },
-);
-
-export default SkeletonList;
+export { default, SkeletonItem, SkeletonList } from '@/components/Skeleton/NavPanel/List';
diff --git a/src/features/PageEditor/History/index.tsx b/src/features/PageEditor/History/index.tsx
index 9e9ea7a8195..823b547d96f 100644
--- a/src/features/PageEditor/History/index.tsx
+++ b/src/features/PageEditor/History/index.tsx
@@ -9,7 +9,7 @@ import { ArrowLeftIcon, Clock3Icon } from 'lucide-react';
import { memo, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import { DOCUMENT_HISTORY_QUERY_LIST_LIMIT } from '@/const/documentHistory';
import NavHeader from '@/features/NavHeader';
import ToggleRightPanelButton from '@/features/RightPanel/ToggleRightPanelButton';
@@ -250,7 +250,7 @@ const HistoryPanel = memo(() => {
{isLoading && !data ? (
<Flexbox align={'center'} className={styles.empty} justify={'center'}>
- <Loading debugId={'DocumentHistoryPanel'} />
+ <SurfaceSkeleton header={false} variant={'list'} />
</Flexbox>
) : items.length === 0 ? (
<Flexbox align={'center'} className={styles.empty} justify={'center'}>
diff --git a/src/features/PageEditor/PageAgentProvider.test.tsx b/src/features/PageEditor/PageAgentProvider.test.tsx
index 3a1917323b0..9a2d60c129e 100644
--- a/src/features/PageEditor/PageAgentProvider.test.tsx
+++ b/src/features/PageEditor/PageAgentProvider.test.tsx
@@ -29,7 +29,7 @@ const operationState = { isInputLoading: false };
let agentState: AgentState;
let chatState: ChatState;
-vi.mock('@/components/Loading/BrandTextLoading', () => ({
+vi.mock('@/components/Skeleton/Conversation/Segment', () => ({
default: () => <div data-testid="loading" />,
}));
diff --git a/src/features/PageEditor/PageAgentProvider.tsx b/src/features/PageEditor/PageAgentProvider.tsx
index 2c08591a177..805fdf0c073 100644
--- a/src/features/PageEditor/PageAgentProvider.tsx
+++ b/src/features/PageEditor/PageAgentProvider.tsx
@@ -3,7 +3,7 @@ import { isChatGroupSessionId } from '@lobechat/types';
import type { ReactNode } from 'react';
import { memo, useEffect, useMemo, useRef } from 'react';
-import Loading from '@/components/Loading/BrandTextLoading';
+import ConversationSegmentSkeleton from '@/components/Skeleton/Conversation/Segment';
import type { ConversationContext } from '@/features/Conversation';
import { ConversationProvider } from '@/features/Conversation';
import { useOperationState } from '@/hooks/useOperationState';
@@ -102,7 +102,7 @@ export const PageAgentProvider = memo<PageAgentProviderProps>(
// Get operation state for reactive updates
const operationState = useOperationState(context);
- if (!pageAgentId) return <Loading debugId="PageAgentProvider" />;
+ if (!pageAgentId) return <ConversationSegmentSkeleton />;
return (
<ConversationProvider
diff --git a/src/features/Portal/AgentDetail/Body.tsx b/src/features/Portal/AgentDetail/Body.tsx
index 4ca0f24794e..fe4e8cf6059 100644
--- a/src/features/Portal/AgentDetail/Body.tsx
+++ b/src/features/Portal/AgentDetail/Body.tsx
@@ -6,7 +6,7 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import AsyncError from '@/components/AsyncError';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import { AgentNotFound } from '@/features/AgentNotFound';
import { useAgentStore } from '@/store/agent';
import { agentByIdSelectors, agentSelectors } from '@/store/agent/selectors';
@@ -44,7 +44,7 @@ const Body = memo(() => {
);
}
- if (isLoading) return <Loading debugId="PortalAgentDetail" />;
+ if (isLoading) return <SurfaceSkeleton header={false} variant={'form'} />;
return (
<Flexbox align="center" flex={1} gap={16} padding={32} style={{ overflowY: 'auto' }}>
diff --git a/src/features/Portal/TaskDetail/Body.tsx b/src/features/Portal/TaskDetail/Body.tsx
index c90202f303a..445ab28d0df 100644
--- a/src/features/Portal/TaskDetail/Body.tsx
+++ b/src/features/Portal/TaskDetail/Body.tsx
@@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next';
import NotFound from '@/components/404';
import AsyncError from '@/components/AsyncError';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import { TaskDetailSections, TopicChatDrawer, useActiveTaskDetail } from '@/features/AgentTasks';
import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';
@@ -43,7 +43,11 @@ const Body = memo(() => {
paddingInline={16}
style={{ minHeight: 0, overflowY: 'auto' }}
>
- {isInitialLoading ? <Loading debugId="PortalTaskDetail" /> : <TaskDetailSections />}
+ {isInitialLoading ? (
+ <SurfaceSkeleton header={false} variant={'editor'} />
+ ) : (
+ <TaskDetailSections />
+ )}
<TopicChatDrawer />
</Flexbox>
);
diff --git a/src/features/Portal/TopicComments/Body.tsx b/src/features/Portal/TopicComments/Body.tsx
index 585cc7778c4..e325e9b9665 100644
--- a/src/features/Portal/TopicComments/Body.tsx
+++ b/src/features/Portal/TopicComments/Body.tsx
@@ -5,7 +5,7 @@ import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import AsyncError from '@/components/AsyncError';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import { useTopicCommentThreads } from '@/features/TopicComment/hooks';
import { mutate } from '@/libs/swr';
import { topicCommentKeys } from '@/libs/swr/keys';
@@ -56,7 +56,7 @@ const Body = memo(() => {
<Flexbox className={styles.body}>
<Flexbox className={styles.list}>
{isLoadingInitial ? (
- <Loading debugId="TopicCommentsPortal" />
+ <SurfaceSkeleton header={false} variant={'list'} />
) : items.length === 0 ? (
<Center className={styles.empty}>
<Empty description={t('topicComment.empty')} icon={MessageCircle} />
diff --git a/src/features/Portal/TopicComments/ThreadBody.tsx b/src/features/Portal/TopicComments/ThreadBody.tsx
index 8a29afc7e05..30240a3a2f9 100644
--- a/src/features/Portal/TopicComments/ThreadBody.tsx
+++ b/src/features/Portal/TopicComments/ThreadBody.tsx
@@ -5,7 +5,7 @@ import { memo, useCallback, useEffect, useMemo, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import AsyncError from '@/components/AsyncError';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import {
useTopicCommentDetail,
useTopicCommentReplies,
@@ -100,7 +100,7 @@ const ThreadBody = memo(() => {
);
}
if (state === 'loading') {
- return <Loading debugId="TopicCommentThreadPortal" />;
+ return <SurfaceSkeleton header={false} variant={'list'} />;
}
if (!root.data) return null;
diff --git a/src/features/ResourcePermission/ResourceConfigAccessGate.test.tsx b/src/features/ResourcePermission/ResourceConfigAccessGate.test.tsx
index 0b6aedc4a23..f280c39f7d5 100644
--- a/src/features/ResourcePermission/ResourceConfigAccessGate.test.tsx
+++ b/src/features/ResourcePermission/ResourceConfigAccessGate.test.tsx
@@ -16,7 +16,7 @@ vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => k
vi.mock('@/components/AsyncBoundary', () => ({
default: ({ children }: { children: ReactNode }) => children,
}));
-vi.mock('@/components/Loading/BrandTextLoading', () => ({ default: () => null }));
+vi.mock('@/components/Skeleton/Surface', () => ({ default: () => null }));
vi.mock('@/features/Workspace/useWorkspaceAwareNavigate', () => ({
useWorkspaceAwareNavigate: () => mocks.navigate,
}));
diff --git a/src/features/ResourcePermission/ResourceConfigAccessGate.tsx b/src/features/ResourcePermission/ResourceConfigAccessGate.tsx
index 75dda45ed96..9240e930f3b 100644
--- a/src/features/ResourcePermission/ResourceConfigAccessGate.tsx
+++ b/src/features/ResourcePermission/ResourceConfigAccessGate.tsx
@@ -5,7 +5,7 @@ import { memo, type ReactNode, useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import AsyncBoundary from '@/components/AsyncBoundary';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { usePermission } from '@/hooks/usePermission';
@@ -66,10 +66,10 @@ const ResourceConfigAccessGate = memo<ResourceConfigAccessGateProps>(
error={accessError}
errorVariant={'page'}
isLoading={!accessReady && !accessError}
- loading={<Loading debugId="ResourceConfigAccessGate" />}
+ loading={<SurfaceSkeleton variant={'form'} />}
onRetry={() => void retryAccess()}
>
- {canConfigure ? children : <Loading debugId="ResourceConfigAccessRedirect" />}
+ {canConfigure ? children : <SurfaceSkeleton variant={'form'} />}
</AsyncBoundary>
);
},
diff --git a/src/features/RightPanel/index.tsx b/src/features/RightPanel/index.tsx
index 5b0b0bc53d6..6f5ec160bfb 100644
--- a/src/features/RightPanel/index.tsx
+++ b/src/features/RightPanel/index.tsx
@@ -3,7 +3,7 @@ import { DraggablePanel } from '@lobehub/ui';
import { cssVar } from 'antd-style';
import { memo, Suspense, useState } from 'react';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
@@ -77,7 +77,9 @@ const RightPanel = memo<RightPanelProps>(
}}
{...rest}
>
- <Suspense fallback={<Loading debugId={'RightPanel'} />}>{children}</Suspense>
+ <Suspense fallback={<SurfaceSkeleton header={false} variant={'list'} />}>
+ {children}
+ </Suspense>
</DraggablePanel>
);
},
diff --git a/src/features/Settings/features/componentMap.ts b/src/features/Settings/features/componentMap.ts
index 529a7946b87..29cd4c10829 100644
--- a/src/features/Settings/features/componentMap.ts
+++ b/src/features/Settings/features/componentMap.ts
@@ -1,10 +1,11 @@
import { createElement } from 'react';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SettingsProfileSkeleton from '@/components/Skeleton/Settings/Profile';
+import SettingsSectionSkeleton from '@/components/Skeleton/Settings/Section';
import dynamic from '@/libs/next/dynamic';
import { SettingsTabs } from '@/store/global/initialState';
-const loading = (debugId: string) => () => createElement(Loading, { debugId });
+const loading = (_debugId: string) => () => createElement(SettingsSectionSkeleton);
export const componentMap = {
[SettingsTabs.Advanced]: dynamic(() => import('../advanced'), {
@@ -57,7 +58,7 @@ export const componentMap = {
}),
// Profile related tabs
[SettingsTabs.Profile]: dynamic(() => import('../profile'), {
- loading: loading('Settings > Profile'),
+ loading: () => createElement(SettingsProfileSkeleton),
}),
[SettingsTabs.Stats]: dynamic(() => import('../stats'), {
loading: loading('Settings > Stats'),
diff --git a/src/features/Settings/profile/index.tsx b/src/features/Settings/profile/index.tsx
index 9b1ed1362d6..945b57119ce 100644
--- a/src/features/Settings/profile/index.tsx
+++ b/src/features/Settings/profile/index.tsx
@@ -1,11 +1,12 @@
'use client';
import { isDesktop } from '@lobechat/const';
-import { Flexbox, FormGroup, Skeleton } from '@lobehub/ui';
+import { Flexbox, FormGroup } from '@lobehub/ui';
import { Divider } from 'antd';
import { useEffect } from 'react';
import { useTranslation } from 'react-i18next';
+import { SettingsProfileRowSkeleton } from '@/components/Skeleton/Settings/Profile';
import SettingHeader from '@/features/Settings/features/SettingHeader';
import { useServerConfigStore } from '@/store/serverConfig';
import { serverConfigSelectors } from '@/store/serverConfig/selectors';
@@ -24,15 +25,6 @@ import ProfileRow from './features/ProfileRow';
import SSOProvidersList from './features/SSOProvidersList';
import UsernameRow from './features/UsernameRow';
-const SkeletonRow = () => (
- <ProfileRow
- action={<Skeleton.Button active size="small" style={{ height: 22, width: 80 }} />}
- labelSlot={<Skeleton.Button active size="small" style={{ height: 22, width: 80 }} />}
- >
- <Skeleton.Button active size="small" style={{ height: 22, width: 160 }} />
- </ProfileRow>
-);
-
interface ProfileSettingProps {
showSettingHeader?: boolean;
}
@@ -76,13 +68,13 @@ const ProfileSetting = ({ showSettingHeader = true }: ProfileSettingProps) => {
{showSettingHeader && <SettingHeader title={t('profile.title')} />}
<FormGroup collapsible={false} gap={16} title={t('profile.account')} variant={'filled'}>
<Flexbox style={{ display: isLoading ? 'flex' : 'none' }}>
- <SkeletonRow />
+ <SettingsProfileRowSkeleton />
<Divider style={{ margin: 0 }} />
- <SkeletonRow />
+ <SettingsProfileRowSkeleton />
<Divider style={{ margin: 0 }} />
- <SkeletonRow />
+ <SettingsProfileRowSkeleton />
<Divider style={{ margin: 0 }} />
- <SkeletonRow />
+ <SettingsProfileRowSkeleton />
</Flexbox>
<Flexbox style={{ display: isLoading ? 'none' : 'flex' }}>
<AvatarRow />
diff --git a/src/features/Settings/provider/detail/default/CustomProviderDetail.tsx b/src/features/Settings/provider/detail/default/CustomProviderDetail.tsx
index 9149dc42407..88de4f9655b 100644
--- a/src/features/Settings/provider/detail/default/CustomProviderDetail.tsx
+++ b/src/features/Settings/provider/detail/default/CustomProviderDetail.tsx
@@ -3,7 +3,7 @@
import { Flexbox } from '@lobehub/ui';
import { memo } from 'react';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import { useClientDataSWR } from '@/libs/swr';
import { providerKeys } from '@/libs/swr/keys';
import { aiProviderService } from '@/services/aiProvider';
@@ -20,7 +20,7 @@ const CustomProviderDetail = memo<{ id: string }>(({ id }) => {
aiProviderService.getAiProviderById(id),
);
- if (isLoading || !data || !data.id) return <Loading debugId="Provider > CustomProviderDetail" />;
+ if (isLoading || !data || !data.id) return <SurfaceSkeleton header={false} variant={'form'} />;
return (
// No block padding of its own — SettingContainer already insets the page.
diff --git a/src/features/Settings/provider/detail/index.tsx b/src/features/Settings/provider/detail/index.tsx
index b71a5893a88..bdbe5273c6e 100644
--- a/src/features/Settings/provider/detail/index.tsx
+++ b/src/features/Settings/provider/detail/index.tsx
@@ -1,52 +1,52 @@
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import dynamic from '@/libs/next/dynamic';
const NewAPI = dynamic(() => import('./newapi'), {
- loading: () => <Loading debugId="Provider > NewAPI" />,
+ loading: () => <SurfaceSkeleton header={false} variant={'form'} />,
ssr: false,
});
const OpenAI = dynamic(() => import('./openai'), {
- loading: () => <Loading debugId="Provider > OpenAI" />,
+ loading: () => <SurfaceSkeleton header={false} variant={'form'} />,
ssr: false,
});
const VertexAI = dynamic(() => import('./vertexai'), {
- loading: () => <Loading debugId="Provider > VertexAI" />,
+ loading: () => <SurfaceSkeleton header={false} variant={'form'} />,
ssr: false,
});
const GitHub = dynamic(() => import('./github'), {
- loading: () => <Loading debugId="Provider > GitHub" />,
+ loading: () => <SurfaceSkeleton header={false} variant={'form'} />,
ssr: false,
});
const Ollama = dynamic(() => import('./ollama'), {
- loading: () => <Loading debugId="Provider > Ollama" />,
+ loading: () => <SurfaceSkeleton header={false} variant={'form'} />,
ssr: false,
});
const ComfyUI = dynamic(() => import('./comfyui'), {
- loading: () => <Loading debugId="Provider > ComfyUI" />,
+ loading: () => <SurfaceSkeleton header={false} variant={'form'} />,
ssr: false,
});
const Cloudflare = dynamic(() => import('./cloudflare'), {
- loading: () => <Loading debugId="Provider > Cloudflare" />,
+ loading: () => <SurfaceSkeleton header={false} variant={'form'} />,
ssr: false,
});
const Bedrock = dynamic(() => import('./bedrock'), {
- loading: () => <Loading debugId="Provider > Bedrock" />,
+ loading: () => <SurfaceSkeleton header={false} variant={'form'} />,
ssr: false,
});
const AzureAI = dynamic(() => import('./azureai'), {
- loading: () => <Loading debugId="Provider > AzureAI" />,
+ loading: () => <SurfaceSkeleton header={false} variant={'form'} />,
ssr: false,
});
const Azure = dynamic(() => import('./azure'), {
- loading: () => <Loading debugId="Provider > Azure" />,
+ loading: () => <SurfaceSkeleton header={false} variant={'form'} />,
ssr: false,
});
const ProviderGrid = dynamic(() => import('../(list)/ProviderGrid'), {
- loading: () => <Loading debugId="Provider > Grid" />,
+ loading: () => <SurfaceSkeleton header={false} variant={'grid'} />,
ssr: false,
});
const DefaultPage = dynamic(() => import('./default/ProviderDetialPage'), {
- loading: () => <Loading debugId="Provider > Default" />,
+ loading: () => <SurfaceSkeleton header={false} variant={'form'} />,
ssr: false,
});
diff --git a/src/routes/(main)/_layout/index.tsx b/src/routes/(main)/_layout/index.tsx
index f6c944f1ad1..3ab59dd3dae 100644
--- a/src/routes/(main)/_layout/index.tsx
+++ b/src/routes/(main)/_layout/index.tsx
@@ -10,7 +10,7 @@ import { HotkeysProvider } from 'react-hotkeys-hook';
import { Outlet } from 'react-router';
import WorkspaceContextSlot from '@/business/client/WorkspaceContextSlot';
-import ContentLoading from '@/components/Loading/ContentLoading';
+import RouteSegmentSkeleton from '@/components/Skeleton/RouteSegment';
import { isDesktop } from '@/const/version';
import { BANNER_HEIGHT } from '@/features/AlertBanner/CloudBanner';
import DesktopBrowserGatewayBridge from '@/features/DesktopBrowserGatewayBridge';
@@ -83,7 +83,7 @@ const Layout: FC = () => {
<DesktopHomeLayout>
<DesktopHome />
</DesktopHomeLayout>
- <Suspense fallback={<ContentLoading />}>
+ <Suspense fallback={<RouteSegmentSkeleton />}>
<Outlet />
</Suspense>
</DesktopLayoutContainer>
diff --git a/src/routes/(main)/agent/channel/index.tsx b/src/routes/(main)/agent/channel/index.tsx
index 404d930e657..88675c370db 100644
--- a/src/routes/(main)/agent/channel/index.tsx
+++ b/src/routes/(main)/agent/channel/index.tsx
@@ -7,7 +7,7 @@ import { useNavigate, useParams } from 'react-router';
import NotFound from '@/components/404';
import AsyncBoundary from '@/components/AsyncBoundary';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import ResourceConfigAccessGate from '@/features/ResourcePermission/ResourceConfigAccessGate';
import { usePermission } from '@/hooks/usePermission';
import { useAgentStore } from '@/store/agent';
@@ -138,7 +138,7 @@ const ChannelContent = memo(() => {
error={error}
errorVariant={'block'}
isLoading={isLoading}
- loading={<Loading debugId="ChannelPage" />}
+ loading={<SurfaceSkeleton header={false} variant={'grid'} />}
onRetry={() => {
mutatePlatforms();
mutateProviders();
diff --git a/src/routes/(main)/agent/docs/[docId]/index.tsx b/src/routes/(main)/agent/docs/[docId]/index.tsx
index a17233cb312..e91d6be22ef 100644
--- a/src/routes/(main)/agent/docs/[docId]/index.tsx
+++ b/src/routes/(main)/agent/docs/[docId]/index.tsx
@@ -3,7 +3,7 @@
import { memo, Suspense } from 'react';
import { useParams } from 'react-router';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import AgentDocumentPage from '@/features/AgentDocumentPage';
import { getIdFromIdentifier } from '@/utils/identifier';
@@ -12,7 +12,7 @@ const AgentDocumentRoute = memo(() => {
const documentId = getIdFromIdentifier(docId ?? '', 'docs');
return (
- <Suspense fallback={<Loading debugId="AgentDocumentRoute" />}>
+ <Suspense fallback={<SurfaceSkeleton variant={'editor'} />}>
{/* key remounts the editor when switching between documents */}
<AgentDocumentPage documentId={documentId} key={documentId} />
</Suspense>
diff --git a/src/routes/(main)/agent/features/Conversation/index.tsx b/src/routes/(main)/agent/features/Conversation/index.tsx
index 79127f5036d..1e6a0df2421 100644
--- a/src/routes/(main)/agent/features/Conversation/index.tsx
+++ b/src/routes/(main)/agent/features/Conversation/index.tsx
@@ -3,7 +3,7 @@ import { Flexbox, TooltipGroup } from '@lobehub/ui';
import React, { memo, Suspense, useCallback } from 'react';
import DragUploadZone, { type DroppedLocalPath, useUploadFiles } from '@/components/DragUploadZone';
-import Loading from '@/components/Loading/BrandTextLoading';
+import ConversationSegmentSkeleton from '@/components/Skeleton/Conversation/Segment';
import { insertLocalPathTags } from '@/features/ChatInput/InputEditor/insertLocalFileTags';
import { useAgentContext } from '@/features/Conversation/useAgentContext';
import { useResourceAccess } from '@/features/ResourcePermission/useResourceAccess';
@@ -66,7 +66,7 @@ const ChatConversation = memo(() => {
);
return (
- <Suspense fallback={<Loading debugId="Agent > ChatConversation" />}>
+ <Suspense fallback={<ConversationSegmentSkeleton />}>
{canUseResource ? (
<DragUploadZone
enableLocalPathReference={enableLocalPathReference}
diff --git a/src/routes/(main)/agent/features/Portal/features/PortalPanel.tsx b/src/routes/(main)/agent/features/Portal/features/PortalPanel.tsx
index 91c182f8ce1..1c55967f0fb 100644
--- a/src/routes/(main)/agent/features/Portal/features/PortalPanel.tsx
+++ b/src/routes/(main)/agent/features/Portal/features/PortalPanel.tsx
@@ -1,6 +1,6 @@
-import { memo,Suspense } from 'react';
+import { memo, Suspense } from 'react';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import DesktopLayout from '../_layout/Desktop';
import MobileLayout from '../_layout/Mobile';
@@ -13,7 +13,7 @@ const PortalPanel = memo<PortalPanelProps>(({ mobile }) => {
const Layout = mobile ? MobileLayout : DesktopLayout;
return (
- <Suspense fallback={<Loading debugId="PortalPanel" />}>
+ <Suspense fallback={<SurfaceSkeleton header={false} variant={'list'} />}>
<Layout />
</Suspense>
);
diff --git a/src/routes/(main)/agent/features/Portal/index.tsx b/src/routes/(main)/agent/features/Portal/index.tsx
index 237b6c85421..eb31aa66b31 100644
--- a/src/routes/(main)/agent/features/Portal/index.tsx
+++ b/src/routes/(main)/agent/features/Portal/index.tsx
@@ -1,6 +1,6 @@
import { Suspense } from 'react';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import Portal from './features/Portal';
import PortalPanel from './features/PortalPanel';
@@ -8,7 +8,7 @@ import PortalPanel from './features/PortalPanel';
const ChatPortal = () => {
return (
<Portal>
- <Suspense fallback={<Loading debugId={'ChatPortal'} />}>
+ <Suspense fallback={<SurfaceSkeleton header={false} variant={'list'} />}>
<PortalPanel mobile={false} />
</Suspense>
</Portal>
diff --git a/src/routes/(main)/agent/permission/index.tsx b/src/routes/(main)/agent/permission/index.tsx
index 9093b7293c8..8b1e6393726 100644
--- a/src/routes/(main)/agent/permission/index.tsx
+++ b/src/routes/(main)/agent/permission/index.tsx
@@ -3,7 +3,7 @@
import { memo, Suspense } from 'react';
import { useParams } from 'react-router';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import AgentPermission from '@/features/AgentPermission';
import ResourceConfigAccessGate from '@/features/ResourcePermission/ResourceConfigAccessGate';
@@ -11,7 +11,7 @@ const AgentPermissionPage = memo(() => {
const { aid } = useParams<{ aid: string }>();
return (
- <Suspense fallback={<Loading debugId="AgentPermissionPage" />}>
+ <Suspense fallback={<SurfaceSkeleton variant={'form'} />}>
{/* Managing who can do what is a configuration action: a chat-only member
gets the same redirect + reason toast as on Agent Profile. */}
<ResourceConfigAccessGate
diff --git a/src/routes/(main)/agent/profile/index.tsx b/src/routes/(main)/agent/profile/index.tsx
index e1a3441b581..5d1770e36e1 100644
--- a/src/routes/(main)/agent/profile/index.tsx
+++ b/src/routes/(main)/agent/profile/index.tsx
@@ -6,7 +6,7 @@ import { memo, Suspense } from 'react';
import { useParams } from 'react-router';
import AsyncBoundary from '@/components/AsyncBoundary';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import AgentBuilder from '@/features/AgentBuilder';
import ResourceConfigAccessGate from '@/features/ResourcePermission/ResourceConfigAccessGate';
import WideScreenContainer from '@/features/WideScreenContainer';
@@ -62,7 +62,7 @@ const ProfileArea = memo(() => {
// gate on `!configError` so under loading→error precedence the loading
// branch yields to the error state instead of spinning forever.
isLoading={isAgentConfigLoading && !configError}
- loading={<Loading debugId="ProfileArea" />}
+ loading={<SurfaceSkeleton variant={'editor'} />}
onRetry={() => retryAgentConfigFetch()}
>
<Header />
@@ -103,7 +103,7 @@ const AgentProfile: FC = () => {
const { aid } = useParams<{ aid: string }>();
return (
- <Suspense fallback={<Loading debugId="AgentProfile" />}>
+ <Suspense fallback={<SurfaceSkeleton variant={'editor'} />}>
<ResourceConfigAccessGate
redirectPath={`/agent/${aid ?? ''}`}
resourceId={aid}
diff --git a/src/routes/(main)/agent/statistics/index.tsx b/src/routes/(main)/agent/statistics/index.tsx
index 50870586e59..1f65e525758 100644
--- a/src/routes/(main)/agent/statistics/index.tsx
+++ b/src/routes/(main)/agent/statistics/index.tsx
@@ -2,11 +2,11 @@
import { memo, Suspense } from 'react';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import AgentUsage from '@/features/AgentUsage';
const AgentStatisticsPage = memo(() => (
- <Suspense fallback={<Loading debugId="AgentUsage" />}>
+ <Suspense fallback={<SurfaceSkeleton variant={'grid'} />}>
<AgentUsage />
</Suspense>
));
diff --git a/src/routes/(main)/agent/topics/index.tsx b/src/routes/(main)/agent/topics/index.tsx
index cb2da97b907..af9689c0198 100644
--- a/src/routes/(main)/agent/topics/index.tsx
+++ b/src/routes/(main)/agent/topics/index.tsx
@@ -2,11 +2,11 @@
import { memo, Suspense } from 'react';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import AgentTopicManager from '@/features/AgentTopicManager';
const AgentTopicsPage = memo(() => (
- <Suspense fallback={<Loading debugId="AgentTopicManager" />}>
+ <Suspense fallback={<SurfaceSkeleton variant={'list'} />}>
<AgentTopicManager />
</Suspense>
));
diff --git a/src/routes/(main)/group/features/Portal/index.tsx b/src/routes/(main)/group/features/Portal/index.tsx
index 84a9421ea9f..7160c6b30a7 100644
--- a/src/routes/(main)/group/features/Portal/index.tsx
+++ b/src/routes/(main)/group/features/Portal/index.tsx
@@ -1,13 +1,13 @@
import { Suspense } from 'react';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import Portal from '@/routes/(main)/agent/features/Portal/features/Portal';
import PortalPanel from '@/routes/(main)/agent/features/Portal/features/PortalPanel';
const ChatPortal = () => {
return (
<Portal>
- <Suspense fallback={<Loading debugId={'ChatPortal'} />}>
+ <Suspense fallback={<SurfaceSkeleton header={false} variant={'list'} />}>
<PortalPanel mobile={false} />
</Suspense>
</Portal>
diff --git a/src/routes/(main)/group/permission/index.tsx b/src/routes/(main)/group/permission/index.tsx
index d431f663d9c..72da9995667 100644
--- a/src/routes/(main)/group/permission/index.tsx
+++ b/src/routes/(main)/group/permission/index.tsx
@@ -3,7 +3,7 @@
import { memo, Suspense } from 'react';
import { useParams } from 'react-router';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import GroupPermission from '@/features/GroupPermission';
import ResourceConfigAccessGate from '@/features/ResourcePermission/ResourceConfigAccessGate';
@@ -11,7 +11,7 @@ const GroupPermissionPage = memo(() => {
const { gid } = useParams<{ gid: string }>();
return (
- <Suspense fallback={<Loading debugId="GroupPermissionPage" />}>
+ <Suspense fallback={<SurfaceSkeleton variant={'form'} />}>
{/* Managing who can do what is a configuration action: a chat-only member
gets the same redirect + reason toast as on Group Profile. */}
<ResourceConfigAccessGate
diff --git a/src/routes/(main)/group/profile/features/AgentBuilder/index.tsx b/src/routes/(main)/group/profile/features/AgentBuilder/index.tsx
index f74c62ece9c..29df5438097 100644
--- a/src/routes/(main)/group/profile/features/AgentBuilder/index.tsx
+++ b/src/routes/(main)/group/profile/features/AgentBuilder/index.tsx
@@ -3,7 +3,7 @@ import { DraggablePanel } from '@lobehub/ui';
import { cssVar } from 'antd-style';
import { memo } from 'react';
-import Loading from '@/components/Loading/BrandTextLoading';
+import ConversationSegmentSkeleton from '@/components/Skeleton/Conversation/Segment';
import { useAgentStore } from '@/store/agent';
import { builtinAgentSelectors } from '@/store/agent/selectors';
import { useGlobalStore } from '@/store/global';
@@ -51,7 +51,7 @@ const AgentBuilder = memo(() => {
<AgentBuilderConversation agentId={groupAgentBuilderId} />
</AgentBuilderProvider>
) : (
- <Loading debugId="GroupAgentBuilder > Init" />
+ <ConversationSegmentSkeleton />
)}
</DraggablePanel>
);
diff --git a/src/routes/(main)/group/profile/index.tsx b/src/routes/(main)/group/profile/index.tsx
index eb4fdd871c5..9aec59cdc99 100644
--- a/src/routes/(main)/group/profile/index.tsx
+++ b/src/routes/(main)/group/profile/index.tsx
@@ -5,7 +5,7 @@ import { type FC } from 'react';
import { memo, Suspense } from 'react';
import { useParams } from 'react-router';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import ResourceConfigAccessGate from '@/features/ResourcePermission/ResourceConfigAccessGate';
import WideScreenContainer from '@/features/WideScreenContainer';
import { useAgentGroupStore } from '@/store/agentGroup';
@@ -28,7 +28,7 @@ const ProfileArea = memo(() => {
return (
<Flexbox flex={1} height={'100%'} style={{ minWidth: 0, overflow: 'hidden' }}>
{isGroupsLoading ? (
- <Loading debugId="ProfileArea" />
+ <SurfaceSkeleton variant={'editor'} />
) : (
<>
<Header />
@@ -55,7 +55,7 @@ const GroupProfile: FC = () => {
const { gid } = useParams<{ gid: string }>();
return (
- <Suspense fallback={<Loading debugId="GroupProfile" />}>
+ <Suspense fallback={<SurfaceSkeleton variant={'editor'} />}>
<ResourceConfigAccessGate
redirectPath={`/group/${gid ?? ''}`}
resourceId={gid}
diff --git a/src/routes/(main)/memory/(home)/features/RoleTagCloud/index.tsx b/src/routes/(main)/memory/(home)/features/RoleTagCloud/index.tsx
index 7b94e3bd689..4e9007948bf 100644
--- a/src/routes/(main)/memory/(home)/features/RoleTagCloud/index.tsx
+++ b/src/routes/(main)/memory/(home)/features/RoleTagCloud/index.tsx
@@ -3,13 +3,13 @@ import { createStaticStyles, cx } from 'antd-style';
import { MaximizeIcon, MinimizeIcon } from 'lucide-react';
import { memo, useEffect, useState } from 'react';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SkeletonBar from '@/components/Skeleton/Bar';
import { DESKTOP_HEADER_ICON_SIZE } from '@/const/layoutTokens';
import { type QueryTagsResult } from '@/database/models/userMemory';
import dynamic from '@/libs/next/dynamic';
const TagCloudCanvas = dynamic(() => import('./TagCloudCanvas'), {
- loading: () => <Loading debugId={'TagCloud'} />,
+ loading: () => <SkeletonBar height={400} radius={12} />,
ssr: false,
});
diff --git a/src/routes/(main)/memory/(home)/index.tsx b/src/routes/(main)/memory/(home)/index.tsx
index f31f0f8924e..2d87aedf6ca 100644
--- a/src/routes/(main)/memory/(home)/index.tsx
+++ b/src/routes/(main)/memory/(home)/index.tsx
@@ -3,7 +3,7 @@ import { Flexbox } from '@lobehub/ui';
import { type FC } from 'react';
import AsyncBoundary from '@/components/AsyncBoundary';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import NavHeader from '@/features/NavHeader';
import WideScreenContainer from '@/features/WideScreenContainer';
import WideScreenButton from '@/features/WideScreenContainer/WideScreenButton';
@@ -31,7 +31,7 @@ const Home: FC = () => {
} = useFetchPersona();
// const { EditorModalElement, openEditor } = usePersonaEditor();
- if (isTagsLoading || isPersonaLoading) return <Loading debugId={'Home'} />;
+ if (isTagsLoading || isPersonaLoading) return <SurfaceSkeleton variant={'editor'} />;
// Persona / tags feed the store, so a failed fetch left the render falling
// through to the "analyze to get started" onboarding — telling the user they
diff --git a/src/routes/(main)/page/[id]/index.tsx b/src/routes/(main)/page/[id]/index.tsx
index 839874a62ff..11e02f43d13 100644
--- a/src/routes/(main)/page/[id]/index.tsx
+++ b/src/routes/(main)/page/[id]/index.tsx
@@ -5,7 +5,7 @@ import { memo, Suspense } from 'react';
import { useParams } from 'react-router';
import { createStoreUpdater } from 'zustand-utils';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import PageExplorer from '@/features/PageExplorer';
import { usePageStore } from '@/store/page';
import { getIdFromIdentifier } from '@/utils/identifier';
@@ -23,7 +23,7 @@ const PagesPage = memo(() => {
storeUpdater('selectedPageId', pageId);
return (
- <Suspense fallback={<Loading debugId="PagesPage" />}>
+ <Suspense fallback={<SurfaceSkeleton variant={'editor'} />}>
<PageExplorer pageId={pageId} />
</Suspense>
);
diff --git a/src/routes/(main)/page/index.tsx b/src/routes/(main)/page/index.tsx
index a7d345abe3d..55f35a0c704 100644
--- a/src/routes/(main)/page/index.tsx
+++ b/src/routes/(main)/page/index.tsx
@@ -2,12 +2,12 @@
import { memo, Suspense } from 'react';
-import Loading from '@/components/Loading/BrandTextLoading';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import PageExplorerPlaceholder from '@/features/PageExplorer/PageExplorerPlaceholder';
const PagesPage = memo(() => {
return (
- <Suspense fallback={<Loading debugId="PagesPage" />}>
+ <Suspense fallback={<SurfaceSkeleton variant={'editor'} />}>
<PageExplorerPlaceholder />
</Suspense>
);
diff --git a/src/spa/router/desktopRouter.bootInitOrder.test.ts b/src/spa/router/desktopRouter.bootInitOrder.test.ts
index 61261a24cc9..ca7989177fa 100644
--- a/src/spa/router/desktopRouter.bootInitOrder.test.ts
+++ b/src/spa/router/desktopRouter.bootInitOrder.test.ts
@@ -1,11 +1,11 @@
// Import ORDER is load-bearing and must not be reshuffled: the desktop boot
-// evaluates the navigation facade (`NavigatorRegistrar.desktop` → `appNavigate`
-// → `activeTabNavigate`) before the router config. If any of those statically
-// pull `desktopRouter.config` back in, the Electron adapter runs its top-level
-// `redirectElement(...)` while `@/utils/router` is still initializing and hits
-// a jsx-runtime TDZ ("Cannot access '_jsxDEV' before initialization"), leaving
-// the renderer white-screened. This test wires that order up so a regression in
-// the navigation import graph fails here instead of only on the packaged app.
+// evaluates structural fallbacks and the navigation facade
+// (`NavigatorRegistrar.desktop` → `appNavigate` → `activeTabNavigate`) before
+// the router config. If either graph statically pulls `desktopRouter.config`
+// back in, the Electron adapter can evaluate `redirectElement(...)` or a
+// platform route component while its dependency is still initializing and
+// leave the renderer white-screened with a TDZ error.
+import '@/components/Skeleton/RouteSegment';
import '@/utils/NavigatorRegistrar.desktop';
import { describe, expect, it } from 'vitest';
diff --git a/src/spa/router/desktopRouter.shared.tsx b/src/spa/router/desktopRouter.shared.tsx
index e49c5b6b4c9..aa01df91812 100644
--- a/src/spa/router/desktopRouter.shared.tsx
+++ b/src/spa/router/desktopRouter.shared.tsx
@@ -16,7 +16,7 @@ import {
ShapesIcon,
SquarePlay,
} from 'lucide-react';
-import { cloneElement, isValidElement, type ReactElement, Suspense } from 'react';
+import { createElement, isValidElement, type ReactElement, type ReactNode, Suspense } from 'react';
import type { RouteObject } from 'react-router';
import {
@@ -24,7 +24,11 @@ import {
BusinessDesktopRoutesWithoutMainLayout,
BusinessResourceRoutes,
} from '@/business/client/BusinessDesktopRoutes';
-import ContentLoading from '@/components/Loading/ContentLoading';
+import BrandTextLoading from '@/components/Loading/BrandTextLoading';
+import ConversationLayoutSkeleton from '@/components/Skeleton/Conversation/Layout';
+import ConversationSegmentSkeleton from '@/components/Skeleton/Conversation/Segment';
+import RouteSegmentSkeleton from '@/components/Skeleton/RouteSegment';
+import SettingsPageSkeleton from '@/components/Skeleton/Settings/Page';
import { agentDocumentRouteMeta } from '@/features/AgentDocumentPage/routeMeta';
import { goalsRouteMeta } from '@/features/AgentGoals/routeMeta';
import { taskRouteMeta, tasksRouteMeta } from '@/features/AgentTasks/routeMeta';
@@ -54,13 +58,13 @@ import { dynamicElement, dynamicLayout, ErrorBoundary, redirectElement } from '@
const agentChatElement = dynamicElement(
() => loadRouteWithBuiltinToolSurfaces(() => import('@/routes/(main)/agent')),
'Desktop > Chat',
- { preloadId: 'agent' },
+ { fallback: <ConversationSegmentSkeleton />, preloadId: 'agent' },
);
const groupChatElement = dynamicElement(
() => loadRouteWithBuiltinToolSurfaces(() => import('@/routes/(main)/group')),
'Desktop > Agent Group',
- { preloadId: 'group' },
+ { fallback: <ConversationLayoutSkeleton />, preloadId: 'group' },
);
const resourceCategoryRoutes: RouteObject[] = [
@@ -87,6 +91,9 @@ export interface MainAreaRouteOptions {
createWorkspaceSettingsIndexElement?: () => ReactElement;
}
+const deferPlatformElement = (factory?: () => ReactElement) =>
+ factory ? createElement(factory) : undefined;
+
/**
* Children shared between the root tree (`/`) and the workspace tree
* (`/:workspaceSlug`). Personal-only segments (settings, index, catch-all,
@@ -121,7 +128,7 @@ export const sharedMainAreaChildren: RouteObject[] = [
element: dynamicLayout(
() => import('@/routes/(main)/agent/(chat)/_layout'),
'Desktop > Chat > ChatLayout',
- { preloadId: 'agent' },
+ { fallback: <ConversationLayoutSkeleton />, preloadId: 'agent' },
),
},
{
@@ -920,6 +927,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
element: dynamicElement(
() => import('@/routes/(main)/settings'),
'Desktop > Settings > Memory',
+ { fallback: <SettingsPageSkeleton /> },
),
handle: { settingsTab: SettingsTabs.Memory },
path: 'memory',
@@ -933,6 +941,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
element: dynamicElement(
() => import('@/routes/(main)/settings'),
'Desktop > Settings > Tab',
+ { fallback: <SettingsPageSkeleton /> },
),
handle: { meta: settingsRouteMeta },
path: ':tab',
@@ -943,6 +952,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
element: dynamicElement(
() => import('@/routes/(main)/settings'),
'Desktop > Settings > Tab > Sub',
+ { fallback: <SettingsPageSkeleton /> },
),
handle: { meta: settingsRouteMeta },
path: ':tab/:sub',
@@ -951,6 +961,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
element: dynamicElement(
() => import('@/routes/(main)/settings/_layout'),
'Desktop > Settings > Layout',
+ { fallback: <SettingsPageSkeleton /> },
),
errorElement: <ErrorBoundary />,
path: 'settings',
@@ -963,7 +974,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
// Web renders Home beside the router outlet; Electron injects a per-tab
// Home element because each tab owns an independent memory router.
{
- element: options.createHomeElement?.(),
+ element: deferPlatformElement(options.createHomeElement),
handle: { meta: workspaceHomeRouteMeta },
index: true,
},
@@ -974,7 +985,9 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
{
children: [
{
- element: options.createWorkspaceSettingsIndexElement?.() ?? redirectElement('general'),
+ element:
+ deferPlatformElement(options.createWorkspaceSettingsIndexElement) ??
+ redirectElement('general'),
index: true,
},
// Full-bleed tabs render directly inside the workspace settings
@@ -1188,7 +1201,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
// Web leaves this element empty; Electron injects the per-tab Home route.
{
- element: options.createHomeElement?.(),
+ element: deferPlatformElement(options.createHomeElement),
handle: {
meta: routeMeta({
icon: MessageSquarePlus,
@@ -1228,27 +1241,34 @@ export interface SharedDesktopRouteOptions {
* supply only the root children, runtime-only routes, and onboarding route.
*/
/**
- * Swap the brand-loading fallback for a content one across a route subtree.
+ * Swap the default brand-loading fallback for a structural segment skeleton.
*
* `dynamicElement` / `dynamicLayout` wrap every route element in their own
* `Suspense`, and that boundary is always nearer the suspending component than
* any outlet-level one — so a fallback set on the main layout's outlet never
* fires for route content, and the 100+ call sites would otherwise each need
- * the option. Rewriting the elements once here keeps the main area consistent
- * without touching routes outside it (mobile still wants the full-page brand
- * loading, since its nav bar is inside the same boundary as its outlet).
+ * the option. Explicit route fallbacks are preserved so a route can render the
+ * nearest segment skeleton instead. Rewriting only defaults here keeps the main
+ * area consistent without touching routes outside it (mobile still wants the
+ * full-page brand loading, since its nav bar is inside the same boundary as its
+ * outlet).
*/
-export const withContentFallback = (routes: RouteObject[]): RouteObject[] =>
+export const withSegmentFallback = (routes: RouteObject[]): RouteObject[] =>
routes.map((route) => {
- const element =
+ const suspenseElement =
isValidElement(route.element) && route.element.type === Suspense
- ? // right that this couples to `dynamicElement` returning a bare Suspense.
- // The alternative is the option on all 104 call sites; the coupling is
- // guarded instead — `desktopRouter.sync.test.tsx` asserts every
- // main-area fallback is `ContentLoading`, so if that shape ever changes
- // the rewrite fails loudly rather than silently restoring the logo.
- cloneElement(route.element as ReactElement<{ fallback: ReactElement }>, {
- fallback: <ContentLoading />,
+ ? (route.element as ReactElement<{ fallback: ReactNode }>)
+ : undefined;
+ const fallback = suspenseElement?.props.fallback;
+ const element =
+ suspenseElement && isValidElement(fallback) && fallback.type === BrandTextLoading
+ ? // This intentionally couples to `dynamicElement` / `dynamicLayout`
+ // returning a bare Suspense with BrandTextLoading as their default.
+ // Explicit segment fallbacks must pass through unchanged.
+ createElement(Suspense, {
+ ...suspenseElement.props,
+ fallback: <RouteSegmentSkeleton />,
+ key: suspenseElement.key,
})
: route.element;
@@ -1256,7 +1276,7 @@ export const withContentFallback = (routes: RouteObject[]): RouteObject[] =>
// spreading loses the discriminant — the copy keeps the original's shape.
return {
...route,
- ...(route.children && { children: withContentFallback(route.children) }),
+ ...(route.children && { children: withSegmentFallback(route.children) }),
element,
} as RouteObject;
});
@@ -1267,7 +1287,7 @@ export const createSharedDesktopRoutes = ({
platformRoutes = [],
}: SharedDesktopRouteOptions): RouteObject[] => [
{
- children: withContentFallback(mainAreaChildren),
+ children: withSegmentFallback(mainAreaChildren),
// `BootShell` unmounts the moment the cache gate releases, which is often
// before this chunk resolves. Falling back to the same skeleton keeps the
// handoff invisible instead of flashing the brand logo a second time.
diff --git a/src/spa/router/desktopRouter.sync.test.tsx b/src/spa/router/desktopRouter.sync.test.tsx
index 0409a3073cd..35dd7cb1a60 100644
--- a/src/spa/router/desktopRouter.sync.test.tsx
+++ b/src/spa/router/desktopRouter.sync.test.tsx
@@ -4,10 +4,13 @@ import path from 'node:path';
import type { ReactElement } from 'react';
import type { RouteObject } from 'react-router';
import { matchRoutes } from 'react-router';
-import { describe, expect, it } from 'vitest';
+import { describe, expect, it, vi } from 'vitest';
import BrandTextLoading from '@/components/Loading/BrandTextLoading';
-import ContentLoading from '@/components/Loading/ContentLoading';
+import ConversationLayoutSkeleton from '@/components/Skeleton/Conversation/Layout';
+import ConversationSegmentSkeleton from '@/components/Skeleton/Conversation/Segment';
+import RouteSegmentSkeleton from '@/components/Skeleton/RouteSegment';
+import SettingsPageSkeleton from '@/components/Skeleton/Settings/Page';
import { WORKSPACE_SETTINGS_TABS } from '@/features/Workspace/workspaceAwarePath';
import AppShellSkeleton from '@/spa/BootShell/AppShellSkeleton';
import { createTabRouter } from '@/spa/router/tabRouter';
@@ -20,6 +23,7 @@ import {
createMainAreaChildren as createElectronMainAreaChildren,
desktopRoutes as electronDesktopRoutes,
} from './desktopRouter.config.desktop';
+import { createMainAreaRouteFactory } from './desktopRouter.shared';
type MainAreaFactory = () => RouteObject[];
@@ -62,6 +66,31 @@ async function readRouterSources() {
}
describe('desktop router shared definition', () => {
+ it('defers platform route factories until React renders their route elements', () => {
+ const createHomeElement = vi.fn(() => <div>Home</div>);
+ const createWorkspaceSettingsIndexElement = vi.fn(() => <div>Workspace settings</div>);
+ const createRoutes = createMainAreaRouteFactory({
+ createHomeElement,
+ createWorkspaceSettingsIndexElement,
+ });
+ const routes = createRoutes();
+
+ expect(createHomeElement).not.toHaveBeenCalled();
+ expect(createWorkspaceSettingsIndexElement).not.toHaveBeenCalled();
+
+ const rootHome = routes.find((route) => route.index);
+ const workspace = routes.find((route) => route.path === ':workspaceSlug');
+ const workspaceHome = workspace?.children?.find((route) => route.index);
+ const workspaceSettings = workspace?.children?.find((route) => route.path === 'settings');
+ const workspaceSettingsIndex = workspaceSettings?.children?.find((route) => route.index);
+
+ expect((rootHome?.element as ReactElement).type).toBe(createHomeElement);
+ expect((workspaceHome?.element as ReactElement).type).toBe(createHomeElement);
+ expect((workspaceSettingsIndex?.element as ReactElement).type).toBe(
+ createWorkspaceSettingsIndexElement,
+ );
+ });
+
it('matches the nested acceptance check route on Web only', () => {
const matches = matchRoutes(webDesktopRoutes, '/acceptance/acceptance-1/check/check-1');
@@ -214,13 +243,71 @@ describe('desktop router shared definition', () => {
// live in the per-tab memory routers, which build their own tree.
['Web', () => webDesktopRoutes.find((route) => route.path === '/')?.children ?? []],
['Electron', () => createTabRouter('/').routes[0]?.children ?? []],
- ])('%s main-area routes load behind the content fallback, not the brand logo', (_, getRoutes) => {
- const fallbacks = collectFallbacks(getRoutes());
+ ])(
+ '%s main-area routes load behind content or segment feedback, not branding',
+ (_, getRoutes) => {
+ const fallbacks = collectFallbacks(getRoutes());
+
+ expect(fallbacks.length).toBeGreaterThan(0);
+ expect(fallbacks).not.toContain(BrandTextLoading);
+ expect(new Set(fallbacks)).toEqual(
+ new Set([
+ RouteSegmentSkeleton,
+ ConversationLayoutSkeleton,
+ ConversationSegmentSkeleton,
+ SettingsPageSkeleton,
+ ]),
+ );
+ },
+ );
- expect(fallbacks.length).toBeGreaterThan(0);
- expect(fallbacks).not.toContain(BrandTextLoading);
- expect(new Set(fallbacks)).toEqual(new Set([ContentLoading]));
- });
+ it.each([
+ ['Web', (_pathname: string) => webDesktopRoutes],
+ ['Electron', (pathname: string) => createTabRouter(pathname).routes],
+ ])(
+ '%s selects the closest conversation segment feedback for each pending boundary',
+ (_, createRuntimeRoutes) => {
+ for (const [pathname, expectedFallbacks] of [
+ [
+ '/agent/agent-1/topic-1',
+ [RouteSegmentSkeleton, ConversationLayoutSkeleton, ConversationSegmentSkeleton],
+ ],
+ ['/group/group-1/topic-1', [RouteSegmentSkeleton, ConversationLayoutSkeleton]],
+ ] as const) {
+ const matches = matchRoutes(createRuntimeRoutes(pathname), pathname);
+ const fallbackTypes = matches
+ ?.map(
+ ({ route }) =>
+ (route.element as ReactElement<{ fallback?: ReactElement }> | undefined)?.props
+ .fallback?.type,
+ )
+ .filter(Boolean);
+
+ expect(fallbackTypes?.slice(-expectedFallbacks.length), pathname).toEqual(
+ expectedFallbacks,
+ );
+ }
+ },
+ );
+
+ it.each([
+ ['Web', (_pathname: string) => webDesktopRoutes],
+ ['Electron', (pathname: string) => createTabRouter(pathname).routes],
+ ])(
+ '%s keeps the settings layout and tab chunks on the settings page skeleton',
+ (_, getRoutes) => {
+ const matches = matchRoutes(getRoutes('/settings/profile'), '/settings/profile');
+ const fallbackTypes = matches
+ ?.map(
+ ({ route }) =>
+ (route.element as ReactElement<{ fallback?: ReactElement }> | undefined)?.props.fallback
+ ?.type,
+ )
+ .filter(Boolean);
+
+ expect(fallbackTypes?.slice(-2)).toEqual([SettingsPageSkeleton, SettingsPageSkeleton]);
+ },
+ );
it('injects Home only into Electron per-tab content routes', () => {
const webChildren = createWebMainAreaChildren();
diff --git a/src/spa/router/tabRouter.tsx b/src/spa/router/tabRouter.tsx
index 336bb944723..b736a8238f2 100644
--- a/src/spa/router/tabRouter.tsx
+++ b/src/spa/router/tabRouter.tsx
@@ -3,15 +3,15 @@
import { Suspense } from 'react';
import { createMemoryRouter, Outlet } from 'react-router';
-import ContentLoading from '@/components/Loading/ContentLoading';
+import RouteSegmentSkeleton from '@/components/Skeleton/RouteSegment';
import TabLocationReporter from '@/features/Electron/TabHost/TabLocationReporter';
import { ErrorBoundary } from '@/utils/router';
import { createMainAreaChildren } from './desktopRouter.config';
-import { withContentFallback } from './desktopRouter.shared';
+import { withSegmentFallback } from './desktopRouter.shared';
const TabRootLayout = () => (
- <Suspense fallback={<ContentLoading />}>
+ <Suspense fallback={<RouteSegmentSkeleton />}>
<Outlet />
<TabLocationReporter />
</Suspense>
@@ -23,7 +23,7 @@ export const createTabRouter = (initialUrl: string) =>
{
// Per-tab routers bypass `createSharedDesktopRoutes`, so the main-area
// fallback rewrite has to be applied here too.
- children: withContentFallback(createMainAreaChildren()),
+ children: withSegmentFallback(createMainAreaChildren()),
element: <TabRootLayout />,
// The error element replaces `TabRootLayout`, so the reporter is repeated
// here: the memory router has already advanced to the failing url, and