🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
💄 style(nav-panel): shape the sidebar loading skeleton per route (#17950)
Innei6db34906c7f9
diff --git a/.agents/acceptance/probe-mock-patterns.md b/.agents/acceptance/probe-mock-patterns.mdindex e123b02f7aa..d83fdd5fa39 100644--- a/.agents/acceptance/probe-mock-patterns.md+++ b/.agents/acceptance/probe-mock-patterns.md@@ -719,9 +719,44 @@ const aside = drawer && [...drawer.parentElement.children].find((c) => c.tagName```Then assert on `aside.innerText` line count plus a count of text-free rounded boxes-(the skeleton rows). Distinguish the two skeleton states explicitly: the whole panel-collapsing to \~8 text-free rows is the nav-panel fallback, while fixed items present-with only the list area shimmering is ordinary data loading.+(the skeleton rows). Distinguish the two skeleton states explicitly: a text-free panel+carrying `[data-testid="nav-sidebar-skeleton"]` is the nav-panel fallback, while fixed+items present with only the list area shimmering is ordinary data loading. Do NOT+identify the fallback by a row count — it is shaped per navKey now+(`NAV_SKELETON_SHAPES`), so memory/discover render header plus a nav list and no body+at all, while settings renders a search box plus four accordion groups.++### Park a route's lazy chunk to hold its pending sidebar on screen++**Situation:** verifying what a route's `NavPanel` fallback (or any `dynamicElement`+Suspense fallback) actually renders. The pending state lasts a few hundred ms, so no+screenshot or `agent-browser eval` catches it.++**Doesn't work:** network throttling, or adding a debug flag that force-renders the+fallback. Throttling does not bound the module fetch predictably, and a force-render+flag proves the component renders, not that the product path reaches it.++**Works:** raw CDP `Fetch.enable` intercepts `app://renderer/...` module requests in+the Electron renderer. Park the route's layout chunk and the portal never registers,+so the fallback stays up indefinitely — measure and screenshot at leisure, then kill+the CDP connection to release the request and measure the settled sidebar in the same+session.++```js+Fetch.enable({ patterns: [{ requestStage: 'Request', urlPattern: '*settings/_layout*' }] });+// on Fetch.requestPaused: keep the requestId, never continueRequest+// [paused] app://renderer/src/routes/(main)/settings/_layout/index.tsx?t=1785957215039+```++Two traps. The pattern must name the **layout** chunk only: a broad `*settings*`+also parks `store/user/slices/settings/*` and the router's own `routeMeta`, which+stalls boot instead of the route. And the layout module is not always under the path+you guess — the agent sidebar registers from `(main)/agent/_layout`, not+`(main)/agent/(chat)/_layout`; when the measurement comes back `mode: real`, the+pattern missed, it is not a product finding.++Drive the navigation with `app-probe.sh goto <route>` (a full reload, so the module+is re-requested and re-parked).### Boot-phase UI cannot be observed by CDP polling — sample in-page, and mirror the timerdiff --git a/.agents/skills/ux/SKILL.md b/.agents/skills/ux/SKILL.mdindex 1b29c32b8cf..b6efb77c7fa 100644--- a/.agents/skills/ux/SKILL.md+++ b/.agents/skills/ux/SKILL.md@@ -141,6 +141,7 @@ The one-screen scan. Each line links back to a module above for the full rule +**Feedback — loading & system response** ([feedback.md](references/feedback.md))- [ ] No antd `Spin`; use `NeuralNetworkLoading` / project loaders.+- [ ] A whole-surface skeleton (route fallback, sidebar panel) matches the settled layout's **structural anchors** — header height, fixed nav block, body start, first group title — measured from the rendered DOM, never derived by reading the JSX. Conditional chrome that changes height (platform flags) is branched with the same condition, a shell with per-route panels drives its skeleton from a per-route shape (a panel with no body gets a skeleton with no body), and data-driven lists align only up to the first group title.- [ ] Every loading state can fail: on error or timeout, show a failed state with a Reload/Retry action — never an infinite spinner. In an auto-dismissing surface (upload dock / progress toast), the countdown clears **success only** — a failed item persists with Retry. An error state / retry action that's **modeled in the store but consumed by no surface** (`isXError` selector / `retryX` action with zero `rg` call sites) is still a missing error state — a built-but-orphaned path is a permanent skeleton at the pixel. A **load-more / infinite-scroll** page fetch that fails shows an inline Retry at the list tail (distinct from end-of-list), never a silently vanished "loading more" row with `hasMore` still true that an `IntersectionObserver` re-fires into a silent retry loop (topics).- [ ] A compound gate waiting on a secondary/dependent fetch gates on its **in-flight** flag and releases on settled (data / resolved-`null` / error) — never on the dependency being present in a map, or an absent-by-design dependency hangs it forever. An error branch **ordered after** a data-presence gate (`{error && …}` below `if (isLoading = !map[id]) return <Skeleton/>`) is unreachable on first-load failure — it paints only on revalidation, and a resolved-`null` not-found hangs the same permanent skeleton; check error/not-found **before** the gate.- [ ] An awaited write that gates navigation/advance resets its busy flag in `finally` + offers retry — a failed write never permanently disables the forward/Back control.diff --git a/.agents/skills/ux/references/feedback.md b/.agents/skills/ux/references/feedback.mdindex 8b67c9e0f2b..eb5d47b4530 100644--- a/.agents/skills/ux/references/feedback.md+++ b/.agents/skills/ux/references/feedback.md@@ -57,6 +57,58 @@ doesn't leak a stale start onto a later one that reuses the slot.- [ ] Known-shape surface not downgraded to a bare block / spinner. _(Natural)_- [ ] A long-op elapsed / progress readout derives from a **persisted start timestamp keyed by job id** (survives remount, shows true duration) and clears the key when the job ends — never a local counter that resets to 0 on remount. _(Certainty・Natural)_+### Whole-surface skeletons: match the layout's structure, not just its rows++The rules above size one row against one row. A skeleton that stands in for a **whole+surface** — a route-level `Suspense` fallback, a sidebar panel, a page shell — is judged by+something else: its **structural anchors**. Header height, any fixed nav block sitting above+the scroll area, where the body starts, where the first group title lands. Get every row+right and the header wrong, and the real content still arrives \~100 px from where the+skeleton drew it — the exact relayout the skeleton existed to prevent.++**Measure the settled DOM; never derive the numbers from the source.** Reading the JSX and+adding up paddings is the fast way to be confidently wrong, because the rendered height is+decided by things the source doesn't show: a conditionally-hidden sibling, a component's own+default size, a layout primitive's padding shorthand. Three such assumptions were wrong in+one sidebar — a header read as 44 was really 36, a search box read as 32 was 36, an accordion+title read as 28 was 26.9 — and each error propagated into every anchor below it. Open the+real surface, read `getBoundingClientRect()` on each anchor, and build the skeleton from+those values. (To hold a route's pending state on screen long enough to measure, see the+agent-testing skill's probe pattern for parking a lazy chunk.)++**Branch the skeleton wherever the real chrome branches.** Platform and feature conditions+that remove an element change the container's height: on macOS desktop+`ToggleLeftPanelButton` renders `null`, so the nav header's content box collapses from the+28 px icon to the 22 px breadcrumb and the header goes 44 → 36. A hard-coded height is+correct on exactly one platform. Reuse the same condition (import the flag, don't re-derive+it) so both branches stay in step.++**Many variants of one surface → a shape table, not one generic skeleton.** When a shell+renders a different panel per route, a single "8 generic rows" placeholder is wrong nearly+everywhere: some panels open with a fixed nav list, some have accordion groups, and some+have **no body at all** — for those the generic skeleton invents a list that never appears.+Model the surface as data (header variant, fixed nav rows, body gap, group title height,+rows per group) and key it by route, so adding a panel is one row in the table.++**Know which parts can be pixel-exact.** A statically enumerated menu (settings categories,+a fixed nav list) has a known row count — align it exactly. A data-driven list (topics,+documents, search results) cannot be predicted, so guarantee alignment only **up to the+first group title** and treat the rows below as a plausible fill. That boundary is where+users' eyes settle first anyway; pretending to know the row count buys nothing.++> ✅ `NavSideBarSkeleton` + `NAV_SKELETON_SHAPES` (`src/features/NavPanel/components/SideBarSkeleton.tsx`)+> — one component driven by a per-navKey shape measured against each settled sidebar; memory+> and discover render header + nav list and **no body**, matching panels that genuinely have+> none. ❌ The generic 8-row list it replaced: no header placeholder at all, so every settings+> row landed \~102 px below where the skeleton had drawn it.++**Checklist**++- [ ] A whole-surface skeleton's **structural anchors** (header height, fixed nav block, body start, first group title) match the settled surface — verified by measuring, not by reading the JSX. _(Certainty)_+- [ ] Any conditional chrome that changes height (platform flags, feature gates) is branched in the skeleton with the **same** condition, not hard-coded. _(Certainty)_+- [ ] A shell that renders per-route panels drives its skeleton from a **per-route shape**, and a panel with no body gets a skeleton with no body. _(Certainty・Natural)_+- [ ] Static menus align exactly; data-driven lists align **to the first group title** and stop claiming to know the row count. _(Certainty)_+## 4.2 Loading must be able to fail — timeout → error + retry・Certainty・MeaningfulA loading state that can only ever resolve to _success_ is a bug. Any async fetch can hang,diff --git a/src/features/NavPanel/SideBarLayout.tsx b/src/features/NavPanel/SideBarLayout.tsxindex 1d05b8df02a..9663898a85a 100644--- a/src/features/NavPanel/SideBarLayout.tsx+++ b/src/features/NavPanel/SideBarLayout.tsx@@ -2,7 +2,8 @@ import { Flexbox, ScrollShadow, TooltipGroup } from '@lobehub/ui';import { type ReactNode } from 'react';import { memo, Suspense } from 'react';-import SkeletonList, { SkeletonItem } from '@/features/NavPanel/components/SkeletonList';+import { SideBarHeaderSkeleton } from '@/features/NavPanel/components/SideBarSkeleton';+import SkeletonList from '@/features/NavPanel/components/SkeletonList';interface SidebarLayoutProps {body?: ReactNode;@@ -12,7 +13,7 @@ interface SidebarLayoutProps {const SideBarLayout = memo<SidebarLayoutProps>(({ header, body }) => {return (<Flexbox gap={1} style={{ height: '100%', overflow: 'hidden' }}>- <Suspense fallback={<SkeletonItem height={44} style={{ marginTop: 8 }} />}>{header}</Suspense>+ <Suspense fallback={<SideBarHeaderSkeleton />}>{header}</Suspense><ScrollShadow size={2} style={{ height: '100%' }}><TooltipGroup><Suspense fallback={<SkeletonList paddingBlock={8} />}>{body}</Suspense>diff --git a/src/features/NavPanel/components/SideBarSkeleton.tsx b/src/features/NavPanel/components/SideBarSkeleton.tsxnew file mode 100644index 00000000000..f464b4807b4--- /dev/null+++ b/src/features/NavPanel/components/SideBarSkeleton.tsx@@ -0,0 +1,185 @@+'use client';++import { Center, Flexbox, Skeleton } from '@lobehub/ui';+import { cssVar } from 'antd-style';+import { memo } from 'react';++import { isMacDesktop } from '../ToggleLeftPanelButton';++interface SkeletonBarProps {+ height: number;+ radius?: number | string;+ width?: number | string;+}++const SkeletonBar = memo<SkeletonBarProps>(({ height, width = '100%', radius }) => (+ <Skeleton.Button+ active+ block+ size={'small'}+ style={{+ borderRadius: radius ?? cssVar.borderRadius,+ height,+ margin: 0,+ maxHeight: height,+ maxWidth: width,+ minHeight: height,+ minWidth: width,+ opacity: 0.5,+ padding: 0,+ width,+ }}+ />+));++export type SideBarHeaderVariant = 'breadcrumb' | 'title';++// The real header's height comes from its tallest child. A breadcrumb header holds+// a 22px trail plus a 28px action icon — and ToggleLeftPanelButton renders nothing+// on macOS desktop, so 22 wins there. A title header (agent / page / home) carries+// a 16px title beside a back button and settles at 32.+const headerContentHeight = (variant: SideBarHeaderVariant) => {+ if (variant === 'title') return 32;+ return isMacDesktop ? 22 : 28;+};++export const SideBarHeaderSkeleton = memo<{ variant?: SideBarHeaderVariant }>(+ ({ variant = 'breadcrumb' }) => (+ <Flexbox horizontal align={'center'} flex={'none'} padding={'8px 6px'}>+ <Flexbox flex={1} height={headerContentHeight(variant)} justify={'center'} paddingInline={6}>+ <SkeletonBar height={variant === 'title' ? 18 : 14} width={variant === 'title' ? 96 : 72} />+ </Flexbox>+ </Flexbox>+ ),+);++const SkeletonNavItem = memo<{ width: string }>(({ width }) => (+ <Flexbox horizontal align={'center'} flex={'none'} gap={8} height={36} paddingInline={4}>+ <Center flex={'none'} height={28} width={28}>+ <SkeletonBar height={18} radius={cssVar.borderRadiusSM} width={18} />+ </Center>+ <Flexbox flex={1}>+ <SkeletonBar height={14} width={width} />+ </Flexbox>+ </Flexbox>+));++const TITLE_WIDTHS = [56, 72, 48, 64];+const ITEM_WIDTHS = ['62%', '44%', '70%', '52%', '66%', '48%', '58%', '74%'];++// `paddingBlock` mirrors the accordion content wrapper; the header-slot nav list has+// no such padding, so passing 0 there keeps the skeleton 2px shorter and on target.+const SkeletonRows = memo<{ count: number; gap?: number; paddingBlock?: number; seed?: number }>(+ ({ count, seed = 0, paddingBlock = 1, gap = 1 }) => (+ <Flexbox gap={gap} paddingBlock={paddingBlock}>+ {Array.from({ length: count }).map((_, index) => (+ <SkeletonNavItem key={index} width={ITEM_WIDTHS[(seed * 3 + index) % ITEM_WIDTHS.length]} />+ ))}+ </Flexbox>+ ),+);++export interface NavSkeletonShape {+ /** `gap` of the body flex column, matching the real sidebar's body wrapper. */+ bodyGap?: number;+ bodyPaddingBlock?: number;+ /** Row count per accordion group; 0 renders a collapsed group (title only). */+ groups?: number[];+ /** Accordion header height: 27 with `paddingBlock={4}`, 32 by default, 40 with a toolbar. */+ groupTitleHeight?: number;+ headerVariant?: SideBarHeaderVariant;+ /** Rows inside the body that sit above the first group. */+ leadingRows?: number;+ /** `gap` between the header-slot nav rows. */+ navGap?: number;+ /** Fixed rows rendered in the header slot, above the scroll area. */+ navRows?: number;+ /** A search box placeholder inside the body (settings only). */+ search?: boolean;+}++export const NavSideBarSkeleton = memo<NavSkeletonShape>(+ ({+ bodyGap = 0,+ bodyPaddingBlock = 0,+ groups,+ groupTitleHeight = 32,+ headerVariant = 'breadcrumb',+ leadingRows = 0,+ navGap = 1,+ navRows = 0,+ search = false,+ }) => {+ const hasBody = search || leadingRows > 0 || !!groups?.length;++ return (+ <Flexbox data-testid={'nav-sidebar-skeleton'} gap={1} style={{ height: '100%' }}>+ <SideBarHeaderSkeleton variant={headerVariant} />+ {navRows > 0 && (+ <Flexbox data-testid={'nav-sidebar-skeleton-nav'} flex={'none'} paddingInline={4}>+ <SkeletonRows count={navRows} gap={navGap} paddingBlock={0} />+ </Flexbox>+ )}+ {hasBody && (+ <Flexbox+ gap={bodyGap}+ paddingBlock={bodyPaddingBlock}+ paddingInline={4}+ style={{ overflow: 'hidden' }}+ >+ {search && (+ <Flexbox data-testid={'nav-sidebar-skeleton-search'} paddingInline={4}>+ <SkeletonBar height={36} />+ </Flexbox>+ )}+ {leadingRows > 0 && <SkeletonRows count={leadingRows} paddingBlock={0} />}+ {!!groups?.length && (+ <Flexbox gap={8}>+ {groups.map((rows, groupIndex) => (+ <Flexbox key={groupIndex}>+ <Flexbox+ flex={'none'}+ height={groupTitleHeight}+ justify={'center'}+ paddingBlock={4}+ paddingInline={'8px 4px'}+ >+ <SkeletonBar+ height={12}+ width={TITLE_WIDTHS[groupIndex % TITLE_WIDTHS.length]}+ />+ </Flexbox>+ {rows > 0 && <SkeletonRows count={rows} seed={groupIndex} />}+ </Flexbox>+ ))}+ </Flexbox>+ )}+ </Flexbox>+ )}+ </Flexbox>+ );+ },+);++// Every shape below was measured against its settled sidebar in the desktop shell+// (301px panel): header slot height, body gap/padding, accordion header height, and+// group composition. A shape that drifts from its sidebar shifts the whole list at+// the moment the route chunk resolves, which is the defect this file exists to avoid.+export const NAV_SKELETON_SHAPES: Record<string, NavSkeletonShape> = {+ 'agent': { groups: [0, 12], headerVariant: 'title', navRows: 5 },+ 'discover': { navRows: 6 },+ 'eval': { bodyGap: 8, groups: [3, 3], groupTitleHeight: 27, leadingRows: 1 },+ 'evalBench': { bodyGap: 8, groups: [3, 3], groupTitleHeight: 27, leadingRows: 1 },+ 'group': { groups: [3, 8], headerVariant: 'title' },+ 'home': { bodyGap: 1, groups: [5, 7, 3], headerVariant: 'title', leadingRows: 2, navRows: 2 },+ 'image': { bodyGap: 1, groups: [4], groupTitleHeight: 40, navGap: 0, navRows: 2 },+ 'memory': { navRows: 7 },+ 'page': { bodyGap: 1, groups: [12], headerVariant: 'title', navRows: 1 },+ 'resource': { bodyPaddingBlock: 8, groups: [5], navRows: 6 },+ 'resourceLibrary': { bodyPaddingBlock: 8, groups: [6] },+ 'settings': { bodyGap: 4, groups: [6, 5, 8, 3], groupTitleHeight: 27, search: true },+ 'video': { bodyGap: 1, groups: [4], groupTitleHeight: 40, navGap: 0, navRows: 2 },+ 'workspace-settings': { groups: [5, 5, 6, 3], groupTitleHeight: 27 },+};++export const DEFAULT_NAV_SKELETON_SHAPE: NavSkeletonShape = { groups: [6, 4] };diff --git a/src/features/NavPanel/index.test.tsx b/src/features/NavPanel/index.test.tsxindex 84f98144a27..85768c5cf27 100644--- a/src/features/NavPanel/index.test.tsx+++ b/src/features/NavPanel/index.test.tsx@@ -44,10 +44,6 @@ vi.mock('./components/NavPanelDraggable', () => ({),}));-vi.mock('./components/SkeletonList', () => ({- default: () => <div>Nav panel loading</div>,-}));-vi.mock('@/features/HomeSidebar/Content', () => ({default: () => <div>Home sidebar</div>,}));@@ -109,12 +105,47 @@ describe('NavPanel', () => {);await waitFor(() => {- expect(screen.getByText('Nav panel loading')).toBeInTheDocument();+ expect(screen.getByTestId('nav-sidebar-skeleton')).toBeInTheDocument();});expect(screen.getByTestId('nav-panel')).toHaveAttribute('data-nav-key', 'pending:discover');expect(screen.queryByText('Home sidebar')).not.toBeInTheDocument();});+ it('gives the settings skeleton a search placeholder', async () => {+ pathname = '/settings/profile';++ render(<NavPanel />);++ await waitFor(() => {+ expect(screen.getByTestId('nav-sidebar-skeleton')).toBeInTheDocument();+ });+ expect(screen.getByTestId('nav-sidebar-skeleton-search')).toBeInTheDocument();+ expect(screen.queryByTestId('nav-sidebar-skeleton-nav')).not.toBeInTheDocument();+ });++ it('drops the search placeholder for the searchless workspace settings sidebar', async () => {+ pathname = '/lobe-team/settings/general';++ render(<NavPanel />);++ await waitFor(() => {+ expect(screen.getByTestId('nav-sidebar-skeleton')).toBeInTheDocument();+ });+ expect(screen.queryByTestId('nav-sidebar-skeleton-search')).not.toBeInTheDocument();+ });++ it('shapes the skeleton per nav key: discover is header-plus-nav with no body', async () => {+ pathname = '/community';++ render(<NavPanel />);++ await waitFor(() => {+ expect(screen.getByTestId('nav-sidebar-skeleton')).toBeInTheDocument();+ });+ expect(screen.getByTestId('nav-sidebar-skeleton-nav')).toBeInTheDocument();+ expect(screen.queryByTestId('nav-sidebar-skeleton-search')).not.toBeInTheDocument();+ });+it('does not let an older owner cleanup remove the newer entry for the same key', async () => {const Harness = ({ showOld }: { showOld: boolean }) => (<>@@ -142,7 +173,7 @@ describe('NavPanel', () => {await waitFor(() => {expect(screen.getByText('New Home sidebar')).toBeInTheDocument();});- expect(screen.queryByText('Nav panel loading')).not.toBeInTheDocument();+ expect(screen.queryByTestId('nav-sidebar-skeleton')).not.toBeInTheDocument();});});@@ -160,7 +191,7 @@ describe('NavPanelShell', () => {expect(screen.getByText('Home sidebar')).toBeInTheDocument();});expect(screen.getByTestId('nav-panel')).toHaveAttribute('data-nav-key', 'home');- expect(screen.queryByText('Nav panel loading')).not.toBeInTheDocument();+ expect(screen.queryByTestId('nav-sidebar-skeleton')).not.toBeInTheDocument();});it('still yields to a dedicated route panel', async () => {@@ -169,7 +200,7 @@ describe('NavPanelShell', () => {render(<NavPanelShell />);await waitFor(() => {- expect(screen.getByText('Nav panel loading')).toBeInTheDocument();+ expect(screen.getByTestId('nav-sidebar-skeleton')).toBeInTheDocument();});expect(screen.queryByText('Home sidebar')).not.toBeInTheDocument();});diff --git a/src/features/NavPanel/index.tsx b/src/features/NavPanel/index.tsxindex 1d6744bd2c8..3f443b69223 100644--- a/src/features/NavPanel/index.tsx+++ b/src/features/NavPanel/index.tsx@@ -1,18 +1,19 @@'use client';-import { Flexbox } from '@lobehub/ui';import { memo, useSyncExternalStore } from 'react';import { NavPanelDraggable } from './components/NavPanelDraggable';-import SkeletonList from './components/SkeletonList';+import {+ DEFAULT_NAV_SKELETON_SHAPE,+ NAV_SKELETON_SHAPES,+ NavSideBarSkeleton,+} from './components/SideBarSkeleton';import { NAV_PANEL_RIGHT_DRAWER_ID } from './constants';import { getNavPanelRegistrySnapshot, subscribeNavPanelRegistry } from './registry';import { useActiveNavKey } from './useActiveNavKey';-const NavPanelFallback = memo(() => (- <Flexbox gap={1} paddingBlock={1} paddingInline={4}>- <SkeletonList rows={8} />- </Flexbox>+const NavPanelFallback = memo<{ navKey: string }>(({ navKey }) => (+ <NavSideBarSkeleton {...(NAV_SKELETON_SHAPES[navKey] ?? DEFAULT_NAV_SKELETON_SHAPE)} />));const NavPanel = memo(() => {@@ -25,7 +26,7 @@ const NavPanel = memo(() => {const registeredContent = registry.get(activeNavKey);const activeContent = registeredContent? { key: activeNavKey, node: registeredContent.node }- : { key: `pending:${activeNavKey}`, node: <NavPanelFallback /> };+ : { key: `pending:${activeNavKey}`, node: <NavPanelFallback navKey={activeNavKey} /> };return (<>