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: align loading skeletons with settled page layouts (#20802)

YuTengjing682c93712d08
diff --git a/src/components/Skeleton/AgentChannel.tsx b/src/components/Skeleton/AgentChannel.tsx
new file mode 100644
index 00000000000..a94c2f54417
--- /dev/null
+++ b/src/components/Skeleton/AgentChannel.tsx
@@ -0,0 +1,170 @@
+'use client';
+
+import { Block, Flexbox } from '@lobehub/ui';
+import { createStaticStyles, cssVar, responsive } from 'antd-style';
+
+import type { RouteSkeletonProps } from '@/spa/router/routeMeta';
+
+import AgentProfileNavSkeleton from './AgentProfileNav';
+import SkeletonBar from './Bar';
+
+/** Platform cards drawn by the list skeleton — the built-in catalog fills three rows. */
+const PLATFORM_CARD_COUNT = 9;
+
+const styles = createStaticStyles(({ css }) => ({
+ // `content-box` so the 1px divider sits outside the measured row height,
+ // matching `Form.Field divider` / `Form.Group` (64px rows, 45px group header).
+ advanced: css`
+ box-sizing: content-box;
+ border-block-start: 1px solid ${cssVar.colorBorderSecondary};
+ `,
+ card: css`
+ min-height: 104px;
+ `,
+ field: css`
+ box-sizing: content-box;
+ min-height: 64px;
+
+ & + & {
+ border-block-start: 1px solid ${cssVar.colorBorderSecondary};
+ }
+ `,
+ grid: css`
+ display: grid;
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ gap: 12px;
+ width: 100%;
+
+ ${responsive.md} {
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ }
+
+ ${responsive.sm} {
+ grid-template-columns: minmax(0, 1fr);
+ }
+ `,
+ root: css`
+ overflow: hidden;
+ display: flex;
+ flex: 1;
+ flex-direction: column;
+ align-items: center;
+
+ width: 100%;
+ min-height: 0;
+ `,
+ title: css`
+ height: 34px;
+ margin-block-end: 20px;
+ `,
+}));
+
+/**
+ * Body of the agent channel list (`routes/(main)/agent/channel/list.tsx`):
+ * 24px section padding around a 1024px column, the 24px/600 h1 with its inline
+ * 28px agent avatar, then the 3/2/1-column grid of outlined platform cards
+ * (24px icon + bold name, two 12px description lines). Also the page's own
+ * data-loading state, so route load and platform fetch share one shape.
+ */
+export const AgentChannelListBodySkeleton = () => (
+ <div aria-busy className={styles.root}>
+ <Flexbox padding={24} width={'100%'}>
+ <Flexbox style={{ alignSelf: 'center', maxWidth: 1024, width: '100%' }}>
+ <Flexbox horizontal align={'center'} className={styles.title} gap={8}>
+ <SkeletonBar height={24} width={220} />
+ <SkeletonBar height={28} width={28} />
+ <SkeletonBar height={24} width={96} />
+ </Flexbox>
+ <div className={styles.grid}>
+ {Array.from({ length: PLATFORM_CARD_COUNT }).map((_, index) => (
+ <Block className={styles.card} gap={8} key={index} padding={12} variant={'outlined'}>
+ <Flexbox horizontal align={'center'} gap={8} height={24}>
+ <SkeletonBar height={24} width={24} />
+ <SkeletonBar height={14} width={56 + (index % 3) * 12} />
+ </Flexbox>
+ <Flexbox gap={6} paddingBlock={3}>
+ <SkeletonBar height={12} width={'92%'} />
+ <SkeletonBar height={12} width={`${48 + (index % 3) * 10}%`} />
+ </Flexbox>
+ </Block>
+ ))}
+ </div>
+ </Flexbox>
+ </Flexbox>
+ </div>
+);
+
+/**
+ * Body of a platform detail (`routes/(main)/agent/channel/detail`): the 1024px
+ * outlined credential block — field rows with a 20px icon + label on the left
+ * and a half-width input on the right, then the collapsed advanced-settings
+ * group — followed by the right-aligned save button of the footer.
+ */
+export const AgentChannelDetailBodySkeleton = () => (
+ <div aria-busy className={styles.root}>
+ <Flexbox
+ align={'center'}
+ paddingInline={24}
+ style={{ paddingBlock: '16px 24px' }}
+ width={'100%'}
+ >
+ <Flexbox paddingBlock={16} style={{ maxWidth: 1024 }} width={'100%'}>
+ <Block paddingInline={16} variant={'outlined'}>
+ {[112, 40, 128].map((labelWidth, index) => (
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={styles.field}
+ gap={16}
+ justify={'space-between'}
+ key={index}
+ >
+ <Flexbox horizontal align={'center'} gap={8}>
+ <SkeletonBar height={20} width={20} />
+ <SkeletonBar height={14} width={labelWidth} />
+ </Flexbox>
+ <SkeletonBar height={32} width={'50%'} />
+ </Flexbox>
+ ))}
+ {/* Collapsed `Form.Group` header: a 28px title button at the top of a 45px row. */}
+ <Flexbox className={styles.advanced} height={45}>
+ <Flexbox justify={'center'} style={{ height: 28 }}>
+ <SkeletonBar height={13} width={52} />
+ </Flexbox>
+ </Flexbox>
+ </Block>
+ </Flexbox>
+ <Flexbox
+ horizontal
+ justify={'flex-end'}
+ style={{ maxWidth: 1024, paddingBlockStart: 16 }}
+ width={'100%'}
+ >
+ <SkeletonBar height={32} width={82} />
+ </Flexbox>
+ </Flexbox>
+ </div>
+);
+
+/**
+ * Route-level skeleton for `/agent/:aid/channel` (see `agentChannelRouteMeta`):
+ * the profile header (breadcrumb, centred tabs, "…" menu) over the list body.
+ */
+export const AgentChannelSkeleton = ({ chrome = 'page' }: RouteSkeletonProps) => (
+ <Flexbox aria-busy flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
+ {chrome !== 'body' && <AgentProfileNavSkeleton actions={1} />}
+ <AgentChannelListBodySkeleton />
+ </Flexbox>
+);
+
+/**
+ * Route-level skeleton for `/agent/:aid/channel/:platform` (see
+ * `agentChannelDetailRouteMeta`): breadcrumb `Agent › Channels › Platform`
+ * without the tab switcher, docs + "…" actions, over the credential form.
+ */
+export const AgentChannelDetailSkeleton = ({ chrome = 'page' }: RouteSkeletonProps) => (
+ <Flexbox aria-busy flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
+ {chrome !== 'body' && <AgentProfileNavSkeleton actions={2} breadcrumbItems={2} tabs={false} />}
+ <AgentChannelDetailBodySkeleton />
+ </Flexbox>
+);
diff --git a/src/components/Skeleton/AgentProfileNav.tsx b/src/components/Skeleton/AgentProfileNav.tsx
new file mode 100644
index 00000000000..3b90f815416
--- /dev/null
+++ b/src/components/Skeleton/AgentProfileNav.tsx
@@ -0,0 +1,71 @@
+'use client';
+
+import { Center, Flexbox } from '@lobehub/ui';
+import { cssVar } from 'antd-style';
+
+import SkeletonBar from './Bar';
+
+export interface AgentProfileNavSkeletonProps {
+ /** Number of `ActionIcon` placeholders on the right (36px hit box, 20px glyph), e.g. Channel's docs / "…" menu. */
+ actions?: number;
+ /** Extra breadcrumb segments after the agent name (e.g. `Channels › Discord`). */
+ breadcrumbItems?: number;
+ /** Whether the centred profile tab switcher is drawn (hidden on nested detail pages). */
+ tabs?: boolean;
+}
+
+/**
+ * `NavHeader` of the agent profile group (Profile / Channels / Statistics /
+ * Share): a 44px bar with padding 8, the `AgentBreadcrumb` text (no avatar)
+ * offset by the extra 8px `paddingInlineStart`, the small `AgentProfileTabs`
+ * Segmented centred on the header midpoint (`AGENT_PROFILE_TABS_CENTER_STYLE`,
+ * measured 244×34), and optional right-side action icons.
+ */
+const AgentProfileNavSkeleton = ({
+ actions = 0,
+ breadcrumbItems = 0,
+ tabs = true,
+}: AgentProfileNavSkeletonProps) => (
+ <Flexbox
+ horizontal
+ align={'center'}
+ flex={'none'}
+ height={44}
+ justify={'space-between'}
+ padding={8}
+ style={{ position: 'relative' }}
+ >
+ <Flexbox horizontal align={'center'} gap={8} style={{ paddingInlineStart: 8 }}>
+ <SkeletonBar height={14} width={72} />
+ {Array.from({ length: breadcrumbItems }).map((_, index) => (
+ <Flexbox horizontal align={'center'} gap={8} key={index}>
+ <SkeletonBar height={10} radius={'50%'} width={10} />
+ <SkeletonBar height={14} width={56} />
+ </Flexbox>
+ ))}
+ </Flexbox>
+ {tabs && (
+ <Flexbox
+ style={{
+ left: '50%',
+ position: 'absolute',
+ top: '50%',
+ transform: 'translate(-50%, -50%)',
+ }}
+ >
+ <SkeletonBar height={34} radius={cssVar.borderRadiusLG} width={244} />
+ </Flexbox>
+ )}
+ {actions > 0 && (
+ <Flexbox horizontal align={'center'} gap={8}>
+ {Array.from({ length: actions }).map((_, index) => (
+ <Center height={36} key={index} width={36}>
+ <SkeletonBar height={20} width={20} />
+ </Center>
+ ))}
+ </Flexbox>
+ )}
+ </Flexbox>
+);
+
+export default AgentProfileNavSkeleton;
diff --git a/src/components/Skeleton/AgentShare.tsx b/src/components/Skeleton/AgentShare.tsx
index c89d3908ec9..226415c5bc1 100644
--- a/src/components/Skeleton/AgentShare.tsx
+++ b/src/components/Skeleton/AgentShare.tsx
@@ -7,12 +7,10 @@ import type { ReactNode } from 'react';
import WideScreenContainer from '@/features/WideScreenContainer';
import type { RouteSkeletonProps } from '@/spa/router/routeMeta';
+import AgentProfileNavSkeleton from './AgentProfileNav';
import SkeletonBar from './Bar';
const styles = createStaticStyles(({ css }) => ({
- header: css`
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
- `,
notice: css`
border: 1px solid ${cssVar.colorBorderSecondary};
border-radius: ${cssVar.borderRadiusLG};
@@ -23,28 +21,6 @@ const styles = createStaticStyles(({ css }) => ({
`,
}));
-/** Breadcrumb on the left, the profile tab switcher centred — same as `NavHeader` on the page. */
-const NavigationSkeleton = () => (
- <Flexbox
- horizontal
- align={'center'}
- className={styles.header}
- flex={'none'}
- height={44}
- paddingInline={16}
- style={{ position: 'relative' }}
- >
- <Flexbox horizontal align={'center'} gap={8}>
- <SkeletonBar height={20} radius={'50%'} width={20} />
- <SkeletonBar height={14} width={120} />
- </Flexbox>
- {/* Mirrors `AGENT_PROFILE_TABS_CENTER_STYLE`: centred on the header midpoint. */}
- <Flexbox style={{ left: '50%', position: 'absolute', transform: 'translateX(-50%)' }}>
- <SkeletonBar height={28} radius={14} width={280} />
- </Flexbox>
- </Flexbox>
-);
-
const SettingRowSkeleton = ({ control, index }: { control: 'switch' | 'input'; index: number }) => (
<Flexbox horizontal align={'center'} gap={16} justify={'space-between'}>
<Flexbox gap={6}>
@@ -123,7 +99,7 @@ export const AgentShareSettingsBodySkeleton = () => (
/** Route-level skeleton for `/agent/:aid/share` (see `agentShareRouteMeta`). */
const AgentShareSkeleton = ({ chrome = 'page' }: RouteSkeletonProps) => (
<Flexbox aria-busy flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
- {chrome !== 'body' && <NavigationSkeleton />}
+ {chrome !== 'body' && <AgentProfileNavSkeleton />}
<Flexbox flex={1} style={{ minHeight: 0, overflow: 'hidden' }}>
<WideScreenContainer>
<AgentShareSettingsBodySkeleton />
diff --git a/src/components/Skeleton/AgentStatistics.tsx b/src/components/Skeleton/AgentStatistics.tsx
new file mode 100644
index 00000000000..07953650537
--- /dev/null
+++ b/src/components/Skeleton/AgentStatistics.tsx
@@ -0,0 +1,177 @@
+'use client';
+
+import { Block, Flexbox, Grid } from '@lobehub/ui';
+import { Skeleton } from '@lobehub/ui/base-ui';
+import { createStaticStyles, cssVar } from 'antd-style';
+
+import WideScreenContainer from '@/features/WideScreenContainer';
+import type { RouteSkeletonProps } from '@/spa/router/routeMeta';
+
+import AgentProfileNavSkeleton from './AgentProfileNav';
+import SkeletonBar from './Bar';
+
+const styles = createStaticStyles(({ css }) => ({
+ tableHead: css`
+ border-radius: ${cssVar.borderRadius} ${cssVar.borderRadius} 0 0;
+ background: ${cssVar.colorFillQuaternary};
+ `,
+ tableRow: css`
+ border-block-end: 1px solid ${cssVar.colorBorderSecondary};
+ `,
+}));
+
+/** Label + small Segmented pair of the controls row (`维度 [按天|按周]`). */
+const LabelledSegmentedSkeleton = ({
+ labelWidth,
+ segmentedWidth,
+}: {
+ labelWidth: number;
+ segmentedWidth: number;
+}) => (
+ <Flexbox horizontal align={'center'} gap={8}>
+ <SkeletonBar height={13} width={labelWidth} />
+ <SkeletonBar height={34} radius={cssVar.borderRadiusLG} width={segmentedWidth} />
+ </Flexbox>
+);
+
+/**
+ * The three `StatisticCard`s of `AgentUsage/StatCards.tsx`: a 32px title line,
+ * a 24px value line, and (cost-saving / token cards only) a 12px description
+ * 16px below. Same `Grid` props as the real cards so the columns line up.
+ */
+export const AgentStatCardsSkeleton = () => (
+ <Grid gap={8} maxItemWidth={240} rows={3}>
+ {[96, 128, 112].map((titleWidth, index) => (
+ <Flexbox flex={1} key={index}>
+ <Flexbox justify={'center'} style={{ height: 32 }}>
+ <SkeletonBar height={16} width={titleWidth} />
+ </Flexbox>
+ <Flexbox gap={16}>
+ <Flexbox justify={'center'} style={{ height: 29 }}>
+ <SkeletonBar height={24} width={index === 2 ? 40 : 72} />
+ </Flexbox>
+ {index > 0 && (
+ <Flexbox justify={'center'} style={{ height: 19 }}>
+ <SkeletonBar height={12} width={index === 1 ? 112 : 96} />
+ </Flexbox>
+ )}
+ </Flexbox>
+ </Flexbox>
+ ))}
+ </Grid>
+);
+
+/**
+ * Body rows of the `ModelBreakdown` table (antd `size="middle"`, 12/16px cell
+ * padding): model icon + name/provider on the left, then right-aligned
+ * requests / tokens / cost columns.
+ */
+const ModelBreakdownRowsSkeleton = () => (
+ <Flexbox>
+ {Array.from({ length: 3 }).map((_, index) => (
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={styles.tableRow}
+ gap={16}
+ key={index}
+ paddingBlock={12}
+ paddingInline={16}
+ >
+ <Flexbox horizontal align={'center'} flex={1} gap={8}>
+ <SkeletonBar height={20} radius={'50%'} width={20} />
+ <Flexbox gap={6}>
+ <SkeletonBar height={14} width={120 + (index % 3) * 24} />
+ <SkeletonBar height={12} width={56 + (index % 2) * 16} />
+ </Flexbox>
+ </Flexbox>
+ <Flexbox align={'flex-end'} flex={1}>
+ <SkeletonBar height={14} width={32} />
+ </Flexbox>
+ <Flexbox align={'flex-end'} flex={1}>
+ <SkeletonBar height={14} width={48} />
+ </Flexbox>
+ <Flexbox align={'flex-end'} flex={1}>
+ <SkeletonBar height={14} width={48} />
+ </Flexbox>
+ </Flexbox>
+ ))}
+ </Flexbox>
+);
+
+/** Header row + body rows of the `ModelBreakdown` table; also its own loading state. */
+export const AgentModelBreakdownTableSkeleton = () => (
+ <Flexbox>
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={styles.tableHead}
+ gap={16}
+ height={44}
+ paddingInline={16}
+ >
+ <Flexbox flex={1}>
+ <SkeletonBar height={13} width={28} />
+ </Flexbox>
+ {[40, 44, 28].map((width, index) => (
+ <Flexbox align={'flex-end'} flex={1} key={index}>
+ <SkeletonBar height={13} width={width} />
+ </Flexbox>
+ ))}
+ </Flexbox>
+ <ModelBreakdownRowsSkeleton />
+ </Flexbox>
+);
+
+/** Section title row: 16px title (25px line) with an optional Segmented on the right. */
+const SectionTitleSkeleton = ({ segmented, width }: { segmented?: boolean; width: number }) => (
+ <Flexbox
+ horizontal
+ align={'center'}
+ justify={'space-between'}
+ style={{ minHeight: segmented ? 40 : 25 }}
+ >
+ <SkeletonBar height={16} width={width} />
+ {segmented && <SkeletonBar height={40} radius={cssVar.borderRadiusLG} width={124} />}
+ </Flexbox>
+);
+
+/**
+ * Body of `/agent/:aid/statistics` (`features/AgentUsage`): three outlined
+ * blocks in the 960px column — controls + stat cards, the usage-trend chart
+ * (title + Spend/Token Segmented over a 320px chart), and the per-model
+ * breakdown table.
+ */
+export const AgentStatisticsBodySkeleton = () => (
+ <Flexbox aria-busy gap={16} paddingBlock={16}>
+ <Block gap={16} padding={20} variant={'outlined'}>
+ <Flexbox horizontal align={'center'} gap={16} justify={'space-between'} wrap={'wrap'}>
+ <LabelledSegmentedSkeleton labelWidth={26} segmentedWidth={100} />
+ <LabelledSegmentedSkeleton labelWidth={52} segmentedWidth={136} />
+ </Flexbox>
+ <AgentStatCardsSkeleton />
+ </Block>
+ <Block gap={16} padding={20} variant={'outlined'}>
+ <SectionTitleSkeleton segmented width={112} />
+ <Skeleton height={320} />
+ </Block>
+ <Block gap={16} padding={20} variant={'outlined'}>
+ <SectionTitleSkeleton width={80} />
+ <AgentModelBreakdownTableSkeleton />
+ </Block>
+ </Flexbox>
+);
+
+/** Route-level skeleton for `/agent/:aid/statistics` (see `agentStatisticsRouteMeta`). */
+const AgentStatisticsSkeleton = ({ chrome = 'page' }: RouteSkeletonProps) => (
+ <Flexbox aria-busy flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
+ {chrome !== 'body' && <AgentProfileNavSkeleton />}
+ <Flexbox flex={1} style={{ minHeight: 0, overflow: 'hidden' }}>
+ <WideScreenContainer>
+ <AgentStatisticsBodySkeleton />
+ </WideScreenContainer>
+ </Flexbox>
+ </Flexbox>
+);
+
+export default AgentStatisticsSkeleton;
diff --git a/src/components/Skeleton/AgentViewAll.test.ts b/src/components/Skeleton/AgentViewAll.test.ts
new file mode 100644
index 00000000000..ac5f39185d8
--- /dev/null
+++ b/src/components/Skeleton/AgentViewAll.test.ts
@@ -0,0 +1,44 @@
+// @vitest-environment happy-dom
+import { act, createElement } from 'react';
+import { createRoot } from 'react-dom/client';
+import { afterEach, describe, expect, it } from 'vitest';
+
+import { useGlobalStore } from '@/store/global';
+
+import AgentViewAllSkeleton from './AgentViewAll';
+
+const setCollapsed = (collapsed: boolean) =>
+ useGlobalStore.setState((s) => ({
+ status: { ...s.status, agentListSidebarSectionCollapsed: collapsed },
+ }));
+
+const render = () => {
+ const container = document.createElement('div');
+ const root = createRoot(container);
+ act(() => root.render(createElement(AgentViewAllSkeleton)));
+ const count = (testId: string) => container.querySelectorAll(`[data-testid="${testId}"]`).length;
+ return { count, unmount: () => act(() => root.unmount()) };
+};
+
+describe('AgentViewAllSkeleton', () => {
+ afterEach(() => setCollapsed(false));
+
+ // The loaded page puts the "In sidebar" block above the toolbar; a skeleton
+ // without it dropped the toolbar and rows by the block's height on load.
+ it('reserves the expanded "In sidebar" block above the toolbar', () => {
+ const { count, unmount } = render();
+
+ expect(count('agent-view-all-sidebar-skeleton')).toBe(1);
+ expect(count('agent-view-all-sidebar-card-skeleton')).toBe(3);
+ unmount();
+ });
+
+ it('keeps only the block header when the block is collapsed', () => {
+ setCollapsed(true);
+ const { count, unmount } = render();
+
+ expect(count('agent-view-all-sidebar-skeleton')).toBe(1);
+ expect(count('agent-view-all-sidebar-card-skeleton')).toBe(0);
+ unmount();
+ });
+});
diff --git a/src/components/Skeleton/AgentViewAll.tsx b/src/components/Skeleton/AgentViewAll.tsx
new file mode 100644
index 00000000000..1960fcbf290
--- /dev/null
+++ b/src/components/Skeleton/AgentViewAll.tsx
@@ -0,0 +1,147 @@
+'use client';
+
+import { Block, Center, Flexbox } from '@lobehub/ui';
+import { createStaticStyles, cssVar, responsive } from 'antd-style';
+
+import WideScreenContainer from '@/features/WideScreenContainer';
+import type { RouteSkeletonProps } from '@/spa/router/routeMeta';
+import { useGlobalStore } from '@/store/global';
+import { systemStatusSelectors } from '@/store/global/selectors';
+
+import SkeletonBar from './Bar';
+
+/** Matches `ACTION_COL_WIDTH` in `features/AgentViewAll/AgentRow.tsx`. */
+const ACTION_COL_WIDTH = 64;
+
+const styles = createStaticStyles(({ css }) => ({
+ sidebarCard: css`
+ min-height: 72px;
+ padding-block: 10px;
+ padding-inline: 12px;
+ `,
+ sidebarGrid: css`
+ display: grid;
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ gap: 12px;
+
+ ${responsive.md} {
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ }
+
+ ${responsive.sm} {
+ grid-template-columns: minmax(0, 1fr);
+ }
+ `,
+ sidebarSection: css`
+ padding: 12px;
+ border-radius: ${cssVar.borderRadiusLG};
+ background: ${cssVar.colorFillQuaternary};
+ `,
+}));
+
+/**
+ * The "In sidebar" block (`features/AgentViewAll/SidebarAgentsSection.tsx`)
+ * that sits above the toolbar once the list loads whenever any agent shows in
+ * the sidebar — i.e. for almost every account. Without it the toolbar and rows
+ * dropped by the block's height on load. Honors the persisted collapsed state;
+ * an expanded block reserves one row of mini cards (the item count is unknown
+ * until the list arrives).
+ */
+export const AgentViewAllSidebarSectionSkeleton = () => {
+ const collapsed = useGlobalStore(systemStatusSelectors.agentListSidebarSectionCollapsed);
+
+ return (
+ <Flexbox
+ className={styles.sidebarSection}
+ data-testid={'agent-view-all-sidebar-skeleton'}
+ gap={12}
+ >
+ <Flexbox horizontal align={'center'} height={20} justify={'space-between'}>
+ <SkeletonBar height={13} width={72} />
+ <SkeletonBar height={12} width={40} />
+ </Flexbox>
+ {!collapsed && (
+ <div className={styles.sidebarGrid}>
+ {[0, 1, 2].map((key) => (
+ <Block
+ className={styles.sidebarCard}
+ data-testid={'agent-view-all-sidebar-card-skeleton'}
+ key={key}
+ variant={'outlined'}
+ >
+ <Flexbox horizontal align={'center'} flex={1} gap={8}>
+ <SkeletonBar height={24} width={24} />
+ <SkeletonBar height={14} width={`${36 + key * 12}%`} />
+ </Flexbox>
+ </Block>
+ ))}
+ </div>
+ )}
+ </Flexbox>
+ );
+};
+
+/**
+ * Dense `AgentRow`s of the default list view (`agentListViewMode: 'list'`,
+ * `groupBy: 'none'`): padding 8/12, 28px square avatar + 14px name, then the
+ * right-aligned 88px update-time column and the 64px eye / "…" action column.
+ * Also the page's own loading state while the agent list initialises.
+ */
+export const AgentViewAllRowsSkeleton = ({ rows = 8 }: { rows?: number }) => (
+ <Flexbox aria-busy gap={2}>
+ {Array.from({ length: rows }).map((_, index) => (
+ <Flexbox horizontal align={'center'} gap={12} key={index} paddingBlock={8} paddingInline={12}>
+ <Flexbox horizontal align={'center'} flex={1} gap={12} style={{ minWidth: 0 }}>
+ <SkeletonBar height={28} width={28} />
+ <SkeletonBar height={14} width={`${18 + (index % 4) * 6}%`} />
+ </Flexbox>
+ <Flexbox align={'flex-end'} flex={'none'} style={{ minWidth: 88 }}>
+ <SkeletonBar height={12} width={56} />
+ </Flexbox>
+ <Flexbox horizontal align={'center'} flex={'none'} gap={4} width={ACTION_COL_WIDTH}>
+ {[0, 1].map((key) => (
+ <Center height={24} key={key} width={24}>
+ <SkeletonBar height={14} width={14} />
+ </Center>
+ ))}
+ </Flexbox>
+ </Flexbox>
+ ))}
+ </Flexbox>
+);
+
+/**
+ * Route-level skeleton for `/agents` (`features/AgentViewAll/AgentViewAllPage.tsx`):
+ * the 44px header (title left, list-config icon right), then the 960px column
+ * with the "In sidebar" block and the toolbar (240px-max search left, split
+ * create button right) over the default list view's rows.
+ */
+const AgentViewAllSkeleton = ({ chrome = 'page' }: RouteSkeletonProps) => (
+ <Flexbox aria-busy flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
+ {chrome !== 'body' && (
+ <Flexbox
+ horizontal
+ align={'center'}
+ flex={'none'}
+ height={44}
+ justify={'space-between'}
+ padding={8}
+ >
+ <Flexbox style={{ paddingInlineStart: 4 }}>
+ <SkeletonBar height={14} width={48} />
+ </Flexbox>
+ <SkeletonBar height={28} width={28} />
+ </Flexbox>
+ )}
+ <WideScreenContainer gap={16} paddingBlock={16}>
+ <AgentViewAllSidebarSectionSkeleton />
+ <Flexbox horizontal align={'center'} gap={12} justify={'space-between'}>
+ <SkeletonBar height={32} width={206} />
+ <SkeletonBar height={32} width={64} />
+ </Flexbox>
+ <AgentViewAllRowsSkeleton />
+ </WideScreenContainer>
+ </Flexbox>
+);
+
+export default AgentViewAllSkeleton;
diff --git a/src/components/Skeleton/Settings/Page.test.ts b/src/components/Skeleton/Settings/Page.test.ts
index 2e07ba6828a..a144d520b25 100644
--- a/src/components/Skeleton/Settings/Page.test.ts
+++ b/src/components/Skeleton/Settings/Page.test.ts
@@ -15,6 +15,16 @@ describe('resolveSettingsSkeletonBody', () => {
expect(resolveSettingsSkeletonBody('/settings/common')).toEqual({ kind: 'section' });
});
+ it('uses a per-tab sections shape for tabs that are not plain forms', () => {
+ for (const tab of ['billing', 'credits', 'plans', 'referral', 'usage']) {
+ expect(resolveSettingsSkeletonBody(`/settings/${tab}`)).toEqual({ kind: 'sections', tab });
+ }
+ });
+
+ it('ignores inherited object keys when looking up a tab shape', () => {
+ expect(resolveSettingsSkeletonBody('/settings/toString')).toEqual({ kind: 'section' });
+ });
+
it('uses the profile shape for the default tab', () => {
expect(resolveSettingsSkeletonBody('/settings')).toEqual({ kind: 'profile' });
expect(resolveSettingsSkeletonBody('/settings/profile')).toEqual({ kind: 'profile' });
diff --git a/src/components/Skeleton/Settings/Page.tsx b/src/components/Skeleton/Settings/Page.tsx
index 1ad1c1389ed..158c9b6a30c 100644
--- a/src/components/Skeleton/Settings/Page.tsx
+++ b/src/components/Skeleton/Settings/Page.tsx
@@ -11,15 +11,21 @@ import SkeletonBar from '../Bar';
import { MessengerPlatformDetailSkeleton } from './MessengerDetail';
import SettingsProfileSkeleton from './Profile';
import SettingsSectionSkeleton from './Section';
+import { SettingsSectionsBody } from './Sections';
+import { SETTINGS_SECTION_SHAPES } from './sectionShapes';
type SettingsSkeletonBody =
- { kind: 'messengerDetail'; platform: string } | { kind: 'profile' } | { kind: 'section' };
+ | { kind: 'messengerDetail'; platform: string }
+ | { kind: 'profile' }
+ | { kind: 'section' }
+ | { kind: 'sections'; tab: string };
export const resolveSettingsSkeletonBody = (pathname: string): SettingsSkeletonBody => {
const [, tab = 'profile', sub] = pathname.match(/\/settings\/([^/]+)(?:\/([^/]+))?/) ?? [];
if (tab === 'profile') return { kind: 'profile' };
if (tab === 'messenger' && sub) return { kind: 'messengerDetail', platform: sub };
+ if (Object.hasOwn(SETTINGS_SECTION_SHAPES, tab)) return { kind: 'sections', tab };
return { kind: 'section' };
};
@@ -29,6 +35,8 @@ export const SettingsBodySkeleton = () => {
if (body.kind === 'profile') return <SettingsProfileSkeleton />;
if (body.kind === 'messengerDetail')
return <MessengerPlatformDetailSkeleton platform={body.platform} />;
+ if (body.kind === 'sections')
+ return <SettingsSectionsBody shape={SETTINGS_SECTION_SHAPES[body.tab]} />;
return <SettingsSectionSkeleton />;
};
diff --git a/src/components/Skeleton/Settings/Section.tsx b/src/components/Skeleton/Settings/Section.tsx
index 35841961094..1c2cbc6bc1e 100644
--- a/src/components/Skeleton/Settings/Section.tsx
+++ b/src/components/Skeleton/Settings/Section.tsx
@@ -12,6 +12,13 @@ const styles = createStaticStyles(({ css }) => ({
height: 1px;
background: ${cssVar.colorBorderSecondary};
`,
+ // A loaded settings form renders its fields flush in the group body (each field
+ // pads itself), while a bare `Form.Group` pads the body by 16px on both ends.
+ group: css`
+ & > :last-child {
+ padding-block: 0;
+ }
+ `,
row: css`
display: flex;
gap: 24px;
@@ -23,37 +30,105 @@ const styles = createStaticStyles(({ css }) => ({
`,
}));
-const Row = ({ index }: { index: number }) => (
+export interface SettingsSectionSkeletonControl {
+ height: number;
+ width: number;
+}
+
+const Row = ({
+ control,
+ index,
+ withDesc,
+}: {
+ control?: SettingsSectionSkeletonControl;
+ index: number;
+ withDesc: boolean;
+}) => (
<div className={styles.row}>
- <Flexbox gap={8}>
- <SkeletonBar height={16} width={112 + (index % 2) * 40} />
- <SkeletonBar height={12} width={224 + (index % 3) * 36} />
+ {/* Line boxes match the loaded label (14px / 22px) and description (12px / 13px) stack. */}
+ <Flexbox gap={4}>
+ <Flexbox height={22} justify={'center'}>
+ <SkeletonBar height={16} width={112 + (index % 2) * 40} />
+ </Flexbox>
+ {withDesc && (
+ <Flexbox height={13} justify={'center'}>
+ <SkeletonBar height={12} width={224 + (index % 3) * 36} />
+ </Flexbox>
+ )}
</Flexbox>
- <SkeletonBar height={32} width={index % 2 ? 152 : 88} />
+ <SkeletonBar
+ height={control?.height ?? 32}
+ radius={control ? cssVar.borderRadiusLG : undefined}
+ width={control?.width ?? (index % 2 ? 152 : 88)}
+ />
</div>
);
-const Group = ({ rows, titleWidth }: { rows: number; titleWidth: number }) => (
+export interface SettingsSectionSkeletonGroup {
+ /** Control size for every row without an entry in `controls` (default 32px tall). */
+ control?: SettingsSectionSkeletonControl;
+ /**
+ * Control size overrides keyed by row index, for fields taller than a 32px input
+ * (e.g. an image picker). The row grows with the control, as the loaded row does.
+ */
+ controls?: Record<number, SettingsSectionSkeletonControl>;
+ /** Number of form rows, ideally the real group's field count. */
+ rows: number;
+ /** Width of the group title bar, close to the real title's rendered width. */
+ titleWidth?: number;
+ /** Render the description line under each label. Hotkey-style forms have none. */
+ withDesc?: boolean;
+}
+
+const DEFAULT_GROUPS: SettingsSectionSkeletonGroup[] = [
+ { rows: 2, titleWidth: 104 },
+ { rows: 3, titleWidth: 136 },
+];
+
+const Group = ({
+ control,
+ controls,
+ rows,
+ titleWidth = 120,
+ withDesc = true,
+}: SettingsSectionSkeletonGroup) => (
<Form.Group
+ className={styles.group}
collapsible={false}
- title={<SkeletonBar height={18} width={titleWidth} />}
variant={'filled'}
+ title={
+ // The loaded 16px bold title sits in a 25px line box.
+ <Flexbox height={25} justify={'center'}>
+ <SkeletonBar height={18} width={titleWidth} />
+ </Flexbox>
+ }
>
<Flexbox>
{Array.from({ length: rows }).map((_, index) => (
<Flexbox key={index}>
{index > 0 && <div className={styles.divider} />}
- <Row index={index} />
+ <Row control={controls?.[index] ?? control} index={index} withDesc={withDesc} />
</Flexbox>
))}
</Flexbox>
</Form.Group>
);
-const SettingsSectionSkeleton = () => (
+export interface SettingsSectionSkeletonProps {
+ /** One entry per `Form.Group` in the loaded form. Defaults to a 2-row + 3-row pair. */
+ groups?: SettingsSectionSkeletonGroup[];
+}
+
+/**
+ * Loading stand-in for a settings `Form` rendered with `itemsType="group"` and
+ * `variant="filled"`: same filled group chrome, one label/description/control row
+ * per field, so the real form swaps in without relayout.
+ */
+const SettingsSectionSkeleton = ({ groups = DEFAULT_GROUPS }: SettingsSectionSkeletonProps) => (
<Flexbox aria-busy data-testid={'settings-section-skeleton'} gap={36}>
- <Group rows={2} titleWidth={104} />
- <Group rows={3} titleWidth={136} />
+ {groups.map((group, index) => (
+ <Group key={index} {...group} />
+ ))}
</Flexbox>
);
diff --git a/src/components/Skeleton/Settings/Sections.tsx b/src/components/Skeleton/Settings/Sections.tsx
new file mode 100644
index 00000000000..afe0ccccd16
--- /dev/null
+++ b/src/components/Skeleton/Settings/Sections.tsx
@@ -0,0 +1,566 @@
+'use client';
+
+import { Flexbox } from '@lobehub/ui';
+import { Form } from '@lobehub/ui/base-ui/form';
+import { createStaticStyles, cssVar } from 'antd-style';
+import type { ComponentType, ReactNode } from 'react';
+
+import NavHeader from '@/features/NavHeader';
+import SettingContainer from '@/features/Setting/SettingContainer';
+import type { RouteSkeletonProps } from '@/spa/router/routeMeta';
+
+import SkeletonBar from '../Bar';
+
+/** Shared head options of every section rendered as a filled `Form.Group`. */
+interface GroupHeadOptions {
+ /** The real group shows a description line under its title. */
+ desc?: boolean;
+ /** The real group shows an action button on the right of its head. */
+ extra?: boolean;
+ titleWidth?: number;
+}
+
+/**
+ * One block of a settings page. Every variant except `cards` (ungrouped) and
+ * `banner` is a filled `Form.Group`, so the skeleton reuses the real group
+ * chrome and only the contents are placeholders.
+ */
+export type SettingsSectionSkeleton =
+ | (GroupHeadOptions & {
+ /** One full-width input with a trailing button instead of labelled rows. */
+ field?: boolean;
+ /** Label + description on the left, control on the right. */
+ rows?: number;
+ variant: 'form';
+ })
+ | (GroupHeadOptions & {
+ /** Table rows below the header row. */
+ rows?: number;
+ /** A filter / search bar above the table. */
+ toolbar?: boolean;
+ /** A tab strip above the table. */
+ tabs?: boolean;
+ variant: 'table';
+ })
+ | (GroupHeadOptions & {
+ columns?: number;
+ /** Height of one tile; defaults to a two-line tile. */
+ tileHeight?: number;
+ /** Compact label + value tiles laid out edge to edge. */
+ tiles?: number;
+ variant: 'tiles';
+ })
+ | (GroupHeadOptions & {
+ /** A media block on the right of the figures, e.g. an illustrated card. */
+ aside?: { height: number; width: number };
+ /** A second label/value pair plus a divider and a link row below the figure. */
+ secondary?: boolean;
+ /** Label, one large figure and a caption line. */
+ variant: 'summary';
+ })
+ | (GroupHeadOptions & {
+ /** Icon + title header followed by a checklist. */
+ lines?: number;
+ variant: 'detail';
+ })
+ | (GroupHeadOptions & {
+ cards?: number;
+ columns?: number;
+ /** Key/value lines, a note block and a total + action row below the grid. */
+ footer?: boolean;
+ gap?: number;
+ /** Wrap the grid in a titled filled group; otherwise the cards stand alone. */
+ grouped?: boolean;
+ /** `large` cards carry icon, title, figure, button and a checklist. */
+ size?: 'large' | 'small';
+ /** A centred segmented control above the grid, and its gap to the grid. */
+ toolbar?: { gap: number; height: number; width: number };
+ variant: 'cards';
+ })
+ | {
+ /** An outlined block with an avatar and two text lines. */
+ variant: 'banner';
+ };
+
+export interface SettingsSectionsShape {
+ /** Vertical gap between sections, as set by the real page's stack. */
+ gap?: number;
+ sections: SettingsSectionSkeleton[];
+ /** The page draws its own large title + divider above the sections. */
+ title?: boolean;
+}
+
+/**
+ * Where the skeleton sits when the route has no layout chrome around it
+ * (`chrome='page'`). Under `chrome='body'` the host layout already draws its
+ * header and padded container, so only the sections render.
+ *
+ * - `header`: navigation header above a padded, centred 1024px container.
+ * - `container`: padded, centred container only (the page draws its own title).
+ * - `none`: the sections alone.
+ */
+export type SettingsSectionsFrame = 'container' | 'header' | 'none';
+
+const styles = createStaticStyles(({ css }) => ({
+ banner: css`
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: ${cssVar.borderRadiusLG};
+ `,
+ card: css`
+ overflow: hidden;
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: ${cssVar.borderRadiusLG};
+ `,
+ divider: css`
+ width: 100%;
+ height: 1px;
+ background: ${cssVar.colorBorderSecondary};
+ `,
+ flush: css`
+ overflow: hidden;
+
+ [data-form-group-body] {
+ padding: 0;
+ }
+ `,
+ grid: css`
+ display: grid;
+ `,
+ tile: css`
+ border-block-end: 1px solid ${cssVar.colorBorderSecondary};
+ border-inline-end: 1px solid ${cssVar.colorBorderSecondary};
+ `,
+}));
+
+const widthAt = (index: number, widths: number[]) => widths[index % widths.length];
+
+/** Matches the 16px/25px title line of a filled group head. */
+const GroupTitle = ({ width = 104 }: { width?: number }) => (
+ <Flexbox height={25} justify={'center'}>
+ <SkeletonBar height={16} width={width} />
+ </Flexbox>
+);
+
+/** Matches the 12px/19px description line of a group head. */
+const GroupDesc = () => (
+ <Flexbox height={19} justify={'center'}>
+ <SkeletonBar height={12} width={220} />
+ </Flexbox>
+);
+
+const Group = ({
+ children,
+ desc,
+ extra,
+ flush,
+ titleWidth,
+}: GroupHeadOptions & { children: ReactNode; flush?: boolean }) => (
+ <Form.Group
+ className={flush ? styles.flush : undefined}
+ collapsible={false}
+ desc={desc ? <GroupDesc /> : undefined}
+ extra={extra ? <SkeletonBar height={32} width={120} /> : undefined}
+ title={<GroupTitle width={titleWidth} />}
+ variant={'filled'}
+ >
+ {children}
+ </Form.Group>
+);
+
+const FormRows = ({ rows }: { rows: number }) => (
+ <Flexbox>
+ {Array.from({ length: rows }).map((_, index) => (
+ <Flexbox key={index}>
+ {index > 0 && <div className={styles.divider} />}
+ <Flexbox
+ horizontal
+ align={'center'}
+ gap={24}
+ justify={'space-between'}
+ style={{ minHeight: 64, paddingBlock: 16 }}
+ >
+ <Flexbox gap={8}>
+ <SkeletonBar height={16} width={widthAt(index, [112, 152])} />
+ <SkeletonBar height={12} width={widthAt(index, [224, 260, 296])} />
+ </Flexbox>
+ <SkeletonBar height={32} width={widthAt(index, [88, 152])} />
+ </Flexbox>
+ </Flexbox>
+ ))}
+ </Flexbox>
+);
+
+const TABLE_COLUMNS = [18, 12, 14, 16, 12];
+
+const TableBody = ({
+ rows,
+ tabs,
+ toolbar,
+}: {
+ rows: number;
+ tabs?: boolean;
+ toolbar?: boolean;
+}) => (
+ <Flexbox>
+ {tabs && (
+ <Flexbox horizontal align={'center'} gap={24} height={48} paddingInline={16}>
+ <SkeletonBar height={14} width={64} />
+ <SkeletonBar height={14} width={72} />
+ <SkeletonBar height={14} width={64} />
+ </Flexbox>
+ )}
+ {toolbar && (
+ <Flexbox horizontal align={'center'} gap={8} height={61} paddingInline={16}>
+ <Flexbox flex={2}>
+ <SkeletonBar height={32} />
+ </Flexbox>
+ <Flexbox flex={1}>
+ <SkeletonBar height={32} />
+ </Flexbox>
+ <Flexbox flex={1.5}>
+ <SkeletonBar height={32} />
+ </Flexbox>
+ <SkeletonBar height={32} width={72} />
+ </Flexbox>
+ )}
+ <Flexbox horizontal align={'center'} gap={24} height={40} paddingInline={16}>
+ {TABLE_COLUMNS.map((flex, index) => (
+ <Flexbox flex={flex} key={index}>
+ <SkeletonBar height={12} width={'48%'} />
+ </Flexbox>
+ ))}
+ </Flexbox>
+ {Array.from({ length: rows }).map((_, row) => (
+ <Flexbox key={row}>
+ <div className={styles.divider} />
+ <Flexbox horizontal align={'center'} gap={24} height={52} paddingInline={16}>
+ {TABLE_COLUMNS.map((flex, index) => (
+ <Flexbox flex={flex} key={index}>
+ <SkeletonBar height={14} width={`${56 + ((row + index) % 3) * 14}%`} />
+ </Flexbox>
+ ))}
+ </Flexbox>
+ </Flexbox>
+ ))}
+ </Flexbox>
+);
+
+const Field = () => (
+ <Flexbox horizontal align={'center'} gap={8}>
+ <Flexbox flex={1}>
+ <SkeletonBar height={38} />
+ </Flexbox>
+ <SkeletonBar height={38} width={88} />
+ </Flexbox>
+);
+
+const Tiles = ({
+ columns,
+ tileHeight,
+ tiles,
+}: {
+ columns: number;
+ tileHeight: number;
+ tiles: number;
+}) => (
+ <div
+ className={styles.grid}
+ style={{ gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))` }}
+ >
+ {Array.from({ length: tiles }).map((_, index) => (
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={styles.tile}
+ gap={12}
+ height={tileHeight}
+ justify={'space-between'}
+ key={index}
+ paddingInline={12}
+ >
+ <Flexbox gap={8}>
+ <SkeletonBar height={14} width={widthAt(index, [56, 72, 64])} />
+ <SkeletonBar height={14} width={widthAt(index, [160, 96, 136])} />
+ </Flexbox>
+ <SkeletonBar height={26} radius={'50%'} width={26} />
+ </Flexbox>
+ ))}
+ </div>
+);
+
+const Summary = ({
+ aside,
+ secondary,
+}: {
+ aside?: { height: number; width: number };
+ secondary?: boolean;
+}) => {
+ const figures = secondary ? (
+ <Flexbox flex={1} gap={16}>
+ <SkeletonBar height={16} width={96} />
+ <SkeletonBar height={28} width={48} />
+ <SkeletonBar height={16} width={72} />
+ <SkeletonBar height={20} width={'56%'} />
+ <div className={styles.divider} />
+ <SkeletonBar height={20} width={200} />
+ </Flexbox>
+ ) : (
+ <Flexbox flex={1} gap={19}>
+ <SkeletonBar height={16} width={120} />
+ <SkeletonBar height={36} width={200} />
+ <SkeletonBar height={12} width={'42%'} />
+ </Flexbox>
+ );
+
+ if (!aside) return figures;
+ return (
+ <Flexbox horizontal gap={16}>
+ {figures}
+ <SkeletonBar height={aside.height} radius={cssVar.borderRadiusLG} width={aside.width} />
+ </Flexbox>
+ );
+};
+
+const Checklist = ({ lines }: { lines: number }) => (
+ <Flexbox>
+ {Array.from({ length: lines }).map((_, index) => (
+ <Flexbox horizontal align={'center'} gap={10} height={25} key={index}>
+ <SkeletonBar height={12} width={12} />
+ <SkeletonBar height={14} width={widthAt(index, [180, 132, 220, 156])} />
+ </Flexbox>
+ ))}
+ </Flexbox>
+);
+
+const Detail = ({ lines }: { lines: number }) => (
+ <Flexbox gap={19}>
+ <Flexbox horizontal align={'center'} gap={12}>
+ <SkeletonBar height={40} radius={cssVar.borderRadiusLG} width={40} />
+ <Flexbox gap={6}>
+ <SkeletonBar height={16} width={96} />
+ <SkeletonBar height={12} width={200} />
+ </Flexbox>
+ </Flexbox>
+ <div className={styles.divider} />
+ <Checklist lines={lines} />
+ </Flexbox>
+);
+
+const Card = ({ size }: { size: 'large' | 'small' }) =>
+ size === 'large' ? (
+ <Flexbox className={styles.card} gap={16} height={720} padding={16}>
+ <SkeletonBar height={36} radius={cssVar.borderRadiusLG} width={36} />
+ <Flexbox gap={10}>
+ <SkeletonBar height={18} width={72} />
+ <SkeletonBar height={14} width={'72%'} />
+ </Flexbox>
+ {/* Large figure then the full-width action, spaced like the loaded card. */}
+ <Flexbox gap={19} paddingBlock={'20px 15px'}>
+ <SkeletonBar height={32} width={128} />
+ <SkeletonBar height={32} />
+ </Flexbox>
+ <Checklist lines={12} />
+ </Flexbox>
+ ) : (
+ <Flexbox className={styles.card} gap={8} height={65} justify={'center'} paddingInline={12}>
+ <SkeletonBar height={18} width={48} />
+ <SkeletonBar height={12} width={64} />
+ </Flexbox>
+ );
+
+const CardsFooter = () => (
+ <Flexbox gap={16}>
+ <Flexbox>
+ {[96, 72, 64].map((width, index) => (
+ <Flexbox horizontal align={'center'} height={25} justify={'space-between'} key={index}>
+ <SkeletonBar height={12} width={width} />
+ <SkeletonBar height={12} width={56} />
+ </Flexbox>
+ ))}
+ </Flexbox>
+ <SkeletonBar height={56} radius={cssVar.borderRadiusLG} />
+ <div className={styles.divider} />
+ <Flexbox horizontal align={'center'} justify={'space-between'}>
+ <SkeletonBar height={28} width={120} />
+ <SkeletonBar height={38} width={128} />
+ </Flexbox>
+ </Flexbox>
+);
+
+const CardGrid = ({
+ cards,
+ columns,
+ gap,
+ size,
+}: {
+ cards: number;
+ columns: number;
+ gap: number;
+ size: 'large' | 'small';
+}) => (
+ <div
+ className={styles.grid}
+ style={{ gap, gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))` }}
+ >
+ {Array.from({ length: cards }).map((_, index) => (
+ <Card key={index} size={size} />
+ ))}
+ </div>
+);
+
+const Section = ({ section }: { section: SettingsSectionSkeleton }) => {
+ switch (section.variant) {
+ case 'banner': {
+ return (
+ <Flexbox horizontal align={'center'} className={styles.banner} gap={16} padding={18}>
+ <SkeletonBar height={48} radius={'50%'} width={48} />
+ <Flexbox gap={10}>
+ <SkeletonBar height={18} width={240} />
+ <SkeletonBar height={12} width={360} />
+ </Flexbox>
+ </Flexbox>
+ );
+ }
+ case 'cards': {
+ const {
+ cards = 3,
+ columns = 3,
+ footer,
+ gap = 12,
+ grouped,
+ size = 'large',
+ toolbar,
+ } = section;
+ const grid = <CardGrid cards={cards} columns={columns} gap={gap} size={size} />;
+ if (grouped)
+ return (
+ <Group {...section}>
+ <Flexbox gap={16}>
+ {grid}
+ {footer && <CardsFooter />}
+ </Flexbox>
+ </Group>
+ );
+ return (
+ <Flexbox gap={toolbar?.gap ?? 0}>
+ {toolbar && (
+ <Flexbox align={'center'}>
+ <SkeletonBar
+ height={toolbar.height}
+ radius={cssVar.borderRadiusLG}
+ width={toolbar.width}
+ />
+ </Flexbox>
+ )}
+ {grid}
+ </Flexbox>
+ );
+ }
+ case 'detail': {
+ return (
+ <Group {...section}>
+ <Detail lines={section.lines ?? 8} />
+ </Group>
+ );
+ }
+ case 'form': {
+ return (
+ <Group {...section}>
+ {section.field ? <Field /> : <FormRows rows={section.rows ?? 2} />}
+ </Group>
+ );
+ }
+ case 'summary': {
+ return (
+ <Group {...section}>
+ <Summary aside={section.aside} secondary={section.secondary} />
+ </Group>
+ );
+ }
+ case 'table': {
+ return (
+ <Group {...section} flush>
+ <TableBody rows={section.rows ?? 3} tabs={section.tabs} toolbar={section.toolbar} />
+ </Group>
+ );
+ }
+ case 'tiles': {
+ return (
+ <Group {...section} flush>
+ <Tiles
+ columns={section.columns ?? 2}
+ tileHeight={section.tileHeight ?? 63}
+ tiles={section.tiles ?? 4}
+ />
+ </Group>
+ );
+ }
+ }
+};
+
+/** Large page title + divider, matching a settings page that renders its own heading. */
+const PageTitle = () => (
+ <Flexbox gap={24} style={{ paddingTop: 12 }}>
+ <Flexbox height={38} justify={'center'}>
+ <SkeletonBar height={28} width={96} />
+ </Flexbox>
+ <div className={styles.divider} />
+ </Flexbox>
+);
+
+/**
+ * The sections of a settings page without any surrounding chrome. Use it
+ * directly where a layout already draws the header and padded container.
+ */
+export const SettingsSectionsBody = ({ shape }: { shape: SettingsSectionsShape }) => (
+ <Flexbox aria-busy data-testid={'settings-sections-skeleton'} gap={shape.gap ?? 36}>
+ {shape.title && <PageTitle />}
+ {shape.sections.map((section, index) => (
+ <Section key={index} section={section} />
+ ))}
+ </Flexbox>
+);
+
+/**
+ * Route skeleton for a settings-style page made of stacked filled groups.
+ * Under `chrome='page'` it draws the frame named by `frame`; under
+ * `chrome='body'` the host layout owns that frame, so only the sections render.
+ */
+export const SettingsSectionsSkeleton = ({
+ chrome = 'page',
+ frame = 'header',
+ shape,
+}: RouteSkeletonProps & { frame?: SettingsSectionsFrame; shape: SettingsSectionsShape }) => {
+ const body = <SettingsSectionsBody shape={shape} />;
+ if (chrome === 'body' || frame === 'none') return body;
+
+ return (
+ <Flexbox aria-busy flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
+ {frame === 'header' && (
+ <NavHeader styles={{ center: { alignItems: 'center' } }}>
+ <SkeletonBar height={16} width={88} />
+ </NavHeader>
+ )}
+ <SettingContainer maxWidth={1024} paddingBlock={'24px 128px'} paddingInline={24}>
+ {body}
+ </SettingContainer>
+ </Flexbox>
+ );
+};
+
+/**
+ * Binds a shape and frame into a route `Skeleton` component. Call it once per
+ * route definition (module scope) so the component identity stays stable.
+ */
+export const createSettingsSectionsSkeleton = (
+ shape: SettingsSectionsShape,
+ frame: SettingsSectionsFrame = 'header',
+): ComponentType<RouteSkeletonProps> => {
+ const Component = ({ chrome }: RouteSkeletonProps) => (
+ <SettingsSectionsSkeleton chrome={chrome} frame={frame} shape={shape} />
+ );
+ Component.displayName = `SettingsSectionsSkeleton(${frame})`;
+ return Component;
+};
+
+export default SettingsSectionsSkeleton;
diff --git a/src/components/Skeleton/Settings/sectionShapes.ts b/src/components/Skeleton/Settings/sectionShapes.ts
new file mode 100644
index 00000000000..90b01039519
--- /dev/null
+++ b/src/components/Skeleton/Settings/sectionShapes.ts
@@ -0,0 +1,117 @@
+import type { SettingsSectionsShape } from './Sections';
+
+/**
+ * Per-tab section shapes for settings pages whose layout is not a plain form.
+ * Measured against the settled pages at a 1440px-wide window: filled group heads
+ * are 57px (76px with a description, 64px with an action button), sections are
+ * 36px apart, and the first section starts 24px below the navigation header.
+ * Rows below the first viewport are a plausible fill, not a promise.
+ */
+export const SETTINGS_SECTION_SHAPES: Record<string, SettingsSectionsShape> = {
+ billing: {
+ sections: [
+ { titleWidth: 72, variant: 'summary' },
+ { extra: true, lines: 13, titleWidth: 72, variant: 'detail' },
+ { rows: 1, titleWidth: 72, variant: 'table' },
+ ],
+ },
+ credits: {
+ sections: [
+ { aside: { height: 200, width: 350 }, secondary: true, titleWidth: 40, variant: 'summary' },
+ {
+ cards: 6,
+ columns: 3,
+ footer: true,
+ gap: 8,
+ grouped: true,
+ size: 'small',
+ titleWidth: 72,
+ variant: 'cards',
+ },
+ { desc: true, field: true, titleWidth: 112, variant: 'form' },
+ { desc: true, field: true, titleWidth: 72, variant: 'form' },
+ { tabs: true, rows: 2, titleWidth: 88, variant: 'table' },
+ ],
+ },
+ plans: {
+ sections: [
+ {
+ cards: 3,
+ columns: 3,
+ gap: 12,
+ toolbar: { gap: 24, height: 44, width: 304 },
+ variant: 'cards',
+ },
+ ],
+ },
+ referral: {
+ sections: [
+ { variant: 'banner' },
+ { desc: true, field: true, titleWidth: 104, variant: 'form' },
+ { desc: true, field: true, titleWidth: 88, variant: 'form' },
+ { columns: 4, desc: true, tileHeight: 95, tiles: 4, titleWidth: 72, variant: 'tiles' },
+ { rows: 1, titleWidth: 72, variant: 'table' },
+ ],
+ },
+ usage: {
+ sections: [
+ { columns: 2, tiles: 4, titleWidth: 40, variant: 'tiles' },
+ { rows: 4, titleWidth: 40, toolbar: true, variant: 'table' },
+ ],
+ },
+};
+
+/**
+ * Shapes for the same tabs inside the workspace settings content layout, whose
+ * pages stack sections 16px apart. That layout draws the navigation header and
+ * the padded container, so these render as bare bodies under it.
+ */
+export const WORKSPACE_SETTINGS_SECTION_SHAPES: Record<
+ 'billing' | 'budget' | 'credits' | 'plans' | 'usage',
+ SettingsSectionsShape
+> = {
+ billing: {
+ gap: 16,
+ sections: [
+ { titleWidth: 96, variant: 'summary' },
+ { rows: 2, titleWidth: 120, variant: 'form' },
+ { rows: 2, titleWidth: 96, variant: 'table' },
+ ],
+ },
+ budget: {
+ gap: 16,
+ sections: [
+ { desc: true, rows: 1, titleWidth: 120, variant: 'form' },
+ { desc: true, extra: true, rows: 2, titleWidth: 120, variant: 'form' },
+ { desc: true, rows: 3, titleWidth: 120, variant: 'table' },
+ ],
+ },
+ credits: {
+ gap: 16,
+ sections: [
+ { secondary: true, titleWidth: 72, variant: 'summary' },
+ { rows: 2, titleWidth: 96, variant: 'form' },
+ { desc: true, rows: 2, titleWidth: 96, variant: 'form' },
+ { tabs: true, rows: 2, titleWidth: 96, variant: 'table' },
+ ],
+ },
+ plans: {
+ gap: 24,
+ sections: [
+ {
+ cards: 3,
+ columns: 3,
+ gap: 16,
+ toolbar: { gap: 16, height: 44, width: 360 },
+ variant: 'cards',
+ },
+ ],
+ },
+ usage: {
+ gap: 16,
+ sections: [
+ { columns: 2, extra: true, tiles: 4, titleWidth: 72, variant: 'tiles' },
+ { rows: 5, titleWidth: 96, toolbar: true, variant: 'table' },
+ ],
+ },
+};
diff --git a/src/features/AgentUsage/ModelBreakdown.tsx b/src/features/AgentUsage/ModelBreakdown.tsx
index c9e72db7d4c..a51473d5777 100644
--- a/src/features/AgentUsage/ModelBreakdown.tsx
+++ b/src/features/AgentUsage/ModelBreakdown.tsx
@@ -6,6 +6,7 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { ModelIcon } from '@/components/LobeIcons';
+import { AgentModelBreakdownTableSkeleton } from '@/components/Skeleton/AgentStatistics';
import { type AgentUsageModelRow } from '@/types/usage/usageRecord';
import { formatNumber, formatUsageValue } from '@/utils/format';
@@ -62,14 +63,19 @@ const ModelBreakdown = memo<ModelBreakdownProps>(({ rows, isLoading }) => {
<Text fontSize={16} weight={500}>
{t('usageStats.breakdown.title')}
</Text>
- <Table<AgentUsageModelRow>
- columns={columns}
- dataSource={rows}
- loading={isLoading}
- pagination={false}
- rowKey={'id'}
- size={'middle'}
- />
+ {/* First load shows the route skeleton's table rows instead of a spinner over "No data". */}
+ {isLoading && rows.length === 0 ? (
+ <AgentModelBreakdownTableSkeleton />
+ ) : (
+ <Table<AgentUsageModelRow>
+ columns={columns}
+ dataSource={rows}
+ loading={isLoading}
+ pagination={false}
+ rowKey={'id'}
+ size={'middle'}
+ />
+ )}
</Block>
);
});
diff --git a/src/features/AgentUsage/StatCards.tsx b/src/features/AgentUsage/StatCards.tsx
index 7b98b9cee7d..3ed4fc203a0 100644
--- a/src/features/AgentUsage/StatCards.tsx
+++ b/src/features/AgentUsage/StatCards.tsx
@@ -6,6 +6,7 @@ import { cssVar } from 'antd-style';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
+import { AgentStatCardsSkeleton } from '@/components/Skeleton/AgentStatistics';
import StatisticCard from '@/components/StatisticCard';
import { type AgentUsageStats } from '@/types/usage/usageRecord';
import { formatNumber, formatUsageValue } from '@/utils/format';
@@ -26,10 +27,13 @@ const StatCards = memo<StatCardsProps>(({ summary, isLoading, rangeLabel }) => {
const { t } = useTranslation('spend');
const suffix = ` · ${rangeLabel}`;
+ // Same shape as the route skeleton, so the route → data wait hands over
+ // without the cards flashing `$0.00` behind a spinner.
+ if (isLoading) return <AgentStatCardsSkeleton />;
+
return (
<Grid gap={8} maxItemWidth={240} rows={3}>
<StatisticCard
- loading={isLoading}
title={t('usageStats.cards.cost') + suffix}
statistic={{
precision: 2,
@@ -38,7 +42,6 @@ const StatCards = memo<StatCardsProps>(({ summary, isLoading, rangeLabel }) => {
}}
/>
<StatisticCard
- loading={isLoading}
title={t('usageStats.cards.cacheSavings') + suffix}
statistic={{
description: desc(
@@ -54,7 +57,6 @@ const StatCards = memo<StatCardsProps>(({ summary, isLoading, rangeLabel }) => {
}}
/>
<StatisticCard
- loading={isLoading}
title={t('usageStats.cards.token') + suffix}
statistic={{
description: desc(
diff --git a/src/features/AgentViewAll/AgentViewAllPage.tsx b/src/features/AgentViewAll/AgentViewAllPage.tsx
index d0781654e36..b77e8a3892c 100644
--- a/src/features/AgentViewAll/AgentViewAllPage.tsx
+++ b/src/features/AgentViewAll/AgentViewAllPage.tsx
@@ -14,12 +14,15 @@ import { useSearchParams } from 'react-router';
import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';
import { useWorkspaceMembers } from '@/business/client/hooks/useWorkspaceMembers';
+import {
+ AgentViewAllRowsSkeleton,
+ AgentViewAllSidebarSectionSkeleton,
+} from '@/components/Skeleton/AgentViewAll';
import { useKeepSidebarGroupsListed } from '@/features/HomeSidebar/Body/Agent/List/useAgentList';
import { AgentModalProvider } from '@/features/HomeSidebar/Body/Agent/ModalProvider';
import { useSidebarItemVisibility } from '@/features/HomeSidebar/Body/Agent/useSidebarItemVisibility';
import { useCreateMenuItems } from '@/features/HomeSidebar/hooks';
import NavHeader from '@/features/NavHeader';
-import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import WideScreenContainer from '@/features/WideScreenContainer';
import { useFetchAgentLabels } from '@/hooks/useFetchAgentLabels';
import { useFetchAgentList } from '@/hooks/useFetchAgentList';
@@ -519,6 +522,7 @@ const AgentViewAllPage = memo(() => {
}
/>
<WideScreenContainer gap={16} paddingBlock={16} wrapperStyle={{ flex: 1, overflowY: 'auto' }}>
+ {!isInit && !keyword.trim() && <AgentViewAllSidebarSectionSkeleton />}
{isInit && !keyword.trim() && sidebarItems.length > 0 && (
<SidebarAgentsSection items={sidebarItems} onToggleSidebar={handleToggleSidebar} />
)}
@@ -585,7 +589,7 @@ const AgentViewAllPage = memo(() => {
</Flexbox>
</Flexbox>
{!isInit ? (
- <SkeletonList rows={8} />
+ <AgentViewAllRowsSkeleton />
) : filteredItems.length === 0 ? (
<Center flex={1} padding={40}>
<Empty
diff --git a/src/features/AgentViewAll/routeMeta.ts b/src/features/AgentViewAll/routeMeta.ts
index 80ddc8fbc70..45ed7054058 100644
--- a/src/features/AgentViewAll/routeMeta.ts
+++ b/src/features/AgentViewAll/routeMeta.ts
@@ -1,10 +1,10 @@
import { BotIcon } from 'lucide-react';
-import { createSurfaceSkeleton } from '@/components/Skeleton/Surface';
+import AgentViewAllSkeleton from '@/components/Skeleton/AgentViewAll';
import { routeMeta } from '@/spa/router/routeMeta';
export const agentsRouteMeta = routeMeta({
icon: BotIcon,
- Skeleton: createSurfaceSkeleton('grid'),
+ Skeleton: AgentViewAllSkeleton,
titleKey: 'navigation.agents',
});
diff --git a/src/features/ChatInput/ActionBar/AgentMode/index.tsx b/src/features/ChatInput/ActionBar/AgentMode/index.tsx
index 3f320bb30cc..38371f66230 100644
--- a/src/features/ChatInput/ActionBar/AgentMode/index.tsx
+++ b/src/features/ChatInput/ActionBar/AgentMode/index.tsx
@@ -13,6 +13,7 @@ import { memo, useCallback, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useBusinessAgentModeSync } from '@/business/client/hooks/useBusinessAgentMode';
+import { SkeletonBar } from '@/components/Skeleton';
import { useAgentId } from '@/features/ChatInput/hooks/useAgentId';
import { useChatInputResourceAccess } from '@/features/ChatInput/hooks/useChatInputResourceAccess';
import { useEffectiveAgentMode } from '@/features/ChatInput/hooks/useEffectiveAgentMode';
@@ -249,7 +250,9 @@ const AgentMode = memo(() => {
</div>
);
- if (isAccessLoading || isPreferenceLoading) return null;
+ // Hold the 28px pill's footprint so the action bar does not shift when it resolves.
+ if (isAccessLoading || isPreferenceLoading)
+ return <SkeletonBar height={28} radius={999} width={84} />;
if (disabled)
return (
diff --git a/src/features/ChatInput/ControlBar/HeteroControlBar/index.tsx b/src/features/ChatInput/ControlBar/HeteroControlBar/index.tsx
index eeec09e61ea..cf4be9c5e64 100644
--- a/src/features/ChatInput/ControlBar/HeteroControlBar/index.tsx
+++ b/src/features/ChatInput/ControlBar/HeteroControlBar/index.tsx
@@ -7,13 +7,13 @@ import {
useWatchBroadcast,
} from '@lobechat/electron-client-ipc';
import { Flexbox, Icon, Tooltip } from '@lobehub/ui';
-import { Skeleton } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar, cx } from 'antd-style';
import { ActivityIcon, CircleAlertIcon, RadioTowerIcon, TimerResetIcon } from 'lucide-react';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import ChatInputCredits from '@/business/client/features/ChatInputCredits';
+import { SkeletonBar } from '@/components/Skeleton';
import DeviceSwitcher from '@/features/ChatInput/ControlBar/DeviceSwitcher';
import WorkspaceControls from '@/features/ChatInput/ControlBar/WorkspaceControls';
import { useAgentId } from '@/features/ChatInput/hooks/useAgentId';
@@ -127,6 +127,26 @@ const visibleSdkRuntimeStates = new Set<HeterogeneousAgentRuntimeState>([
'error',
]);
+/**
+ * Same 28px row as the loaded bar: the workspace / device chip on the left and,
+ * on desktop once config is known, the full-access badge on the right. Keeps the
+ * composer from jumping while access or agent config resolve.
+ */
+const HeteroControlBarSkeleton = ({ showRight }: { showRight?: boolean }) => (
+ <Flexbox
+ aria-busy
+ horizontal
+ align={'center'}
+ className={styles.bar}
+ data-testid={'hetero-control-bar-skeleton'}
+ gap={4}
+ justify={'space-between'}
+ >
+ <SkeletonBar height={22} radius={4} width={100} />
+ {showRight && <SkeletonBar height={22} radius={4} width={80} />}
+ </Flexbox>
+);
+
const HeteroControlBar = memo(() => {
const { t: tChat } = useTranslation('chat');
const agentId = useAgentId();
@@ -176,12 +196,12 @@ const HeteroControlBar = memo(() => {
heteroProvider?.type === 'kimi-code' &&
(isLocalHeteroExecution || !!quotaDeviceId);
- if (isAccessLoading) return null;
+ if (isAccessLoading) return <HeteroControlBarSkeleton />;
// A can-use collaborator may choose only their execution device; working
// directory, git, provider quota and runtime details remain author/editor config.
if (!canConfigureResource) {
- if (!agentId || isLoading) return null;
+ if (!agentId || isLoading) return <HeteroControlBarSkeleton />;
return (
<Flexbox horizontal align={'center'} className={styles.bar} justify={'space-between'}>
<DeviceSwitcher agentId={agentId} />
@@ -227,14 +247,7 @@ const HeteroControlBar = memo(() => {
);
}
- if (!agentId || isLoading) {
- return (
- <Flexbox horizontal align={'center'} className={styles.bar} gap={4} justify={'space-between'}>
- <Skeleton style={{ height: 22, minWidth: 100, width: 100 }} />
- <Skeleton style={{ height: 22, minWidth: 80, width: 80 }} />
- </Flexbox>
- );
- }
+ if (!agentId || isLoading) return <HeteroControlBarSkeleton showRight />;
const fullAccessBadge = (
<div className={styles.fullAccess}>
diff --git a/src/features/ChatInput/ControlBar/ModeSelector.tsx b/src/features/ChatInput/ControlBar/ModeSelector.tsx
index 4ec2d96a161..4a2777722d5 100644
--- a/src/features/ChatInput/ControlBar/ModeSelector.tsx
+++ b/src/features/ChatInput/ControlBar/ModeSelector.tsx
@@ -13,6 +13,7 @@ import { memo, useCallback, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useBusinessAgentModeSync } from '@/business/client/hooks/useBusinessAgentMode';
+import { SkeletonBar } from '@/components/Skeleton';
import { useAgentId } from '@/features/ChatInput/hooks/useAgentId';
import { useChatInputResourceAccess } from '@/features/ChatInput/hooks/useChatInputResourceAccess';
import { useEffectiveAgentMode } from '@/features/ChatInput/hooks/useEffectiveAgentMode';
@@ -251,7 +252,8 @@ const ModeSelector = memo(() => {
</div>
);
- if (isPreferenceLoading) return null;
+ // Hold the pill's footprint (~70x23 settled) instead of collapsing the left cluster.
+ if (isPreferenceLoading) return <SkeletonBar height={22} radius={4} width={68} />;
if (disabled)
return (
diff --git a/src/features/ChatInput/ControlBar/__tests__/resolveControlBarView.test.ts b/src/features/ChatInput/ControlBar/__tests__/resolveControlBarView.test.ts
new file mode 100644
index 00000000000..d67b77c0eed
--- /dev/null
+++ b/src/features/ChatInput/ControlBar/__tests__/resolveControlBarView.test.ts
@@ -0,0 +1,39 @@
+import { describe, expect, it } from 'vitest';
+
+import { resolveControlBarView, type ResolveControlBarViewParams } from '../resolveControlBarView';
+
+const ready: ResolveControlBarViewParams = {
+ agentId: 'agent-1',
+ canShowControls: true,
+ isAccessLoading: false,
+ isAgentConfigLoading: false,
+ isPreferenceLoading: false,
+};
+
+describe('resolveControlBarView', () => {
+ it('keeps a skeleton (not nothing) while the agent-mode preference loads', () => {
+ expect(resolveControlBarView({ ...ready, isPreferenceLoading: true })).toBe('skeleton');
+ });
+
+ it('keeps a skeleton while resource access resolves', () => {
+ expect(resolveControlBarView({ ...ready, canShowControls: false, isAccessLoading: true })).toBe(
+ 'skeleton',
+ );
+ });
+
+ it('keeps a skeleton while the agent config or agent id is pending', () => {
+ expect(resolveControlBarView({ ...ready, isAgentConfigLoading: true })).toBe('skeleton');
+ expect(resolveControlBarView({ ...ready, agentId: '' })).toBe('skeleton');
+ });
+
+ it('hides the bar once access resolves to "cannot use"', () => {
+ expect(resolveControlBarView({ ...ready, canShowControls: false })).toBe('hidden');
+ expect(
+ resolveControlBarView({ ...ready, canShowControls: false, isPreferenceLoading: true }),
+ ).toBe('hidden');
+ });
+
+ it('renders the controls once everything is loaded', () => {
+ expect(resolveControlBarView(ready)).toBe('controls');
+ });
+});
diff --git a/src/features/ChatInput/ControlBar/index.tsx b/src/features/ChatInput/ControlBar/index.tsx
index 2eaac127a01..18ca79fdfa0 100644
--- a/src/features/ChatInput/ControlBar/index.tsx
+++ b/src/features/ChatInput/ControlBar/index.tsx
@@ -1,9 +1,9 @@
import { Flexbox } from '@lobehub/ui';
-import { Skeleton } from '@lobehub/ui/base-ui';
import { createStaticStyles } from 'antd-style';
import { memo } from 'react';
import ChatInputCredits from '@/business/client/features/ChatInputCredits';
+import { SkeletonBar } from '@/components/Skeleton';
import { useAgentStore } from '@/store/agent';
import { agentByIdSelectors } from '@/store/agent/selectors';
@@ -14,6 +14,7 @@ import { useEffectiveAgentMode } from '../hooks/useEffectiveAgentMode';
import { useChatInputStore } from '../store';
import ApprovalMode from './ApprovalMode';
import ModeSelector from './ModeSelector';
+import { resolveControlBarView } from './resolveControlBarView';
import WorkspaceControls from './WorkspaceControls';
const styles = createStaticStyles(({ css }) => ({
@@ -45,9 +46,27 @@ const styles = createStaticStyles(({ css }) => ({
`,
}));
+interface ControlBarSkeletonProps {
+ /** Mirror the right-pinned context-window pill only when the loaded bar renders it. */
+ showContextWindow?: boolean;
+}
+
+/**
+ * Same-height stand-in for the control bar: the 28px row with the mode pill on the
+ * left and, when configured, the context-window pill pinned right. Pill sizes follow
+ * the settled DOM (mode button ~70x23, context-window tag ~89x24), so the composer
+ * does not move when the real controls replace it.
+ */
+export const ControlBarSkeleton = ({ showContextWindow }: ControlBarSkeletonProps) => (
+ <Flexbox aria-busy horizontal align={'center'} className={styles.bar} justify={'space-between'}>
+ <SkeletonBar height={22} radius={4} width={68} />
+ {showContextWindow && <SkeletonBar height={22} radius={4} width={88} />}
+ </Flexbox>
+);
+
const ControlBar = memo(() => {
const agentId = useAgentId();
- const { canShowControls } = useChatInputResourceAccess();
+ const { canShowControls, isAccessLoading } = useChatInputResourceAccess();
const showContextWindow = useChatInputStore((s) =>
s.rightActions.flat().includes('contextWindow'),
);
@@ -55,17 +74,16 @@ const ControlBar = memo(() => {
const isLoading = useAgentStore((s) => agentByIdSelectors.isAgentConfigLoadingById(agentId)(s));
const { isAgentRuntimeMode, isPreferenceLoading } = useEffectiveAgentMode(agentId);
- if (!canShowControls || isPreferenceLoading) return null;
+ const view = resolveControlBarView({
+ agentId,
+ canShowControls,
+ isAccessLoading,
+ isAgentConfigLoading: isLoading,
+ isPreferenceLoading,
+ });
- // Skeleton placeholder to prevent layout jump during loading
- if (!agentId || isLoading) {
- return (
- <Flexbox horizontal align={'center'} className={styles.bar} gap={4}>
- <Skeleton style={{ height: 22, minWidth: 64, width: 64 }} />
- <Skeleton style={{ height: 22, minWidth: 100, width: 100 }} />
- </Flexbox>
- );
- }
+ if (view === 'hidden') return null;
+ if (view === 'skeleton') return <ControlBarSkeleton showContextWindow={showContextWindow} />;
return (
<Flexbox horizontal align={'center'} className={styles.bar} justify={'space-between'}>
diff --git a/src/features/ChatInput/ControlBar/resolveControlBarView.ts b/src/features/ChatInput/ControlBar/resolveControlBarView.ts
new file mode 100644
index 00000000000..ad34646ea1e
--- /dev/null
+++ b/src/features/ChatInput/ControlBar/resolveControlBarView.ts
@@ -0,0 +1,29 @@
+export type ControlBarView = 'controls' | 'hidden' | 'skeleton';
+
+export interface ResolveControlBarViewParams {
+ agentId?: string;
+ canShowControls: boolean;
+ isAccessLoading: boolean;
+ isAgentConfigLoading: boolean;
+ isPreferenceLoading: boolean;
+}
+
+/**
+ * Decide what the chat input control bar renders. Every pending state (resource
+ * access, agent-mode preference, agent config) keeps a same-height skeleton:
+ * rendering nothing there collapsed the 28px row and made the composer jump each
+ * time a conversation opened. Only a resolved "cannot use" hides the bar.
+ */
+export const resolveControlBarView = ({
+ agentId,
+ canShowControls,
+ isAccessLoading,
+ isAgentConfigLoading,
+ isPreferenceLoading,
+}: ResolveControlBarViewParams): ControlBarView => {
+ if (isAccessLoading) return 'skeleton';
+ if (!canShowControls) return 'hidden';
+ if (!agentId || isAgentConfigLoading || isPreferenceLoading) return 'skeleton';
+
+ return 'controls';
+};
diff --git a/src/features/Integrations/OverviewSkeleton.tsx b/src/features/Integrations/OverviewSkeleton.tsx
new file mode 100644
index 00000000000..6522b67b043
--- /dev/null
+++ b/src/features/Integrations/OverviewSkeleton.tsx
@@ -0,0 +1,94 @@
+'use client';
+
+import { Block, Flexbox } from '@lobehub/ui';
+import { createStaticStyles, cssVar, cx } from 'antd-style';
+
+import { SkeletonBar } from '@/components/Skeleton';
+
+import { INTEGRATIONS, UPCOMING_INTEGRATIONS } from './registry';
+
+const styles = createStaticStyles(({ css, cssVar }) => ({
+ // Card chrome mirrors `IntegrationCard` (filled block, LG radius, 14/16 padding).
+ card: css`
+ padding-block: 14px;
+ padding-inline: 16px;
+ border-radius: ${cssVar.borderRadiusLG};
+ background: ${cssVar.colorFillQuaternary};
+ `,
+ list: css`
+ display: grid;
+ grid-template-columns: 1fr;
+ gap: 10px;
+ `,
+ upcoming: css`
+ display: grid;
+ grid-template-columns: repeat(2, 1fr);
+ gap: 8px;
+
+ @media (width <= 720px) {
+ grid-template-columns: 1fr;
+ }
+ `,
+ upcomingCard: css`
+ padding-block: 10px;
+ padding-inline: 14px;
+ `,
+}));
+
+/** Section label line (12px text, ~20px line box). */
+const Label = ({ width }: { width: number }) => (
+ <Flexbox height={20} justify={'center'}>
+ <SkeletonBar height={12} width={width} />
+ </Flexbox>
+);
+
+const CardSkeleton = ({ upcoming }: { upcoming?: boolean }) => (
+ <Block className={cx(styles.card, upcoming && styles.upcomingCard)} variant={'filled'}>
+ <Flexbox horizontal align={'center'} gap={14}>
+ <SkeletonBar
+ height={upcoming ? 32 : 40}
+ radius={cssVar.borderRadius}
+ width={upcoming ? 32 : 40}
+ />
+ <Flexbox flex={1} gap={2} style={{ minWidth: 0 }}>
+ <Flexbox height={24} justify={'center'}>
+ <SkeletonBar height={15} width={upcoming ? 72 : 88} />
+ </Flexbox>
+ {!upcoming && (
+ <Flexbox height={22} justify={'center'}>
+ <SkeletonBar height={13} width={'60%'} />
+ </Flexbox>
+ )}
+ </Flexbox>
+ <SkeletonBar height={13} width={upcoming ? 64 : 80} />
+ </Flexbox>
+ </Block>
+);
+
+/**
+ * Integrations directory placeholder: the "All" list and the "Coming soon" grid
+ * with the registry's real card counts. The connected strip is data-driven, so
+ * it is not predicted here.
+ */
+const OverviewSkeleton = () => (
+ <Flexbox aria-busy gap={24}>
+ <Flexbox gap={10}>
+ <Label width={40} />
+ <div className={styles.list}>
+ {Array.from({ length: Math.max(INTEGRATIONS.length, 1) }).map((_, index) => (
+ <CardSkeleton key={index} />
+ ))}
+ </div>
+ </Flexbox>
+ <Flexbox gap={10}>
+ <Label width={72} />
+ <div className={styles.upcoming}>
+ {UPCOMING_INTEGRATIONS.map((item) => (
+ <CardSkeleton upcoming key={item.id} />
+ ))}
+ </div>
+ </Flexbox>
+ </Flexbox>
+);
+
+export default OverviewSkeleton;
diff --git a/src/features/Settings/advanced/index.tsx b/src/features/Settings/advanced/index.tsx
index f88a220e6d7..ba79c55fe4d 100644
--- a/src/features/Settings/advanced/index.tsx
+++ b/src/features/Settings/advanced/index.tsx
@@ -1,13 +1,14 @@
'use client';
import { isDesktop } from '@lobechat/const';
-import { Select, Skeleton, Spin, Switch } from '@lobehub/ui/base-ui';
+import { Select, Spin, Switch } from '@lobehub/ui/base-ui';
import { Form, type FormFieldProps, type FormGroupItem, useForm } from '@lobehub/ui/base-ui/form';
import isEqual from 'fast-deep-equal';
import { memo, useCallback, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import AsyncError from '@/components/AsyncError';
+import { SettingsSectionSkeleton } from '@/components/Skeleton';
import { FORM_STYLE } from '@/const/layoutTokens';
import SettingHeader from '@/features/Settings/features/SettingHeader';
import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
@@ -82,7 +83,19 @@ const Page = memo(() => {
onRetry={() => refreshUserState()}
/>
);
- return <Skeleton.Text rows={5} />;
+ // Mirror the loaded page: header plus the tools group (dev mode + optional
+ // gateway mode) and, on desktop, the single-row update-channel group.
+ return (
+ <>
+ <SettingHeader title={t('tab.advanced')} />
+ <SettingsSectionSkeleton
+ groups={[
+ { rows: enableGatewayMode ? 2 : 1, titleWidth: 160 },
+ ...(isDesktop ? [{ rows: 1, titleWidth: 112 }] : []),
+ ]}
+ />
+ </>
+ );
}
const advancedGroup: FormGroupItem<UserGeneralConfig> = {
diff --git a/src/features/Settings/common/features/Common/Common.tsx b/src/features/Settings/common/features/Common/Common.tsx
index 2a4f39c5622..f4fb02e63e9 100644
--- a/src/features/Settings/common/features/Common/Common.tsx
+++ b/src/features/Settings/common/features/Common/Common.tsx
@@ -1,7 +1,7 @@
'use client';
import { Flexbox, Icon, ImageSelect } from '@lobehub/ui';
-import { Select, Skeleton, Tabs } from '@lobehub/ui/base-ui';
+import { Select, Tabs } from '@lobehub/ui/base-ui';
import { Form, type FormGroupItem, useForm } from '@lobehub/ui/base-ui/form';
import isEqual from 'fast-deep-equal';
import { Ban, Gauge, Monitor, Moon, Mouse, Sun, Waves } from 'lucide-react';
@@ -10,6 +10,7 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import AutoSaveHint from '@/components/Editor/AutoSaveHint';
+import { SettingsSectionSkeleton } from '@/components/Skeleton';
import { FORM_STYLE } from '@/const/layoutTokens';
import { imageUrl } from '@/const/url';
import { isDesktop } from '@/const/version';
@@ -46,7 +47,29 @@ const Common = memo(() => {
switchLocale(value);
};
- if (!(isStatusInit && isUserStateInit)) return <Skeleton.Text rows={5} />;
+ // One filled group: theme, language, animation, context menu, response language.
+ // The theme row is the 332×86 `ImageSelect`, so it reserves that size instead of an input.
+ if (!(isStatusInit && isUserStateInit))
+ return (
+ <SettingsSectionSkeleton
+ groups={[
+ {
+ // Settled sizes: theme ImageSelect, language Select, motion and
+ // context-menu Segmented controls, reply-language Select.
+ controls: {
+ 0: { height: 86, width: 332 },
+ 1: { height: 32, width: 167 },
+ 2: { height: 38, width: 230 },
+ 3: { height: 38, width: 165 },
+ 4: { height: 32, width: 167 },
+ },
+ rows: 5,
+ titleWidth: 96,
+ withDesc: false,
+ },
+ ]}
+ />
+ );
const themeFormGroup: FormGroupItem<UserGeneralConfig> = {
children: [
diff --git a/src/features/Settings/hotkey/features/Conversation.tsx b/src/features/Settings/hotkey/features/Conversation.tsx
index e85e0964ab2..733b32abc11 100644
--- a/src/features/Settings/hotkey/features/Conversation.tsx
+++ b/src/features/Settings/hotkey/features/Conversation.tsx
@@ -2,13 +2,13 @@
import { HotkeyGroupEnum } from '@lobechat/const/hotkeys';
import { HotkeyInput } from '@lobehub/ui';
-import { Skeleton } from '@lobehub/ui/base-ui';
import { Form, type FormGroupItem, useForm } from '@lobehub/ui/base-ui/form';
import isEqual from 'fast-deep-equal';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import AutoSaveHint from '@/components/Editor/AutoSaveHint';
+import { SettingsSectionSkeleton } from '@/components/Skeleton';
import { HOTKEYS_REGISTRATION } from '@/const/hotkeys';
import { FORM_STYLE } from '@/const/layoutTokens';
import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
@@ -29,7 +29,21 @@ const HotkeySetting = memo(() => {
onValuesChange: (values) => save(() => setSettings({ hotkey: values })),
});
- if (!isUserStateInit) return <Skeleton.Text rows={5} />;
+ if (!isUserStateInit)
+ return (
+ <SettingsSectionSkeleton
+ groups={[
+ {
+ // Hotkey recorder inputs settle at 335x36.
+ control: { height: 36, width: 335 },
+ rows: HOTKEYS_REGISTRATION.filter((item) => item.group === HotkeyGroupEnum.Conversation)
+ .length,
+ titleWidth: 96,
+ withDesc: false,
+ },
+ ]}
+ />
+ );
const clearHotkeyBinding = (id: HotkeyItem['id']) => {
if (!hotkey[id]) return;
diff --git a/src/features/Settings/hotkey/features/Desktop.tsx b/src/features/Settings/hotkey/features/Desktop.tsx
index 9b34b4bc50d..e49263be3f7 100644
--- a/src/features/Settings/hotkey/features/Desktop.tsx
+++ b/src/features/Settings/hotkey/features/Desktop.tsx
@@ -1,12 +1,13 @@
'use client';
import { HotkeyInput } from '@lobehub/ui';
-import { Skeleton, Spin, toast } from '@lobehub/ui/base-ui';
+import { Spin, toast } from '@lobehub/ui/base-ui';
import { Form, type FormGroupItem, useForm } from '@lobehub/ui/base-ui/form';
import isEqual from 'fast-deep-equal';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { SettingsSectionSkeleton } from '@/components/Skeleton';
import { DESKTOP_HOTKEYS_REGISTRATION } from '@/const/desktopGlobalShortcuts';
import { FORM_STYLE } from '@/const/layoutTokens';
import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
@@ -29,7 +30,20 @@ const HotkeySetting = memo(() => {
const [loading, setLoading] = useState(false);
- if (!isHotkeysInit) return <Skeleton.Text rows={5} />;
+ if (!isHotkeysInit)
+ return (
+ <SettingsSectionSkeleton
+ groups={[
+ {
+ // Hotkey recorder inputs settle at 335x36.
+ control: { height: 36, width: 335 },
+ rows: DESKTOP_HOTKEYS_REGISTRATION.length,
+ titleWidth: 96,
+ withDesc: false,
+ },
+ ]}
+ />
+ );
const updateHotkey = async (id: DesktopHotkeyItem['id'], value: string) => {
setLoading(true);
diff --git a/src/features/Settings/hotkey/features/Essential.tsx b/src/features/Settings/hotkey/features/Essential.tsx
index f038fe5d9cf..c0b77251216 100644
--- a/src/features/Settings/hotkey/features/Essential.tsx
+++ b/src/features/Settings/hotkey/features/Essential.tsx
@@ -2,13 +2,13 @@
import { HotkeyGroupEnum } from '@lobechat/const/hotkeys';
import { HotkeyInput } from '@lobehub/ui';
-import { Skeleton } from '@lobehub/ui/base-ui';
import { Form, type FormGroupItem, useForm } from '@lobehub/ui/base-ui/form';
import isEqual from 'fast-deep-equal';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import AutoSaveHint from '@/components/Editor/AutoSaveHint';
+import { SettingsSectionSkeleton } from '@/components/Skeleton';
import { HOTKEYS_REGISTRATION } from '@/const/hotkeys';
import { FORM_STYLE } from '@/const/layoutTokens';
import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
@@ -29,7 +29,21 @@ const HotkeySetting = memo(() => {
onValuesChange: (values) => save(() => setSettings({ hotkey: values })),
});
- if (!isUserStateInit) return <Skeleton.Text rows={5} />;
+ if (!isUserStateInit)
+ return (
+ <SettingsSectionSkeleton
+ groups={[
+ {
+ // Hotkey recorder inputs settle at 335x36.
+ control: { height: 36, width: 335 },
+ rows: HOTKEYS_REGISTRATION.filter((item) => item.group === HotkeyGroupEnum.Essential)
+ .length,
+ titleWidth: 96,
+ withDesc: false,
+ },
+ ]}
+ />
+ );
const clearHotkeyBinding = (id: HotkeyItem['id']) => {
if (!hotkey[id]) return;
diff --git a/src/features/Settings/image/features/Image.tsx b/src/features/Settings/image/features/Image.tsx
index 1e726c10a83..0b5264bf7a1 100644
--- a/src/features/Settings/image/features/Image.tsx
+++ b/src/features/Settings/image/features/Image.tsx
@@ -2,13 +2,14 @@
import { type UserImageConfig } from '@lobechat/types';
import { Flexbox, Icon, Tooltip } from '@lobehub/ui';
-import { Skeleton, Spin } from '@lobehub/ui/base-ui';
+import { Spin } from '@lobehub/ui/base-ui';
import { Form, type FormGroupItem, useForm } from '@lobehub/ui/base-ui/form';
import { CircleHelpIcon } from 'lucide-react';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { FormSliderWithInput } from '@/components/FormInput';
+import { SettingsSectionSkeleton } from '@/components/Skeleton';
import { FORM_STYLE } from '@/const/layoutTokens';
import { MAX_DEFAULT_IMAGE_NUM, MIN_DEFAULT_IMAGE_NUM } from '@/const/settings';
import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
@@ -39,7 +40,8 @@ const ImageSettings = memo(() => {
});
if (!isUserStateInit) {
- return <Skeleton.Text rows={1} />;
+ // One filled group holding the default image count slider.
+ return <SettingsSectionSkeleton groups={[{ rows: 1, titleWidth: 136 }]} />;
}
const items: FormGroupItem<UserImageConfig>[] = [
diff --git a/src/features/Settings/integrations/index.tsx b/src/features/Settings/integrations/index.tsx
index 6586841d4bc..1fe9d1dcb39 100644
--- a/src/features/Settings/integrations/index.tsx
+++ b/src/features/Settings/integrations/index.tsx
@@ -1,10 +1,13 @@
-import { Skeleton } from '@lobehub/ui/base-ui';
+import { Center } from '@lobehub/ui';
+import { Spin } from '@lobehub/ui/base-ui';
import { createStaticStyles } from 'antd-style';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router';
import NotFound from '@/components/404';
import IntegrationsSettings from '@/features/Integrations';
+import IntegrationsLayout from '@/features/Integrations/Layout';
+import IntegrationsOverviewSkeleton from '@/features/Integrations/OverviewSkeleton';
import SettingHeader from '@/features/Settings/features/SettingHeader';
import { useUserStore } from '@/store/user';
import { labPreferSelectors, preferenceSelectors } from '@/store/user/selectors';
@@ -32,8 +35,7 @@ const Page = ({ showSettingHeader = true }: PageProps) => {
const showHeader = showSettingHeader && !params.sub;
// Labs alpha: a deep link with the flag off is a missing page, not a leak.
- if (!isPreferenceInit) return <Skeleton.Text rows={5} />;
- if (!enableIntegrations) return <NotFound />;
+ if (!enableIntegrations && isPreferenceInit) return <NotFound />;
return (
<>
@@ -42,7 +44,21 @@ const Page = ({ showSettingHeader = true }: PageProps) => {
<SettingHeader description={t('overview.description')} title={t('overview.title')} />
</div>
)}
- <IntegrationsSettings />
+ {isPreferenceInit ? (
+ <IntegrationsSettings />
+ ) : (
+ // Keep the header and reading-width column while the flag resolves. The
+ // directory has a known card layout; an integration page's hero does not.
+ <IntegrationsLayout>
+ {params.sub ? (
+ <Center paddingBlock={48}>
+ <Spin size={'large'} />
+ </Center>
+ ) : (
+ <IntegrationsOverviewSkeleton />
+ )}
+ </IntegrationsLayout>
+ )}
</>
);
};
diff --git a/src/features/Settings/labs/index.tsx b/src/features/Settings/labs/index.tsx
index b99d96ad19c..ec47dba5390 100644
--- a/src/features/Settings/labs/index.tsx
+++ b/src/features/Settings/labs/index.tsx
@@ -2,13 +2,14 @@
import { isDesktop } from '@lobechat/const';
import { Flexbox, Tooltip } from '@lobehub/ui';
-import { Alert, Skeleton, Switch, Tag } from '@lobehub/ui/base-ui';
+import { Alert, Switch, Tag } from '@lobehub/ui/base-ui';
import { Form, type FormFieldProps, type FormGroupItem, useForm } from '@lobehub/ui/base-ui/form';
import { FlaskConicalIcon } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import AsyncError from '@/components/AsyncError';
+import { SettingsSectionSkeleton } from '@/components/Skeleton';
import { FORM_STYLE } from '@/const/layoutTokens';
import SettingHeader from '@/features/Settings/features/SettingHeader';
import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
@@ -55,7 +56,22 @@ const LabsForm = memo(() => {
onRetry={() => refreshUserState()}
/>
);
- return <Skeleton.Text rows={5} />;
+ // Same groups as the loaded form: General always, Desktop only in Electron.
+ return (
+ <SettingsSectionSkeleton
+ groups={[
+ { rows: LAB_FEATURES.filter((feature) => !feature.desktopOnly).length, titleWidth: 72 },
+ ...(isDesktop
+ ? [
+ {
+ rows: LAB_FEATURES.filter((feature) => feature.desktopOnly).length,
+ titleWidth: 72,
+ },
+ ]
+ : []),
+ ]}
+ />
+ );
}
const checkedByFlag = Object.fromEntries(
diff --git a/src/features/Settings/memory/features/Memory.tsx b/src/features/Settings/memory/features/Memory.tsx
index 84d9d4ac365..539808dcb2f 100644
--- a/src/features/Settings/memory/features/Memory.tsx
+++ b/src/features/Settings/memory/features/Memory.tsx
@@ -2,7 +2,7 @@
import { type UserMemoryEffort, type UserMemorySettings } from '@lobechat/types';
import { Flexbox, Icon, Tooltip } from '@lobehub/ui';
-import { Skeleton, Switch } from '@lobehub/ui/base-ui';
+import { Switch } from '@lobehub/ui/base-ui';
import { Form, type FormGroupItem, useForm } from '@lobehub/ui/base-ui/form';
import isEqual from 'fast-deep-equal';
import { CircleHelpIcon } from 'lucide-react';
@@ -10,6 +10,7 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import AutoSaveHint from '@/components/Editor/AutoSaveHint';
+import { SettingsSectionSkeleton } from '@/components/Skeleton';
import { FORM_STYLE } from '@/const/layoutTokens';
import LevelSlider from '@/features/ModelSwitchPanel/components/ControlsForm/LevelSlider';
import { usePermission } from '@/hooks/usePermission';
@@ -37,7 +38,14 @@ const MemorySetting = memo(() => {
},
});
- if (!isUserStateInit) return <Skeleton.Text rows={3} />;
+ // One filled group: the enable switch and the effort slider (settles at ~180x44
+ // with its marks), which makes the second row taller than a plain input row.
+ if (!isUserStateInit)
+ return (
+ <SettingsSectionSkeleton
+ groups={[{ controls: { 1: { height: 44, width: 180 } }, rows: 2, titleWidth: 80 }]}
+ />
+ );
const memorySettings: FormGroupItem<UserMemorySettings> = {
children: [
diff --git a/src/features/Settings/notification/index.tsx b/src/features/Settings/notification/index.tsx
index cae30f2bc23..394fc2246f2 100644
--- a/src/features/Settings/notification/index.tsx
+++ b/src/features/Settings/notification/index.tsx
@@ -3,13 +3,14 @@ import {
type CompletionSoundSettings,
} from '@lobechat/electron-client-ipc';
import { Flexbox } from '@lobehub/ui';
-import { Alert, Button, Segmented, Select, Skeleton, Slider, Switch } from '@lobehub/ui/base-ui';
+import { Alert, Button, Segmented, Select, Slider, Switch } from '@lobehub/ui/base-ui';
import { Form, useForm } from '@lobehub/ui/base-ui/form';
import { Play } from 'lucide-react';
import { useCallback, useEffect, useId, useState } from 'react';
import { useTranslation } from 'react-i18next';
import BusinessNotification from '@/business/client/BusinessSettingPages/Notification';
+import { SettingsSectionSkeleton } from '@/components/Skeleton';
import { FORM_STYLE } from '@/const/layoutTokens';
import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
import { completionSoundService } from '@/services/electron/completionSound';
@@ -81,7 +82,15 @@ export const DesktopNotificationSettings = () => {
/>
)}
{!settings ? (
- !error && <Skeleton.Text rows={3} />
+ !error && (
+ // Completion sound (toggle/sound/volume) and banner sound groups.
+ <SettingsSectionSkeleton
+ groups={[
+ { rows: 3, titleWidth: 136 },
+ { rows: 1, titleWidth: 112 },
+ ]}
+ />
+ )
) : (
<Form
collapsible={false}
diff --git a/src/features/Settings/oauth-apps/features/AppDetail/index.tsx b/src/features/Settings/oauth-apps/features/AppDetail/index.tsx
index 2ba649cb169..a7f6a04ba44 100644
--- a/src/features/Settings/oauth-apps/features/AppDetail/index.tsx
+++ b/src/features/Settings/oauth-apps/features/AppDetail/index.tsx
@@ -77,6 +77,16 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
`,
}));
+/** The app page while it loads; also shown while the Labs flag resolves on a direct visit. */
+export const AppDetailSkeleton = () => (
+ <Flexbox gap={16}>
+ <Skeleton.Text rows={1} width={200} />
+ <div className={styles.card}>
+ <Skeleton.Text rows={4} />
+ </div>
+ </Flexbox>
+);
+
const TAB_KEYS = ['overview', 'credentials', 'advanced'] as const;
interface AppDetailProps {
@@ -192,15 +202,7 @@ const AppDetail: FC<AppDetailProps> = ({ canEdit, id, onBack, onChanged }) => {
/>
);
- if (!detail)
- return (
- <Flexbox gap={16}>
- <Skeleton.Text rows={1} width={200} />
- <div className={styles.card}>
- <Skeleton.Text rows={4} />
- </div>
- </Flexbox>
- );
+ if (!detail) return <AppDetailSkeleton />;
const isWebApp = detail.applicationType === 'web';
const isDisabled = !detail.enabled;
diff --git a/src/features/Settings/oauth-apps/features/AppListSkeleton.tsx b/src/features/Settings/oauth-apps/features/AppListSkeleton.tsx
new file mode 100644
index 00000000000..0eedd8d48dc
--- /dev/null
+++ b/src/features/Settings/oauth-apps/features/AppListSkeleton.tsx
@@ -0,0 +1,69 @@
+'use client';
+
+import { Flexbox } from '@lobehub/ui';
+import { createStaticStyles, cssVar } from 'antd-style';
+
+import { SkeletonBar } from '@/components/Skeleton';
+
+const styles = createStaticStyles(({ css, cssVar }) => ({
+ // Same card chrome as the loaded list column in `OAuthApps`.
+ listCol: css`
+ overflow: hidden;
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: ${cssVar.borderRadiusLG};
+ background: ${cssVar.colorBgContainer};
+ `,
+ // Same padding and gap as `AppItem`'s row.
+ row: css`
+ padding-block: 12px;
+ padding-inline: 12px;
+ `,
+}));
+
+/** Centres a text-height skeleton bar inside the line box of the text it replaces. */
+const Line = ({
+ lineHeight,
+ height,
+ width,
+}: {
+ height: number;
+ lineHeight: number;
+ width: number;
+}) => (
+ <Flexbox height={lineHeight} justify={'center'}>
+ <SkeletonBar height={height} width={width} />
+ </Flexbox>
+);
+
+interface AppRowsSkeletonProps {
+ rows?: number;
+}
+
+/**
+ * Rows of the OAuth app list while it loads: 36px logo, the name and
+ * description lines, then the type / last-used meta on the right, matching
+ * `AppItem` so rows swap in place.
+ */
+export const AppRowsSkeleton = ({ rows = 2 }: AppRowsSkeletonProps) => (
+ <>
+ {Array.from({ length: rows }).map((_, index) => (
+ <Flexbox horizontal align={'center'} className={styles.row} gap={12} key={index}>
+ <SkeletonBar height={36} radius={cssVar.borderRadius} width={36} />
+ <Flexbox flex={1} gap={2} style={{ minWidth: 0 }}>
+ <Line height={14} lineHeight={22} width={index % 2 ? 112 : 144} />
+ <Line height={12} lineHeight={20} width={index % 2 ? 200 : 240} />
+ </Flexbox>
+ <Line height={12} lineHeight={20} width={index % 2 ? 120 : 136} />
+ </Flexbox>
+ ))}
+ </>
+);
+
+/** The OAuth app list card (same chrome as the loaded list) filled with row skeletons. */
+const AppListSkeleton = ({ rows }: AppRowsSkeletonProps) => (
+ <Flexbox aria-busy className={styles.listCol} gap={2} padding={4}>
+ <AppRowsSkeleton rows={rows} />
+ </Flexbox>
+);
+
+export default AppListSkeleton;
diff --git a/src/features/Settings/oauth-apps/features/OAuthApps.tsx b/src/features/Settings/oauth-apps/features/OAuthApps.tsx
index 4810f65c983..3beeda427a5 100644
--- a/src/features/Settings/oauth-apps/features/OAuthApps.tsx
+++ b/src/features/Settings/oauth-apps/features/OAuthApps.tsx
@@ -1,7 +1,6 @@
'use client';
import { Empty, Flexbox } from '@lobehub/ui';
-import { Skeleton } from '@lobehub/ui/base-ui';
import { createStaticStyles } from 'antd-style';
import { AppWindowIcon } from 'lucide-react';
import { type FC } from 'react';
@@ -14,6 +13,7 @@ import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwar
import { resolveAppListState } from '../appList';
import AppDetail from './AppDetail';
import AppItem from './AppItem';
+import { AppRowsSkeleton } from './AppListSkeleton';
import CreateAppButton from './CreateAppButton';
import { useOAuthAppList } from './useOAuthAppList';
@@ -72,13 +72,7 @@ const OAuthApps: FC<OAuthAppsProps> = ({ canEdit }) => {
);
const renderRows = () => {
- if (listState === 'loading')
- return (
- <Flexbox gap={12} padding={12}>
- <Skeleton.Text rows={2} />
- <Skeleton.Text rows={2} />
- </Flexbox>
- );
+ if (listState === 'loading') return <AppRowsSkeleton />;
return apps?.map((app) => (
<AppItem
diff --git a/src/features/Settings/oauth-apps/index.test.tsx b/src/features/Settings/oauth-apps/index.test.tsx
index d7088ddcf89..51e63b51540 100644
--- a/src/features/Settings/oauth-apps/index.test.tsx
+++ b/src/features/Settings/oauth-apps/index.test.tsx
@@ -16,8 +16,10 @@ vi.hoisted(() => {
});
});
+const params = vi.hoisted(() => ({ value: {} as { sub?: string } }));
+
vi.mock('react-router', () => ({
- useParams: () => ({}),
+ useParams: () => params.value,
}));
vi.mock('@/business/client/hooks/useActiveWorkspaceId', () => ({
@@ -48,6 +50,14 @@ vi.mock('./features/useOAuthAppList', () => ({
useOAuthAppList: () => ({ data: undefined }),
}));
+vi.mock('./features/AppDetail', () => ({
+ AppDetailSkeleton: () => <div>app-detail-skeleton</div>,
+}));
+
+vi.mock('./features/AppListSkeleton', () => ({
+ default: () => <div>app-list-skeleton</div>,
+}));
+
vi.mock('./features/OAuthApps', () => ({
default: () => <div>oauth-apps-page</div>,
}));
@@ -56,6 +66,7 @@ const initialUserStoreState = useUserStore.getState();
afterEach(() => {
cleanup();
+ params.value = {};
useUserStore.setState(initialUserStoreState, true);
});
@@ -83,4 +94,22 @@ describe('OAuth Apps settings page', () => {
expect(screen.getByText('tab.oauthApps')).toBeDefined();
expect(screen.getByText('oauth-apps-page')).toBeDefined();
});
+
+ it('keeps the list skeleton under the header while preferences load', () => {
+ render(<Page />);
+
+ expect(screen.getByText('tab.oauthApps')).toBeDefined();
+ expect(screen.getByText('app-list-skeleton')).toBeDefined();
+ });
+
+ // Regression: a direct visit to an app page showed only the header until
+ // preferences loaded.
+ it('shows the app page skeleton on a detail route while preferences load', () => {
+ params.value = { sub: 'app_1' };
+
+ render(<Page />);
+
+ expect(screen.getByText('app-detail-skeleton')).toBeDefined();
+ expect(screen.queryByText('app-list-skeleton')).toBeNull();
+ });
});
diff --git a/src/features/Settings/oauth-apps/index.tsx b/src/features/Settings/oauth-apps/index.tsx
index 345cd2a5a92..d9fd3bd3554 100644
--- a/src/features/Settings/oauth-apps/index.tsx
+++ b/src/features/Settings/oauth-apps/index.tsx
@@ -1,4 +1,3 @@
-import { Skeleton } from '@lobehub/ui/base-ui';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router';
@@ -9,6 +8,8 @@ import { usePermission } from '@/hooks/usePermission';
import { useUserStore } from '@/store/user';
import { labPreferSelectors, preferenceSelectors } from '@/store/user/selectors';
+import { AppDetailSkeleton } from './features/AppDetail';
+import AppListSkeleton from './features/AppListSkeleton';
import CreateAppButton from './features/CreateAppButton';
import OAuthApps from './features/OAuthApps';
import { useOAuthAppList } from './features/useOAuthAppList';
@@ -30,7 +31,15 @@ const Page = () => {
const { data: apps } = useOAuthAppList(isPreferenceInit && enableOAuthApps);
const listEmpty = apps?.length === 0;
- if (!isPreferenceInit) return <Skeleton.Text rows={5} />;
+ // Keep the page header and the body's own skeleton while the Labs flag
+ // resolves; the Create button waits for the flag because disabled means 404.
+ if (!isPreferenceInit)
+ return (
+ <>
+ <SettingHeader title={t('tab.oauthApps')} />
+ {params.sub ? <AppDetailSkeleton /> : <AppListSkeleton />}
+ </>
+ );
if (!enableOAuthApps) return <NotFound />;
return (
diff --git a/src/features/Settings/proxy/features/ProxyForm.tsx b/src/features/Settings/proxy/features/ProxyForm.tsx
index 8de8932a355..582a78713d3 100644
--- a/src/features/Settings/proxy/features/ProxyForm.tsx
+++ b/src/features/Settings/proxy/features/ProxyForm.tsx
@@ -2,19 +2,12 @@
import { type NetworkProxySettings } from '@lobechat/electron-client-ipc';
import { Flexbox } from '@lobehub/ui';
-import {
- Button,
- Input,
- InputPassword,
- RadioGroup,
- Skeleton,
- Switch,
- toast,
-} from '@lobehub/ui/base-ui';
+import { Button, Input, InputPassword, RadioGroup, Switch, toast } from '@lobehub/ui/base-ui';
import { Form, type FormGroupItem, useForm, useWatch } from '@lobehub/ui/base-ui/form';
import { useCallback, useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { SettingsSectionSkeleton } from '@/components/Skeleton';
import { FORM_STYLE } from '@/const/layoutTokens';
import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
import { desktopSettingsService } from '@/services/electron/settings';
@@ -200,7 +193,19 @@ const ProxyForm = () => {
}
}, [proxySettings, testUrl, form, t]);
- if (isLoading) return <Skeleton.Text rows={5} />;
+ // Enable, basic settings (type/server/port), auth (credentials hidden until
+ // enabled) and connection test groups, as in the loaded form.
+ if (isLoading)
+ return (
+ <SettingsSectionSkeleton
+ groups={[
+ { rows: 1, titleWidth: 96 },
+ { rows: 3, titleWidth: 112 },
+ { rows: 1, titleWidth: 128 },
+ { rows: 1, titleWidth: 120 },
+ ]}
+ />
+ );
const enableProxyGroup: FormGroupItem<NetworkProxySettings> = {
children: [
diff --git a/src/features/SkillStore/SkillList/Loading.tsx b/src/features/SkillStore/SkillList/Loading.tsx
index 4113e90d07e..9a7544243a3 100644
--- a/src/features/SkillStore/SkillList/Loading.tsx
+++ b/src/features/SkillStore/SkillList/Loading.tsx
@@ -1,12 +1,55 @@
-import { Flexbox } from '@lobehub/ui';
-import { Skeleton } from '@lobehub/ui/base-ui';
+import { Block, Center, Flexbox } from '@lobehub/ui';
+import { cssVar } from 'antd-style';
-const Loading = () => {
- return (
- <Flexbox padding={16}>
- <Skeleton.Text rows={8} />
+import { SkeletonBar } from '@/components/Skeleton';
+
+import { virtuosoGridStyles } from './style';
+
+/** Enough cards to fill the 60vh list on a tall viewport; overflow is clipped. */
+const CARD_COUNT = 16;
+
+const CardSkeleton = ({ index }: { index: number }) => (
+ <Block
+ horizontal
+ align={'center'}
+ gap={12}
+ paddingBlock={12}
+ paddingInline={12}
+ variant={'outlined'}
+ >
+ <SkeletonBar height={40} radius={cssVar.borderRadius} width={40} />
+ <Flexbox flex={1} gap={4} style={{ minWidth: 0 }}>
+ {/* Line boxes measured on the settled card: 22px title, 18.8px description. */}
+ <Flexbox height={22} justify={'center'}>
+ <SkeletonBar height={14} width={['48%', '36%', '56%', '42%'][index % 4]} />
+ </Flexbox>
+ <Flexbox height={18.8} justify={'center'}>
+ <SkeletonBar height={12} width={['88%', '72%', '80%'][index % 3]} />
+ </Flexbox>
</Flexbox>
- );
-};
+ {/* Install / more action icon slot. */}
+ <Center flex={'none'} height={36} width={36}>
+ <SkeletonBar height={16} radius={4} width={16} />
+ </Center>
+ </Block>
+);
+
+/**
+ * Skill Store list placeholder: the same 60vh box and two-column wrap grid as the
+ * loaded `VirtuosoGrid`, filled with outlined cards shaped like the skill / MCP
+ * item (40px avatar, title over a shorter description, action slot), so results
+ * replace the cards in place on first load and on every search.
+ */
+const Loading = () => (
+ <div aria-busy style={{ height: '60vh', overflow: 'hidden', width: '100%' }}>
+ <div className={virtuosoGridStyles.list}>
+ {Array.from({ length: CARD_COUNT }).map((_, index) => (
+ <div className={virtuosoGridStyles.item} key={index}>
+ <CardSkeleton index={index} />
+ </div>
+ ))}
+ </div>
+ </div>
+);
export default Loading;
diff --git a/src/routes/(main)/agent/channel/Header.tsx b/src/routes/(main)/agent/channel/Header.tsx
index 39a51eb9b35..d814a866452 100644
--- a/src/routes/(main)/agent/channel/Header.tsx
+++ b/src/routes/(main)/agent/channel/Header.tsx
@@ -17,6 +17,7 @@ import { memo, useCallback, useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router';
+import SkeletonBar from '@/components/Skeleton/Bar';
import AgentBreadcrumb from '@/features/AgentBreadcrumb';
import AgentProfileTabs, { AGENT_PROFILE_TABS_CENTER_STYLE } from '@/features/AgentProfileTabs';
import NavHeader from '@/features/NavHeader';
@@ -25,6 +26,7 @@ import { useAgentStore } from '@/store/agent';
import type { BotProviderItem } from '@/store/agent/slices/bot/action';
import { BOT_RUNTIME_STATUSES, type BotRuntimeStatus } from '../../../../types/botRuntimeStatus';
+import { resolveChannelHeaderView } from './headerView';
import { isImportableChannel, planChannelImport } from './importPlan';
interface HeaderProps {
@@ -32,6 +34,10 @@ interface HeaderProps {
currentConfig?: BotProviderItem;
disabled?: boolean;
platformDef?: SerializedPlatformDefinition & { comingSoon?: boolean };
+ /** The `:platform` route param; set on a platform detail even before `platformDef` loads. */
+ platformId?: string;
+ /** Platform definitions are still loading. */
+ platformsLoading?: boolean;
providers?: BotProviderItem[];
runtimeStatus?: BotRuntimeStatus;
}
@@ -45,8 +51,18 @@ const STATUS_TAG_COLORS: Partial<Record<BotRuntimeStatus, string>> = {
};
const Header = memo<HeaderProps>(
- ({ agentId, currentConfig, disabled, platformDef, providers, runtimeStatus }) => {
+ ({
+ agentId,
+ currentConfig,
+ disabled,
+ platformDef,
+ platformId,
+ platformsLoading = false,
+ providers,
+ runtimeStatus,
+ }) => {
const { t } = useTranslation(['agent', 'chat', 'common']);
+ const view = resolveChannelHeaderView(platformId, platformDef, platformsLoading);
const fileInputRef = useRef<HTMLInputElement>(null);
const [pendingEnabled, setPendingEnabled] = useState<boolean>();
@@ -331,9 +347,13 @@ const Header = memo<HeaderProps>(
// is the only way back to the list.
<AgentBreadcrumb
agentId={agentId}
- extraItems={platformDef ? [platformDef.name] : undefined}
+ extraItems={
+ view.detail
+ ? [view.platformName ?? <SkeletonBar height={14} width={56} />]
+ : undefined
+ }
title={
- platformDef ? (
+ view.detail ? (
<Link relative="path" to="..">
{t('tab.integration', { ns: 'chat' })}
</Link>
@@ -351,7 +371,7 @@ const Header = memo<HeaderProps>(
On a platform detail (`/channel/:platform`) it is one level too
deep, so drop it there and let the breadcrumb's Channels link be
the way back. */}
- {!platformDef && <AgentProfileTabs active={'channel'} agentId={agentId} />}
+ {!view.detail && <AgentProfileTabs active={'channel'} agentId={agentId} />}
</NavHeader>
</>
);
diff --git a/src/routes/(main)/agent/channel/headerView.test.ts b/src/routes/(main)/agent/channel/headerView.test.ts
new file mode 100644
index 00000000000..803d5cb9596
--- /dev/null
+++ b/src/routes/(main)/agent/channel/headerView.test.ts
@@ -0,0 +1,40 @@
+import { describe, expect, it } from 'vitest';
+
+import { resolveChannelHeaderView } from './headerView';
+
+describe('resolveChannelHeaderView', () => {
+ it('keeps the detail breadcrumb while platform definitions are still loading', () => {
+ expect(resolveChannelHeaderView('telegram', undefined, true)).toEqual({
+ detail: true,
+ platformName: undefined,
+ });
+ });
+
+ it('names the platform once its definition is loaded', () => {
+ expect(resolveChannelHeaderView('telegram', { name: 'Telegram' }, false)).toEqual({
+ detail: true,
+ platformName: 'Telegram',
+ });
+ });
+
+ it('falls back to the route id for an unknown platform once loading settles', () => {
+ expect(resolveChannelHeaderView('unknown', undefined, false)).toEqual({
+ detail: true,
+ platformName: 'unknown',
+ });
+ });
+
+ it('treats a loaded definition without a route id as a detail page', () => {
+ expect(resolveChannelHeaderView(undefined, { name: 'Discord' }, false)).toEqual({
+ detail: true,
+ platformName: 'Discord',
+ });
+ });
+
+ it('shows the tab switcher on the platform list', () => {
+ expect(resolveChannelHeaderView(undefined, undefined, false)).toEqual({
+ detail: false,
+ platformName: undefined,
+ });
+ });
+});
diff --git a/src/routes/(main)/agent/channel/headerView.ts b/src/routes/(main)/agent/channel/headerView.ts
new file mode 100644
index 00000000000..aed324af00a
--- /dev/null
+++ b/src/routes/(main)/agent/channel/headerView.ts
@@ -0,0 +1,26 @@
+export interface ChannelHeaderView {
+ /** Show the `Agent › Channels › Platform` trail; otherwise the profile tab switcher. */
+ detail: boolean;
+ /**
+ * Platform name for the last crumb; `undefined` while the definitions are
+ * loading. An unknown id (the page renders 404) falls back to the raw id.
+ */
+ platformName?: string;
+}
+
+/**
+ * Decide the channel header layout from the route, not from the loaded platform
+ * catalog. A deep link to `/channel/:platform` renders the header before the
+ * definitions arrive; keying on the definition flashed the list's tab switcher
+ * between the detail route skeleton and the loaded breadcrumb.
+ */
+export const resolveChannelHeaderView = (
+ platformId: string | undefined,
+ platformDef: { name: string } | undefined,
+ loading: boolean,
+): ChannelHeaderView => ({
+ // A loaded definition still implies a detail page for callers that pass
+ // only `platformDef`.
+ detail: !!platformId || !!platformDef,
+ platformName: platformDef?.name ?? (loading ? undefined : platformId),
+});
diff --git a/src/routes/(main)/agent/channel/index.tsx b/src/routes/(main)/agent/channel/index.tsx
index d0b7e56809f..d6663862598 100644
--- a/src/routes/(main)/agent/channel/index.tsx
+++ b/src/routes/(main)/agent/channel/index.tsx
@@ -7,7 +7,10 @@ import { useNavigate, useParams } from 'react-router';
import NotFound from '@/components/404';
import AsyncBoundary from '@/components/AsyncBoundary';
-import SurfaceSkeleton from '@/components/Skeleton/Surface';
+import {
+ AgentChannelDetailBodySkeleton,
+ AgentChannelListBodySkeleton,
+} from '@/components/Skeleton/AgentChannel';
import ResourceConfigAccessGate from '@/features/ResourcePermission/ResourceConfigAccessGate';
import { usePermission } from '@/hooks/usePermission';
import { useAgentStore } from '@/store/agent';
@@ -134,6 +137,8 @@ const ChannelContent = memo(() => {
currentConfig={currentConfig}
disabled={!canEdit}
platformDef={activePlatformDef}
+ platformId={platform}
+ platformsLoading={platformsLoading}
providers={providers}
runtimeStatus={
activePlatformDef ? platformRuntimeStatuses.get(activePlatformDef.id) : undefined
@@ -145,7 +150,9 @@ const ChannelContent = memo(() => {
error={error}
errorVariant={'block'}
isLoading={isLoading}
- loading={<SurfaceSkeleton header={false} variant={'grid'} />}
+ // Body half of the route skeleton (the real header is already mounted),
+ // so the chunk wait and the platform fetch share one shape.
+ loading={platform ? <AgentChannelDetailBodySkeleton /> : <AgentChannelListBodySkeleton />}
onRetry={() => {
mutatePlatforms();
mutateProviders();
diff --git a/src/routes/(main)/agent/features/routeMeta.ts b/src/routes/(main)/agent/features/routeMeta.ts
index c97938819c7..8ee0936bd3b 100644
--- a/src/routes/(main)/agent/features/routeMeta.ts
+++ b/src/routes/(main)/agent/features/routeMeta.ts
@@ -10,7 +10,12 @@ import {
} from 'lucide-react';
import { lazy } from 'react';
+import {
+ AgentChannelDetailSkeleton,
+ AgentChannelSkeleton,
+} from '@/components/Skeleton/AgentChannel';
import AgentShareSkeleton from '@/components/Skeleton/AgentShare';
+import AgentStatisticsSkeleton from '@/components/Skeleton/AgentStatistics';
import AgentConversationLayoutSkeleton from '@/components/Skeleton/Conversation/AgentLayout';
import ConversationLayoutSkeleton from '@/components/Skeleton/Conversation/Layout';
import ProfileSkeleton from '@/components/Skeleton/Profile';
@@ -85,14 +90,20 @@ export const agentProfileRouteMeta = routeMeta({
export const agentChannelRouteMeta = routeMeta({
DynamicMeta: ChannelDynamicMeta,
icon: RadioTowerIcon,
- Skeleton: createSurfaceSkeleton('grid'),
+ Skeleton: AgentChannelSkeleton,
titleKey: 'navigation.channels',
});
+// A platform detail is a credential form without the tab switcher, not the card grid.
+export const agentChannelDetailRouteMeta = routeMeta({
+ ...agentChannelRouteMeta,
+ Skeleton: AgentChannelDetailSkeleton,
+});
+
export const agentStatisticsRouteMeta = routeMeta({
DynamicMeta: StatisticsDynamicMeta,
icon: ChartColumnBigIcon,
- Skeleton: createSurfaceSkeleton('grid'),
+ Skeleton: AgentStatisticsSkeleton,
titleKey: 'navigation.stats',
});
diff --git a/src/spa/router/agentRouteSkeletons.test.ts b/src/spa/router/agentRouteSkeletons.test.ts
new file mode 100644
index 00000000000..52741e6480d
--- /dev/null
+++ b/src/spa/router/agentRouteSkeletons.test.ts
@@ -0,0 +1,45 @@
+// @vitest-environment happy-dom
+import type { RouteObject } from 'react-router';
+import { describe, expect, it } from 'vitest';
+
+import {
+ AgentChannelDetailSkeleton,
+ AgentChannelSkeleton,
+} from '@/components/Skeleton/AgentChannel';
+import AgentStatisticsSkeleton from '@/components/Skeleton/AgentStatistics';
+import AgentViewAllSkeleton from '@/components/Skeleton/AgentViewAll';
+
+import { desktopRoutes } from './desktopRouter.config';
+import { getRouteMetaFromHandle } from './routeMeta';
+
+const flatten = (routes: RouteObject[]): RouteObject[] =>
+ routes.flatMap((route) => [route, ...(route.children ? flatten(route.children) : [])]);
+
+const skeletonsOf = (path: string) =>
+ new Set(
+ flatten(desktopRoutes)
+ .filter((route) => route.path === path)
+ // A path-only parent (e.g. `agents`) carries its meta on the index child.
+ .map((route) => route.children?.find((child) => child.index) ?? route)
+ .map((route) => getRouteMetaFromHandle(route.handle)?.Skeleton),
+ );
+
+describe('agent page route skeletons', () => {
+ it('draws the channel card grid for the channel list', () => {
+ expect(skeletonsOf('channel')).toEqual(new Set([AgentChannelSkeleton]));
+ });
+
+ // The detail used to inherit the list's meta and flash a card grid before a form.
+ it('draws the credential form for a channel platform detail', () => {
+ expect(skeletonsOf('channel/:platform')).toEqual(new Set([AgentChannelDetailSkeleton]));
+ });
+
+ // Workspace settings also has a `statistics` child, so only assert membership.
+ it('draws the usage dashboard for agent statistics', () => {
+ expect(skeletonsOf('statistics').has(AgentStatisticsSkeleton)).toBe(true);
+ });
+
+ it('draws the agent list rows for the view-all page', () => {
+ expect(skeletonsOf('agents')).toEqual(new Set([AgentViewAllSkeleton]));
+ });
+});
diff --git a/src/spa/router/desktopRouter.shared.tsx b/src/spa/router/desktopRouter.shared.tsx
index 0901ee06a75..354924c7acc 100644
--- a/src/spa/router/desktopRouter.shared.tsx
+++ b/src/spa/router/desktopRouter.shared.tsx
@@ -41,6 +41,8 @@ import RouteSegmentSkeleton from '@/components/Skeleton/RouteSegment';
import ProviderSettingsSkeleton, {
ProviderDetailSkeleton,
} from '@/components/Skeleton/Settings/Provider';
+import { createSettingsSectionsSkeleton } from '@/components/Skeleton/Settings/Sections';
+import { WORKSPACE_SETTINGS_SECTION_SHAPES } from '@/components/Skeleton/Settings/sectionShapes';
import { createSurfaceSkeleton } from '@/components/Skeleton/Surface';
import { acceptanceRouteMeta } from '@/features/Acceptance/routeMeta';
import { agentDocumentRouteMeta } from '@/features/AgentDocumentPage/routeMeta';
@@ -59,6 +61,7 @@ import { createSettingsRouteMeta, settingsRouteMeta } from '@/features/Settings/
import { workspaceHomeRouteMeta } from '@/features/Workspace/routeMeta';
import WorkspaceProviderRedirect from '@/features/WorkspaceSetting/ProviderRedirect';
import {
+ agentChannelDetailRouteMeta,
agentChannelRouteMeta,
agentChatDesktopRouteMeta,
agentPermissionRouteMeta,
@@ -86,6 +89,17 @@ import { dynamicElement, dynamicLayout, ErrorBoundary, redirectElement } from '@
export { ResourceCategorySkeleton };
+// Workspace settings tabs made of stacked filled groups. The content layout
+// declares `chrome='body'` and draws the header + padded container, so inside
+// it these render only the sections.
+const workspaceSettingsSkeletons = {
+ billing: createSettingsSectionsSkeleton(WORKSPACE_SETTINGS_SECTION_SHAPES.billing),
+ budget: createSettingsSectionsSkeleton(WORKSPACE_SETTINGS_SECTION_SHAPES.budget),
+ credits: createSettingsSectionsSkeleton(WORKSPACE_SETTINGS_SECTION_SHAPES.credits),
+ plans: createSettingsSectionsSkeleton(WORKSPACE_SETTINGS_SECTION_SHAPES.plans),
+ usage: createSettingsSectionsSkeleton(WORKSPACE_SETTINGS_SECTION_SHAPES.usage),
+};
+
const agentChatElement = dynamicElement(
() => loadRouteWithBuiltinToolSurfaces(() => import('@/routes/(main)/agent')),
'Desktop > Chat',
@@ -227,7 +241,7 @@ export const sharedMainAreaChildren: RouteObject[] = [
() => import('@/routes/(main)/agent/channel/[platform]'),
'Desktop > Chat > Channel Platform',
),
- handle: { meta: agentChannelRouteMeta },
+ handle: { meta: agentChannelDetailRouteMeta },
loader: channelDataLoader,
path: 'channel/:platform',
},
@@ -1489,7 +1503,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/plans'),
'Desktop > Workspace > Settings > Plans',
),
- handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('detail') }) },
+ handle: { meta: routeMeta({ Skeleton: workspaceSettingsSkeletons.plans }) },
path: 'plans',
},
{
@@ -1497,7 +1511,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/billing'),
'Desktop > Workspace > Settings > Billing',
),
- handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('detail') }) },
+ handle: { meta: routeMeta({ Skeleton: workspaceSettingsSkeletons.billing }) },
path: 'billing',
},
{
@@ -1505,7 +1519,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/budget'),
'Desktop > Workspace > Settings > Budget',
),
- handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('detail') }) },
+ handle: { meta: routeMeta({ Skeleton: workspaceSettingsSkeletons.budget }) },
path: 'budget',
},
{
@@ -1513,7 +1527,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/credits'),
'Desktop > Workspace > Settings > Credits',
),
- handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('detail') }) },
+ handle: { meta: routeMeta({ Skeleton: workspaceSettingsSkeletons.credits }) },
path: 'credits',
},
{
@@ -1521,7 +1535,7 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
() => import('@/routes/(main)/[workspaceSlug]/settings/usage'),
'Desktop > Workspace > Settings > Usage',
),
- handle: { meta: routeMeta({ Skeleton: createSurfaceSkeleton('grid') }) },
+ handle: { meta: routeMeta({ Skeleton: workspaceSettingsSkeletons.usage }) },
path: 'usage',
},
{
diff --git a/src/spa/router/desktopRouter.sync.test.tsx b/src/spa/router/desktopRouter.sync.test.tsx
index 027fbdb5ee5..84bc9eba937 100644
--- a/src/spa/router/desktopRouter.sync.test.tsx
+++ b/src/spa/router/desktopRouter.sync.test.tsx
@@ -23,6 +23,7 @@ import SettingsPageSkeleton from '@/components/Skeleton/Settings/Page';
import ProviderSettingsSkeleton, {
ProviderDetailSkeleton,
} from '@/components/Skeleton/Settings/Provider';
+import { createSurfaceSkeleton } from '@/components/Skeleton/Surface';
import TasksSkeleton from '@/components/Skeleton/Tasks';
import TopicsSkeleton from '@/components/Skeleton/Topics';
import TaskDetailSkeleton from '@/features/AgentTasks/AgentTaskDetail/TaskDetailSkeleton';
@@ -496,6 +497,43 @@ describe('desktop router shared definition', () => {
}
});
+ it.each([
+ ['Web', (_pathname: string) => webDesktopRoutes],
+ ['Electron', (pathname: string) => createTabRouter(pathname).routes],
+ ])(
+ '%s gives section-stacked workspace settings tabs a sections skeleton without a second frame',
+ (_, getRoutes) => {
+ // Regression: these tabs used the generic avatar/detail surface, which
+ // looked nothing like the stacked groups the page renders.
+ const genericSurfaces = new Set([
+ createSurfaceSkeleton('detail'),
+ createSurfaceSkeleton('grid'),
+ ]);
+
+ for (const tab of ['plans', 'billing', 'budget', 'credits', 'usage']) {
+ const pathname = `/team/settings/${tab}`;
+ const matches = matchRoutes(getRoutes(pathname), pathname);
+ const Skeleton = resolveRouteSkeleton(
+ matches?.map(({ route }) => ({ handle: route.handle })) ?? [],
+ );
+
+ expect(Skeleton, pathname).toBeDefined();
+ expect(genericSurfaces.has(Skeleton!), pathname).toBe(false);
+
+ // Inside the content layout (`chrome='body'`) only the sections render:
+ // the layout already owns the navigation header and padded container.
+ const html = renderToString(
+ <MemoryRouter initialEntries={[pathname]}>
+ {Skeleton && <Skeleton chrome={'body'} />}
+ </MemoryRouter>,
+ );
+
+ expect(html, pathname).toContain('data-testid="settings-sections-skeleton"');
+ expect(html, pathname).not.toContain('max-width:1024px');
+ }
+ },
+ );
+
it.each([
['Web', (_pathname: string) => webDesktopRoutes],
['Electron', (pathname: string) => createTabRouter(pathname).routes],