Skip to content

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

πŸ’„ style(skeleton): keep first-screen skeletons continuous (#20624)

Innei26ffb3cf21fa
diff --git a/.agents/skills/spa-routes/SKILL.md b/.agents/skills/spa-routes/SKILL.md
index 78f1f810b39..09ade4e0dcd 100644
--- a/.agents/skills/spa-routes/SKILL.md
+++ b/.agents/skills/spa-routes/SKILL.md
@@ -89,6 +89,9 @@ Each feature should:
- Where to put it: on the route's `routeMeta` (feature `routeMeta.ts` or inline in `desktopRouter.shared.tsx`). A whole subtree sharing one shape can register once on the parent/layout route's `handle` β€” children with their own `Skeleton` still override.
- When changing a page's layout, update its registered skeleton in the same PR β€” a stale skeleton that no longer matches the page is a regression.
- Skeleton-only parent handles are safe for titles: title/icon resolution also walks deepest-first, and leaf metas keep winning.
+ - The same deepest skeleton renders at every pending boundary of the chain (layout chunk, page chunk, then the page's own data wait). Make the page's in-component loading state the registered skeleton, or a body that continues it; a different shape there reads as a second, unrelated skeleton.
+ - Route skeletons are always static imports: a fallback has to paint on its first render, and a `lazy()` skeleton (preloaded or not) renders blank until its chunk lands. That puts the skeleton's whole import graph in the entry chunk, so it may only reach UI primitives, other skeletons, constants and `import type`. Keep stores, services, feature components and value imports from barrels (`@/types/*` re-exports zod schemas) out of it; move the minimal piece next to the skeleton instead (see `ResourceHome/Skeleton` and `Explorer/viewMode.ts`).
+ - A custom fallback (`fallback:` option, in-page `Suspense`, or an early `return <XSkeleton />`) keeps the handover continuous only through `delayed()` / `DelayedFallback` or `RouteLoading`, which register the skeleton as visible (`retainSkeleton`). Rendering a skeleton any other way lets the next boundary wait out its 200ms delay on a blank pane.
---
diff --git a/src/components/Skeleton/Conversation/AgentLayout.tsx b/src/components/Skeleton/Conversation/AgentLayout.tsx
new file mode 100644
index 00000000000..abb277f6bd7
--- /dev/null
+++ b/src/components/Skeleton/Conversation/AgentLayout.tsx
@@ -0,0 +1,71 @@
+'use client';
+
+import { Flexbox } from '@lobehub/ui';
+import { createStaticStyles, cssVar } from 'antd-style';
+
+import {
+ OVERVIEW_PANEL_WIDTH,
+ resolveWorkingPanelPlaceholder,
+} from '@/features/Conversation/WorkingSidebar/layout';
+import { useGlobalStore } from '@/store/global';
+import { systemStatusSelectors } from '@/store/global/selectors';
+
+import SkeletonBar from '../Bar';
+import ConversationLayoutSkeleton from './Layout';
+
+const styles = createStaticStyles(({ css }) => ({
+ overviewCard: css`
+ margin: 16px;
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: 16px;
+ background: ${cssVar.colorBgContainer};
+ `,
+ rightPanel: css`
+ border-inline-start: 1px solid ${cssVar.colorBorderSecondary};
+ `,
+}));
+
+const PanelRows = ({ rows }: { rows: number }) => (
+ <Flexbox gap={12} padding={16}>
+ <SkeletonBar height={16} width={120} />
+ {Array.from({ length: rows }).map((_, index) => (
+ <SkeletonBar height={12} key={index} width={`${60 + ((index * 17) % 35)}%`} />
+ ))}
+ </Flexbox>
+);
+
+const AgentConversationLayoutSkeleton = () => {
+ const [showRightPanel, showWorkingOverview, workingSidebarWidth] = useGlobalStore((s) => [
+ systemStatusSelectors.showRightPanel(s),
+ systemStatusSelectors.showWorkingOverview(s),
+ systemStatusSelectors.workingSidebarWidth(s),
+ ]);
+ const { overview, rightPanelWidth } = resolveWorkingPanelPlaceholder({
+ showRightPanel,
+ showWorkingOverview,
+ workingSidebarWidth,
+ });
+
+ return (
+ <Flexbox horizontal flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
+ <ConversationLayoutSkeleton
+ aside={
+ overview && (
+ <Flexbox flex={'none'} width={OVERVIEW_PANEL_WIDTH + 32}>
+ <Flexbox className={styles.overviewCard}>
+ <PanelRows rows={5} />
+ </Flexbox>
+ </Flexbox>
+ )
+ }
+ />
+ {rightPanelWidth && (
+ <Flexbox className={styles.rightPanel} flex={'none'} width={rightPanelWidth}>
+ <PanelRows rows={8} />
+ </Flexbox>
+ )}
+ </Flexbox>
+ );
+};
+
+export default AgentConversationLayoutSkeleton;
diff --git a/src/components/Skeleton/Conversation/Layout.tsx b/src/components/Skeleton/Conversation/Layout.tsx
index 96ab685e6bd..d9242207e26 100644
--- a/src/components/Skeleton/Conversation/Layout.tsx
+++ b/src/components/Skeleton/Conversation/Layout.tsx
@@ -1,11 +1,18 @@
'use client';
import { Flexbox } from '@lobehub/ui';
+import type { ReactNode } from 'react';
+
+import type { RouteSkeletonProps } from '@/spa/router/routeMeta';
import SkeletonBar from '../Bar';
import ConversationSegmentSkeleton from './Segment';
-const ConversationLayoutSkeleton = () => (
+interface ConversationLayoutSkeletonProps extends RouteSkeletonProps {
+ aside?: ReactNode;
+}
+
+const ConversationLayoutSkeleton = ({ aside }: ConversationLayoutSkeletonProps) => (
<Flexbox aria-busy flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
<Flexbox
horizontal
@@ -18,7 +25,16 @@ const ConversationLayoutSkeleton = () => (
<SkeletonBar height={24} width={144} />
<SkeletonBar height={28} width={72} />
</Flexbox>
- <ConversationSegmentSkeleton />
+ {aside ? (
+ <Flexbox horizontal flex={1} style={{ minHeight: 0, minWidth: 0 }}>
+ <Flexbox flex={1} style={{ minHeight: 0, minWidth: 0 }}>
+ <ConversationSegmentSkeleton />
+ </Flexbox>
+ {aside}
+ </Flexbox>
+ ) : (
+ <ConversationSegmentSkeleton />
+ )}
</Flexbox>
);
diff --git a/src/components/Skeleton/Delayed.test.ts b/src/components/Skeleton/Delayed.test.ts
new file mode 100644
index 00000000000..667ce2753f0
--- /dev/null
+++ b/src/components/Skeleton/Delayed.test.ts
@@ -0,0 +1,29 @@
+/**
+ * @vitest-environment happy-dom
+ */
+import { act, renderHook } from '@testing-library/react';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+import { FALLBACK_DELAY, useDelayedVisible } from './Delayed';
+import { HANDOVER_WINDOW, isSkeletonHandover } from './skeletonHandover';
+
+afterEach(() => {
+ vi.useRealTimers();
+});
+
+describe('useDelayedVisible', () => {
+ it('counts as a visible skeleton for the next boundary while it is shown', () => {
+ vi.useFakeTimers();
+ const { result, unmount } = renderHook(() => useDelayedVisible());
+
+ expect(result.current).toBe(false);
+ act(() => {
+ vi.advanceTimersByTime(FALLBACK_DELAY);
+ });
+ expect(result.current).toBe(true);
+ expect(isSkeletonHandover(performance.now() + HANDOVER_WINDOW * 10)).toBe(true);
+
+ unmount();
+ expect(isSkeletonHandover(performance.now() + HANDOVER_WINDOW * 10)).toBe(false);
+ });
+});
diff --git a/src/components/Skeleton/Delayed.tsx b/src/components/Skeleton/Delayed.tsx
index aa9ac7e27ba..219d45a8d1b 100644
--- a/src/components/Skeleton/Delayed.tsx
+++ b/src/components/Skeleton/Delayed.tsx
@@ -1,8 +1,8 @@
'use client';
-import { type ReactNode, useEffect, useState } from 'react';
+import { type ReactNode, useEffect, useLayoutEffect, useState } from 'react';
-import { isSkeletonHandover } from './skeletonHandover';
+import { isSkeletonHandover, retainSkeleton } from './skeletonHandover';
/**
* Matches `BOOT_SHELL_DELAY`: below this, a placeholder is on screen for less
@@ -16,12 +16,7 @@ interface DelayedFallbackProps {
delay?: number;
}
-/**
- * Holds a page-level skeleton back until the wait is long enough to be worth
- * showing. A segment that resolves faster renders nothing at all β€” the
- * previous screen simply stays until the next one paints.
- */
-const DelayedFallback = ({ children, delay = FALLBACK_DELAY }: DelayedFallbackProps) => {
+export const useDelayedVisible = (delay = FALLBACK_DELAY) => {
const [elapsed, setElapsed] = useState(() => isSkeletonHandover());
useEffect(() => {
@@ -30,9 +25,22 @@ const DelayedFallback = ({ children, delay = FALLBACK_DELAY }: DelayedFallbackPr
return () => clearTimeout(timer);
}, [delay, elapsed]);
- return elapsed ? children : null;
+ useLayoutEffect(() => {
+ if (!elapsed) return;
+ return retainSkeleton();
+ }, [elapsed]);
+
+ return elapsed;
};
+/**
+ * Holds a page-level skeleton back until the wait is long enough to be worth
+ * showing. A segment that resolves faster renders nothing at all β€” the
+ * previous screen simply stays until the next one paints.
+ */
+const DelayedFallback = ({ children, delay }: DelayedFallbackProps) =>
+ useDelayedVisible(delay) ? children : null;
+
/** Wraps a route fallback element so it inherits the same 200ms gate. */
export const delayed = (fallback: ReactNode) => <DelayedFallback>{fallback}</DelayedFallback>;
diff --git a/src/components/Skeleton/RouteSegment.tsx b/src/components/Skeleton/RouteSegment.tsx
index fa5138fcf64..a93a8623e1b 100644
--- a/src/components/Skeleton/RouteSegment.tsx
+++ b/src/components/Skeleton/RouteSegment.tsx
@@ -6,7 +6,7 @@ import { useRouteSkeletonChrome } from '@/spa/router/routeSkeletonChrome';
import { useRouteSkeleton } from '@/spa/router/useRouteSkeleton';
import DelayedFallback from './Delayed';
-import { markSkeletonVisible } from './skeletonHandover';
+import { retainSkeleton } from './skeletonHandover';
// Same component the route Suspense fallback renders, so a page's data wait
// continues the chunk wait's skeleton instead of swapping to a second one.
@@ -16,8 +16,7 @@ export const RouteLoading = () => {
useLayoutEffect(() => {
if (!Skeleton) return;
- markSkeletonVisible();
- return markSkeletonVisible;
+ return retainSkeleton();
}, [Skeleton]);
if (!Skeleton) return null;
diff --git a/src/components/Skeleton/Settings/MessengerDetail.tsx b/src/components/Skeleton/Settings/MessengerDetail.tsx
new file mode 100644
index 00000000000..2f93ee7ddfd
--- /dev/null
+++ b/src/components/Skeleton/Settings/MessengerDetail.tsx
@@ -0,0 +1,75 @@
+'use client';
+
+import { Block, Flexbox } from '@lobehub/ui';
+import { Skeleton } from '@lobehub/ui/base-ui';
+import { createStaticStyles } from 'antd-style';
+import { memo } from 'react';
+
+const styles = createStaticStyles(({ css, cssVar }) => ({
+ card: css`
+ padding: 16px;
+ border: 1px solid ${cssVar.colorBorder};
+ border-radius: ${cssVar.borderRadius};
+ `,
+}));
+
+const ConnectionsSkeleton = memo<{ withNestedContent?: boolean }>(
+ ({ withNestedContent = false }) => (
+ <Flexbox gap={12}>
+ {Array.from({ length: 2 }).map((_, index) => (
+ <Block className={styles.card} key={index}>
+ <Flexbox gap={12}>
+ <Flexbox horizontal align="center" gap={12}>
+ <Skeleton.Avatar shape={'square'} size={36} />
+ <Flexbox flex={1} gap={6}>
+ <Skeleton height={28} width={56} />
+ <Skeleton height={18} width={'40%'} />
+ </Flexbox>
+ <Skeleton height={28} width={72} />
+ <Skeleton height={28} width={84} />
+ </Flexbox>
+ {withNestedContent && (
+ <Flexbox gap={6} style={{ paddingInlineStart: 48 }}>
+ <Skeleton height={28} width={72} />
+ <Skeleton height={32} width={'100%'} />
+ </Flexbox>
+ )}
+ </Flexbox>
+ </Block>
+ ))}
+ </Flexbox>
+ ),
+);
+ConnectionsSkeleton.displayName = 'MessengerConnectionsSkeleton';
+
+export const IntegrationDetailSkeleton = memo<{ withNestedContent?: boolean }>(
+ ({ withNestedContent = false }) => (
+ <Flexbox gap={20}>
+ <Flexbox horizontal align="center" gap={12}>
+ <Skeleton height={28} width={20} />
+ <Skeleton height={28} width={96} />
+ </Flexbox>
+
+ <Block className={styles.card}>
+ <Flexbox horizontal align="center" gap={16}>
+ <Skeleton.Avatar shape={'square'} size={48} />
+ <Flexbox flex={1} gap={6}>
+ <Skeleton height={28} width={64} />
+ <Skeleton.Text rows={1} width={'65%'} />
+ </Flexbox>
+ <Skeleton height={40} width={120} />
+ </Flexbox>
+ </Block>
+
+ <Flexbox gap={8}>
+ <Skeleton height={28} width={72} />
+ <ConnectionsSkeleton withNestedContent={withNestedContent} />
+ </Flexbox>
+ </Flexbox>
+ ),
+);
+IntegrationDetailSkeleton.displayName = 'MessengerIntegrationDetailSkeleton';
+
+export const MessengerPlatformDetailSkeleton = ({ platform }: { platform: string }) => (
+ <IntegrationDetailSkeleton withNestedContent={platform !== 'slack'} />
+);
diff --git a/src/components/Skeleton/Settings/Page.test.ts b/src/components/Skeleton/Settings/Page.test.ts
new file mode 100644
index 00000000000..2e07ba6828a
--- /dev/null
+++ b/src/components/Skeleton/Settings/Page.test.ts
@@ -0,0 +1,22 @@
+import { describe, expect, it } from 'vitest';
+
+import { resolveSettingsSkeletonBody } from './Page';
+
+describe('resolveSettingsSkeletonBody', () => {
+ it('uses the platform detail shape for a messenger platform page', () => {
+ expect(resolveSettingsSkeletonBody('/settings/messenger/discord')).toEqual({
+ kind: 'messengerDetail',
+ platform: 'discord',
+ });
+ });
+
+ it('keeps the section shape for the messenger list and other tabs', () => {
+ expect(resolveSettingsSkeletonBody('/settings/messenger')).toEqual({ kind: 'section' });
+ expect(resolveSettingsSkeletonBody('/settings/common')).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 176a8db08a3..1ad1c1389ed 100644
--- a/src/components/Skeleton/Settings/Page.tsx
+++ b/src/components/Skeleton/Settings/Page.tsx
@@ -8,13 +8,32 @@ import SettingContainer from '@/features/Setting/SettingContainer';
import type { RouteSkeletonProps } from '@/spa/router/routeMeta';
import SkeletonBar from '../Bar';
+import { MessengerPlatformDetailSkeleton } from './MessengerDetail';
import SettingsProfileSkeleton from './Profile';
import SettingsSectionSkeleton from './Section';
+type SettingsSkeletonBody =
+ { kind: 'messengerDetail'; platform: string } | { kind: 'profile' } | { kind: 'section' };
+
+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 };
+ return { kind: 'section' };
+};
+
+export const SettingsBodySkeleton = () => {
+ const body = resolveSettingsSkeletonBody(useLocation().pathname);
+
+ if (body.kind === 'profile') return <SettingsProfileSkeleton />;
+ if (body.kind === 'messengerDetail')
+ return <MessengerPlatformDetailSkeleton platform={body.platform} />;
+ return <SettingsSectionSkeleton />;
+};
+
const SettingsPageSkeleton = ({ chrome = 'page' }: RouteSkeletonProps) => {
- const { pathname } = useLocation();
- const tab = pathname.match(/\/settings\/([^/]+)/)?.[1] ?? 'profile';
- const profile = tab === 'profile';
+ const profile = resolveSettingsSkeletonBody(useLocation().pathname).kind === 'profile';
return (
<Flexbox aria-busy flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
@@ -24,7 +43,7 @@ const SettingsPageSkeleton = ({ chrome = 'page' }: RouteSkeletonProps) => {
</NavHeader>
)}
<SettingContainer maxWidth={1024} paddingBlock={'24px 128px'} paddingInline={24}>
- {profile ? <SettingsProfileSkeleton /> : <SettingsSectionSkeleton />}
+ <SettingsBodySkeleton />
</SettingContainer>
</Flexbox>
);
diff --git a/src/components/Skeleton/Settings/Provider.tsx b/src/components/Skeleton/Settings/Provider.tsx
new file mode 100644
index 00000000000..080c4ba4838
--- /dev/null
+++ b/src/components/Skeleton/Settings/Provider.tsx
@@ -0,0 +1,58 @@
+'use client';
+
+import { Flexbox } from '@lobehub/ui';
+import { cssVar } from 'antd-style';
+import { useLocation } from 'react-router';
+
+import NavHeader from '@/features/NavHeader';
+import SettingContainer from '@/features/Setting/SettingContainer';
+import { PROVIDER_MENU_WIDTH } from '@/features/Settings/provider/const';
+
+import SkeletonBar from '../Bar';
+import SkeletonList from '../NavPanel/List';
+import SurfaceSkeleton from '../Surface';
+
+const isProviderGridPath = (pathname: string) => /\/provider(?:\/all)?\/?$/.test(pathname);
+
+export const ProviderDetailSkeleton = () => {
+ const { pathname } = useLocation();
+
+ return (
+ <SurfaceSkeleton header={false} variant={isProviderGridPath(pathname) ? 'grid' : 'form'} />
+ );
+};
+
+const ProviderSettingsSkeleton = () => (
+ <Flexbox aria-busy horizontal height={'100%'} width={'100%'}>
+ <Flexbox
+ width={PROVIDER_MENU_WIDTH}
+ style={{
+ background: cssVar.colorBgContainer,
+ borderRight: `1px solid ${cssVar.colorBorderSecondary}`,
+ minWidth: PROVIDER_MENU_WIDTH,
+ }}
+ >
+ <Flexbox
+ horizontal
+ align={'center'}
+ gap={8}
+ padding={8}
+ style={{ borderBottom: `1px solid ${cssVar.colorBorderSecondary}`, marginBottom: 8 }}
+ >
+ <Flexbox flex={1}>
+ <SkeletonBar height={32} />
+ </Flexbox>
+ <SkeletonBar height={28} width={28} />
+ </Flexbox>
+ <SkeletonList />
+ </Flexbox>
+ <Flexbox height={'100%'} width={'100%'}>
+ <NavHeader />
+ <SettingContainer maxWidth={1024} padding={24} style={{ minHeight: '100%' }}>
+ <ProviderDetailSkeleton />
+ </SettingContainer>
+ </Flexbox>
+ </Flexbox>
+);
+
+export default ProviderSettingsSkeleton;
diff --git a/src/components/Skeleton/skeletonHandover.test.ts b/src/components/Skeleton/skeletonHandover.test.ts
index cc9eba8f44c..dd40959d1f8 100644
--- a/src/components/Skeleton/skeletonHandover.test.ts
+++ b/src/components/Skeleton/skeletonHandover.test.ts
@@ -1,6 +1,11 @@
import { describe, expect, it } from 'vitest';
-import { HANDOVER_WINDOW, isSkeletonHandover, markSkeletonVisible } from './skeletonHandover';
+import {
+ HANDOVER_WINDOW,
+ isSkeletonHandover,
+ markSkeletonVisible,
+ retainSkeleton,
+} from './skeletonHandover';
describe('skeletonHandover', () => {
it('is not a handover before any skeleton was visible', () => {
@@ -16,4 +21,12 @@ describe('skeletonHandover', () => {
markSkeletonVisible(20_000);
expect(isSkeletonHandover(20_000 + HANDOVER_WINDOW)).toBe(false);
});
+
+ it('is a handover while a skeleton is still mounted, however long it has been visible', () => {
+ const release = retainSkeleton();
+ expect(isSkeletonHandover(performance.now() + HANDOVER_WINDOW * 10)).toBe(true);
+
+ release();
+ expect(isSkeletonHandover(performance.now() + HANDOVER_WINDOW)).toBe(false);
+ });
});
diff --git a/src/components/Skeleton/skeletonHandover.ts b/src/components/Skeleton/skeletonHandover.ts
index fb00180ff55..3f90c327d48 100644
--- a/src/components/Skeleton/skeletonHandover.ts
+++ b/src/components/Skeleton/skeletonHandover.ts
@@ -5,10 +5,22 @@
export const HANDOVER_WINDOW = 400;
let lastSkeletonVisibleAt = -Infinity;
+let visibleSkeletons = 0;
export const markSkeletonVisible = (now = performance.now()) => {
lastSkeletonVisibleAt = now;
};
+// The next fallback renders before the previous one's unmount cleanup runs, so
+// a skeleton that is still mounted has to count as visible on its own.
+export const retainSkeleton = () => {
+ visibleSkeletons += 1;
+ markSkeletonVisible();
+ return () => {
+ visibleSkeletons -= 1;
+ markSkeletonVisible();
+ };
+};
+
export const isSkeletonHandover = (now = performance.now()) =>
- now - lastSkeletonVisibleAt < HANDOVER_WINDOW;
+ visibleSkeletons > 0 || now - lastSkeletonVisibleAt < HANDOVER_WINDOW;
diff --git a/src/features/Conversation/WorkingSidebar/__tests__/index.test.tsx b/src/features/Conversation/WorkingSidebar/__tests__/index.test.tsx
index c37366ae9c0..5d1dbad9d5c 100644
--- a/src/features/Conversation/WorkingSidebar/__tests__/index.test.tsx
+++ b/src/features/Conversation/WorkingSidebar/__tests__/index.test.tsx
@@ -256,6 +256,8 @@ vi.mock('@/store/global/selectors', () => ({
systemStatusSelectors: {
portalWidth: (s: typeof globalStore) => s.status.portalWidth || 400,
portalWidths: (s: typeof globalStore) => s.status.portalWidths,
+ showWorkingOverview: (s: typeof globalStore) =>
+ s.status.showWorkingOverview ?? !s.status.showRightPanel,
workingSidebarWidth: (s: typeof globalStore) => s.status.workingSidebarWidth || 360,
},
}));
diff --git a/src/features/Conversation/WorkingSidebar/index.tsx b/src/features/Conversation/WorkingSidebar/index.tsx
index 9daff27e579..a5d0a5482f0 100644
--- a/src/features/Conversation/WorkingSidebar/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/index.tsx
@@ -83,6 +83,7 @@ import { systemStatusSelectors } from '@/store/global/selectors';
import { type ComposerTarget, createComposerTarget, resolveThreadComposerTarget } from '../types';
import Files from './Files';
import { sidebarWidthBudget } from './fitsBesidePortal';
+import { MAX_PANEL_WIDTH, MIN_PANEL_WIDTH, OVERVIEW_PANEL_WIDTH } from './layout';
import Overview from './Overview';
import OverviewSlot from './OverviewSlot';
import PullRequest from './PullRequest';
@@ -187,10 +188,7 @@ const styles = createStaticStyles(({ css }) => ({
const REVIEW_TREE_STORAGE_KEY = 'lobechat-review-tree';
const OPEN_TABS_STORAGE_KEY = 'lobechat-working-sidebar-open-tabs-v1';
const PINNED_TABS_STORAGE_KEY = 'lobechat-working-sidebar-pinned-tabs-v1';
-const OVERVIEW_PANEL_WIDTH = 340;
const OVERVIEW_TRANSITION = { duration: 0.25, ease: [0.32, 0.72, 0, 1] } as const;
-const MIN_PANEL_WIDTH = 300;
-const MAX_PANEL_WIDTH = 1200;
// Two-pane Review (diff list + file-tree rail) is cramped below this.
const TWO_PANE_MIN_WIDTH = 560;
@@ -250,7 +248,7 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth })
// the resources pane's document fetch so a collapsed sidebar doesn't pull the
// full agent-document list into the conversation's initial batch.
s.status.showRightPanel,
- s.status.showWorkingOverview ?? !s.status.showRightPanel,
+ systemStatusSelectors.showWorkingOverview(s),
s.status.workingSidebarTab,
s.status.workingSidebarTabRequest,
]);
diff --git a/src/features/Conversation/WorkingSidebar/layout.test.ts b/src/features/Conversation/WorkingSidebar/layout.test.ts
new file mode 100644
index 00000000000..9d0865429e1
--- /dev/null
+++ b/src/features/Conversation/WorkingSidebar/layout.test.ts
@@ -0,0 +1,31 @@
+import { describe, expect, it } from 'vitest';
+
+import { MIN_PANEL_WIDTH, resolveWorkingPanelPlaceholder } from './layout';
+
+describe('resolveWorkingPanelPlaceholder', () => {
+ it('reserves only the overview card when the working panel is closed', () => {
+ expect(
+ resolveWorkingPanelPlaceholder({ showWorkingOverview: true, workingSidebarWidth: 360 }),
+ ).toEqual({ overview: true, rightPanelWidth: undefined });
+ });
+
+ it('reserves the stored panel width when the working panel is open', () => {
+ expect(
+ resolveWorkingPanelPlaceholder({
+ showRightPanel: true,
+ showWorkingOverview: false,
+ workingSidebarWidth: 480,
+ }),
+ ).toEqual({ overview: false, rightPanelWidth: 480 });
+ });
+
+ it('clamps a stored width below the panel minimum', () => {
+ expect(
+ resolveWorkingPanelPlaceholder({
+ showRightPanel: true,
+ showWorkingOverview: true,
+ workingSidebarWidth: 100,
+ }),
+ ).toEqual({ overview: true, rightPanelWidth: MIN_PANEL_WIDTH });
+ });
+});
diff --git a/src/features/Conversation/WorkingSidebar/layout.ts b/src/features/Conversation/WorkingSidebar/layout.ts
new file mode 100644
index 00000000000..6e3cdce81d7
--- /dev/null
+++ b/src/features/Conversation/WorkingSidebar/layout.ts
@@ -0,0 +1,27 @@
+export const OVERVIEW_PANEL_WIDTH = 340;
+export const MIN_PANEL_WIDTH = 300;
+export const MAX_PANEL_WIDTH = 1200;
+
+interface WorkingPanelPreference {
+ showRightPanel?: boolean;
+ showWorkingOverview: boolean;
+ workingSidebarWidth: number;
+}
+
+export interface WorkingPanelPlaceholder {
+ overview: boolean;
+ rightPanelWidth?: number;
+}
+
+// Mirrors the sidebar's first paint, where the row is not measured yet and
+// every width fits, so a skeleton can hold the same space before it mounts.
+export const resolveWorkingPanelPlaceholder = ({
+ showRightPanel,
+ showWorkingOverview,
+ workingSidebarWidth,
+}: WorkingPanelPreference): WorkingPanelPlaceholder => ({
+ overview: showWorkingOverview,
+ rightPanelWidth: showRightPanel
+ ? Math.min(MAX_PANEL_WIDTH, Math.max(MIN_PANEL_WIDTH, workingSidebarWidth))
+ : undefined,
+});
diff --git a/src/features/Messenger/IntegrationDetail/shared.tsx b/src/features/Messenger/IntegrationDetail/shared.tsx
index 5e56f5b14fe..a8f2e43a7d3 100644
--- a/src/features/Messenger/IntegrationDetail/shared.tsx
+++ b/src/features/Messenger/IntegrationDetail/shared.tsx
@@ -1,7 +1,7 @@
'use client';
import { Block, Flexbox, Icon } from '@lobehub/ui';
-import { Button, confirmModal, Select, Skeleton, Tag, Text, toast } from '@lobehub/ui/base-ui';
+import { Button, confirmModal, Select, Tag, Text, toast } from '@lobehub/ui/base-ui';
import { createStaticStyles } from 'antd-style';
import { ArrowLeftIcon, CheckCircle2Icon, Trash2Icon, UserIcon } from 'lucide-react';
import type { ReactNode } from 'react';
@@ -117,62 +117,7 @@ export const ConnectionRow = memo<ConnectionRowProps>(
);
ConnectionRow.displayName = 'MessengerConnectionRow';
-const ConnectionsSkeleton = memo<{ withNestedContent?: boolean }>(
- ({ withNestedContent = false }) => (
- <Flexbox gap={12}>
- {Array.from({ length: 2 }).map((_, index) => (
- <Block className={styles.card} key={index}>
- <Flexbox gap={12}>
- <Flexbox horizontal align="center" gap={12}>
- <Skeleton.Avatar shape={'square'} size={36} />
- <Flexbox flex={1} gap={6}>
- <Skeleton height={28} width={56} />
- <Skeleton height={18} width={'40%'} />
- </Flexbox>
- <Skeleton height={28} width={72} />
- <Skeleton height={28} width={84} />
- </Flexbox>
- {withNestedContent && (
- <Flexbox gap={6} style={{ paddingInlineStart: 48 }}>
- <Skeleton height={28} width={72} />
- <Skeleton height={32} width={'100%'} />
- </Flexbox>
- )}
- </Flexbox>
- </Block>
- ))}
- </Flexbox>
- ),
-);
-ConnectionsSkeleton.displayName = 'MessengerConnectionsSkeleton';
-
-export const IntegrationDetailSkeleton = memo<{ withNestedContent?: boolean }>(
- ({ withNestedContent = false }) => (
- <Flexbox gap={20}>
- <Flexbox horizontal align="center" gap={12}>
- <Skeleton height={28} width={20} />
- <Skeleton height={28} width={96} />
- </Flexbox>
-
- <Block className={styles.card}>
- <Flexbox horizontal align="center" gap={16}>
- <Skeleton.Avatar shape={'square'} size={48} />
- <Flexbox flex={1} gap={6}>
- <Skeleton height={28} width={64} />
- <Skeleton.Text rows={1} width={'65%'} />
- </Flexbox>
- <Skeleton height={40} width={120} />
- </Flexbox>
- </Block>
-
- <Flexbox gap={8}>
- <Skeleton height={28} width={72} />
- <ConnectionsSkeleton withNestedContent={withNestedContent} />
- </Flexbox>
- </Flexbox>
- ),
-);
-IntegrationDetailSkeleton.displayName = 'MessengerIntegrationDetailSkeleton';
+export { IntegrationDetailSkeleton } from '@/components/Skeleton/Settings/MessengerDetail';
interface DetailLayoutProps {
children?: ReactNode;
diff --git a/src/features/Messenger/index.tsx b/src/features/Messenger/index.tsx
index c79b96ba8fe..683e0561b99 100644
--- a/src/features/Messenger/index.tsx
+++ b/src/features/Messenger/index.tsx
@@ -10,6 +10,7 @@ import useSWR from 'swr';
import AsyncBoundary from '@/components/AsyncBoundary';
import ImperativeModal from '@/components/ImperativeModal';
+import { MessengerPlatformDetailSkeleton } from '@/components/Skeleton/Settings/MessengerDetail';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { messengerKeys } from '@/libs/swr/keys';
import { messengerService } from '@/services/messenger';
@@ -129,7 +130,9 @@ const MessengerSettings = memo(() => {
return (
<div className={styles.page}>
<Flexbox gap={20}>
- {selected && selectedMeta ? (
+ {selected && !selectedMeta && platformsSWR.isLoading ? (
+ <MessengerPlatformDetailSkeleton platform={selected} />
+ ) : selected && selectedMeta ? (
<IntegrationDetail
access={selectedMeta.access}
appId={selectedMeta.appId}
diff --git a/src/features/PageEditor/PageAgentProvider.test.tsx b/src/features/PageEditor/PageAgentProvider.test.tsx
index 9a2d60c129e..e1fdb4be620 100644
--- a/src/features/PageEditor/PageAgentProvider.test.tsx
+++ b/src/features/PageEditor/PageAgentProvider.test.tsx
@@ -30,7 +30,13 @@ let agentState: AgentState;
let chatState: ChatState;
vi.mock('@/components/Skeleton/Conversation/Segment', () => ({
- default: () => <div data-testid="loading" />,
+ default: () => <div data-testid="conversation-skeleton" />,
+}));
+
+vi.mock('@/components/Skeleton/Surface', () => ({
+ default: ({ variant }: { variant?: string }) => (
+ <div data-testid="surface-skeleton" data-variant={variant} />
+ ),
}));
vi.mock('@/features/Conversation', () => ({
@@ -100,6 +106,20 @@ beforeEach(() => {
});
describe('PageAgentProvider', () => {
+ it('keeps the editor skeleton while the page agent is initializing', () => {
+ agentState.activeAgentId = undefined;
+ agentState.pageAgentId = '';
+
+ const { queryByTestId, getByTestId } = render(
+ <PageAgentProvider pageId="doc-1">
+ <div>child</div>
+ </PageAgentProvider>,
+ );
+
+ expect(getByTestId('surface-skeleton').dataset.variant).toBe('editor');
+ expect(queryByTestId('conversation-skeleton')).toBeNull();
+ });
+
it('resets a stale page topic on initial scoped agent sync only', async () => {
const { rerender } = render(
<PageAgentProvider>
diff --git a/src/features/PageEditor/PageAgentProvider.tsx b/src/features/PageEditor/PageAgentProvider.tsx
index 805fdf0c073..bceb22416eb 100644
--- a/src/features/PageEditor/PageAgentProvider.tsx
+++ b/src/features/PageEditor/PageAgentProvider.tsx
@@ -3,7 +3,7 @@ import { isChatGroupSessionId } from '@lobechat/types';
import type { ReactNode } from 'react';
import { memo, useEffect, useMemo, useRef } from 'react';
-import ConversationSegmentSkeleton from '@/components/Skeleton/Conversation/Segment';
+import SurfaceSkeleton from '@/components/Skeleton/Surface';
import type { ConversationContext } from '@/features/Conversation';
import { ConversationProvider } from '@/features/Conversation';
import { useOperationState } from '@/hooks/useOperationState';
@@ -102,7 +102,9 @@ export const PageAgentProvider = memo<PageAgentProviderProps>(
// Get operation state for reactive updates
const operationState = useOperationState(context);
- if (!pageAgentId) return <ConversationSegmentSkeleton />;
+ // This provider wraps the whole editor, so its wait has to keep the editor's
+ // shape; a conversation skeleton here replaces the page with a chat layout.
+ if (!pageAgentId) return <SurfaceSkeleton variant={'editor'} />;
return (
<ConversationProvider
diff --git a/src/features/ResourceManager/components/Explorer/viewMode.ts b/src/features/ResourceManager/components/Explorer/viewMode.ts
index 1f4f1ec704e..1235779ad84 100644
--- a/src/features/ResourceManager/components/Explorer/viewMode.ts
+++ b/src/features/ResourceManager/components/Explorer/viewMode.ts
@@ -1,12 +1,16 @@
import type { ViewMode } from '@/features/ResourceManager/store/initialState';
-import { FilesTabs } from '@/types/files';
+import type { FilesTabs } from '@/types/files';
-const GALLERY_FIRST_CATEGORIES = new Set<FilesTabs>([
- FilesTabs.Audios,
- FilesTabs.Images,
- FilesTabs.Videos,
- FilesTabs.Websites,
+// Type-only on `@/types/files`: the route skeleton reads this from the entry
+// chunk, and the value import would drag that barrel's zod schemas in with it.
+const GALLERY_FIRST_CATEGORIES = new Set<`${FilesTabs}`>([
+ 'audios',
+ 'images',
+ 'videos',
+ 'websites',
]);
-export const getDefaultResourceViewMode = (category: FilesTabs, libraryId?: string): ViewMode =>
- !libraryId && GALLERY_FIRST_CATEGORIES.has(category) ? 'masonry' : 'list';
+export const getDefaultResourceViewMode = (
+ category: `${FilesTabs}`,
+ libraryId?: string,
+): ViewMode => (!libraryId && GALLERY_FIRST_CATEGORIES.has(category) ? 'masonry' : 'list');
diff --git a/src/features/Settings/features/componentMap.ts b/src/features/Settings/features/componentMap.ts
index a4f5862cabe..18038b0ce7a 100644
--- a/src/features/Settings/features/componentMap.ts
+++ b/src/features/Settings/features/componentMap.ts
@@ -1,11 +1,11 @@
import { createElement } from 'react';
+import { SettingsBodySkeleton } from '@/components/Skeleton/Settings/Page';
import SettingsProfileSkeleton from '@/components/Skeleton/Settings/Profile';
-import SettingsSectionSkeleton from '@/components/Skeleton/Settings/Section';
import dynamic from '@/libs/next/dynamic';
import { SettingsTabs } from '@/store/global/initialState';
-const loading = (_debugId: string) => () => createElement(SettingsSectionSkeleton);
+const loading = (_debugId: string) => () => createElement(SettingsBodySkeleton);
export const componentMap = {
[SettingsTabs.Advanced]: dynamic(() => import('../advanced'), {
diff --git a/src/features/Settings/provider/ProviderMenu/index.tsx b/src/features/Settings/provider/ProviderMenu/index.tsx
index 1c0d6c0a5cd..3c982781cb8 100644
--- a/src/features/Settings/provider/ProviderMenu/index.tsx
+++ b/src/features/Settings/provider/ProviderMenu/index.tsx
@@ -11,6 +11,7 @@ import AsyncBoundary from '@/components/AsyncBoundary';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import { useAiInfraStore } from '@/store/aiInfra/store';
+import { PROVIDER_MENU_WIDTH } from '../const';
import AddNew from './AddNew';
import ProviderList from './List';
import SearchResult from './SearchResult';
@@ -24,7 +25,7 @@ const Layout = memo(({ children, mobile }: ProviderMenuProps) => {
const providerSearchKeyword = useAiInfraStore((s) => s.providerSearchKeyword);
- const width = mobile ? undefined : 280;
+ const width = mobile ? undefined : PROVIDER_MENU_WIDTH;
return (
<Flexbox
width={width}
diff --git a/src/features/Settings/provider/const.ts b/src/features/Settings/provider/const.ts
index 73c4e9c234b..6133dc67514 100644
--- a/src/features/Settings/provider/const.ts
+++ b/src/features/Settings/provider/const.ts
@@ -18,3 +18,5 @@ export const LLMProviderBaseUrlKey = 'baseURL';
* equal CUSTOM_MODELS
*/
export const LLMProviderModelListKey = 'enabledModels';
+
+export const PROVIDER_MENU_WIDTH = 280;
diff --git a/src/routes/(main)/agent/features/Conversation/Header/WorkingPanelToggle/index.tsx b/src/routes/(main)/agent/features/Conversation/Header/WorkingPanelToggle/index.tsx
index 137c3034879..641138c4486 100644
--- a/src/routes/(main)/agent/features/Conversation/Header/WorkingPanelToggle/index.tsx
+++ b/src/routes/(main)/agent/features/Conversation/Header/WorkingPanelToggle/index.tsx
@@ -22,7 +22,7 @@ const WorkingPanelToggle = memo(() => {
isStatusInit,
] = useGlobalStore((s) => [
systemStatusSelectors.showRightPanel(s),
- s.status.showWorkingOverview ?? !s.status.showRightPanel,
+ systemStatusSelectors.showWorkingOverview(s),
s.toggleRightPanel,
s.openWorkingSidebar,
s.updateSystemStatus,
diff --git a/src/routes/(main)/agent/features/routeMeta.ts b/src/routes/(main)/agent/features/routeMeta.ts
index be41c2d3521..c97938819c7 100644
--- a/src/routes/(main)/agent/features/routeMeta.ts
+++ b/src/routes/(main)/agent/features/routeMeta.ts
@@ -11,6 +11,7 @@ import {
import { lazy } from 'react';
import AgentShareSkeleton from '@/components/Skeleton/AgentShare';
+import AgentConversationLayoutSkeleton from '@/components/Skeleton/Conversation/AgentLayout';
import ConversationLayoutSkeleton from '@/components/Skeleton/Conversation/Layout';
import ProfileSkeleton from '@/components/Skeleton/Profile';
import { createSurfaceSkeleton } from '@/components/Skeleton/Surface';
@@ -61,6 +62,12 @@ export const agentRouteMeta = routeMeta({
titleKey: 'navigation.chat',
});
+// Desktop mounts the working sidebar beside the conversation; mobile does not.
+export const agentChatDesktopRouteMeta = routeMeta({
+ ...agentRouteMeta,
+ Skeleton: AgentConversationLayoutSkeleton,
+});
+
export const topicsRouteMeta = routeMeta({
DynamicMeta: TopicsDynamicMeta,
icon: MessagesSquareIcon,
diff --git a/src/spa/BootShell/AppShellSkeleton.tsx b/src/spa/BootShell/AppShellSkeleton.tsx
index 95fae50ae47..fa4092ff768 100644
--- a/src/spa/BootShell/AppShellSkeleton.tsx
+++ b/src/spa/BootShell/AppShellSkeleton.tsx
@@ -4,9 +4,10 @@ import { TITLE_BAR_HEIGHT } from '@lobechat/desktop-bridge';
import { Flexbox } from '@lobehub/ui';
import { LobeHub } from '@lobehub/ui/brand';
import { createStaticStyles, keyframes } from 'antd-style';
-import { memo, useEffect, useState } from 'react';
+import { memo, useEffect, useLayoutEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { retainSkeleton } from '@/components/Skeleton/skeletonHandover';
import { isDesktop } from '@/const/version';
import {
getInnerCssVariables,
@@ -119,6 +120,8 @@ const AppShellSkeleton = memo<AppShellSkeletonProps>(({ id }) => {
const { isDark, navPanelBackground, navPanelWidth, showLeftPanel } = readBootShellGeometry();
const [waiting, setWaiting] = useState(false);
+ useLayoutEffect(retainSkeleton, []);
+
useEffect(() => {
const timer = setTimeout(() => setWaiting(true), HINT_DELAY);
return () => clearTimeout(timer);
diff --git a/src/spa/router/agentChatTopicListLoader.wiring.test.ts b/src/spa/router/agentChatTopicListLoader.wiring.test.ts
index 2115463a1a1..2dfc9864e38 100644
--- a/src/spa/router/agentChatTopicListLoader.wiring.test.ts
+++ b/src/spa/router/agentChatTopicListLoader.wiring.test.ts
@@ -2,7 +2,10 @@
import type { RouteObject } from 'react-router';
import { describe, expect, it, vi } from 'vitest';
-import { agentRouteMeta } from '@/routes/(main)/agent/features/routeMeta';
+import {
+ agentChatDesktopRouteMeta,
+ agentRouteMeta,
+} from '@/routes/(main)/agent/features/routeMeta';
import { agentChatTopicListLoader } from './agentChatTopicListLoader';
import { desktopRoutes } from './desktopRouter.config';
@@ -24,10 +27,11 @@ const flatten = (routes: RouteObject[]): RouteObject[] =>
/**
* The chat routes are the ones carrying the agent chat meta (index + `:topicId`);
* every other agent sub-route (docs, goals, profile, …) has its own meta.
+ * Desktop uses agentChatDesktopRouteMeta so the working-sidebar skeleton can differ.
*/
-const chatRoutes = (routes: RouteObject[]) =>
+const chatRoutes = (routes: RouteObject[], meta: unknown) =>
flatten(routes).filter(
- (route) => (route.handle as { meta?: unknown } | undefined)?.meta === agentRouteMeta,
+ (route) => (route.handle as { meta?: unknown } | undefined)?.meta === meta,
);
// The hydration itself is covered elsewhere; this guards the wiring, which is the
@@ -39,14 +43,14 @@ describe('agent chat topic list loader wiring', () => {
});
it('pre-hydrates the topic list on every desktop agent chat route', () => {
- const routes = chatRoutes(desktopRoutes);
+ const routes = chatRoutes(desktopRoutes, agentChatDesktopRouteMeta);
expect(routes.length).toBeGreaterThan(0);
expect(routes.map((route) => route.loader)).toEqual(routes.map(() => agentChatTopicListLoader));
});
it('pre-hydrates the topic list on the mobile agent chat routes too', () => {
- const routes = chatRoutes(mobileRoutes);
+ const routes = chatRoutes(mobileRoutes, agentRouteMeta);
expect(routes.length).toBeGreaterThan(0);
expect(routes.map((route) => route.loader)).toEqual(routes.map(() => agentChatTopicListLoader));
diff --git a/src/spa/router/desktopRouter.shared.tsx b/src/spa/router/desktopRouter.shared.tsx
index 2575340159e..90cd8997f28 100644
--- a/src/spa/router/desktopRouter.shared.tsx
+++ b/src/spa/router/desktopRouter.shared.tsx
@@ -18,14 +18,7 @@ import {
SquarePlay,
Video,
} from 'lucide-react';
-import {
- createElement,
- isValidElement,
- lazy,
- type ReactElement,
- type ReactNode,
- Suspense,
-} from 'react';
+import { createElement, isValidElement, type ReactElement, type ReactNode, Suspense } from 'react';
import type { RouteObject } from 'react-router';
import {
@@ -37,6 +30,7 @@ import BrandTextLoading from '@/components/Loading/BrandTextLoading';
import AppsSkeleton from '@/components/Skeleton/Apps';
import CommunityHomeSkeleton from '@/components/Skeleton/CommunityHome';
import CommunityListSkeleton from '@/components/Skeleton/CommunityList';
+import AgentConversationLayoutSkeleton from '@/components/Skeleton/Conversation/AgentLayout';
import ConversationLayoutSkeleton from '@/components/Skeleton/Conversation/Layout';
import ConversationSegmentSkeleton from '@/components/Skeleton/Conversation/Segment';
import { delayed } from '@/components/Skeleton/Delayed';
@@ -44,6 +38,9 @@ import GenerationSkeleton from '@/components/Skeleton/Generation';
import MemorySkeleton from '@/components/Skeleton/Memory';
import ResourceHomeSkeleton from '@/components/Skeleton/ResourceHome';
import RouteSegmentSkeleton from '@/components/Skeleton/RouteSegment';
+import ProviderSettingsSkeleton, {
+ ProviderDetailSkeleton,
+} from '@/components/Skeleton/Settings/Provider';
import { createSurfaceSkeleton } from '@/components/Skeleton/Surface';
import { acceptanceRouteMeta } from '@/features/Acceptance/routeMeta';
import { agentDocumentRouteMeta } from '@/features/AgentDocumentPage/routeMeta';
@@ -56,14 +53,15 @@ import {
projectDirectoriesRouteMeta,
projectsRouteMeta,
} from '@/features/Projects/routeMeta';
+import ResourceCategorySkeleton from '@/features/ResourceHome/Skeleton';
import { settingsRouteMeta } from '@/features/Settings/features/routeMeta';
import { workspaceHomeRouteMeta } from '@/features/Workspace/routeMeta';
import WorkspaceProviderRedirect from '@/features/WorkspaceSetting/ProviderRedirect';
import {
agentChannelRouteMeta,
+ agentChatDesktopRouteMeta,
agentPermissionRouteMeta,
agentProfileRouteMeta,
- agentRouteMeta,
agentSelfLearningRouteMeta,
agentShareRouteMeta,
agentStatisticsRouteMeta,
@@ -78,17 +76,11 @@ import AppShellSkeleton, { APP_SHELL_FALLBACK_ID } from '@/spa/BootShell/AppShel
import { loadRouteWithBuiltinToolSurfaces } from '@/spa/initialize/toolSurfaces';
import { agentChatTopicListLoader } from '@/spa/router/agentChatTopicListLoader';
import { pageListLoader } from '@/spa/router/pageListLoader';
-import { NoRouteSkeleton, routeMeta, type RouteSkeletonProps } from '@/spa/router/routeMeta';
+import { NoRouteSkeleton, routeMeta } from '@/spa/router/routeMeta';
import { SettingsTabs } from '@/store/global/initialState';
import { dynamicElement, dynamicLayout, ErrorBoundary, redirectElement } from '@/utils/router';
-const LazyResourceCategorySkeleton = lazy(() => import('@/features/ResourceHome/Skeleton'));
-
-export const ResourceCategorySkeleton = (props: RouteSkeletonProps) => (
- <Suspense fallback={null}>
- <LazyResourceCategorySkeleton {...props} />
- </Suspense>
-);
+export { ResourceCategorySkeleton };
const agentChatElement = dynamicElement(
() => loadRouteWithBuiltinToolSurfaces(() => import('@/routes/(main)/agent')),
@@ -151,13 +143,13 @@ export const sharedMainAreaChildren: RouteObject[] = [
children: [
{
element: agentChatElement,
- handle: { meta: agentRouteMeta },
+ handle: { meta: agentChatDesktopRouteMeta },
index: true,
loader: agentChatTopicListLoader,
},
{
element: agentChatElement,
- handle: { meta: agentRouteMeta },
+ handle: { meta: agentChatDesktopRouteMeta },
loader: agentChatTopicListLoader,
path: ':topicId',
},
@@ -165,7 +157,7 @@ export const sharedMainAreaChildren: RouteObject[] = [
element: dynamicLayout(
() => import('@/routes/(main)/agent/(chat)/_layout'),
'Desktop > Chat > ChatLayout',
- { fallback: delayed(<ConversationLayoutSkeleton />), preloadId: 'agent' },
+ { fallback: delayed(<AgentConversationLayoutSkeleton />), preloadId: 'agent' },
),
},
{
@@ -1200,6 +1192,8 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
element: dynamicElement(
() => import('@/routes/(main)/settings/provider').then((m) => m.ProviderDetailPage),
'Desktop > Settings > Provider > Detail',
+ // Renders inside the provider layout, so only the detail body is pending.
+ { fallback: delayed(<ProviderDetailSkeleton />) },
),
handle: {
meta: routeMeta({ icon: Settings, titleKey: 'navigation.provider' }),
@@ -1212,7 +1206,11 @@ const createMainAreaChildrenDefinition = (options: MainAreaRouteOptions = {}): R
'Desktop > Settings > Provider > Layout',
),
handle: {
- meta: routeMeta({ icon: Settings, titleKey: 'navigation.provider' }),
+ meta: routeMeta({
+ icon: Settings,
+ Skeleton: ProviderSettingsSkeleton,
+ titleKey: 'navigation.provider',
+ }),
},
path: 'provider',
},
diff --git a/src/spa/router/desktopRouter.sync.test.tsx b/src/spa/router/desktopRouter.sync.test.tsx
index c621ce574a8..b291670d10b 100644
--- a/src/spa/router/desktopRouter.sync.test.tsx
+++ b/src/spa/router/desktopRouter.sync.test.tsx
@@ -2,12 +2,14 @@ import { readFile } from 'node:fs/promises';
import path from 'node:path';
import { isValidElement, type ReactElement, Suspense } from 'react';
+import { renderToString } from 'react-dom/server';
import type { RouteObject } from 'react-router';
-import { matchRoutes } from 'react-router';
+import { matchRoutes, MemoryRouter } from 'react-router';
import { describe, expect, it, vi } from 'vitest';
import BrandTextLoading from '@/components/Loading/BrandTextLoading';
import AppsSkeleton from '@/components/Skeleton/Apps';
+import AgentConversationLayoutSkeleton from '@/components/Skeleton/Conversation/AgentLayout';
import ConversationLayoutSkeleton from '@/components/Skeleton/Conversation/Layout';
import ConversationSegmentSkeleton from '@/components/Skeleton/Conversation/Segment';
import DelayedFallback from '@/components/Skeleton/Delayed';
@@ -18,6 +20,9 @@ import ProfileSkeleton, { GroupProfileRouteSkeleton } from '@/components/Skeleto
import ResourceHomeSkeleton from '@/components/Skeleton/ResourceHome';
import RouteSegmentSkeleton from '@/components/Skeleton/RouteSegment';
import SettingsPageSkeleton from '@/components/Skeleton/Settings/Page';
+import ProviderSettingsSkeleton, {
+ ProviderDetailSkeleton,
+} from '@/components/Skeleton/Settings/Provider';
import TasksSkeleton from '@/components/Skeleton/Tasks';
import TopicsSkeleton from '@/components/Skeleton/Topics';
import TaskDetailSkeleton from '@/features/AgentTasks/AgentTaskDetail/TaskDetailSkeleton';
@@ -364,7 +369,13 @@ describe('desktop router shared definition', () => {
expect(fallbacks.length).toBeGreaterThan(0);
expect(fallbacks).not.toContain(BrandTextLoading);
expect(new Set(fallbacks)).toEqual(
- new Set([ConversationLayoutSkeleton, ConversationSegmentSkeleton, RouteSegmentSkeleton]),
+ new Set([
+ AgentConversationLayoutSkeleton,
+ ConversationLayoutSkeleton,
+ ConversationSegmentSkeleton,
+ ProviderDetailSkeleton,
+ RouteSegmentSkeleton,
+ ]),
);
},
);
@@ -378,7 +389,7 @@ describe('desktop router shared definition', () => {
for (const [pathname, expectedFallbacks] of [
[
'/agent/agent-1/topic-1',
- [RouteSegmentSkeleton, ConversationLayoutSkeleton, ConversationSegmentSkeleton],
+ [RouteSegmentSkeleton, AgentConversationLayoutSkeleton, ConversationSegmentSkeleton],
],
['/group/group-1/topic-1', [RouteSegmentSkeleton, ConversationLayoutSkeleton]],
] as const) {
@@ -432,10 +443,12 @@ describe('desktop router shared definition', () => {
['/agent/agent-1/goals', GoalSkeleton],
['/agent/agent-1/goal/goal-1', GoalDetailSkeleton],
['/agent/agent-1/profile', ProfileSkeleton],
- ['/agent/agent-1/topic-1', ConversationLayoutSkeleton],
+ ['/agent/agent-1/topic-1', AgentConversationLayoutSkeleton],
['/group/group-1/profile', GroupProfileRouteSkeleton],
['/group/group-1/topic-1', ConversationLayoutSkeleton],
['/settings/profile', SettingsPageSkeleton],
+ ['/settings/provider/all', ProviderSettingsSkeleton],
+ ['/settings/provider/openai', ProviderSettingsSkeleton],
['/apps', AppsSkeleton],
['/memory', MemorySkeleton],
['/resource', ResourceHomeSkeleton],
@@ -451,6 +464,42 @@ describe('desktop router shared definition', () => {
}
});
+ it.each([
+ ['Web', (_pathname: string) => webDesktopRoutes],
+ ['Electron', (pathname: string) => createTabRouter(pathname).routes],
+ ])(
+ '%s paints the resource skeleton on its first render, without a chunk wait',
+ (_, getRoutes) => {
+ const matches = matchRoutes(getRoutes('/resource/files'), '/resource/files');
+ const Skeleton = resolveRouteSkeleton(
+ matches?.map(({ route }) => ({ handle: route.handle })) ?? [],
+ );
+
+ const html = renderToString(
+ <MemoryRouter initialEntries={['/resource/files']}>
+ {Skeleton && <Skeleton />}
+ </MemoryRouter>,
+ );
+
+ expect(html).toContain('aria-busy');
+ },
+ );
+
+ it.each([
+ ['Web', (_pathname: string) => webDesktopRoutes],
+ ['Electron', (pathname: string) => createTabRouter(pathname).routes],
+ ])('%s keeps the provider detail chunk inside the provider layout skeleton', (_, getRoutes) => {
+ const matches = matchRoutes(
+ getRoutes('/settings/provider/openai'),
+ '/settings/provider/openai',
+ );
+ const detail = matches?.at(-1)?.route.element as
+ ReactElement<{ fallback?: ReactElement<{ children?: ReactElement }> }> | undefined;
+
+ expect(detail?.props.fallback?.type).toBe(DelayedFallback);
+ expect(detail?.props.fallback?.props.children?.type).toBe(ProviderDetailSkeleton);
+ });
+
it.each([
['Web', (_pathname: string) => webDesktopRoutes],
['Electron', (pathname: string) => createTabRouter(pathname).routes],
diff --git a/src/store/global/actions/workspacePane.ts b/src/store/global/actions/workspacePane.ts
index 4c688f56195..995ba880580 100644
--- a/src/store/global/actions/workspacePane.ts
+++ b/src/store/global/actions/workspacePane.ts
@@ -6,7 +6,7 @@ import { INBOX_SESSION_ID } from '@/const/session';
import type { GlobalStore } from '@/store/global';
import type { ModelDetailPanelExpandedKey, WorkingSidebarTab } from '@/store/global/initialState';
import { MODEL_DETAIL_PANEL_EXPANDABLE_KEYS } from '@/store/global/initialState';
-import { readOverridableField } from '@/store/global/selectors/systemStatus';
+import { readOverridableField, systemStatusSelectors } from '@/store/global/selectors/systemStatus';
import type { StoreSetter } from '@/store/types';
import { getStableNavigate } from '@/utils/stableNavigate';
import { setNamespace } from '@/utils/storeDebug';
@@ -141,8 +141,7 @@ export class GlobalWorkspacePaneActionImpl {
};
toggleWorkingOverview = (newValue?: boolean): void => {
- const currentValue =
- this.#get().status.showWorkingOverview ?? !this.#get().status.showRightPanel;
+ const currentValue = systemStatusSelectors.showWorkingOverview(this.#get());
const showWorkingOverview = typeof newValue === 'boolean' ? newValue : !currentValue;
this.#get().updateSystemStatus({ showWorkingOverview }, n('toggleWorkingOverview', newValue));
diff --git a/src/store/global/initialState.test.ts b/src/store/global/initialState.test.ts
index 21ab38fa7b9..192f0f45981 100644
--- a/src/store/global/initialState.test.ts
+++ b/src/store/global/initialState.test.ts
@@ -30,6 +30,16 @@ describe('createInitialSystemStatus', () => {
expect(status.hiddenHomeWidgets).toEqual(['news', 'suggestions']);
});
+ it('restores the agent working panel layout that the chat skeleton reserves', () => {
+ seed({ showRightPanel: true, showWorkingOverview: false, workingSidebarWidth: 480 });
+
+ const status = createInitialSystemStatus();
+
+ expect(status.showRightPanel).toBe(true);
+ expect(status.showWorkingOverview).toBe(false);
+ expect(status.workingSidebarWidth).toBe(480);
+ });
+
it('falls back to defaults when nothing is persisted', () => {
const status = createInitialSystemStatus();
diff --git a/src/store/global/initialState.ts b/src/store/global/initialState.ts
index 8c85372dbf8..8969d5c4b30 100644
--- a/src/store/global/initialState.ts
+++ b/src/store/global/initialState.ts
@@ -615,6 +615,18 @@ export const createInitialSystemStatus = (): SystemStatus => {
typeof persistedStatus.showLeftPanel === 'boolean'
? persistedStatus.showLeftPanel
: INITIAL_STATUS.showLeftPanel,
+ showRightPanel:
+ typeof persistedStatus.showRightPanel === 'boolean'
+ ? persistedStatus.showRightPanel
+ : INITIAL_STATUS.showRightPanel,
+ showWorkingOverview:
+ typeof persistedStatus.showWorkingOverview === 'boolean'
+ ? persistedStatus.showWorkingOverview
+ : undefined,
+ workingSidebarWidth:
+ typeof persistedStatus.workingSidebarWidth === 'number'
+ ? persistedStatus.workingSidebarWidth
+ : INITIAL_STATUS.workingSidebarWidth,
};
};
diff --git a/src/store/global/selectors/systemStatus.test.ts b/src/store/global/selectors/systemStatus.test.ts
index 9d59bf0014d..b3c8414b887 100644
--- a/src/store/global/selectors/systemStatus.test.ts
+++ b/src/store/global/selectors/systemStatus.test.ts
@@ -84,6 +84,15 @@ describe('systemStatusSelectors', () => {
expect(systemStatusSelectors.portalWidth(noPortalWidth)).toBe(400);
});
+ it('should show the working overview by default only while the right panel is closed', () => {
+ const at = (status: { showRightPanel?: boolean; showWorkingOverview?: boolean }) =>
+ systemStatusSelectors.showWorkingOverview(merge(initialState, { status }));
+
+ expect(at({ showRightPanel: false, showWorkingOverview: undefined })).toBe(true);
+ expect(at({ showRightPanel: true, showWorkingOverview: undefined })).toBe(false);
+ expect(at({ showRightPanel: true, showWorkingOverview: true })).toBe(true);
+ });
+
it('should return workingSidebarWidth from status, defaulting to 360', () => {
expect(
systemStatusSelectors.workingSidebarWidth(
diff --git a/src/store/global/selectors/systemStatus.ts b/src/store/global/selectors/systemStatus.ts
index e0afd0a3858..1f3f52d0fba 100644
--- a/src/store/global/selectors/systemStatus.ts
+++ b/src/store/global/selectors/systemStatus.ts
@@ -388,6 +388,8 @@ const homeGoalsCollapsed = (s: GlobalState): boolean => s.status.homeGoalsCollap
const homeRecentsCount = (s: GlobalState): number => s.status.homeRecentsCount ?? 8;
const homeTaskCount = (s: GlobalState): number => s.status.homeTaskCount ?? 8;
const showRightPanel = (s: GlobalState) => s.status.showRightPanel;
+const showWorkingOverview = (s: GlobalState) =>
+ s.status.showWorkingOverview ?? !s.status.showRightPanel;
const showLeftPanel = (s: GlobalState) => s.status.showLeftPanel;
const showPageAgentPanel = (s: GlobalState) => s.status.showPageAgentPanel;
const showTaskAgentPanel = (s: GlobalState) => s.status.showTaskAgentPanel;
@@ -528,6 +530,7 @@ export const systemStatusSelectors = {
showRightPanel,
showSystemRole,
showTaskAgentPanel,
+ showWorkingOverview,
showTerminalPanel,
showVerifyReportPanel,
showVideoPanel,