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(sidebar): group spacer with recents and agents (#15373)

Innei3e51b87b1e83
diff --git a/src/routes/(main)/home/_layout/Body/CustomizeSidebarModal.tsx b/src/routes/(main)/home/_layout/Body/CustomizeSidebarModal.tsx
index d8f7f82fc77..c76e6a7d8bb 100644
--- a/src/routes/(main)/home/_layout/Body/CustomizeSidebarModal.tsx
+++ b/src/routes/(main)/home/_layout/Body/CustomizeSidebarModal.tsx
@@ -168,8 +168,8 @@ const SortableItem = memo<{
});
// ---------------------------------------------------------------------------
-// SpacerSortableItem β€” represents the flex spacer slot; draggable like any
-// other item but rendered as a divider with an "Anchor below to bottom" label.
+// SpacerSortableItem β€” represents the flex spacer slot when it is not bound to
+// the accordion group; draggable like any other item.
// ---------------------------------------------------------------------------
const SpacerSortableItem = memo(() => {
@@ -214,6 +214,21 @@ const SpacerSortableItem = memo(() => {
);
});
+const BoundSpacerItem = memo(() => {
+ const { t } = useTranslation('common');
+
+ return (
+ <Flexbox horizontal align={'center'} className={styles.item} gap={8}>
+ <Icon icon={ArrowDownToLine} size={14} style={{ color: cssVar.colorTextQuaternary }} />
+ <div className={styles.spacerLine} />
+ <Text style={{ fontSize: 12 }} type={'secondary'}>
+ {t('navPanel.bottomDivider' as any)}
+ </Text>
+ <div className={styles.spacerLine} />
+ </Flexbox>
+ );
+});
+
// ---------------------------------------------------------------------------
// AccordionGroup β€” a non-draggable slot at the outer level that wraps a nested
// SortableContext for accordion items. Registers with useSortable so other outer
@@ -285,8 +300,12 @@ const OverlayItem = memo<{ id: string }>(({ id }) => {
// ---------------------------------------------------------------------------
/** Flatten outer list (with ACCORDION_GROUP_ID placeholder) + inner accordion items β†’ full list. */
-const flattenItems = (outer: string[], inner: string[]): string[] =>
- outer.flatMap((id) => (id === ACCORDION_GROUP_ID ? inner : [id]));
+const flattenItems = (outer: string[], inner: string[], bindSpacerToAccordion: boolean): string[] =>
+ outer.flatMap((id) =>
+ id === ACCORDION_GROUP_ID
+ ? [...inner, ...(bindSpacerToAccordion ? [SIDEBAR_SPACER_ID] : [])]
+ : [id],
+ );
const CustomizeSidebarContent = memo(() => {
const [storeItems, hiddenSections, updateSystemStatus] = useGlobalStore((s) => [
@@ -305,10 +324,13 @@ const CustomizeSidebarContent = memo(() => {
}, [storeItems]);
// Derive outer (with group placeholder) and inner (accordion items)
- const { innerItems, outerItems } = useMemo(() => {
+ const { bindSpacerToAccordion, innerItems, outerItems } = useMemo(() => {
+ const hasAccordion = items.some(isAccordionKey);
+ const shouldBindSpacer = hasAccordion && items.includes(SIDEBAR_SPACER_ID);
const outer: string[] = [];
const inner: string[] = [];
let insertedGroup = false;
+
for (const id of items) {
if (isAccordionKey(id)) {
inner.push(id);
@@ -316,11 +338,14 @@ const CustomizeSidebarContent = memo(() => {
outer.push(ACCORDION_GROUP_ID);
insertedGroup = true;
}
+ } else if (isSpacer(id) && shouldBindSpacer) {
+ continue;
} else {
outer.push(id);
}
}
- return { innerItems: inner, outerItems: outer };
+
+ return { bindSpacerToAccordion: shouldBindSpacer, innerItems: inner, outerItems: outer };
}, [items]);
const sensors = useSensors(
@@ -374,19 +399,27 @@ const CustomizeSidebarContent = memo(() => {
const oldIdx = innerItems.indexOf(activeKey);
const newIdx = innerItems.indexOf(overKey);
if (oldIdx === -1 || newIdx === -1) return;
- next = flattenItems(outerItems, arrayMove(innerItems, oldIdx, newIdx));
+ next = flattenItems(
+ outerItems,
+ arrayMove(innerItems, oldIdx, newIdx),
+ bindSpacerToAccordion,
+ );
} else {
// Outer reorder (pages/community/... or the whole accordion group)
const oldIdx = outerItems.indexOf(activeKey);
const newIdx = outerItems.indexOf(overKey);
if (oldIdx === -1 || newIdx === -1) return;
- next = flattenItems(arrayMove(outerItems, oldIdx, newIdx), innerItems);
+ next = flattenItems(
+ arrayMove(outerItems, oldIdx, newIdx),
+ innerItems,
+ bindSpacerToAccordion,
+ );
}
setItems(next);
updateSystemStatus({ sidebarItems: next });
},
- [innerItems, outerItems, updateSystemStatus],
+ [bindSpacerToAccordion, innerItems, outerItems, updateSystemStatus],
);
const handleDragCancel = useCallback(() => {
@@ -417,6 +450,7 @@ const CustomizeSidebarContent = memo(() => {
<SortableContext items={innerItems} strategy={verticalListSortingStrategy}>
{innerItems.map(renderItem)}
</SortableContext>
+ {bindSpacerToAccordion && <BoundSpacerItem />}
</AccordionGroup>
) : (
renderItem(id)