🤯 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
✨ feat(sidebar): layout menus for Favorites and Channels (#23496)
Rdmclin283cbb3334533
diff --git a/src/features/Channels/ChannelList.tsx b/src/features/Channels/ChannelList.tsxindex 00b5a9c6fba..b2b7134e157 100644--- a/src/features/Channels/ChannelList.tsx+++ b/src/features/Channels/ChannelList.tsx@@ -8,6 +8,7 @@ import {accordionStyles,AccordionTrigger,ActionIcon,+ ContextMenuTrigger,cx,type DropdownItem,DropdownMenu,@@ -113,7 +114,7 @@ const styles = stylex.create({fontSize: 10,fontWeight: 600,lineHeight: 1,- color: '#fff',+ color: cssVar.colorTextLightSolid,backgroundColor: cssVar.colorError,cursor: 'pointer',},@@ -190,6 +191,11 @@ const ChannelThreads = ({interface ChannelSectionProps {/** The accordion item value; the parent `AccordionRoot` owns the expanded state. */itemKey?: string;+ /**+ * Section-layout entries (move, hide, customize sidebar) for the header's "…" and+ * right-click menus; only the home sidebar, where the section can be rearranged, passes them.+ */+ layoutMenuItems?: DropdownItem[];/*** Lists only this project's Channels, and new ones join it. Without it the list holds the* Channels outside any project.@@ -201,7 +207,11 @@ interface ChannelSectionProps {* Channels beside Agents in the home sidebar or above a project's topics, with the open* Channel's threads nested under it.*/-const EnabledChannelSection = ({ itemKey = 'channels', projectId }: ChannelSectionProps) => {+const EnabledChannelSection = ({+ itemKey = 'channels',+ layoutMenuItems,+ projectId,+}: ChannelSectionProps) => {const { t } = useTranslation('channel');const sectionTriggerStyle = useSectionTriggerStyle();const { pathname } = useActiveLocation();@@ -325,55 +335,71 @@ const EnabledChannelSection = ({ itemKey = 'channels', projectId }: ChannelSecti? archived: archived.filter((channel) => channel.id === activeChannelId);- return (- <AccordionItem value={itemKey}>- <AccordionHeader>- <AccordionTrigger style={sectionTriggerStyle}>- <SectionTitle>{t('title')}</SectionTitle>- </AccordionTrigger>- <Flexbox- horizontal- align="center"- gap={2}- className={cx(- 'accordion-action',- accordionStyles.action,- accordionStyles.actionBorderless,- )}- >- <DropdownMenu items={sortMenuItems} placement="bottomRight">- <ActionIcon- aria-label={t('sort.title')}- icon={ArrowDownUp}- size="small"- title={t('sort.title')}- onClick={(event) => event.stopPropagation()}- />- </DropdownMenu>- {workspaceId && (- <ActionIcon- aria-label={t('browse.title')}- icon={Compass}- size="small"- title={t('browse.title')}- onClick={(event) => {- event.stopPropagation();- browse();- }}- />- )}+ const header = (+ <AccordionHeader>+ <AccordionTrigger style={sectionTriggerStyle}>+ <SectionTitle>{t('title')}</SectionTitle>+ </AccordionTrigger>+ <Flexbox+ horizontal+ align="center"+ className={cx('accordion-action', accordionStyles.action, accordionStyles.actionBorderless)}+ gap={2}+ >+ <DropdownMenu items={sortMenuItems} placement="bottomRight">+ <ActionIcon+ aria-label={t('sort.title')}+ icon={ArrowDownUp}+ size="small"+ title={t('sort.title')}+ onClick={(event) => event.stopPropagation()}+ />+ </DropdownMenu>+ {workspaceId && (<ActionIcon- aria-label={t('create')}- icon={Plus}+ aria-label={t('browse.title')}+ icon={Compass}size="small"- title={t('create')}+ title={t('browse.title')}onClick={(event) => {event.stopPropagation();- create();+ browse();}}/>- </Flexbox>- </AccordionHeader>+ )}+ <ActionIcon+ aria-label={t('create')}+ icon={Plus}+ size="small"+ title={t('create')}+ onClick={(event) => {+ event.stopPropagation();+ create();+ }}+ />+ {layoutMenuItems && (+ <DropdownMenu items={layoutMenuItems}>+ <ActionIcon+ aria-label={t('more', { ns: 'common' })}+ icon={MoreHorizontal}+ size="small"+ style={{ flex: 'none' }}+ title={t('more', { ns: 'common' })}+ onClick={(event) => event.stopPropagation()}+ />+ </DropdownMenu>+ )}+ </Flexbox>+ </AccordionHeader>+ );++ return (+ <AccordionItem value={itemKey}>+ {layoutMenuItems ? (+ <ContextMenuTrigger items={layoutMenuItems}>{header}</ContextMenuTrigger>+ ) : (+ header+ )}<AccordionPanel contentStyle={{ padding: 0 }}><Flexbox gap={1} paddingBlock={1}>{!channels && !sync.error && <SkeletonList rows={3} />}@@ -412,10 +438,10 @@ export const ChannelSection = (props: ChannelSectionProps) =>useChannelsEnabled() ? <EnabledChannelSection {...props} /> : null;/** The home sidebar's standalone Channels, outside any project. */-const ChannelList = () =>+const ChannelList = ({ layoutMenuItems }: Pick<ChannelSectionProps, 'layoutMenuItems'>) =>useChannelsEnabled() ? (<AccordionRoot defaultValue={['channels']} indicatorPlacement="inline">- <EnabledChannelSection />+ <EnabledChannelSection layoutMenuItems={layoutMenuItems} /></AccordionRoot>) : null;diff --git a/src/features/Home/Recents/index.tsx b/src/features/Home/Recents/index.tsxindex e2c2e1bdc03..561fdad1624 100644--- a/src/features/Home/Recents/index.tsx+++ b/src/features/Home/Recents/index.tsx@@ -13,25 +13,15 @@ import {Icon,Spin,} from '@lobehub/ui';-import {- ArrowDownIcon,- ArrowUpIcon,- EyeOffIcon,- Hash,- LucideCheck,- MoreHorizontalIcon,- SlidersHorizontalIcon,-} from 'lucide-react';-import { memo, Suspense, useCallback, useMemo } from 'react';+import { Hash, LucideCheck, MoreHorizontalIcon } from 'lucide-react';+import { memo, Suspense, useMemo } from 'react';import { useTranslation } from 'react-i18next';-import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';-import { openCustomizeSidebarModal } from '@/features/HomeSidebar/Body/CustomizeSidebarModal';+import { useSidebarSectionMenuItems } from '@/features/HomeSidebar/Body/useSidebarSectionMenuItems';import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';import SkeletonList from '@/features/NavPanel/components/SkeletonList';import { useGlobalStore } from '@/store/global';import { systemStatusSelectors } from '@/store/global/selectors';-import { reorderSidebarItems } from '@/store/global/selectors/systemStatus';import { useHomeStore } from '@/store/home';import { homeRecentSelectors } from '@/store/home/selectors';import { createRecentQueryKey } from '@/store/home/slices/recent/initialState';@@ -48,38 +38,14 @@ const Recents = memo<RecentsProps>(({ itemKey }) => {const { t } = useTranslation('common');const sectionTriggerStyle = useSectionTriggerStyle();const isLogin = useUserStore(authSelectors.isLogin);- const activeWorkspaceId = useActiveWorkspaceId();const recentPageSize = useGlobalStore(systemStatusSelectors.recentPageSize);const queryKey = createRecentQueryKey(recentPageSize + 1);const items = useHomeStore(homeRecentSelectors.query(queryKey));const useFetchRecents = useHomeStore((s) => s.useFetchRecents);const syncStatus = useFetchRecents(isLogin, recentPageSize);const refreshRecents = useHomeStore((s) => s.refreshRecents);- const sidebarItems = useGlobalStore(systemStatusSelectors.sidebarItems(activeWorkspaceId));- const hiddenSections = useGlobalStore(- systemStatusSelectors.hiddenSidebarSections(activeWorkspaceId),- );const updateSystemStatus = useGlobalStore((s) => s.updateSystemStatus);-- const visibleItems = sidebarItems.filter((k) => !hiddenSections.includes(k));- const visibleIndex = visibleItems.indexOf('recents');- const isFirst = visibleIndex === 0;- const isLast = visibleIndex === visibleItems.length - 1;-- const moveSection = useCallback(- (direction: 'up' | 'down') => {- const idx = sidebarItems.indexOf('recents');- if (idx === -1) return;- const next = reorderSidebarItems(sidebarItems, idx, direction === 'up' ? idx - 1 : idx + 1);- if (next === sidebarItems) return;- updateSystemStatus({ sidebarItems: next });- },- [sidebarItems, updateSystemStatus],- );-- const hideSection = useCallback(() => {- updateSystemStatus({ hiddenSidebarSections: [...hiddenSections, 'recents'] });- }, [hiddenSections, updateSystemStatus]);+ const sectionMenuItems = useSidebarSectionMenuItems(itemKey);const dropdownMenu = useMemo(() => {const pageSizeOptions = [5, 10, 15, 20];@@ -100,36 +66,9 @@ const Recents = memo<RecentsProps>(({ itemKey }) => {key: 'show',label: t('navPanel.show'),},- {- disabled: isFirst,- icon: <Icon icon={ArrowUpIcon} />,- key: 'moveUp',- label: t('navPanel.moveUp'),- onClick: () => moveSection('up'),- },- {- disabled: isLast,- icon: <Icon icon={ArrowDownIcon} />,- key: 'moveDown',- label: t('navPanel.moveDown'),- onClick: () => moveSection('down'),- },- {- disabled: false,- icon: <Icon icon={EyeOffIcon} />,- key: 'hideSection',- label: t('navPanel.hideSection'),- onClick: hideSection,- },- { type: 'divider' as const },- {- icon: <Icon icon={SlidersHorizontalIcon} />,- key: 'customizeSidebar',- label: t('navPanel.customizeSidebar'),- onClick: () => openCustomizeSidebarModal(),- },+ ...sectionMenuItems,] as DropdownItem[];- }, [recentPageSize, updateSystemStatus, t, isFirst, isLast, moveSection, hideSection]);+ }, [recentPageSize, updateSystemStatus, t, sectionMenuItems]);if (!isLogin) return null;if (items && items.length === 0) return null;@@ -152,7 +91,13 @@ const Recents = memo<RecentsProps>(({ itemKey }) => {)}><DropdownMenu items={dropdownMenu}>- <ActionIcon icon={MoreHorizontalIcon} size={'small'} style={{ flex: 'none' }} />+ <ActionIcon+ aria-label={t('more')}+ icon={MoreHorizontalIcon}+ size={'small'}+ style={{ flex: 'none' }}+ title={t('more')}+ /></DropdownMenu></div></AccordionHeader>diff --git a/src/features/HomeSidebar/Body/Channels.tsx b/src/features/HomeSidebar/Body/Channels.tsxnew file mode 100644index 00000000000..49c276c1ef1--- /dev/null+++ b/src/features/HomeSidebar/Body/Channels.tsx@@ -0,0 +1,22 @@+'use client';++import { memo } from 'react';++import ChannelList from '@/features/Channels/ChannelList';++import { useSidebarSectionMenuItems } from './useSidebarSectionMenuItems';++interface ChannelsProps {+ itemKey: string;+}++/** The home sidebar's Channels section, with the same layout menu as the other sections. */+const Channels = memo<ChannelsProps>(({ itemKey }) => {+ const layoutMenuItems = useSidebarSectionMenuItems(itemKey);++ return <ChannelList layoutMenuItems={layoutMenuItems} />;+});++Channels.displayName = 'HomeSidebarChannels';++export default Channels;diff --git a/src/features/HomeSidebar/Body/CustomizeSidebarModal.test.ts b/src/features/HomeSidebar/Body/CustomizeSidebarModal.test.tsindex b8c16af83a7..0d25934d99c 100644--- a/src/features/HomeSidebar/Body/CustomizeSidebarModal.test.ts+++ b/src/features/HomeSidebar/Body/CustomizeSidebarModal.test.ts@@ -47,4 +47,16 @@ describe('CustomizeSidebarModal', () => {expect(getSortableSidebarItemIds(false, { goalsEnabled: true }).has('goals')).toBe(true);expect(getSortableSidebarItemIds(true, { goalsEnabled: true }).has('goals')).toBe(true);});++ it('offers Channels, hideable, only while Channels are enabled', () => {+ expect(getSortableSidebarItemIds(false).has('channels')).toBe(false);+ expect(getSortableSidebarItemIds(false, { channelsEnabled: true }).has('channels')).toBe(true);+ expect(getSortableSidebarItemIds(true, { channelsEnabled: true }).has('channels')).toBe(true);++ const channels = getAvailableSidebarItems(true, { channelsEnabled: true }).find(+ (item) => item.id === 'channels',+ );+ expect(channels).toMatchObject({ labelKey: 'title', labelNs: 'channel' });+ expect(channels?.alwaysVisible).toBeUndefined();+ });});diff --git a/src/features/HomeSidebar/Body/CustomizeSidebarModal.tsx b/src/features/HomeSidebar/Body/CustomizeSidebarModal.tsxindex a4819e9c6c6..488e723769a 100644--- a/src/features/HomeSidebar/Body/CustomizeSidebarModal.tsx+++ b/src/features/HomeSidebar/Body/CustomizeSidebarModal.tsx@@ -42,6 +42,7 @@ import { useTranslation } from 'react-i18next';import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';import { useActiveWorkspaceSlug } from '@/business/client/hooks/useActiveWorkspaceSlug';import { getRouteById } from '@/config/routes';+import { useChannelsEnabled } from '@/features/Channels/useChannelsEnabled';import { useGlobalStore } from '@/store/global';import { DEFAULT_HOME_SIDEBAR_EXPANDED_KEYS } from '@/store/global/initialState';import { systemStatusSelectors } from '@/store/global/selectors';@@ -66,6 +67,8 @@ export interface SidebarItemConfig {alwaysVisible?: boolean;id: string;labelKey: string;+ /** i18n namespace of `labelKey`; defaults to `common`. */+ labelNs?: string;routeId?: string;}@@ -77,23 +80,32 @@ const ALL_SIDEBAR_ITEMS: SidebarItemConfig[] = [{ id: 'recents', labelKey: 'recents' },{ id: 'project', labelKey: 'tab.projects', routeId: 'project' },{ alwaysVisible: true, id: 'agent', labelKey: 'navPanel.agent' },+ { id: 'channels', labelKey: 'title', labelNs: 'channel' },{ id: 'image', labelKey: 'tab.generation', routeId: 'image' },{ id: 'community', labelKey: 'tab.community', routeId: 'community' },{ id: 'resource', labelKey: 'tab.resource', routeId: 'resource' },{ id: 'memory', labelKey: 'tab.memory', routeId: 'memory' },];+interface SidebarItemAvailability {+ channelsEnabled?: boolean;+ dashboardEnabled?: boolean;+ goalsEnabled?: boolean;+}+// Dashboards also stay out until the `dashboard` feature flag is on for the-// user, and Goals until the user turns on its lab; a dropped id is restored by-// `withAllKnownKeys` once it is.+// user, Channels until Channels are enabled, and Goals until the user turns on+// its lab; a dropped id is restored by `withAllKnownKeys` once it is.export const getAvailableSidebarItems = (isWorkspaceMode: boolean,{+ channelsEnabled = false,dashboardEnabled = false,goalsEnabled = false,- }: { dashboardEnabled?: boolean; goalsEnabled?: boolean } = {},+ }: SidebarItemAvailability = {},): SidebarItemConfig[] =>ALL_SIDEBAR_ITEMS.filter((item) => {+ if (item.id === 'channels' && !channelsEnabled) return false;if (item.id === 'dashboard' && !dashboardEnabled) return false;if (item.id === 'goals' && !goalsEnabled) return false;if (isWorkspaceMode && (item.id === 'memory' || item.id === 'dashboard')) return false;@@ -102,7 +114,7 @@ export const getAvailableSidebarItems = (export const getSortableSidebarItemIds = (isWorkspaceMode: boolean,- options?: { dashboardEnabled?: boolean; goalsEnabled?: boolean },+ options?: SidebarItemAvailability,): Set<string> =>new Set([...getAvailableSidebarItems(isWorkspaceMode, options).map((item) => item.id),@@ -182,7 +194,7 @@ const SortableItem = memo<{id: string;onToggle: (key: string) => void;}>(({ id, hiddenSections, onToggle }) => {- const { t } = useTranslation('common');+ const { t } = useTranslation(['common', 'channel']);const item = ITEM_MAP.get(id);const labelKey = item?.labelKey;const {@@ -228,7 +240,7 @@ const SortableItem = memo<{<Icon icon={GripVertical} size={14} style={{ color: cssVar.colorTextQuaternary }} /></Flexbox>{route?.icon && <Icon icon={route.icon} size={18} />}- <Text>{t(labelKey as any)}</Text>+ <Text>{t(labelKey as any, { ns: item.labelNs ?? 'common' })}</Text></Flexbox>{item.alwaysVisible ? (<Tooltip title={t('navPanel.pinned' as any)}>@@ -337,7 +349,7 @@ const AccordionGroup = memo<{ children: React.ReactNode }>(({ children }) => {// ---------------------------------------------------------------------------const OverlayItem = memo<{ id: string }>(({ id }) => {- const { t } = useTranslation('common');+ const { t } = useTranslation(['common', 'channel']);const agentLabelKey = 'navPanel.agent';// Accordion group overlay: render a compact representation@@ -377,12 +389,13 @@ const OverlayItem = memo<{ id: string }>(({ id }) => {if (!item) return null;const route = item.routeId ? getRouteById(item.routeId) : undefined;const labelKey = item.id === 'agent' ? agentLabelKey : item.labelKey;+ const labelNs = item.id === 'agent' ? 'common' : (item.labelNs ?? 'common');return (<Flexbox horizontal align={'center'} className={stylex.props(styles.overlay).className} gap={8}><Icon icon={GripVertical} size={14} style={{ color: cssVar.colorTextQuaternary }} />{route?.icon && <Icon icon={route.icon} size={18} />}- <Text>{t(labelKey as any)}</Text>+ <Text>{t(labelKey as any, { ns: labelNs })}</Text></Flexbox>);});@@ -411,9 +424,15 @@ const CustomizeSidebarContent = memo(() => {const isWorkspaceMode = !!useActiveWorkspaceSlug();const dashboardEnabled = useServerConfigStore(serverConfigSelectors.enableDashboard);const goalsEnabled = useUserStore(labPreferSelectors.enableGoals);+ const channelsEnabled = useChannelsEnabled();const sortableItemIds = useMemo(- () => getSortableSidebarItemIds(isWorkspaceMode, { dashboardEnabled, goalsEnabled }),- [isWorkspaceMode, dashboardEnabled, goalsEnabled],+ () =>+ getSortableSidebarItemIds(isWorkspaceMode, {+ channelsEnabled,+ dashboardEnabled,+ goalsEnabled,+ }),+ [isWorkspaceMode, channelsEnabled, dashboardEnabled, goalsEnabled],);const filteredStoreItems = useMemo(() => storeItems.filter((id) => sortableItemIds.has(id)),diff --git a/src/features/HomeSidebar/Body/Favorites/index.test.tsx b/src/features/HomeSidebar/Body/Favorites/index.test.tsxindex e9b14539868..6308fbcb30a 100644--- a/src/features/HomeSidebar/Body/Favorites/index.test.tsx+++ b/src/features/HomeSidebar/Body/Favorites/index.test.tsx@@ -10,6 +10,7 @@ import Favorites from './index';const state = vi.hoisted(() => ({error: undefined as Error | undefined,list: undefined as unknown[] | undefined,+ menuKey: undefined as string | undefined,revalidate: vi.fn(),}));@@ -30,6 +31,12 @@ vi.mock('@/components/AsyncError', () => ({</button>),}));+vi.mock('../useSidebarSectionMenuItems', () => ({+ useSidebarSectionMenuItems: (key: string) => {+ state.menuKey = key;+ return [{ key: 'customizeSidebar', label: 'navPanel.customizeSidebar' }];+ },+}));vi.mock('./SortableFavoriteList', () => ({ default: () => <div data-testid="favorite-list" /> }));const renderSection = () =>@@ -64,4 +71,12 @@ describe('Favorites sidebar section', () => {expect(screen.queryByText('favorite.section')).toBeNull();});++ it('gives the header the section layout menu, like the other sections', () => {+ state.list = [{ id: 'fav-1' }];+ const { container } = renderSection();++ expect(state.menuKey).toBe('favorites');+ expect(container.querySelector('.accordion-action')).toBeTruthy();+ });});diff --git a/src/features/HomeSidebar/Body/Favorites/index.tsx b/src/features/HomeSidebar/Body/Favorites/index.tsxindex 35a8d58b527..626c9b7a4b3 100644--- a/src/features/HomeSidebar/Body/Favorites/index.tsx+++ b/src/features/HomeSidebar/Body/Favorites/index.tsx@@ -1,6 +1,17 @@'use client';-import { AccordionHeader, AccordionItem, AccordionPanel, AccordionTrigger } from '@lobehub/ui';+import {+ AccordionHeader,+ AccordionItem,+ AccordionPanel,+ accordionStyles,+ AccordionTrigger,+ ActionIcon,+ ContextMenuTrigger,+ cx,+ DropdownMenu,+} from '@lobehub/ui';+import { MoreHorizontalIcon } from 'lucide-react';import { memo } from 'react';import { useTranslation } from 'react-i18next';@@ -10,6 +21,7 @@ import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/componimport { useHomeStore } from '@/store/home';import { favoriteSelectors } from '@/store/home/selectors';+import { useSidebarSectionMenuItems } from '../useSidebarSectionMenuItems';import SortableFavoriteList from './SortableFavoriteList';interface FavoritesProps {@@ -29,19 +41,36 @@ const Favorites = memo<FavoritesProps>(({ itemKey }) => {const { error, revalidate } = useFetchFavorites();const list = useHomeStore(favoriteSelectors.favoriteList);const loadFailed = list === undefined && !!error;+ const menuItems = useSidebarSectionMenuItems(itemKey);if (!loadFailed && (!list || list.length === 0)) return null;return (<AccordionItem value={itemKey}>- {/* Recents and Agents carry a 24px header action that sets their height;- Favorites has none, so pin the same height to keep the section- headers aligned. */}- <AccordionHeader style={{ minHeight: 24 + sectionTriggerStyle.paddingBlock * 2 }}>- <AccordionTrigger style={sectionTriggerStyle}>- <SectionTitle>{t('favorite.section')}</SectionTitle>- </AccordionTrigger>- </AccordionHeader>+ <ContextMenuTrigger items={menuItems}>+ <AccordionHeader>+ <AccordionTrigger style={sectionTriggerStyle}>+ <SectionTitle>{t('favorite.section')}</SectionTitle>+ </AccordionTrigger>+ <div+ className={cx(+ 'accordion-action',+ accordionStyles.action,+ accordionStyles.actionBorderless,+ )}+ >+ <DropdownMenu items={menuItems}>+ <ActionIcon+ aria-label={t('more')}+ icon={MoreHorizontalIcon}+ size={'small'}+ style={{ flex: 'none' }}+ title={t('more')}+ />+ </DropdownMenu>+ </div>+ </AccordionHeader>+ </ContextMenuTrigger><AccordionPanel>{loadFailed ? (<AsyncError error={error} variant="inline" onRetry={() => revalidate()} />diff --git a/src/features/HomeSidebar/Body/index.test.tsx b/src/features/HomeSidebar/Body/index.test.tsxindex f435d0fd210..d7770142244 100644--- a/src/features/HomeSidebar/Body/index.test.tsx+++ b/src/features/HomeSidebar/Body/index.test.tsx@@ -97,6 +97,10 @@ vi.mock('@/features/Channels/ChannelList', () => ({default: () => <div data-testid="sidebar-channels" />,}));+vi.mock('@/features/Channels/useChannelsEnabled', () => ({+ useChannelsEnabled: () => true,+}));+vi.mock('./Agent', () => ({default: ({ itemKey }: { itemKey: string }) => <div data-testid={`sidebar-item-${itemKey}`} />,}));@@ -218,6 +222,28 @@ describe('Home sidebar body', () => {expect(children[2]).toContainElement(screen.getByTestId('sidebar-item-recents'));});+ it('places Channels where the saved order puts them', () => {+ mocks.globalState.status.sidebarItems = ['channels', 'recents', 'agent', 'favorites'];++ render(<Body />);++ const children = Array.from(screen.getByTestId('sidebar-sections').children);++ expect(children[0]).toHaveAttribute('data-testid', 'sidebar-channels');+ expect(children[1]).toContainElement(screen.getByTestId('sidebar-item-recents'));+ expect(children[1]).toContainElement(screen.getByTestId('sidebar-item-agent'));+ });++ it('leaves Channels out once they are hidden', () => {+ mocks.globalState.status.sidebarItems = ['recents', 'agent', 'channels'];+ mocks.globalState.status.hiddenSidebarSections = ['channels'];++ render(<Body />);++ expect(screen.queryByTestId('sidebar-channels')).toBeNull();+ expect(screen.getByTestId('sidebar-item-agent')).toBeInTheDocument();+ });+// The Projects entry is keyed `project` like its sidebar layout id, but its page is `/projects`.it('highlights the Projects link on the project list page', () => {mocks.activeTab = 'projects';diff --git a/src/features/HomeSidebar/Body/index.tsx b/src/features/HomeSidebar/Body/index.tsxindex fdcb7fb0061..0d9be357dd3 100644--- a/src/features/HomeSidebar/Body/index.tsx+++ b/src/features/HomeSidebar/Body/index.tsx@@ -8,7 +8,6 @@ import { memo, useCallback, useMemo } from 'react';import { useTranslation } from 'react-i18next';import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';-import ChannelList from '@/features/Channels/ChannelList';import Recents from '@/features/Home/Recents';import NavItem from '@/features/NavPanel/components/NavItem';import { useNavItemMetrics } from '@/features/NavPanel/density';@@ -25,12 +24,14 @@ import { useUserStore } from '@/store/user';import { isModifierClick } from '@/utils/navigation';import Agent from './Agent';+import Channels from './Channels';import { openCustomizeSidebarModal } from './CustomizeSidebarModal';import Favorites from './Favorites';import { useSyncWorkspaceSidebarPreference } from './useSyncWorkspaceSidebarPreference';export enum GroupKey {Agent = 'agent',+ Channels = 'channels',Community = 'community',Favorites = 'favorites',Pages = 'pages',@@ -39,7 +40,12 @@ export enum GroupKey {Resource = 'resource',}-const ACCORDION_KEYS = new Set<string>([GroupKey.Favorites, GroupKey.Recents, GroupKey.Agent]);+const ACCORDION_KEYS = new Set<string>([+ GroupKey.Favorites,+ GroupKey.Recents,+ GroupKey.Agent,+ GroupKey.Channels,+]);/** Keys rendered in the header — must be excluded from the body to avoid duplicates* when migrating users whose persisted sidebarItems still include them. */@@ -234,14 +240,14 @@ const Body = memo(() => {style={{ flex: '1 1 0', minHeight: 0 }}/>,);+ } else if (key === GroupKey.Channels) {+ // Channels keep their own accordion (and its unsaved expanded state)+ // but take their place in the section order like the others.+ flushAccordion();+ sectionGroup.push(<Channels itemKey={key} key={key} />);} else if (ACCORDION_KEYS.has(key)) {const comp = accordionComponents[key]?.(key);if (comp) accGroup.push({ element: comp, key });- // Channels sit right below Agents, in their own accordion.- if (key === GroupKey.Agent) {- flushAccordion();- sectionGroup.push(<ChannelList key="channels" />);- }} else {const link = renderNavLink(key);if (link) {diff --git a/src/features/HomeSidebar/Body/useSidebarSectionMenuItems.test.ts b/src/features/HomeSidebar/Body/useSidebarSectionMenuItems.test.tsnew file mode 100644index 00000000000..f3e70b4a5ed--- /dev/null+++ b/src/features/HomeSidebar/Body/useSidebarSectionMenuItems.test.ts@@ -0,0 +1,189 @@+import { act, renderHook } from '@testing-library/react';+import { beforeEach, describe, expect, it, vi } from 'vitest';++import { useSidebarSectionMenuItems } from './useSidebarSectionMenuItems';++const mocks = vi.hoisted(() => ({+ channelsEnabled: true,+ favorites: [{ id: 'f1' }] as unknown[] | undefined,+ favoritesError: undefined as Error | undefined,+ links: ['tasks', 'image'],+ recents: [{ id: 'r1' }] as unknown[] | undefined,+ openCustomizeSidebarModal: vi.fn(),+ status: {} as { hiddenSidebarSections?: string[]; sidebarItems?: string[] },+ updateSystemStatus: vi.fn(),+}));++vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));+vi.mock('@/business/client/hooks/useActiveWorkspaceId', () => ({+ useActiveWorkspaceId: () => null,+}));+vi.mock('@/store/global', () => ({+ useGlobalStore: (selector: (s: unknown) => unknown) =>+ selector({ status: mocks.status, updateSystemStatus: mocks.updateSystemStatus }),+}));+vi.mock('@/features/Channels/useChannelsEnabled', () => ({+ useChannelsEnabled: () => mocks.channelsEnabled,+}));+vi.mock('@/features/Favorites', () => ({+ useFetchFavorites: () => ({ error: mocks.favoritesError }),+}));+vi.mock('@/hooks/useNavLayout', () => ({+ useNavLayout: () => ({+ bottomMenuItems: [],+ topNavItems: mocks.links.map((key) => ({ key })),+ }),+}));+vi.mock('@/store/user', () => ({+ useUserStore: (selector: (s: unknown) => unknown) => selector({}),+}));+vi.mock('@/store/user/slices/auth/selectors', () => ({+ authSelectors: { isLogin: () => true },+}));+vi.mock('@/store/home', () => ({+ useHomeStore: (selector: (s: unknown) => unknown) => selector({}),+}));+vi.mock('@/store/home/selectors', () => ({+ favoriteSelectors: { favoriteList: () => mocks.favorites },+ homeRecentSelectors: { query: () => () => mocks.recents },+}));+vi.mock('./CustomizeSidebarModal', () => ({+ openCustomizeSidebarModal: mocks.openCustomizeSidebarModal,+}));++type MenuItem = { disabled?: boolean; key?: string; onClick?: () => void; type?: string };++const itemsFor = (key: string) =>+ renderHook(() => useSidebarSectionMenuItems(key)).result.current as MenuItem[];+const find = (items: MenuItem[], key: string) => items.find((item) => item.key === key)!;++describe('useSidebarSectionMenuItems', () => {+ beforeEach(() => {+ mocks.channelsEnabled = true;+ mocks.favorites = [{ id: 'f1' }];+ mocks.favoritesError = undefined;+ mocks.links = ['tasks', 'image'];+ mocks.recents = [{ id: 'r1' }];+ mocks.openCustomizeSidebarModal.mockReset();+ mocks.updateSystemStatus.mockReset();+ mocks.status = {+ hiddenSidebarSections: [],+ sidebarItems: ['tasks', 'favorites', 'recents', 'agent', 'channels', '__spacer__', 'image'],+ };+ });++ it('offers move, hide and customize sidebar', () => {+ expect(itemsFor('channels').map((item) => item.key ?? item.type)).toEqual([+ 'moveUp',+ 'moveDown',+ 'hideSection',+ 'divider',+ 'customizeSidebar',+ ]);+ });++ it('moves the section within the accordion block', () => {+ const moveUp = find(itemsFor('channels'), 'moveUp');+ act(() => moveUp.onClick!());++ const { sidebarItems } = mocks.updateSystemStatus.mock.calls[0][0] as {+ sidebarItems: string[];+ };+ const spacerIndex = sidebarItems.indexOf('__spacer__');+ expect(sidebarItems.slice(spacerIndex - 4, spacerIndex)).toEqual([+ 'favorites',+ 'recents',+ 'channels',+ 'agent',+ ]);+ });++ it('hides the section', () => {+ mocks.status.hiddenSidebarSections = ['recents'];++ const hide = find(itemsFor('favorites'), 'hideSection');+ act(() => hide.onClick!());++ expect(mocks.updateSystemStatus).toHaveBeenCalledWith({+ hiddenSidebarSections: ['recents', 'favorites'],+ });+ });++ it('opens the customize sidebar modal', () => {+ const customize = find(itemsFor('favorites'), 'customizeSidebar');+ act(() => customize.onClick!());++ expect(mocks.openCustomizeSidebarModal).toHaveBeenCalled();+ });++ it('disables moving past the ends of the visible sections', () => {+ expect(find(itemsFor('tasks'), 'moveUp').disabled).toBe(true);+ expect(find(itemsFor('tasks'), 'moveDown').disabled).toBe(false);++ // The spacer stays flush below the section block, so its last section cannot move down.+ expect(find(itemsFor('channels'), 'moveDown').disabled).toBe(true);+ expect(find(itemsFor('agent'), 'moveDown').disabled).toBe(false);++ mocks.channelsEnabled = false;+ expect(find(itemsFor('agent'), 'moveDown').disabled).toBe(true);+ });++ it('steps over hidden sections and Channels while they are off', () => {+ mocks.channelsEnabled = false;+ mocks.status = {+ hiddenSidebarSections: ['recents'],+ sidebarItems: ['tasks', 'agent', 'recents', 'channels', 'favorites', '__spacer__', 'image'],+ };++ const moveUp = find(itemsFor('favorites'), 'moveUp');+ act(() => moveUp.onClick!());++ const { sidebarItems } = mocks.updateSystemStatus.mock.calls[0][0] as {+ sidebarItems: string[];+ };+ expect(sidebarItems.indexOf('favorites')).toBeLessThan(sidebarItems.indexOf('agent'));+ });++ it('steps over sections that render nothing', () => {+ // Recents are known empty and Favorites have nothing starred.+ mocks.recents = [];+ mocks.favorites = [];+ mocks.status.sidebarItems = [+ 'tasks',+ 'recents',+ 'channels',+ 'favorites',+ 'agent',+ '__spacer__',+ ];++ const moveUp = find(itemsFor('channels'), 'moveUp');+ act(() => moveUp.onClick!());++ const { sidebarItems } = mocks.updateSystemStatus.mock.calls[0][0] as {+ sidebarItems: string[];+ };+ // Channels pass Tasks, the nearest section that renders, and the sections+ // stay one block led by Channels.+ const block = ['channels', 'recents', 'favorites', 'agent'];+ const start = sidebarItems.indexOf('channels');+ expect(start).toBeLessThan(sidebarItems.indexOf('tasks'));+ expect(sidebarItems.slice(start, start + 4)).toEqual(block);+ });++ it('keeps Recents a move target while they are still loading', () => {+ mocks.recents = undefined;+ mocks.status.sidebarItems = ['recents', 'channels', 'agent', '__spacer__'];++ expect(find(itemsFor('channels'), 'moveUp').disabled).toBe(false);+ });++ it('counts Favorites that failed to load, since they show a retry', () => {+ mocks.favorites = undefined;+ mocks.favoritesError = new Error('offline');+ mocks.status.sidebarItems = ['favorites', 'recents', 'agent', '__spacer__'];++ expect(find(itemsFor('favorites'), 'moveDown').disabled).toBe(false);+ expect(find(itemsFor('recents'), 'moveUp').disabled).toBe(false);+ });+});diff --git a/src/features/HomeSidebar/Body/useSidebarSectionMenuItems.tsx b/src/features/HomeSidebar/Body/useSidebarSectionMenuItems.tsxnew file mode 100644index 00000000000..5b999076dd7--- /dev/null+++ b/src/features/HomeSidebar/Body/useSidebarSectionMenuItems.tsx@@ -0,0 +1,181 @@+import type { DropdownItem } from '@lobehub/ui';+import { Icon } from '@lobehub/ui';+import { ArrowDownIcon, ArrowUpIcon, EyeOffIcon, SlidersHorizontalIcon } from 'lucide-react';+import { useCallback, useMemo } from 'react';+import { useTranslation } from 'react-i18next';++import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';+import { useChannelsEnabled } from '@/features/Channels/useChannelsEnabled';+import { useFetchFavorites } from '@/features/Favorites';+import { useNavLayout } from '@/hooks/useNavLayout';+import { useGlobalStore } from '@/store/global';+import { systemStatusSelectors } from '@/store/global/selectors';+import {+ reorderSidebarItems,+ SIDEBAR_ACCORDION_KEYS,+ SIDEBAR_SPACER_ID,+} from '@/store/global/selectors/systemStatus';+import { useHomeStore } from '@/store/home';+import { favoriteSelectors, homeRecentSelectors } from '@/store/home/selectors';+import { createRecentQueryKey } from '@/store/home/slices/recent/initialState';+import { useUserStore } from '@/store/user';+import { authSelectors } from '@/store/user/slices/auth/selectors';++import { openCustomizeSidebarModal } from './CustomizeSidebarModal';++/** Whether a sidebar entry renders anything right now, mirroring the section components. */+const useSectionRenders = (): ((key: string) => boolean) => {+ const channelsEnabled = useChannelsEnabled();+ const isLogin = useUserStore(authSelectors.isLogin);+ const favoriteCount = useHomeStore((s) => favoriteSelectors.favoriteList(s)?.length);+ // SWR dedupes this with the Favorites section's own request.+ const { error: favoritesError } = useFetchFavorites();+ const recentPageSize = useGlobalStore(systemStatusSelectors.recentPageSize);+ const recentCount = useHomeStore(+ (s) => homeRecentSelectors.query(createRecentQueryKey(recentPageSize + 1))(s)?.length,+ );+ const { bottomMenuItems, topNavItems } = useNavLayout();++ return useMemo(() => {+ const links = new Set(+ [...topNavItems, ...bottomMenuItems].filter((item) => !item.hidden).map((item) => item.key),+ );++ return (key: string) => {+ switch (key) {+ case SIDEBAR_SPACER_ID:+ case 'agent': {+ return true;+ }+ case 'channels': {+ return channelsEnabled;+ }+ // Mirrors the section: shown with items, or with a retry after a failed first load.+ case 'favorites': {+ return favoriteCount === undefined ? !!favoritesError : favoriteCount > 0;+ }+ // Recents show a skeleton while loading and disappear once known to be empty.+ case 'recents': {+ return !!isLogin && recentCount !== 0;+ }+ // The header renders Home and Search; legacy layouts may still list them.+ case 'home':+ case 'search': {+ return false;+ }+ default: {+ return links.has(key);+ }+ }+ };+ }, [+ bottomMenuItems,+ channelsEnabled,+ favoriteCount,+ favoritesError,+ isLogin,+ recentCount,+ topNavItems,+ ]);+};++/**+ * The layout entries every home-sidebar section header offers in its "…" and+ * right-click menus: move up / down, hide, and the customize-sidebar modal.+ * A section adds its own entries ahead of these.+ */+export const useSidebarSectionMenuItems = (sectionKey: string): DropdownItem[] => {+ const { t } = useTranslation('common');+ const activeWorkspaceId = useActiveWorkspaceId();+ const sidebarItems = useGlobalStore(systemStatusSelectors.sidebarItems(activeWorkspaceId));+ const hiddenSections = useGlobalStore(+ systemStatusSelectors.hiddenSidebarSections(activeWorkspaceId),+ );+ const updateSystemStatus = useGlobalStore((s) => s.updateSystemStatus);++ const renders = useSectionRenders();++ // Sections the member can see. Hidden ones, Channels while they are off,+ // empty Favorites / Recents and unavailable links render nothing, so a move+ // steps over them instead of swapping with something invisible.+ const visibleItems = useMemo(+ () =>+ sidebarItems.filter(+ // Agents ignore the hidden list, as the sidebar body does.+ // The section whose menu this is is on screen, whatever the stores say.+ (k) => k === sectionKey || ((k === 'agent' || !hiddenSections.includes(k)) && renders(k)),+ ),+ [sectionKey, sidebarItems, hiddenSections, renders],+ );+ const visibleIndex = visibleItems.indexOf(sectionKey);+ const isFirst = visibleIndex <= 0;+ // The spacer stays flush below the section block, so the block's last+ // section has nowhere further down to go.+ const nextVisible = visibleItems[visibleIndex + 1];+ const isLast =+ visibleIndex === -1 ||+ !nextVisible ||+ (nextVisible === SIDEBAR_SPACER_ID && SIDEBAR_ACCORDION_KEYS.has(sectionKey));++ const moveSection = useCallback(+ (direction: 'up' | 'down') => {+ const neighbor = visibleItems[visibleIndex + (direction === 'up' ? -1 : 1)];+ if (visibleIndex === -1 || !neighbor) return;+ // Step one slot at a time so the block rules of `reorderSidebarItems`+ // (sections stay together, the spacer stays below them) apply on the way.+ const step = direction === 'up' ? -1 : 1;+ const passed = (items: string[]) =>+ direction === 'up'+ ? items.indexOf(sectionKey) < items.indexOf(neighbor)+ : items.indexOf(sectionKey) > items.indexOf(neighbor);+ let next = sidebarItems;+ for (let guard = 0; guard < sidebarItems.length && !passed(next); guard++) {+ const idx = next.indexOf(sectionKey);+ const moved = reorderSidebarItems(next, idx, idx + step);+ if (moved === next) break;+ next = moved;+ }+ if (next === sidebarItems || !passed(next)) return;+ updateSystemStatus({ sidebarItems: next });+ },+ [sectionKey, sidebarItems, visibleItems, visibleIndex, updateSystemStatus],+ );++ const hideSection = useCallback(() => {+ updateSystemStatus({ hiddenSidebarSections: [...hiddenSections, sectionKey] });+ }, [hiddenSections, sectionKey, updateSystemStatus]);++ return useMemo(+ () =>+ [+ {+ disabled: isFirst,+ icon: <Icon icon={ArrowUpIcon} />,+ key: 'moveUp',+ label: t('navPanel.moveUp'),+ onClick: () => moveSection('up'),+ },+ {+ disabled: isLast,+ icon: <Icon icon={ArrowDownIcon} />,+ key: 'moveDown',+ label: t('navPanel.moveDown'),+ onClick: () => moveSection('down'),+ },+ {+ icon: <Icon icon={EyeOffIcon} />,+ key: 'hideSection',+ label: t('navPanel.hideSection'),+ onClick: hideSection,+ },+ { type: 'divider' as const },+ {+ icon: <Icon icon={SlidersHorizontalIcon} />,+ key: 'customizeSidebar',+ label: t('navPanel.customizeSidebar'),+ onClick: () => openCustomizeSidebarModal(),+ },+ ] as DropdownItem[],+ [t, isFirst, isLast, moveSection, hideSection],+ );+};diff --git a/src/store/global/selectors/systemStatus.legacyAgentKeys.test.ts b/src/store/global/selectors/systemStatus.legacyAgentKeys.test.tsindex c32577da954..cef0e6ef266 100644--- a/src/store/global/selectors/systemStatus.legacyAgentKeys.test.ts+++ b/src/store/global/selectors/systemStatus.legacyAgentKeys.test.ts@@ -75,8 +75,10 @@ describe('legacy `private` sidebar key', () => {expect(items).not.toContain('private');expect(items.filter((key) => key === 'agent')).toHaveLength(1);- // Stays in the accordion block, right above the spacer.- expect(items[items.indexOf(SIDEBAR_SPACER_ID) - 1]).toBe('agent');+ // Stays at the end of the accordion block, with Channels right below it.+ expect(+ items.slice(items.indexOf(SIDEBAR_SPACER_ID) - 2, items.indexOf(SIDEBAR_SPACER_ID)),+ ).toEqual(['agent', 'channels']);});it('does not resurrect `private` through the missing-key backfill', () => {diff --git a/src/store/global/selectors/systemStatus.test.ts b/src/store/global/selectors/systemStatus.test.tsindex dece38ace00..ee89efa5d6a 100644--- a/src/store/global/selectors/systemStatus.test.ts+++ b/src/store/global/selectors/systemStatus.test.ts@@ -283,6 +283,7 @@ describe('systemStatusSelectors', () => {'dashboard','favorites','agent',+ 'channels','recents',SIDEBAR_SPACER_ID,'pages',@@ -314,9 +315,12 @@ describe('systemStatusSelectors', () => {const s: GlobalState = merge(initialState, {status: { sidebarItems: stored },});- // The former Private section is merged into Agents.+ // The former Private section is merged into Agents; Channels, saved+ // before they joined the layout, keep their spot right below Agents.expect(systemStatusSelectors.sidebarItems(null)(s)).toEqual(- stored.filter((key) => key !== 'private'),+ stored+ .filter((key) => key !== 'private')+ .flatMap((key) => (key === 'agent' ? ['agent', 'channels'] : [key])),);});@@ -347,6 +351,7 @@ describe('systemStatusSelectors', () => {'favorites','recents','agent',+ 'channels',SIDEBAR_SPACER_ID,'image','community',@@ -383,6 +388,7 @@ describe('systemStatusSelectors', () => {'favorites','recents','agent',+ 'channels',SIDEBAR_SPACER_ID,'image','community',@@ -427,9 +433,12 @@ describe('systemStatusSelectors', () => {const s: GlobalState = merge(initialState, {status: { sidebarItems: stored },});- // The former Private section is merged into Agents.+ // The former Private section is merged into Agents; Channels, saved+ // before they joined the layout, keep their spot right below Agents.expect(systemStatusSelectors.sidebarItems(null)(s)).toEqual(- stored.filter((key) => key !== 'private'),+ stored+ .filter((key) => key !== 'private')+ .flatMap((key) => (key === 'agent' ? ['agent', 'channels'] : [key])),);});@@ -444,19 +453,34 @@ describe('systemStatusSelectors', () => {expect(items).toContain('community');expect(items).toContain('resource');expect(items).toContain('memory');- // accordion block is flush against the spacer, in stored order- expect(items[spacerIdx - 2]).toBe('agent');- expect(items[spacerIdx - 1]).toBe('recents');+ // accordion block is flush against the spacer, in stored order, with+ // Channels kept right below Agents+ expect(items.slice(spacerIdx - 3, spacerIdx)).toEqual(['agent', 'channels', 'recents']);// missing top-group defaults slot in just before the accordion- expect(items.indexOf('tasks')).toBeLessThan(spacerIdx - 2);+ expect(items.indexOf('tasks')).toBeLessThan(spacerIdx - 3);expect(items.indexOf('project')).toBe(items.indexOf('goals') + 1);- expect(items.indexOf('resource')).toBeLessThan(spacerIdx - 2);+ expect(items.indexOf('resource')).toBeLessThan(spacerIdx - 3);// missing bottom-group defaults sit after the spacerexpect(items.indexOf('image')).toBeGreaterThan(spacerIdx);// Pages live in Docs now; the retired entry is not backfilledexpect(items).not.toContain('pages');});+ it('should keep Channels where the user moved them in the accordion block', () => {+ const s: GlobalState = merge(initialState, {+ status: { sidebarItems: ['channels', 'favorites', 'recents', 'agent', SIDEBAR_SPACER_ID] },+ });+ const items = systemStatusSelectors.sidebarItems(null)(s);+ const spacerIdx = items.indexOf(SIDEBAR_SPACER_ID);+ expect(items.slice(spacerIdx - 4, spacerIdx)).toEqual([+ 'channels',+ 'favorites',+ 'recents',+ 'agent',+ ]);+ expect(items.filter((key) => key === 'channels')).toHaveLength(1);+ });+it('should migrate legacy `sidebarSectionOrder` accordion order into the default layout', () => {const s: GlobalState = merge(initialState, {status: { sidebarSectionOrder: ['agent', 'recents'] },@@ -472,6 +496,7 @@ describe('systemStatusSelectors', () => {'resource','favorites','agent',+ 'channels','recents',SIDEBAR_SPACER_ID,'image',@@ -495,6 +520,7 @@ describe('systemStatusSelectors', () => {'favorites','recents','agent',+ 'channels',SIDEBAR_SPACER_ID,'image','community',diff --git a/src/store/global/selectors/systemStatus.ts b/src/store/global/selectors/systemStatus.tsindex a81eb89af66..bcffb6ef529 100644--- a/src/store/global/selectors/systemStatus.ts+++ b/src/store/global/selectors/systemStatus.ts@@ -240,6 +240,7 @@ export const DEFAULT_SIDEBAR_ITEMS: string[] = ['favorites','recents','agent',+ 'channels',SIDEBAR_SPACER_ID,'image','community',@@ -247,7 +248,7 @@ export const DEFAULT_SIDEBAR_ITEMS: string[] = [];/** Items that must stay contiguous in the sidebar list (accordion block). */-export const SIDEBAR_ACCORDION_KEYS = new Set(['favorites', 'recents', 'agent']);+export const SIDEBAR_ACCORDION_KEYS = new Set(['favorites', 'recents', 'agent', 'channels']);/*** Section key of the former workspace "Private" accordion. It was merged into@@ -363,8 +364,18 @@ const liftProjectOutOfAccordion = (order: string[]): string[] => {// bottom-group defaults go after the spacer. Without this split a new top-group// default added in a future version would silently appear in the bottom group// for existing users.+// Channels used to render right below Agents outside the saved order; a saved+// order without them keeps them in that spot instead of the top of the block.+const CHANNELS_SECTION_KEY = 'channels';+const withChannelsAfterAgent = (order: string[]): string[] => {+ if (order.includes(CHANNELS_SECTION_KEY)) return order;+ const agentIndex = order.indexOf(AGENT_SECTION_KEY);+ if (agentIndex === -1) return order;+ return [...order.slice(0, agentIndex + 1), CHANNELS_SECTION_KEY, ...order.slice(agentIndex + 1)];+};+const withAllKnownKeys = (order: string[]): string[] => {- const nextOrder = liftProjectOutOfAccordion(order);+ const nextOrder = withChannelsAfterAgent(liftProjectOutOfAccordion(order));const present = new Set(nextOrder);const missingTop: string[] = [];const missingBottom: string[] = [];