🤯 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(channels): replace channel loading spinners with a channel-shaped skeleton (#22063)
AmAzing-758b1de0bec8
diff --git a/src/components/Skeleton/Channel.tsx b/src/components/Skeleton/Channel.tsxnew file mode 100644index 00000000000..f4cdde77ae2--- /dev/null+++ b/src/components/Skeleton/Channel.tsx@@ -0,0 +1,110 @@+'use client';++import { Flexbox, Skeleton } from '@lobehub/ui';+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';+import * as stylex from '@stylexjs/stylex';++import SkeletonBar from './Bar';++/** Name width and body line widths per row, so the feed reads as a few distinct speakers. */+const MESSAGE_ROWS = [+ { lines: ['72%'], name: 96 },+ { lines: ['88%', '54%'], name: 72 },+ { lines: ['64%'], name: 120 },+ { lines: ['80%', '36%'], name: 88 },+];++const styles = stylex.create({+ // `ChatInput`'s container border and fill, so the real composer paints over the same box.+ composer: {+ borderWidth: '1px',+ borderStyle: 'solid',+ borderColor: cssVar.colorFill,+ borderRadius: cssVar.borderRadiusLG,+ backgroundColor: cssVar.colorBgElevated,+ backgroundImage: 'none',+ boxShadow: cssVar.boxShadowTertiary,+ },+ root: {+ overflow: 'hidden',+ display: 'flex',+ flex: '1',+ flexDirection: 'column',+ minWidth: 0,+ minHeight: 0,+ },+});++/**+ * One `ChannelMessage` row: the 36px avatar pinned left, then the name and time+ * header over the body lines, indented 48px like `ChatItem` in the feed.+ */+const MessageRowSkeleton = ({ lines, name }: (typeof MESSAGE_ROWS)[number]) => (+ <Flexbox horizontal gap={12} paddingBlock={8}>+ <Skeleton.Avatar shape={'circle'} size={36} />+ <Flexbox flex={1} gap={10} paddingBlock={'4px 0'} style={{ minWidth: 0 }}>+ <Flexbox horizontal align={'center'} gap={8}>+ <SkeletonBar height={14} width={name} />+ <SkeletonBar height={12} width={40} />+ </Flexbox>+ {lines.map((width, index) => (+ <SkeletonBar height={14} key={index} width={width} />+ ))}+ </Flexbox>+ </Flexbox>+);++/**+ * Body of a Channel conversation (`features/Channels/ChannelConversation.tsx`):+ * the full-width feed with 24px gutters, then the composer's activity line and+ * its one-row input (attach, editor, send). Also the conversation's own+ * data-loading state, so route load and detail fetch share one shape.+ */+export const ChannelConversationSkeleton = () => (+ <div aria-busy {...stylex.props(styles.root)}>+ <Flexbox flex={1} paddingBlock={'16px 24px'} paddingInline={24} style={{ minHeight: 0 }}>+ {MESSAGE_ROWS.map((row, index) => (+ <MessageRowSkeleton key={index} {...row} />+ ))}+ </Flexbox>+ <Flexbox flex={'none'} gap={4} paddingBlock={'0 12px'} paddingInline={24}>+ <Flexbox height={24} />+ <Flexbox+ horizontal+ align={'center'}+ className={stylex.props(styles.composer).className}+ gap={4}+ padding={4}+ >+ <SkeletonBar height={28} radius={'50%'} width={28} />+ <Flexbox flex={1} paddingInline={8}>+ <SkeletonBar height={14} width={'32%'} />+ </Flexbox>+ <SkeletonBar height={28} radius={'50%'} width={28} />+ </Flexbox>+ </Flexbox>+ </div>+);++/** A Channel page: the 44px header (hash, title, member avatars) over the conversation. */+const ChannelLayoutSkeleton = () => (+ <Flexbox aria-busy flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>+ <Flexbox+ horizontal+ align={'center'}+ flex={'none'}+ height={44}+ justify={'space-between'}+ padding={8}+ >+ <Flexbox horizontal align={'center'} gap={8} paddingInline={4}>+ <SkeletonBar height={18} width={18} />+ <SkeletonBar height={20} width={144} />+ </Flexbox>+ <SkeletonBar height={28} radius={14} width={72} />+ </Flexbox>+ <ChannelConversationSkeleton />+ </Flexbox>+);++export default ChannelLayoutSkeleton;diff --git a/src/features/Channels/ChannelConversation.tsx b/src/features/Channels/ChannelConversation.tsxindex c2098a137ec..975599acf58 100644--- a/src/features/Channels/ChannelConversation.tsx+++ b/src/features/Channels/ChannelConversation.tsx@@ -7,6 +7,8 @@ import { useTranslation } from 'react-i18next';import AsyncBoundary from '@/components/AsyncBoundary';import AsyncError from '@/components/AsyncError';+import { ChannelConversationSkeleton } from '@/components/Skeleton/Channel';+import { delayed } from '@/components/Skeleton/Delayed';import { createStore, Provider } from '@/features/Conversation/store';import WideScreenContainer from '@/features/WideScreenContainer';import { useActiveLocation } from '@/hooks/useActiveLocation';@@ -128,6 +130,9 @@ const Timeline = ({error={sync.error}errorVariant="page"isLoading={!detail && !sync.error}+ // Delayed so a fast fetch (switching Channels, opening a thread) paints no placeholder;+ // right after the route skeleton it hands over immediately.+ loading={delayed(<ChannelConversationSkeleton />)}onRetry={() => void channelActions.refreshDetail(params)}>{detail && (diff --git a/src/features/Channels/index.tsx b/src/features/Channels/index.tsxindex 48f0d574ec2..de727f37428 100644--- a/src/features/Channels/index.tsx+++ b/src/features/Channels/index.tsx@@ -1,4 +1,4 @@-import { Center, Flexbox, Spin, Tag, Text } from '@lobehub/ui';+import { Flexbox, Tag, Text } from '@lobehub/ui';import * as stylex from '@stylexjs/stylex';import { useSize } from 'ahooks';import { Hash } from 'lucide-react';@@ -7,6 +7,7 @@ import { useTranslation } from 'react-i18next';import { useParams } from 'react-router';import NotFound from '@/components/404';+import { RouteLoading } from '@/components/Skeleton/RouteSegment';import NavHeader from '@/features/NavHeader';import { channelActions, channelSelectors, useChannelStore } from '@/store/channel';import { serverConfigSelectors, useServerConfigStore } from '@/store/serverConfig';@@ -111,11 +112,7 @@ function EnabledChannelPage() {export default function ChannelPage() {const ready = useServerConfigStore((s) => s.serverConfigInit);const enabled = useServerConfigStore(serverConfigSelectors.enableChannels);- if (!ready)- return (- <Center height="100%">- <Spin />- </Center>- );+ // Continue the route skeleton while the flag resolves instead of swapping to a spinner.+ if (!ready) return <RouteLoading />;return enabled ? <EnabledChannelPage /> : <NotFound />;}diff --git a/src/features/Channels/routeMeta.ts b/src/features/Channels/routeMeta.tsindex 1fd32338d81..e45b899a1a2 100644--- a/src/features/Channels/routeMeta.ts+++ b/src/features/Channels/routeMeta.ts@@ -1,7 +1,7 @@import { Hash } from 'lucide-react';import { lazy } from 'react';-import ConversationSegmentSkeleton from '@/components/Skeleton/Conversation/Segment';+import ChannelLayoutSkeleton from '@/components/Skeleton/Channel';import { routeMeta } from '@/spa/router/routeMeta';// Route metas load with the router on first paint; keep the Channel store out of that graph.@@ -10,6 +10,6 @@ const ChannelDynamicMeta = lazy(() => import('./ChannelDynamicMeta'));export const channelRouteMeta = routeMeta({DynamicMeta: ChannelDynamicMeta,icon: Hash,- Skeleton: ConversationSegmentSkeleton,+ Skeleton: ChannelLayoutSkeleton,titleKey: 'channel:title',});