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(ui): add Compact / Loose interface density (#23406)

Innei6dc91bf8fa3a
diff --git a/locales/en-US/common.json b/locales/en-US/common.json
index 5acce9b40f2..55e8af13eae 100644
--- a/locales/en-US/common.json
+++ b/locales/en-US/common.json
@@ -374,6 +374,7 @@
"navPanel.moveDown": "Move Down",
"navPanel.moveUp": "Move Up",
"navPanel.myPinned": "Pinned",
+ "navPanel.newChat": "New chat",
"navPanel.openMenu": "Open menu",
"navPanel.pinned": "Pinned",
"navPanel.privateAgents": "Private",
diff --git a/locales/en-US/setting.json b/locales/en-US/setting.json
index 25ea7b0cf83..12ec4f077cb 100644
--- a/locales/en-US/setting.json
+++ b/locales/en-US/setting.json
@@ -1764,6 +1764,10 @@
"settingAppearance.contextMenuMode.desc": "Enable the right-click menu for some list items.",
"settingAppearance.contextMenuMode.disabled": "Disabled",
"settingAppearance.contextMenuMode.title": "Right-Click Menu Mode",
+ "settingAppearance.density.compact": "Compact",
+ "settingAppearance.density.desc": "Row height and spacing in the sidebars. Compact fits more on screen; Loose gives each row more room.",
+ "settingAppearance.density.loose": "Loose",
+ "settingAppearance.density.title": "Interface Density",
"settingAppearance.desktop.title": "Desktop",
"settingAppearance.font.antialiasing.desc": "Render text with grayscale antialiasing for a thinner, crisper look. Turn off to use the system default rendering. Only affects macOS.",
"settingAppearance.font.antialiasing.title": "Font Antialiasing",
diff --git a/locales/zh-CN/common.json b/locales/zh-CN/common.json
index c4e126a4161..788ffee969c 100644
--- a/locales/zh-CN/common.json
+++ b/locales/zh-CN/common.json
@@ -374,6 +374,7 @@
"navPanel.moveDown": "下移",
"navPanel.moveUp": "上移",
"navPanel.myPinned": "我的置顶",
+ "navPanel.newChat": "新对话",
"navPanel.openMenu": "打开菜单",
"navPanel.pinned": "已固定",
"navPanel.privateAgents": "私人",
diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.json
index aec95adaec0..d566b5fb5c9 100644
--- a/locales/zh-CN/setting.json
+++ b/locales/zh-CN/setting.json
@@ -1764,6 +1764,10 @@
"settingAppearance.contextMenuMode.desc": "为部分列表项启用右键菜单。",
"settingAppearance.contextMenuMode.disabled": "不使用",
"settingAppearance.contextMenuMode.title": "右键菜单方案",
+ "settingAppearance.density.compact": "紧凑",
+ "settingAppearance.density.desc": "侧边栏的行高与间距。紧凑一屏能看到更多,宽松让每一行更舒展。",
+ "settingAppearance.density.loose": "宽松",
+ "settingAppearance.density.title": "界面密度",
"settingAppearance.desktop.title": "桌面",
"settingAppearance.font.antialiasing.desc": "使用灰度抗锯齿渲染文字,字形更细更清晰。关闭后使用系统默认渲染。仅对 macOS 生效。",
"settingAppearance.font.antialiasing.title": "字体抗锯齿",
diff --git a/packages/const/src/settings/common.ts b/packages/const/src/settings/common.ts
index 49ce6ccdbf2..f01925c9e08 100644
--- a/packages/const/src/settings/common.ts
+++ b/packages/const/src/settings/common.ts
@@ -8,6 +8,7 @@ export const DEFAULT_COMMON_SETTINGS: UserGeneralConfig = {
costEstimateWarningThreshold: DEFAULT_COST_ESTIMATE_WARNING_THRESHOLD,
fontSize: 14,
highlighterTheme: 'lobe-theme',
+ interfaceDensity: 'loose',
isDevMode: false,
isLiteMode: false,
mermaidTheme: 'lobe-theme',
diff --git a/packages/locales/src/default/common.ts b/packages/locales/src/default/common.ts
index cc2bc83b764..b58ae3f407d 100644
--- a/packages/locales/src/default/common.ts
+++ b/packages/locales/src/default/common.ts
@@ -452,6 +452,7 @@ export default {
'navPanel.createWorkspaceAgent': 'New workspace agent',
'navPanel.managePrivateFolders': 'Manage private categories',
'navPanel.myPinned': 'Pinned',
+ 'navPanel.newChat': 'New chat',
'navPanel.privateTooltip': 'Private · only you can see this',
'navPanel.showLessTeamPinned': 'Show less',
'navPanel.showMoreTeamPinned': 'Show {{count}} more',
diff --git a/packages/locales/src/default/setting.ts b/packages/locales/src/default/setting.ts
index 5345da8dccc..5d3123a2ea7 100644
--- a/packages/locales/src/default/setting.ts
+++ b/packages/locales/src/default/setting.ts
@@ -1538,6 +1538,11 @@ export default {
'settingAppearance.contextMenuMode.desc': 'Enable the right-click menu for some list items.',
'settingAppearance.contextMenuMode.disabled': 'Disabled',
'settingAppearance.contextMenuMode.title': 'Right-Click Menu Mode',
+ 'settingAppearance.density.compact': 'Compact',
+ 'settingAppearance.density.desc':
+ 'Row height and spacing in the sidebars. Compact fits more on screen; Loose gives each row more room.',
+ 'settingAppearance.density.loose': 'Loose',
+ 'settingAppearance.density.title': 'Interface Density',
'settingAppearance.desktop.title': 'Desktop',
'settingAppearance.font.antialiasing.desc':
'Render text with grayscale antialiasing for a thinner, crisper look. Turn off to use the system default rendering. Only affects macOS.',
diff --git a/packages/types/src/user/settings/general.ts b/packages/types/src/user/settings/general.ts
index 0fc71856d1e..fd7ec782bd2 100644
--- a/packages/types/src/user/settings/general.ts
+++ b/packages/types/src/user/settings/general.ts
@@ -6,6 +6,8 @@ export type AnimationMode = 'disabled' | 'agile' | 'elegant';
export type ContextMenuMode = 'disabled' | 'default';
+export type InterfaceDensity = 'compact' | 'loose';
+
/**
* What a message sent while the agent runs does (Better Coding Experience
* lab): `queue` waits for the run to end and sends one message per turn;
@@ -62,6 +64,7 @@ export interface UserGeneralConfig {
fontAntialiasing?: boolean;
fontSize: number;
highlighterTheme?: HighlighterProps['theme'];
+ interfaceDensity?: InterfaceDensity;
isDevMode: boolean;
isLiteMode: boolean;
mermaidTheme?: MermaidProps['theme'];
diff --git a/src/components/Skeleton/AgentViewAll.tsx b/src/components/Skeleton/AgentViewAll.tsx
index 6d12c0bd9c0..057e58a1977 100644
--- a/src/components/Skeleton/AgentViewAll.tsx
+++ b/src/components/Skeleton/AgentViewAll.tsx
@@ -8,6 +8,7 @@ import WideScreenContainer from '@/features/WideScreenContainer';
import type { RouteSkeletonProps } from '@/spa/router/routeMeta';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
+import { useDensityTokens } from '@/styles/density';
import SkeletonBar from './Bar';
@@ -117,32 +118,39 @@ export const AgentViewAllRowsSkeleton = ({ rows = 8 }: { rows?: number }) => (
* with the "In sidebar" block and the toolbar (240px-max search left, split
* create button right) over list-view rows (also the loading state of the card view).
*/
-const AgentViewAllSkeleton = ({ chrome = 'page' }: RouteSkeletonProps) => (
- <Flexbox aria-busy flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
- {chrome !== 'body' && (
- <Flexbox
- horizontal
- align={'center'}
- flex={'none'}
- height={44}
- justify={'space-between'}
- padding={8}
- >
- <Flexbox style={{ paddingInlineStart: 4 }}>
- <SkeletonBar height={14} width={48} />
+const AgentViewAllSkeleton = ({ chrome = 'page' }: RouteSkeletonProps) => {
+ const { headerActionSmallSize, headerHeight } = useDensityTokens();
+
+ return (
+ <Flexbox aria-busy flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
+ {chrome !== 'body' && (
+ <Flexbox
+ horizontal
+ align={'center'}
+ flex={'none'}
+ height={headerHeight}
+ justify={'space-between'}
+ padding={8}
+ >
+ <Flexbox style={{ paddingInlineStart: 4 }}>
+ <SkeletonBar height={14} width={48} />
+ </Flexbox>
+ <SkeletonBar
+ height={headerActionSmallSize.blockSize}
+ width={headerActionSmallSize.blockSize}
+ />
</Flexbox>
- <SkeletonBar height={28} width={28} />
- </Flexbox>
- )}
- <WideScreenContainer fullWidth gap={16} paddingBlock={16} paddingInline={16}>
- <AgentViewAllSidebarSectionSkeleton />
- <Flexbox horizontal align={'center'} gap={12} justify={'space-between'}>
- <SkeletonBar height={32} width={206} />
- <SkeletonBar height={32} width={64} />
- </Flexbox>
- <AgentViewAllRowsSkeleton />
- </WideScreenContainer>
- </Flexbox>
-);
+ )}
+ <WideScreenContainer fullWidth gap={16} paddingBlock={16} paddingInline={16}>
+ <AgentViewAllSidebarSectionSkeleton />
+ <Flexbox horizontal align={'center'} gap={12} justify={'space-between'}>
+ <SkeletonBar height={32} width={206} />
+ <SkeletonBar height={32} width={64} />
+ </Flexbox>
+ <AgentViewAllRowsSkeleton />
+ </WideScreenContainer>
+ </Flexbox>
+ );
+};
export default AgentViewAllSkeleton;
diff --git a/src/components/Skeleton/NavPanel/List.tsx b/src/components/Skeleton/NavPanel/List.tsx
index e456c81486c..686a71b880e 100644
--- a/src/components/Skeleton/NavPanel/List.tsx
+++ b/src/components/Skeleton/NavPanel/List.tsx
@@ -3,41 +3,67 @@
import { type FlexboxProps } from '@lobehub/ui';
import { Flexbox } from '@lobehub/ui';
+import { useDensityTokens, usePanelDensityTokens } from '@/styles/density';
+
import SkeletonBar from '../Bar';
export const SkeletonItem = ({
- padding = 6,
- height = 36,
+ padding,
+ height,
style,
- avatarSize = 28,
+ avatarSize,
...rest
-}: { avatarSize?: number } & Omit<FlexboxProps, 'children'>) => (
- <Flexbox
- horizontal
- align={'center'}
- flex={1}
- gap={8}
- height={height}
- padding={padding}
- style={style}
- {...rest}
- >
- <SkeletonBar height={avatarSize} width={avatarSize} />
- <Flexbox flex={1} height={16}>
- <SkeletonBar height={16} />
+}: { avatarSize?: number } & Omit<FlexboxProps, 'children'>) => {
+ const panel = usePanelDensityTokens();
+ const barHeight = panel ? panel.fontSize + 2 : 16;
+
+ return (
+ <Flexbox
+ horizontal
+ align={'center'}
+ flex={1}
+ gap={panel?.gap ?? 8}
+ height={height ?? panel?.rowHeight ?? 36}
+ padding={padding ?? (panel ? `0 ${panel.paddingInline + 2}px` : 6)}
+ style={style}
+ {...rest}
+ >
+ <SkeletonBar
+ height={avatarSize ?? panel?.iconBox ?? 28}
+ width={avatarSize ?? panel?.iconBox ?? 28}
+ />
+ <Flexbox flex={1} height={barHeight}>
+ <SkeletonBar height={barHeight} />
+ </Flexbox>
</Flexbox>
- </Flexbox>
-);
+ );
+};
export const SkeletonList = ({
+ compact,
rows = 3,
...rest
-}: { rows?: number } & Omit<FlexboxProps, 'children'>) => (
- <Flexbox gap={2} {...rest}>
- {Array.from({ length: rows }).map((_, index) => (
- <SkeletonItem key={index} />
- ))}
- </Flexbox>
-);
+}: { compact?: boolean; rows?: number } & Omit<FlexboxProps, 'children'>) => {
+ const density = useDensityTokens();
+
+ return (
+ <Flexbox gap={compact ? 1 : 2} {...rest}>
+ {Array.from({ length: rows }).map((_, index) =>
+ compact ? (
+ <SkeletonItem
+ avatarSize={density.iconSize}
+ flex={'none'}
+ gap={density.gap}
+ height={density.rowHeight}
+ key={index}
+ padding={`8px ${density.paddingInline}px`}
+ />
+ ) : (
+ <SkeletonItem key={index} />
+ ),
+ )}
+ </Flexbox>
+ );
+};
export default SkeletonList;
diff --git a/src/components/Skeleton/NavPanel/SideBar.tsx b/src/components/Skeleton/NavPanel/SideBar.tsx
index bb0bce0d920..a7043933eb7 100644
--- a/src/components/Skeleton/NavPanel/SideBar.tsx
+++ b/src/components/Skeleton/NavPanel/SideBar.tsx
@@ -3,6 +3,8 @@
import { Center, cssVar, Flexbox } from '@lobehub/ui';
import { isDesktop } from '@/const/version';
+import { getContainerTopInset } from '@/features/DesktopLayoutContainer/cssVariables';
+import { type DensityTokens, usePanelDensityTokens } from '@/styles/density';
import { isMacOS } from '@/utils/platform';
import SkeletonBar from '../Bar';
@@ -11,8 +13,8 @@ const isMacDesktop = isDesktop && isMacOS();
export type SideBarHeaderVariant = 'breadcrumb' | 'title';
-const headerContentHeight = (variant: SideBarHeaderVariant) => {
- if (variant === 'title') return 32;
+const headerContentHeight = (variant: SideBarHeaderVariant, tokens: DensityTokens | null) => {
+ if (variant === 'title') return (tokens?.headerAvatarSize ?? 28) + 4;
return isMacDesktop ? 22 : 28;
};
@@ -20,24 +22,55 @@ export const SideBarHeaderSkeleton = ({
variant = 'breadcrumb',
}: {
variant?: SideBarHeaderVariant;
-}) => (
- <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} />
+}) => {
+ const tokens = usePanelDensityTokens();
+ const topInset = getContainerTopInset();
+
+ return (
+ <Flexbox
+ horizontal
+ align={'center'}
+ flex={'none'}
+ height={tokens ? tokens.headerHeight + topInset : undefined}
+ padding={tokens ? undefined : '8px 6px'}
+ paddingInline={tokens ? 6 : undefined}
+ style={tokens ? { paddingBlockStart: topInset } : undefined}
+ >
+ <Flexbox
+ flex={1}
+ height={headerContentHeight(variant, tokens)}
+ justify={'center'}
+ paddingInline={6}
+ >
+ <SkeletonBar height={variant === 'title' ? 18 : 14} width={variant === 'title' ? 96 : 72} />
+ </Flexbox>
</Flexbox>
- </Flexbox>
-);
+ );
+};
+
+const SkeletonNavItem = ({ width }: { width: string }) => {
+ const tokens = usePanelDensityTokens();
+ const iconBox = tokens?.iconBox ?? 28;
+ const iconSize = tokens?.iconSize ?? 18;
-const SkeletonNavItem = ({ width }: { width: string }) => (
- <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} />
+ return (
+ <Flexbox
+ horizontal
+ align={'center'}
+ flex={'none'}
+ gap={tokens?.gap ?? 8}
+ height={tokens?.rowHeight ?? 36}
+ paddingInline={tokens?.paddingInline ?? 4}
+ >
+ <Center flex={'none'} height={iconBox} width={iconBox}>
+ <SkeletonBar height={iconSize} radius={cssVar.borderRadiusSM} width={iconSize} />
+ </Center>
+ <Flexbox flex={1}>
+ <SkeletonBar height={tokens?.fontSize ?? 14} width={width} />
+ </Flexbox>
</Flexbox>
- </Flexbox>
-);
+ );
+};
const TITLE_WIDTHS = [56, 72, 48, 64];
const ITEM_WIDTHS = ['62%', '44%', '70%', '52%', '66%', '48%', '58%', '74%'];
@@ -76,20 +109,27 @@ export const NavSideBarSkeleton = ({
bodyGap = 0,
bodyPaddingBlock = 0,
groups,
- groupTitleHeight = 32,
+ groupTitleHeight,
headerVariant = 'breadcrumb',
leadingRows = 0,
navGap = 1,
navRows = 0,
search = false,
}: NavSkeletonShape) => {
+ const tokens = usePanelDensityTokens();
+ const panelPaddingInline = tokens?.panelPaddingInline ?? 4;
+ const titleHeight = groupTitleHeight ?? tokens?.sectionHeaderHeight ?? 32;
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}>
+ <Flexbox
+ data-testid={'nav-sidebar-skeleton-nav'}
+ flex={'none'}
+ paddingInline={panelPaddingInline}
+ >
<SkeletonRows count={navRows} gap={navGap} paddingBlock={0} />
</Flexbox>
)}
@@ -97,7 +137,7 @@ export const NavSideBarSkeleton = ({
<Flexbox
gap={bodyGap}
paddingBlock={bodyPaddingBlock}
- paddingInline={4}
+ paddingInline={panelPaddingInline}
style={{ overflow: 'hidden' }}
>
{search && (
@@ -107,12 +147,12 @@ export const NavSideBarSkeleton = ({
)}
{leadingRows > 0 && <SkeletonRows count={leadingRows} paddingBlock={0} />}
{!!groups?.length && (
- <Flexbox gap={8}>
+ <Flexbox gap={tokens?.sectionGap ?? 8}>
{groups.map((rows, groupIndex) => (
<Flexbox key={groupIndex}>
<Flexbox
flex={'none'}
- height={groupTitleHeight}
+ height={titleHeight}
justify={'center'}
paddingBlock={4}
paddingInline={'8px 4px'}
diff --git a/src/components/Skeleton/ResourceHome.tsx b/src/components/Skeleton/ResourceHome.tsx
index 61031277e98..afc2a6825a2 100644
--- a/src/components/Skeleton/ResourceHome.tsx
+++ b/src/components/Skeleton/ResourceHome.tsx
@@ -4,6 +4,8 @@ import { cssVar as cssVarValue, Flexbox } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
+import { useDensityTokens } from '@/styles/density';
+
import SkeletonBar from './Bar';
/**
@@ -72,27 +74,31 @@ const ListSkeleton = () => (
</Flexbox>
);
-const ResourceHomeSkeleton = () => (
- <Flexbox aria-busy flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
- <Flexbox
- horizontal
- align={'center'}
- className={stylex.props(styles.header).className}
- flex={'none'}
- height={44}
- justify={'space-between'}
- paddingInline={16}
- >
- <SkeletonBar height={20} width={96} />
- <SkeletonBar height={28} width={88} />
- </Flexbox>
- <div className={stylex.props(styles.scroll).className}>
- <Flexbox className={stylex.props(styles.content).className} gap={28}>
- <ResourceSectionSkeleton {...RESOURCE_HOME_SECTIONS.quickActions} />
- <ListSkeleton />
+const ResourceHomeSkeleton = () => {
+ const { headerHeight } = useDensityTokens();
+
+ return (
+ <Flexbox aria-busy flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={stylex.props(styles.header).className}
+ flex={'none'}
+ height={headerHeight}
+ justify={'space-between'}
+ paddingInline={16}
+ >
+ <SkeletonBar height={20} width={96} />
+ <SkeletonBar height={28} width={88} />
</Flexbox>
- </div>
- </Flexbox>
-);
+ <div className={stylex.props(styles.scroll).className}>
+ <Flexbox className={stylex.props(styles.content).className} gap={28}>
+ <ResourceSectionSkeleton {...RESOURCE_HOME_SECTIONS.quickActions} />
+ <ListSkeleton />
+ </Flexbox>
+ </div>
+ </Flexbox>
+ );
+};
export default ResourceHomeSkeleton;
diff --git a/src/components/Skeleton/Settings/tabs/Appearance.tsx b/src/components/Skeleton/Settings/tabs/Appearance.tsx
index 9a1428d6bfa..7189225705f 100644
--- a/src/components/Skeleton/Settings/tabs/Appearance.tsx
+++ b/src/components/Skeleton/Settings/tabs/Appearance.tsx
@@ -40,6 +40,11 @@ export const CommonSectionSkeleton = () => {
label: text('settingAppearance.animationMode.title', 64, 14),
minWidth: undefined,
},
+ {
+ control: { height: 38, radius: 8, width: 165 },
+ label: text('settingAppearance.density.title', 64, 14),
+ minWidth: undefined,
+ },
{
control: { height: 38, radius: 8, width: 165 },
label: text('settingAppearance.contextMenuMode.title', 84, 14),
diff --git a/src/components/Skeleton/Topics.tsx b/src/components/Skeleton/Topics.tsx
index 2ddead40d8d..1aa562e289f 100644
--- a/src/components/Skeleton/Topics.tsx
+++ b/src/components/Skeleton/Topics.tsx
@@ -7,6 +7,7 @@ import * as stylex from '@stylexjs/stylex';
import NavHeader from '@/features/NavHeader';
import type { RouteSkeletonProps } from '@/spa/router/routeMeta';
+import { useDensityTokens } from '@/styles/density';
import SkeletonBar from './Bar';
@@ -62,6 +63,8 @@ const TopicGridSkeleton = () => (
);
const TopicsSkeleton = ({ chrome = 'page' }: RouteSkeletonProps) => {
+ const { controlHeight, radius } = useDensityTokens();
+
if (chrome === 'body') return <TopicGridSkeleton />;
return (
@@ -78,13 +81,13 @@ const TopicsSkeleton = ({ chrome = 'page' }: RouteSkeletonProps) => {
>
<Flexbox horizontal align={'center'} gap={8} justify={'space-between'}>
<Flexbox horizontal gap={8}>
- <SkeletonBar height={32} radius={16} width={72} />
- <SkeletonBar height={32} radius={16} width={88} />
- <SkeletonBar height={32} radius={16} width={80} />
+ <SkeletonBar height={controlHeight} radius={controlHeight / 2} width={72} />
+ <SkeletonBar height={controlHeight} radius={controlHeight / 2} width={88} />
+ <SkeletonBar height={controlHeight} radius={controlHeight / 2} width={80} />
</Flexbox>
<Flexbox horizontal gap={8}>
- <SkeletonBar height={32} radius={8} width={36} />
- <SkeletonBar height={32} radius={8} width={36} />
+ <SkeletonBar height={controlHeight} radius={radius} width={36} />
+ <SkeletonBar height={controlHeight} radius={radius} width={36} />
</Flexbox>
</Flexbox>
<TopicGridSkeleton />
diff --git a/src/features/AgentBuilder/TopicSelector.tsx b/src/features/AgentBuilder/TopicSelector.tsx
index 9d47e9d130b..ed428011c1a 100644
--- a/src/features/AgentBuilder/TopicSelector.tsx
+++ b/src/features/AgentBuilder/TopicSelector.tsx
@@ -5,11 +5,11 @@ import { Clock3Icon, PlusIcon } from 'lucide-react';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import NavHeader from '@/features/NavHeader';
import { useFetchAgentChatTopics } from '@/hooks/useFetchChatTopics';
import { useChatStore } from '@/store/chat';
import { topicSelectors } from '@/store/chat/slices/topic/selectors';
+import { useHeaderActionSize } from '@/styles/density';
const styles = createStaticStyles(({ css, cssVar }) => ({
time: css`
@@ -34,6 +34,7 @@ interface TopicSelectorProps {
const TopicSelector = memo<TopicSelectorProps>(({ agentId, disabled }) => {
const { t } = useTranslation('topic');
+ const headerActionSmallSize = useHeaderActionSize(true);
// Fetch topics for the agent builder
useFetchAgentChatTopics(agentId);
@@ -97,7 +98,7 @@ const TopicSelector = memo<TopicSelectorProps>(({ agentId, disabled }) => {
<ActionIcon
disabled={disabled}
icon={PlusIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={t('actions.addNewTopic')}
onClick={() => {
if (disabled) return;
@@ -114,7 +115,7 @@ const TopicSelector = memo<TopicSelectorProps>(({ agentId, disabled }) => {
<ActionIcon
disabled={disabled || isEmpty}
icon={Clock3Icon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
/>
</DropdownMenu>
</>
diff --git a/src/features/AgentDocumentPage/Header/index.tsx b/src/features/AgentDocumentPage/Header/index.tsx
index 3058f103245..db8fb820f94 100644
--- a/src/features/AgentDocumentPage/Header/index.tsx
+++ b/src/features/AgentDocumentPage/Header/index.tsx
@@ -7,13 +7,13 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import ShareButton from '@/business/client/features/PageShare/ShareButton';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { AutoSaveHint } from '@/features/EditorCanvas';
import NavHeader from '@/features/NavHeader';
import ToggleRightPanelButton from '@/features/RightPanel/ToggleRightPanelButton';
import { useAgentStore } from '@/store/agent';
import { agentSelectors } from '@/store/agent/selectors';
import { oneLineEllipsis } from '@/styles';
+import { useHeaderActionSize } from '@/styles/density';
import { useMenu } from './useMenu';
@@ -49,6 +49,7 @@ const Header = memo<HeaderProps>(
}) => {
const { t } = useTranslation(['file', 'chat']);
const meta = useAgentStore(agentSelectors.getAgentMetaById(agentId));
+ const headerActionSmallSize = useHeaderActionSize(true);
const showTitleError = !!itemError && !title;
const resolvedTitle = showTitleError
? t('workingPanel.resources.error', { ns: 'chat' })
@@ -92,7 +93,7 @@ const Header = memo<HeaderProps>(
placement={'bottomLeft'}
popupProps={{ style: { minWidth: 200 } }}
>
- <ActionIcon icon={MoreHorizontal} size={DESKTOP_HEADER_ICON_SMALL_SIZE} />
+ <ActionIcon icon={MoreHorizontal} size={headerActionSmallSize} />
</DropdownMenu>
</Flexbox>
}
diff --git a/src/features/AgentDocumentsExplorer/DocumentExplorerToolbar.tsx b/src/features/AgentDocumentsExplorer/DocumentExplorerToolbar.tsx
index 2673d7a089b..e02360ebb7b 100644
--- a/src/features/AgentDocumentsExplorer/DocumentExplorerToolbar.tsx
+++ b/src/features/AgentDocumentsExplorer/DocumentExplorerToolbar.tsx
@@ -1,6 +1,7 @@
import {
ActionIcon,
createStaticStyles,
+ cx,
type DropdownItem,
DropdownMenu,
Flexbox,
@@ -12,6 +13,7 @@ import { memo, useMemo, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import type { AgentDocumentSort } from '@/store/global/initialState';
+import { sidebarRow } from '@/styles/density.stylex';
const styles = createStaticStyles(({ css, cssVar }) => ({
toolbar: css`
@@ -23,12 +25,31 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
font-size: 11px;
font-weight: 500;
`,
+ compactToolbar: css`
+ flex-shrink: 0;
+ gap: 4px;
+ height: ${sidebarRow.toolbarHeight};
+ padding-inline: ${sidebarRow.toolbarPaddingInlineStart} ${sidebarRow.toolbarPaddingInlineEnd};
+ `,
+ compactTitle: css`
+ overflow: hidden;
+ flex: 1;
+
+ min-width: 0;
+
+ font-size: ${sidebarRow.labelFontSize};
+ font-weight: ${sidebarRow.labelFontWeight};
+ color: ${cssVar.colorTextTertiary};
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ `,
}));
const SORT_FIELDS = ['name', 'createdAt', 'updatedAt'] as const;
const SORT_ORDERS = ['asc', 'desc'] as const;
interface Props {
+ compact?: boolean;
onCreateDocument: () => void;
onCreateFolder: () => void;
onSortChange: (sort: AgentDocumentSort) => void;
@@ -37,7 +58,7 @@ interface Props {
}
const DocumentExplorerToolbar = memo<Props>(
- ({ onCreateDocument, onCreateFolder, onSortChange, onUploadFiles, sort }) => {
+ ({ compact, onCreateDocument, onCreateFolder, onSortChange, onUploadFiles, sort }) => {
const { t } = useTranslation('chat');
const fileInputRef = useRef<HTMLInputElement>(null);
const createMenuItems = useMemo<DropdownItem[]>(
@@ -108,13 +129,19 @@ const DocumentExplorerToolbar = memo<Props>(
<Flexbox
horizontal
align={'center'}
- className={styles.toolbar}
+ className={cx(styles.toolbar, compact && styles.compactToolbar)}
distribution={'space-between'}
>
- <Text className={styles.title} type={'secondary'}>
- {t('workingPanel.resources.filter.documents')}
- </Text>
- <Flexbox horizontal align={'center'}>
+ {compact ? (
+ <span className={styles.compactTitle}>
+ {t('workingPanel.resources.filter.documents')}
+ </span>
+ ) : (
+ <Text className={styles.title} type={'secondary'}>
+ {t('workingPanel.resources.filter.documents')}
+ </Text>
+ )}
+ <Flexbox horizontal align={'center'} gap={compact ? 4 : undefined}>
<DropdownMenu items={sortMenuItems} placement={'bottomRight'}>
<ActionIcon
icon={ArrowDownUpIcon}
diff --git a/src/features/AgentDocumentsExplorer/DocumentExplorerTree.tsx b/src/features/AgentDocumentsExplorer/DocumentExplorerTree.tsx
index 928338078d3..07ab69d7799 100644
--- a/src/features/AgentDocumentsExplorer/DocumentExplorerTree.tsx
+++ b/src/features/AgentDocumentsExplorer/DocumentExplorerTree.tsx
@@ -1,5 +1,5 @@
import { AGENT_DOCUMENT_CATEGORY } from '@lobechat/const';
-import { Center, createStaticStyles, Empty, Flexbox, Icon } from '@lobehub/ui';
+import { Center, createStaticStyles, cx, Empty, Flexbox, Icon } from '@lobehub/ui';
import { SkillsIcon } from '@lobehub/ui/icons';
import {
FilePlusIcon,
@@ -37,6 +37,8 @@ import { agentDocumentService } from '@/services/agentDocument';
import { useGlobalStore } from '@/store/global';
import type { AgentDocumentSort } from '@/store/global/initialState';
import { systemStatusSelectors } from '@/store/global/selectors';
+import { useDensityTokens } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
import { openConvertToSkillModal, slugifySkillName } from './ConvertToSkillModal';
import DocumentExplorerToolbar from './DocumentExplorerToolbar';
@@ -57,6 +59,14 @@ const DOCUMENT_TREE_UNSAFE_CSS = [
DISABLE_ROW_TEXT_SELECTION_CSS,
].join('\n');
+// The WorkingSidebar row system pads rows by its own inset instead of DOCUMENT_TREE_ROW_CSS's 8px.
+const DOCUMENT_TREE_COMPACT_UNSAFE_CSS = [
+ DOCUMENT_TREE_UNSAFE_CSS,
+ `[data-type='item'] {
+ padding-inline-start: ${sidebarRow.paddingInline};
+ }`,
+].join('\n');
+
// pierre/trees auto-selects the full value when the rename input mounts. For
// files with extensions (e.g. `Untitled document.md`), narrow the selection to
// the stem so the user can type a new name without overwriting the suffix.
@@ -109,11 +119,22 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
/* Consumed by DOCUMENT_TREE_ICON_CSS inside the shadow root. */
--explorer-tree-icon-fg: ${cssVar.colorTextDescription};
`,
+ treeCompact: css`
+ --trees-fg-override: ${cssVar.colorTextSecondary};
+ --trees-fg-muted-override: ${cssVar.colorTextTertiary};
+ --trees-font-size-override: ${sidebarRow.textFontSize};
+ --trees-item-padding-x-override: ${sidebarRow.paddingInline};
+ --trees-padding-inline-override: ${sidebarRow.paneInline};
+ --trees-border-radius-override: ${sidebarRow.radius};
+ --explorer-tree-icon-fg: ${cssVar.colorTextTertiary};
+ `,
}));
interface Props {
agentId: string;
data: AgentDocumentItem[];
+ /** `compact`: the WorkingSidebar row system. */
+ density?: 'compact' | 'default';
mutate: AgentDocumentListMutator;
/**
* Starts dragging a plain document out of the tree (e.g. into the chat
@@ -125,7 +146,9 @@ interface Props {
}
const DocumentExplorerTree = memo<Props>((props) => {
- const { agentId, data, mutate, onDocumentDragStart, onOpenDocument, style } = props;
+ const { agentId, data, density, mutate, onDocumentDragStart, onOpenDocument, style } = props;
+ const compact = density === 'compact';
+ const densityTokens = useDensityTokens();
const { t } = useTranslation(['chat', 'common']);
const navigate = useWorkspaceAwareNavigate();
const treeRef = useRef<ExplorerTreeHandle | null>(null);
@@ -530,6 +553,7 @@ const DocumentExplorerTree = memo<Props>((props) => {
const toolbar = (
<DocumentExplorerToolbar
+ compact={compact}
sort={sort}
onCreateDocument={() => handleCreateDocument(null)}
onCreateFolder={() => handleCreateFolder(null)}
@@ -539,7 +563,11 @@ const DocumentExplorerTree = memo<Props>((props) => {
);
return (
- <div className={styles.tree} ref={containerRef} style={treeStyle}>
+ <div
+ className={cx(styles.tree, compact && styles.treeCompact)}
+ ref={containerRef}
+ style={treeStyle}
+ >
<input
hidden
multiple
@@ -566,12 +594,12 @@ const DocumentExplorerTree = memo<Props>((props) => {
getContextMenuItems={getContextMenuItems}
header={toolbar}
iconSet="complete"
- itemHeight={DOCUMENT_TREE_LAYOUT.itemHeight}
+ itemHeight={compact ? densityTokens.treeItemHeight : DOCUMENT_TREE_LAYOUT.itemHeight}
nodes={nodes}
ref={treeRef}
sort={compareNodes}
style={{ height: '100%' }}
- unsafeCSS={DOCUMENT_TREE_UNSAFE_CSS}
+ unsafeCSS={compact ? DOCUMENT_TREE_COMPACT_UNSAFE_CSS : DOCUMENT_TREE_UNSAFE_CSS}
onCommitRename={handleCommitRename}
onMove={handleMove}
onNodeClick={handleNodeClick}
diff --git a/src/features/AgentGoals/AgentGoalsPage.tsx b/src/features/AgentGoals/AgentGoalsPage.tsx
index d01e059c162..df3b9c7d3c4 100644
--- a/src/features/AgentGoals/AgentGoalsPage.tsx
+++ b/src/features/AgentGoals/AgentGoalsPage.tsx
@@ -26,6 +26,7 @@ import { useCacheScope } from '@/libs/swr/useCacheScope';
import type { GoalListFilter } from '@/store/goal';
import { goalSelectors, useGoalStore } from '@/store/goal';
import { globalGoalListScopeId, goalListKey, goalListScopeId } from '@/store/goal/projection';
+import { useDensityTokens } from '@/styles/density';
import { createGoalModal } from './CreateGoalModal';
import GoalAgentFilter from './GoalAgentFilter';
@@ -116,6 +117,7 @@ interface AgentGoalsPageProps {
const AgentGoalsPage = memo<AgentGoalsPageProps>(({ agentId, projectId }) => {
const { t } = useTranslation('chat');
+ const { pageTitleFontSize } = useDensityTokens();
const navigate = useWorkspaceAwareNavigate();
const cacheScope = useCacheScope();
const isGlobal = !agentId && !projectId;
@@ -373,7 +375,7 @@ const AgentGoalsPage = memo<AgentGoalsPageProps>(({ agentId, projectId }) => {
{/* Wraps so the filters drop below the title on a phone instead of crushing it. */}
<Flexbox horizontal align={'center'} gap={8} justify={'space-between'} wrap={'wrap'}>
<Flexbox horizontal align={'center'} flex={'none'} gap={8}>
- <Text fontSize={16} weight={600}>
+ <Text fontSize={pageTitleFontSize} weight={600}>
{t('goalPage.listTitle')}
</Text>
<span className={styles.countBadge}>{visibleGoalCount}</span>
diff --git a/src/features/AgentGoals/GoalChat/Toolbar.tsx b/src/features/AgentGoals/GoalChat/Toolbar.tsx
index 94d3f2f4e34..2b56410859c 100644
--- a/src/features/AgentGoals/GoalChat/Toolbar.tsx
+++ b/src/features/AgentGoals/GoalChat/Toolbar.tsx
@@ -3,13 +3,13 @@ import { Clock3Icon, PanelRightCloseIcon, PlusIcon } from 'lucide-react';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { conversationSelectors, useConversationStore } from '@/features/Conversation';
import NavHeader from '@/features/NavHeader';
import TopicItem from '@/features/PageEditor/Copilot/TopicSelector/TopicItem';
import { useFetchAgentChatTopics } from '@/hooks/useFetchChatTopics';
import { useChatStore } from '@/store/chat';
import { topicSelectors } from '@/store/chat/slices/topic/selectors';
+import { useHeaderActionSize } from '@/styles/density';
import TopicActions from './TopicActions';
import { useConversationTopic } from './useConversationTopic';
@@ -33,6 +33,7 @@ interface ToolbarProps {
*/
const Toolbar = memo<ToolbarProps>(({ fallbackTitle, onCollapse, topicLocked }) => {
const { t } = useTranslation('chat');
+ const headerActionSmallSize = useHeaderActionSize(true);
const [topicPopoverOpen, setTopicPopoverOpen] = useState(false);
const agentId = useConversationStore(conversationSelectors.agentId);
@@ -78,7 +79,7 @@ const Toolbar = memo<ToolbarProps>(({ fallbackTitle, onCollapse, topicLocked })
<>
<ActionIcon
icon={PlusIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={t('goalChat.newTopic')}
onClick={() => switchTopic(null)}
/>
@@ -129,14 +130,14 @@ const Toolbar = memo<ToolbarProps>(({ fallbackTitle, onCollapse, topicLocked })
disabled={isLoadingTopics}
icon={Clock3Icon}
loading={isLoadingTopics}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
/>
</Popover>
</>
)}
<ActionIcon
icon={PanelRightCloseIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
onClick={onCollapse}
/>
</>
diff --git a/src/features/AgentGoals/GoalDetailActions.tsx b/src/features/AgentGoals/GoalDetailActions.tsx
index 5e87004280e..ffa86bbe0ea 100644
--- a/src/features/AgentGoals/GoalDetailActions.tsx
+++ b/src/features/AgentGoals/GoalDetailActions.tsx
@@ -3,8 +3,8 @@ import { ArchiveIcon, ArchiveRestoreIcon, MoreHorizontalIcon } from 'lucide-reac
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { goalSelectors, useGoalStore } from '@/store/goal';
+import { useHeaderActionSize } from '@/styles/density';
import { useGoalArchiveToggle } from './useGoalArchiveToggle';
import { useGoalMenuItems } from './useGoalMenuItems';
@@ -23,6 +23,7 @@ interface GoalDetailActionsProps {
const GoalDetailActions = memo<GoalDetailActionsProps>(
({ agentId, archivedAt, goalId, onRename, projectId }) => {
const { t } = useTranslation('chat');
+ const headerActionSmallSize = useHeaderActionSize(true);
const status = useGoalStore((s) => goalSelectors.goalGraph(goalId)(s)?.goal.status);
const creatorUserId = useGoalStore((s) => goalSelectors.goalGraph(goalId)(s)?.goal.userId);
const title = useGoalStore((s) => goalSelectors.goalGraph(goalId)(s)?.goal.title);
@@ -53,7 +54,7 @@ const GoalDetailActions = memo<GoalDetailActionsProps>(
aria-label={archive.label}
color={canArchive ? undefined : cssVar.colorTextDisabled}
icon={archive.isArchived ? ArchiveRestoreIcon : ArchiveIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
style={canArchive ? undefined : { cursor: 'not-allowed' }}
title={archive.deniedReason ?? archive.label}
tooltipProps={{ placement: 'bottom' }}
diff --git a/src/features/AgentGoals/GoalListItem.tsx b/src/features/AgentGoals/GoalListItem.tsx
index 539a0428f8a..47e28229965 100644
--- a/src/features/AgentGoals/GoalListItem.tsx
+++ b/src/features/AgentGoals/GoalListItem.tsx
@@ -6,6 +6,7 @@ import { memo } from 'react';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useActiveRouteParams } from '@/hooks/useActiveRouteParams';
+import { useDensityTokens } from '@/styles/density';
import GoalAgentLabel from './GoalAgentLabel';
import GoalArchivedMark from './GoalArchivedMark';
@@ -49,6 +50,7 @@ const styles = createStaticStyles(({ css }) => ({
}));
export const GoalListItem = memo<GoalItemProps>(({ globalScopeId, goal: item, projectId }) => {
+ const { listRowHeight } = useDensityTokens();
const navigate = useWorkspaceAwareNavigate();
const { aid } = useActiveRouteParams<{ aid?: string }>();
const { goal } = item;
@@ -81,7 +83,7 @@ export const GoalListItem = memo<GoalItemProps>(({ globalScopeId, goal: item, pr
className={styles.row}
gap={12}
justify={'space-between'}
- paddingBlock={10}
+ paddingBlock={(listRowHeight - 28) / 2}
paddingInline={12}
role={'link'}
tabIndex={0}
diff --git a/src/features/AgentGoals/GoalSupervisorToggle.tsx b/src/features/AgentGoals/GoalSupervisorToggle.tsx
index c3558dc7b37..abc11927b5e 100644
--- a/src/features/AgentGoals/GoalSupervisorToggle.tsx
+++ b/src/features/AgentGoals/GoalSupervisorToggle.tsx
@@ -3,8 +3,8 @@
import { ActionIcon } from '@lobehub/ui';
import { PanelRightOpenIcon } from 'lucide-react';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { useAgentDisplayMeta } from '@/features/AgentTasks/shared/useAgentDisplayMeta';
+import { useHeaderActionSize } from '@/styles/density';
interface GoalSupervisorToggleProps {
/** The agent that supervises the goal; its name goes into the tooltip. */
@@ -35,6 +35,7 @@ const GoalSupervisorToggle = ({
onToggle,
}: GoalSupervisorToggleProps) => {
const meta = useAgentDisplayMeta(agentId);
+ const headerActionSmallSize = useHeaderActionSize(true);
if (hideWhenExpanded && expand) return null;
@@ -47,7 +48,7 @@ const GoalSupervisorToggle = ({
aria-label={title}
data-testid={'goal-supervisor-toggle'}
icon={PanelRightOpenIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={title}
onClick={onToggle}
/>
diff --git a/src/features/AgentGoals/ProcessControl/BatchPlan/PlanHeaderActions.tsx b/src/features/AgentGoals/ProcessControl/BatchPlan/PlanHeaderActions.tsx
index 00b54c9fc7e..e7fda801ce8 100644
--- a/src/features/AgentGoals/ProcessControl/BatchPlan/PlanHeaderActions.tsx
+++ b/src/features/AgentGoals/ProcessControl/BatchPlan/PlanHeaderActions.tsx
@@ -1,11 +1,12 @@
'use client';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@lobechat/const';
import { ActionIcon, Button, type DropdownItem, DropdownMenu, Flexbox, Icon } from '@lobehub/ui';
import { Check, ChevronDown, GitCompareArrows } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
+import { useHeaderActionSize } from '@/styles/density';
+
import type { GoalGraphView } from '../goalGraphViewModel';
import type { BatchModel, BatchRound } from '../Graph/batchModel';
import { openPlanCompareModal } from './PlanCompareModal';
@@ -23,6 +24,7 @@ interface PlanHeaderActionsProps {
*/
const PlanHeaderActions = memo<PlanHeaderActionsProps>(({ graph, model, round }) => {
const { t } = useTranslation('chat');
+ const headerActionSmallSize = useHeaderActionSize(true);
const { selected, setSelected } = usePlanVersionSelection();
const { skillId, versions } = usePlanVersions(graph, model);
if (versions.length < 2) return null;
@@ -56,7 +58,7 @@ const PlanHeaderActions = memo<PlanHeaderActionsProps>(({ graph, model, round })
data-plan-compare-open
disabled={!versions.some((version) => version.revision < current)}
icon={GitCompareArrows}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={t('goalBatch.planPanel.compare')}
onClick={() => openPlanCompareModal({ skillId, target: current, versions })}
/>
diff --git a/src/features/AgentGoals/ProcessControl/Frontier.tsx b/src/features/AgentGoals/ProcessControl/Frontier.tsx
index dab91636f61..570acb95408 100644
--- a/src/features/AgentGoals/ProcessControl/Frontier.tsx
+++ b/src/features/AgentGoals/ProcessControl/Frontier.tsx
@@ -21,6 +21,7 @@ import { openAddGoalTaskModal } from '@/features/AgentGoals/AddTaskModal';
import RunningGlyph from '@/features/Home/components/RunningGlyph';
import { useActivityTime } from '@/hooks/useActivityTime';
import { useChatStore } from '@/store/chat';
+import { useDensityTokens } from '@/styles/density';
import GoalClarification, { type PendingGoalClarification } from '../GoalClarification';
import GoalDecisionCase, {
@@ -630,6 +631,7 @@ AddTaskButton.displayName = 'GoalAddTaskButton';
const Frontier = memo<FrontierProps>(({ actions, canEdit, graph, onSelect, planning }) => {
const { t } = useTranslation('chat');
+ const { pageTitleFontSize } = useDensityTokens();
const [showBlocked, setShowBlocked] = useState(false);
const numbers = new Map(
@@ -666,7 +668,7 @@ const Frontier = memo<FrontierProps>(({ actions, canEdit, graph, onSelect, plann
<Flexbox gap={8}>
<Flexbox horizontal align={'baseline'} justify={'space-between'}>
<Flexbox horizontal align={'baseline'} gap={8}>
- <Text fontSize={16} weight={600}>
+ <Text fontSize={pageTitleFontSize} weight={600}>
{t('goalProcess.frontier.title')}
</Text>
{graph.frontier.length > 0 && (
diff --git a/src/features/AgentGoals/ProcessControl/GoalResultFollowUps.tsx b/src/features/AgentGoals/ProcessControl/GoalResultFollowUps.tsx
index df8c26112da..c10514ede83 100644
--- a/src/features/AgentGoals/ProcessControl/GoalResultFollowUps.tsx
+++ b/src/features/AgentGoals/ProcessControl/GoalResultFollowUps.tsx
@@ -7,6 +7,7 @@ import { useTranslation } from 'react-i18next';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useActivityTime } from '@/hooks/useActivityTime';
+import { useDensityTokens } from '@/styles/density';
import { createGoalModal } from '../CreateGoalModal';
import {
@@ -49,14 +50,17 @@ const styles = createStaticStyles(({ css }) => ({
`,
}));
-export const SectionTitle = ({ children, extra }: { children: ReactNode; extra?: ReactNode }) => (
- <Flexbox horizontal align={'center'} gap={8} justify={'space-between'}>
- <Text fontSize={16} weight={600}>
- {children}
- </Text>
- {extra}
- </Flexbox>
-);
+export const SectionTitle = ({ children, extra }: { children: ReactNode; extra?: ReactNode }) => {
+ const { pageTitleFontSize } = useDensityTokens();
+ return (
+ <Flexbox horizontal align={'center'} gap={8} justify={'space-between'}>
+ <Text fontSize={pageTitleFontSize} weight={600}>
+ {children}
+ </Text>
+ {extra}
+ </Flexbox>
+ );
+};
/** A group inside a section — one step below `SectionTitle`, same row grammar. */
export const GroupLabel = ({ children, extra }: { children: ReactNode; extra?: ReactNode }) => (
diff --git a/src/features/AgentGoals/ProcessControl/Graph/GraphTitle.tsx b/src/features/AgentGoals/ProcessControl/Graph/GraphTitle.tsx
new file mode 100644
index 00000000000..32614ddadb4
--- /dev/null
+++ b/src/features/AgentGoals/ProcessControl/Graph/GraphTitle.tsx
@@ -0,0 +1,17 @@
+import { Text } from '@lobehub/ui';
+import { useTranslation } from 'react-i18next';
+
+import { useDensityTokens } from '@/styles/density';
+
+const GraphTitle = () => {
+ const { t } = useTranslation('chat');
+ const { pageTitleFontSize } = useDensityTokens();
+
+ return (
+ <Text fontSize={pageTitleFontSize} weight={600}>
+ {t('goalProcess.graph.title')}
+ </Text>
+ );
+};
+
+export default GraphTitle;
diff --git a/src/features/AgentGoals/ProcessControl/Graph/index.tsx b/src/features/AgentGoals/ProcessControl/Graph/index.tsx
index 35fee6d91d8..7c57b973926 100644
--- a/src/features/AgentGoals/ProcessControl/Graph/index.tsx
+++ b/src/features/AgentGoals/ProcessControl/Graph/index.tsx
@@ -79,6 +79,7 @@ import ExplorationEdge from './ExplorationEdge';
import { explorationMap } from './explorationMap';
import GraphLegend from './GraphLegend';
import GraphNodeView, { GhostNodeView, type GraphNodeData, type StateChip } from './GraphNode';
+import GraphTitle from './GraphTitle';
import { type GraphBridge, hideKinds, type LayoutBox, layoutGraph, NODE_WIDTH } from './layout';
import {
edgeMarkerColor,
@@ -1214,9 +1215,7 @@ const Graph = memo<GraphProps>(({ extra, fullscreen = false, onFullscreenChange,
);
const titleAndViews = (
<>
- <Text fontSize={16} weight={600}>
- {t('goalProcess.graph.title')}
- </Text>
+ <GraphTitle />
{containers.length === 0 && !stageIsWholeMap && (
<Segmented
size={'small'}
diff --git a/src/features/AgentGoals/ProcessControl/ResultTrail.tsx b/src/features/AgentGoals/ProcessControl/ResultTrail.tsx
index aee5ade9a48..3f1e17d9d37 100644
--- a/src/features/AgentGoals/ProcessControl/ResultTrail.tsx
+++ b/src/features/AgentGoals/ProcessControl/ResultTrail.tsx
@@ -28,6 +28,7 @@ import { useEntityMarkdown } from '@/features/EntityLink';
import { useActivityTime } from '@/hooks/useActivityTime';
import { useChatStore } from '@/store/chat';
import { shinyTextStyles } from '@/styles';
+import { useDensityTokens } from '@/styles/density';
import { coordinatorNodeTitleKey } from './coordinatorCopy';
import { openTargetOf, useOpenGoalArtifact } from './Deliverables';
@@ -570,11 +571,12 @@ interface ResultTrailProps {
const ResultTrail = ({ documentId, graph, onSelect }: ResultTrailProps) => {
const { t } = useTranslation('chat');
+ const { pageTitleFontSize } = useDensityTokens();
const openArtifact = useOpenGoalArtifact();
const openReport = useChatStore((s) => s.openGoalReport);
const source = resultTrailSource(graph);
const title = (
- <Text fontSize={16} weight={600}>
+ <Text fontSize={pageTitleFontSize} weight={600}>
{t('goalProcess.result.trail.title')}
</Text>
);
diff --git a/src/features/AgentSidebar/Header/Agent/index.tsx b/src/features/AgentSidebar/Header/Agent/index.tsx
index 0f63b918d75..3d4295a5ad9 100644
--- a/src/features/AgentSidebar/Header/Agent/index.tsx
+++ b/src/features/AgentSidebar/Header/Agent/index.tsx
@@ -8,6 +8,7 @@ import { useTranslation } from 'react-i18next';
import AgentAvatar from '@/components/AgentAvatar';
import { DEFAULT_INBOX_AVATAR } from '@/const/meta';
import { SkeletonItem } from '@/features/NavPanel/components/SkeletonList';
+import { useNavItemMetrics } from '@/features/NavPanel/density';
import { SidebarHeaderSelectTrigger } from '@/features/NavPanel/SidebarHeaderSelect';
import { useAgentStore } from '@/store/agent';
import { agentSelectors, builtinAgentSelectors } from '@/store/agent/selectors';
@@ -16,6 +17,7 @@ import SwitchPanel from './SwitchPanel';
const Agent = memo<PropsWithChildren>(() => {
const { t } = useTranslation(['chat', 'common']);
+ const { headerAvatarSize } = useNavItemMetrics();
const [agentId, isLoading, isInbox, title, avatar, backgroundColor] = useAgentStore((s) => [
s.activeAgentId,
@@ -30,7 +32,7 @@ const Agent = memo<PropsWithChildren>(() => {
? title || DEFAULT_INBOX_TITLE
: title || t('defaultSession', { ns: 'common' });
- if (isLoading) return <SkeletonItem height={32} padding={0} />;
+ if (isLoading) return <SkeletonItem height={headerAvatarSize + 4} padding={0} />;
return (
<SwitchPanel>
@@ -43,7 +45,7 @@ const Agent = memo<PropsWithChildren>(() => {
avatar={isInbox ? avatar || DEFAULT_INBOX_AVATAR : avatar}
background={backgroundColor || undefined}
name={displayTitle}
- size={28}
+ size={headerAvatarSize}
/>
}
/>
diff --git a/src/features/AgentSidebar/Header/Nav.test.tsx b/src/features/AgentSidebar/Header/Nav.test.tsx
index 882cfb9eba8..385cb5c8998 100644
--- a/src/features/AgentSidebar/Header/Nav.test.tsx
+++ b/src/features/AgentSidebar/Header/Nav.test.tsx
@@ -136,6 +136,7 @@ vi.mock('@/store/user', () => ({
}));
vi.mock('@/store/user/selectors', () => ({
+ userGeneralSettingsSelectors: { interfaceDensity: () => 'loose' },
labPreferSelectors: {
enableSelfLearning: (state: { preference: { lab?: { enableSelfLearning?: boolean } } }) =>
state.preference.lab?.enableSelfLearning ?? false,
diff --git a/src/features/AgentSidebar/Header/index.tsx b/src/features/AgentSidebar/Header/index.tsx
index 175d08dfa8e..8d63d73d673 100644
--- a/src/features/AgentSidebar/Header/index.tsx
+++ b/src/features/AgentSidebar/Header/index.tsx
@@ -6,7 +6,6 @@ import { type PropsWithChildren } from 'react';
import { useTranslation } from 'react-i18next';
import urlJoin from 'url-join';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { useBackButtonProps } from '@/features/NavPanel/backOrigin';
import SideBarHeaderLayout from '@/features/NavPanel/SideBarHeaderLayout';
import { useResourceAccess } from '@/features/ResourcePermission/useResourceAccess';
@@ -15,6 +14,7 @@ import { usePermission } from '@/hooks/usePermission';
import { useQueryRoute } from '@/hooks/useQueryRoute';
import { useChatStore } from '@/store/chat';
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
+import { useHeaderActionSize } from '@/styles/density';
import { isMobileSurface } from '@/utils/mobileSurface';
import Agent from './Agent';
@@ -29,6 +29,7 @@ const HeaderInfo = (_props: PropsWithChildren) => {
const { allowed: canEditContent } = usePermission('edit_own_content');
const { canEditResource } = useResourceAccess('agent', agentId);
const { isAgentEditable } = useServerConfigStore(featureFlagsSelectors);
+ const headerActionSmallSize = useHeaderActionSize(true);
// Keep the entry while resource access is loading; only a confirmed denial
// hides it. The profile page still enforces ResourceConfigAccessGate.
const showProfile = !!agentId && !!isAgentEditable && canEditContent && canEditResource;
@@ -48,7 +49,7 @@ const HeaderInfo = (_props: PropsWithChildren) => {
<ActionIcon
aria-label={t('tab.profile')}
icon={SettingsIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
onClick={openProfile}
/>
) : undefined
diff --git a/src/features/AgentSidebar/Task/index.tsx b/src/features/AgentSidebar/Task/index.tsx
index 6df7aebaeee..644fb893d66 100644
--- a/src/features/AgentSidebar/Task/index.tsx
+++ b/src/features/AgentSidebar/Task/index.tsx
@@ -16,6 +16,7 @@ import { ArrowRight } from 'lucide-react';
import { memo, type MouseEvent, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useAgentStore } from '@/store/agent';
@@ -28,6 +29,7 @@ interface TaskListProps {
}
const TaskList = memo<TaskListProps>(({ itemKey }) => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { t } = useTranslation('chat');
const navigate = useWorkspaceAwareNavigate();
const agentId = useAgentStore((s) => s.activeAgentId);
@@ -50,9 +52,7 @@ const TaskList = memo<TaskListProps>(({ itemKey }) => {
const titleNode = (
<Flexbox horizontal align="center" gap={4}>
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {t('tab.tasks')}
- </Text>
+ <SectionTitle>{t('tab.tasks')}</SectionTitle>
{totalTasks > 0 && (
<Text fontSize={11} type="secondary">
{totalTasks}
@@ -72,9 +72,7 @@ const TaskList = memo<TaskListProps>(({ itemKey }) => {
const header = (
<AccordionHeader>
- <AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
- {titleNode}
- </AccordionTrigger>
+ <AccordionTrigger style={sectionTriggerStyle}>{titleNode}</AccordionTrigger>
<div
className={cx('accordion-action', accordionStyles.action, accordionStyles.actionBorderless)}
>
diff --git a/src/features/AgentSidebar/Topic/List/TopicListSkeleton.tsx b/src/features/AgentSidebar/Topic/List/TopicListSkeleton.tsx
index e7bede3a302..cf4c5d5d005 100644
--- a/src/features/AgentSidebar/Topic/List/TopicListSkeleton.tsx
+++ b/src/features/AgentSidebar/Topic/List/TopicListSkeleton.tsx
@@ -3,7 +3,9 @@
import { cssVar, Flexbox, Skeleton } from '@lobehub/ui';
import { memo } from 'react';
-// Mirrors the grouped topic list frame (12px group caption + icon-led 36px
+import { usePanelDensityTokens } from '@/styles/density';
+
+// Mirrors the grouped topic list frame (12px group caption + icon-led
// rows) so a session without a persisted page reads as the layout it resolves
// into, unlike the avatar-style generic SkeletonList. The test id is the hook a
// product-level frame capture uses to prove no such frame is painted once the
@@ -13,32 +15,36 @@ const GROUPS = [
{ header: 60, rows: ['64%', '76%', '48%', '68%'] },
];
-const RowSkeleton = memo<{ width: string }>(({ width }) => (
- <Flexbox horizontal align={'center'} gap={8} height={36} paddingInline={4}>
- <Skeleton
- style={{
- borderRadius: cssVar.borderRadiusSM,
- height: 16,
- maxHeight: 16,
- maxWidth: 16,
- minWidth: 16,
- }}
- />
- <Flexbox flex={1}>
+const RowSkeleton = memo<{ width: string }>(({ width }) => {
+ const tokens = usePanelDensityTokens();
+
+ return (
+ <Flexbox horizontal align={'center'} gap={8} height={tokens?.rowHeight ?? 36} paddingInline={4}>
<Skeleton
style={{
- borderRadius: cssVar.borderRadius,
- height: 14,
- margin: 0,
- maxHeight: 14,
- opacity: 0.5,
- padding: 0,
- width,
+ borderRadius: cssVar.borderRadiusSM,
+ height: 16,
+ maxHeight: 16,
+ maxWidth: 16,
+ minWidth: 16,
}}
/>
+ <Flexbox flex={1}>
+ <Skeleton
+ style={{
+ borderRadius: cssVar.borderRadius,
+ height: 14,
+ margin: 0,
+ maxHeight: 14,
+ opacity: 0.5,
+ padding: 0,
+ width,
+ }}
+ />
+ </Flexbox>
</Flexbox>
- </Flexbox>
-));
+ );
+});
RowSkeleton.displayName = 'TopicRowSkeleton';
diff --git a/src/features/AgentSidebar/Topic/TopicListContent/ByAgentMode/GroupItem.tsx b/src/features/AgentSidebar/Topic/TopicListContent/ByAgentMode/GroupItem.tsx
index 017373940ec..c5736587d96 100644
--- a/src/features/AgentSidebar/Topic/TopicListContent/ByAgentMode/GroupItem.tsx
+++ b/src/features/AgentSidebar/Topic/TopicListContent/ByAgentMode/GroupItem.tsx
@@ -26,6 +26,7 @@ import { useTranslation } from 'react-i18next';
import AgentAvatar from '@/components/AgentAvatar';
import EmptyNavItem from '@/features/NavPanel/components/EmptyNavItem';
+import { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import { canStageDraftOn } from '@/features/Projects/WorkingDirectories/startProjectTopicDraft';
import { useAgentFixedDeviceId } from '@/features/Projects/WorkingDirectories/useAgentFixedDeviceId';
import { useStartProjectTopic } from '@/features/Projects/WorkingDirectories/useStartProjectTopic';
@@ -66,6 +67,7 @@ interface AgentAttributedRow {
}
const GroupItem = memo<GroupItemComponentProps>(({ group }) => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { t } = useTranslation('topic');
const { t: tProject } = useTranslation('project');
const { id, title, children } = group;
@@ -148,7 +150,7 @@ const GroupItem = memo<GroupItemComponentProps>(({ group }) => {
return (
<AccordionItem value={id}>
<AccordionHeader>
- <AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionTrigger style={sectionTriggerStyle}>
<Flexbox horizontal align="center" gap={8} height={24} style={{ overflow: 'hidden' }}>
<Center className={styles.avatarWrap} flex={'none'} height={18} width={18}>
<AgentAvatar
diff --git a/src/features/AgentSidebar/Topic/TopicListContent/ByDeviceMode/GroupItem.tsx b/src/features/AgentSidebar/Topic/TopicListContent/ByDeviceMode/GroupItem.tsx
index 78158b149eb..af6360fe38e 100644
--- a/src/features/AgentSidebar/Topic/TopicListContent/ByDeviceMode/GroupItem.tsx
+++ b/src/features/AgentSidebar/Topic/TopicListContent/ByDeviceMode/GroupItem.tsx
@@ -22,6 +22,7 @@ import { useTranslation } from 'react-i18next';
import TailMarquee from '@/components/TailMarquee';
import { getDeviceIcon } from '@/features/DeviceManager/getDeviceIcon';
+import { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import { startProjectTopicDraft } from '@/features/Projects/WorkingDirectories/startProjectTopicDraft';
import { useAgentFixedDeviceId } from '@/features/Projects/WorkingDirectories/useAgentFixedDeviceId';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
@@ -47,6 +48,7 @@ import {
const DEVICE_GROUP_PREFIX = 'device:';
const GroupItem = memo<GroupItemComponentProps>(({ group }) => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { t } = useTranslation('topic');
const { t: tProject } = useTranslation('project');
const { t: tChat } = useTranslation('chat');
@@ -109,7 +111,7 @@ const GroupItem = memo<GroupItemComponentProps>(({ group }) => {
return (
<AccordionItem value={id}>
<AccordionHeader>
- <AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionTrigger style={sectionTriggerStyle}>
<Flexbox horizontal align="center" gap={8} height={24} style={{ overflow: 'hidden' }}>
<Center color={cssVar.colorTextTertiary} flex={'none'} height={18} width={18}>
{device ? (
diff --git a/src/features/AgentSidebar/Topic/TopicListContent/ByStatusMode/GroupItem.tsx b/src/features/AgentSidebar/Topic/TopicListContent/ByStatusMode/GroupItem.tsx
index bbd28947cab..ac86807d1fb 100644
--- a/src/features/AgentSidebar/Topic/TopicListContent/ByStatusMode/GroupItem.tsx
+++ b/src/features/AgentSidebar/Topic/TopicListContent/ByStatusMode/GroupItem.tsx
@@ -16,6 +16,7 @@ import {
TOPIC_GROUP_VISUALS,
TOPIC_STATUS_VISUALS,
} from '@/components/ExecutionStatus';
+import { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import TopicItem from '../../List/Item';
import { useTopicListScope } from '../../TopicListScope';
@@ -30,6 +31,7 @@ const STATUS_ICON: Record<string, ExecutionStatusVisual> = {
};
const GroupItem = memo<GroupItemComponentProps>(({ group }) => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { id, title, children } = group;
const statusIcon = STATUS_ICON[id];
// An agent's own status buckets mix topics from different projects, so each
@@ -39,7 +41,7 @@ const GroupItem = memo<GroupItemComponentProps>(({ group }) => {
return (
<AccordionItem value={id}>
<AccordionHeader>
- <AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionTrigger style={sectionTriggerStyle}>
<Flexbox horizontal align="center" gap={6} height={24} style={{ overflow: 'hidden' }}>
{statusIcon && (
<Center flex={'none'} height={16} width={16}>
diff --git a/src/features/AgentSidebar/Topic/TopicListContent/ByTimeMode/GroupItem.tsx b/src/features/AgentSidebar/Topic/TopicListContent/ByTimeMode/GroupItem.tsx
index 2f989d1bc44..9f3c955cfc9 100644
--- a/src/features/AgentSidebar/Topic/TopicListContent/ByTimeMode/GroupItem.tsx
+++ b/src/features/AgentSidebar/Topic/TopicListContent/ByTimeMode/GroupItem.tsx
@@ -10,11 +10,14 @@ import isEqual from 'fast-deep-equal';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
+
import TopicItem from '../../List/Item';
import { type GroupItemComponentProps } from '../GroupedAccordion';
import { formatTimeGroupId } from './timeGroupTitle';
const GroupItem = memo<GroupItemComponentProps>(({ group }) => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { t } = useTranslation('topic');
const { id, title, children } = group;
@@ -26,11 +29,11 @@ const GroupItem = memo<GroupItemComponentProps>(({ group }) => {
return (
<AccordionItem value={id}>
<AccordionHeader>
- <AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionTrigger style={sectionTriggerStyle}>
<Flexbox horizontal align="center" gap={6} height={24} style={{ overflow: 'hidden' }}>
- <Text ellipsis fontSize={12} style={{ flex: 1 }} type={'secondary'} weight={500}>
- {title || timeTitle}
- </Text>
+ <Flexbox flex={1} style={{ minWidth: 0 }}>
+ <SectionTitle>{title || timeTitle}</SectionTitle>
+ </Flexbox>
</Flexbox>
</AccordionTrigger>
</AccordionHeader>
diff --git a/src/features/AgentSidebar/Topic/TopicListContent/ThreadList/ThreadItem/index.tsx b/src/features/AgentSidebar/Topic/TopicListContent/ThreadList/ThreadItem/index.tsx
index 57e3c72356f..28602d83fb3 100644
--- a/src/features/AgentSidebar/Topic/TopicListContent/ThreadList/ThreadItem/index.tsx
+++ b/src/features/AgentSidebar/Topic/TopicListContent/ThreadList/ThreadItem/index.tsx
@@ -5,6 +5,7 @@ import { memo, useCallback } from 'react';
import { startThreadDrag } from '@/features/ChatInput/InputEditor/ReferTopic/threadDragData';
import NavItem from '@/features/NavPanel/components/NavItem';
+import { useNavItemMetrics } from '@/features/NavPanel/density';
import { useChatStore } from '@/store/chat';
import { portalThreadSelectors } from '@/store/chat/selectors';
@@ -21,6 +22,7 @@ export interface ThreadItemProps {
}
const ThreadItem = memo<ThreadItemProps>(({ title, id, isSubagent, sourceMessageId }) => {
+ const { rowHeight } = useNavItemMetrics();
const activeThreadId = useChatStore((s) => s.activeThreadId);
// This row opens its thread in the Portal, so its "current" state is the
// portal's thread — see `isThreadRowActive` for the conversation fallback.
@@ -58,8 +60,8 @@ const ThreadItem = memo<ThreadItemProps>(({ title, id, isSubagent, sourceMessage
iconSize={16}
// The capped ThreadList is a flex column, so rows shrink to fit its
// max-height instead of overflowing — the scroll never engages. Pin the
- // row min-height to the NavItem height (36) to force overflow → scroll.
- style={{ minHeight: 36 }}
+ // row min-height to the NavItem height to force overflow → scroll.
+ style={{ minHeight: rowHeight }}
title={title}
onClick={handleClick}
onDragStart={handleDragStart}
diff --git a/src/features/AgentSidebar/Topic/index.tsx b/src/features/AgentSidebar/Topic/index.tsx
index 82d184812fd..82e02edef1c 100644
--- a/src/features/AgentSidebar/Topic/index.tsx
+++ b/src/features/AgentSidebar/Topic/index.tsx
@@ -16,6 +16,7 @@ import { useDocumentVisibility } from 'ahooks';
import React, { memo, Suspense, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import { useFetchChatTopics } from '@/hooks/useFetchChatTopics';
import { useChatStore } from '@/store/chat';
@@ -48,6 +49,7 @@ interface TopicProps {
}
const Topic = memo<TopicProps>(({ expanded, itemKey }) => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { t } = useTranslation(['topic', 'common']);
const topicCount = useChatStore((s) => topicSelectors.currentTopicCount(s));
const cleanupStaleRunningTopics = useChatStore((s) => s.cleanupStaleRunningTopics);
@@ -118,11 +120,9 @@ const Topic = memo<TopicProps>(({ expanded, itemKey }) => {
<AccordionItem value={itemKey}>
<ContextMenuTrigger items={dropdownMenu}>
<AccordionHeader>
- <AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionTrigger style={sectionTriggerStyle}>
<Flexbox horizontal align="center" gap={4}>
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {t('sidebar.title')}
- </Text>
+ <SectionTitle>{t('sidebar.title')}</SectionTitle>
{topicCount > 0 && (
<Text fontSize={11} type="secondary">
{topicCount}
diff --git a/src/features/AgentTaskManager/Toolbar.tsx b/src/features/AgentTaskManager/Toolbar.tsx
index ab71c657872..f1410305c58 100644
--- a/src/features/AgentTaskManager/Toolbar.tsx
+++ b/src/features/AgentTaskManager/Toolbar.tsx
@@ -3,7 +3,6 @@ import { Clock3Icon, PanelRightCloseIcon, PlusIcon } from 'lucide-react';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { conversationSelectors, useConversationStore } from '@/features/Conversation';
import NavHeader from '@/features/NavHeader';
import TopicItem from '@/features/PageEditor/Copilot/TopicSelector/TopicItem';
@@ -11,9 +10,11 @@ import { useFetchAgentChatTopics } from '@/hooks/useFetchChatTopics';
import { useChatStore } from '@/store/chat';
import { topicSelectors } from '@/store/chat/slices/topic/selectors';
import { useGlobalStore } from '@/store/global';
+import { useHeaderActionSize } from '@/styles/density';
const Toolbar = memo(() => {
const { t } = useTranslation('topic');
+ const headerActionSmallSize = useHeaderActionSize(true);
const [topicPopoverOpen, setTopicPopoverOpen] = useState(false);
const agentId = useConversationStore(conversationSelectors.agentId);
@@ -54,7 +55,7 @@ const Toolbar = memo(() => {
<>
<ActionIcon
icon={PlusIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={t('actions.addNewTopic')}
onClick={handleCreate}
/>
@@ -102,12 +103,12 @@ const Toolbar = memo(() => {
disabled={isLoadingTopics}
icon={Clock3Icon}
loading={isLoadingTopics}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
/>
</Popover>
<ActionIcon
icon={PanelRightCloseIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
onClick={() => toggleTaskAgentPanel()}
/>
</>
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskDetailCopyActions.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskDetailCopyActions.tsx
index 950d86766df..4feef0bad52 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskDetailCopyActions.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskDetailCopyActions.tsx
@@ -5,7 +5,7 @@ import { CopyIcon, LinkIcon } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
+import { useHeaderActionSize } from '@/styles/density';
import { useTaskCopyActions } from './useTaskCopyActions';
@@ -17,6 +17,7 @@ import { useTaskCopyActions } from './useTaskCopyActions';
*/
const TaskDetailCopyActions = memo(() => {
const { t } = useTranslation('chat');
+ const headerActionSmallSize = useHeaderActionSize(true);
const { copyId, copyLink, taskId } = useTaskCopyActions();
@@ -26,14 +27,14 @@ const TaskDetailCopyActions = memo(() => {
<>
<ActionIcon
icon={LinkIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={t('taskList.contextMenu.copyLink')}
tooltipProps={{ placement: 'bottom' }}
onClick={copyLink}
/>
<ActionIcon
icon={CopyIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={t('taskList.contextMenu.copyId')}
tooltipProps={{ placement: 'bottom' }}
onClick={copyId}
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskDetailHeaderActions.test.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskDetailHeaderActions.test.tsx
index 9c180274b7b..bfe571e2509 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskDetailHeaderActions.test.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskDetailHeaderActions.test.tsx
@@ -116,6 +116,9 @@ vi.mock('@/store/user', () => ({
}));
vi.mock('@/store/user/selectors', () => ({
+ userGeneralSettingsSelectors: {
+ interfaceDensity: () => 'loose',
+ },
userProfileSelectors: {
userId: () => mocks.currentUserId,
},
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskDetailHeaderActions.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskDetailHeaderActions.tsx
index 60f40c74244..0a6b0c589bb 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskDetailHeaderActions.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskDetailHeaderActions.tsx
@@ -23,7 +23,6 @@ import { useTranslation } from 'react-i18next';
import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';
import { useTaskTransferMenuItem } from '@/business/client/hooks/useTaskTransferMenuItem';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { FavoriteButton, useFavoriteMenuItem } from '@/features/Favorites';
import VisibilityConfirmContent from '@/features/VisibilityConfirmContent';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
@@ -32,6 +31,7 @@ import { useTaskStore } from '@/store/task';
import { taskDetailSelectors } from '@/store/task/selectors';
import { useUserStore } from '@/store/user';
import { userProfileSelectors } from '@/store/user/selectors';
+import { useHeaderActionSize } from '@/styles/density';
import { getArchiveErrorKey } from '../features/archiveErrorKey';
import { useTaskArchiveGate } from '../features/useTaskArchiveGate';
@@ -41,6 +41,7 @@ import { useTaskFavoriteTarget } from './useTaskFavoriteTarget';
const TaskDetailHeaderActions = memo(() => {
const { t } = useTranslation(['chat', 'common']);
+ const headerActionSmallSize = useHeaderActionSize(true);
const navigate = useWorkspaceAwareNavigate();
const allTasksTarget = useTaskListCrumbTarget('/tasks');
@@ -289,7 +290,7 @@ const TaskDetailHeaderActions = memo(() => {
aria-label={archiveLabel}
color={canArchive ? undefined : cssVar.colorTextDisabled}
icon={isArchived ? ArchiveRestoreIcon : ArchiveIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
style={canArchive ? undefined : { cursor: 'not-allowed' }}
title={archiveDeniedReason ?? archiveLabel}
tooltipProps={{ placement: 'bottom' }}
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskDetailPage.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskDetailPage.tsx
index d5e3517ddcc..f0e34f9a836 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskDetailPage.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskDetailPage.tsx
@@ -7,7 +7,6 @@ import { useTranslation } from 'react-i18next';
import NotFound from '@/components/404';
import AsyncError from '@/components/AsyncError';
import AutoSaveHint from '@/components/Editor/AutoSaveHint';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import NavHeader from '@/features/NavHeader';
import ToggleRightPanelButton from '@/features/RightPanel/ToggleRightPanelButton';
import WideScreenContainer from '@/features/WideScreenContainer';
@@ -18,6 +17,7 @@ import { useTaskStore } from '@/store/task';
import { taskDetailSelectors } from '@/store/task/selectors';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/selectors';
+import { useHeaderActionSize } from '@/styles/density';
import Breadcrumb from '../shared/Breadcrumb';
import { useTaskListCrumbTarget } from '../shared/taskListOrigin';
@@ -37,6 +37,7 @@ interface TaskDetailPageProps {
const TaskDetailPage = memo<TaskDetailPageProps>(({ taskId, showTaskAgentPanelToggle = true }) => {
const { t } = useTranslation('chat');
+ const headerActionSmallSize = useHeaderActionSize(true);
const saveStatus = useTaskStore(taskDetailSelectors.taskSaveStatus);
const [showTaskAgentPanel, toggleTaskAgentPanel] = useGlobalStore((s) => [
systemStatusSelectors.showTaskAgentPanel(s),
@@ -102,7 +103,7 @@ const TaskDetailPage = memo<TaskDetailPageProps>(({ taskId, showTaskAgentPanelTo
<>
<ActionIcon
icon={SearchIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={t('taskDetail.find.open')}
tooltipProps={{ hotkey: findHotkey, placement: 'bottom' }}
onClick={openFind}
diff --git a/src/features/AgentTasks/AgentTaskList/AgentTasksPage.tsx b/src/features/AgentTasks/AgentTaskList/AgentTasksPage.tsx
index 987d226498b..d805a256e47 100644
--- a/src/features/AgentTasks/AgentTaskList/AgentTasksPage.tsx
+++ b/src/features/AgentTasks/AgentTaskList/AgentTasksPage.tsx
@@ -14,7 +14,6 @@ import { useTranslation } from 'react-i18next';
import { useLocation, useSearchParams } from 'react-router';
import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import NavHeader from '@/features/NavHeader';
import ToggleRightPanelButton from '@/features/RightPanel/ToggleRightPanelButton';
import WideScreenContainer from '@/features/WideScreenContainer';
@@ -27,6 +26,7 @@ import { systemStatusSelectors } from '@/store/global/selectors';
import { useTaskStore } from '@/store/task';
import { taskLabelSelectors, taskListSelectors } from '@/store/task/selectors';
import { TASK_COLLECTION_PAGE_SIZE } from '@/store/task/slices/list/action';
+import { useHeaderActionSize } from '@/styles/density';
import { isMobileSurface } from '@/utils/mobileSurface';
import { createTaskModal } from '../CreateTaskModal';
@@ -235,6 +235,7 @@ export const resolveTaskCollectionView = (
const AgentTasksPage = memo<AgentTasksPageProps>(({ agentId, headerActions, projectId }) => {
const { t } = useTranslation('chat');
+ const headerActionSmallSize = useHeaderActionSize(true);
const navigate = useWorkspaceAwareNavigate();
const isMobile = useIsMobile();
const { allowed: canCreateTask, reason } = usePermission('create_content');
@@ -587,7 +588,7 @@ const AgentTasksPage = memo<AgentTasksPageProps>(({ agentId, headerActions, proj
<ActionIcon
disabled={createActionBehavior.disabled}
icon={Plus}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={createActionBehavior.disabled ? reason : undefined}
onClick={handleCreateTask}
/>
@@ -596,7 +597,7 @@ const AgentTasksPage = memo<AgentTasksPageProps>(({ agentId, headerActions, proj
<ActionIcon
disabled={!canCreateTask}
icon={Plus}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={canCreateTask ? t('createTask.submitScheduled') : reason}
onClick={handleCreateScheduledTask}
/>
diff --git a/src/features/AgentTasks/AgentTaskList/TaskItemSkeleton.tsx b/src/features/AgentTasks/AgentTaskList/TaskItemSkeleton.tsx
index 251071833a4..617b3d48150 100644
--- a/src/features/AgentTasks/AgentTaskList/TaskItemSkeleton.tsx
+++ b/src/features/AgentTasks/AgentTaskList/TaskItemSkeleton.tsx
@@ -1,11 +1,15 @@
import { Block, Flexbox, Skeleton } from '@lobehub/ui';
import { memo } from 'react';
+import { useDensityTokens } from '@/styles/density';
+
interface TaskItemSkeletonProps {
variant?: 'compact' | 'default';
}
const TaskItemSkeleton = memo<TaskItemSkeletonProps>(({ variant = 'default' }) => {
+ const { listRowHeight } = useDensityTokens();
+
if (variant === 'compact') {
return (
<Block gap={8} padding={12} variant={'borderless'}>
@@ -26,7 +30,12 @@ const TaskItemSkeleton = memo<TaskItemSkeletonProps>(({ variant = 'default' }) =
}
return (
- <Block gap={8} padding={12} variant={'borderless'}>
+ <Block
+ gap={8}
+ paddingBlock={(listRowHeight - 24) / 2}
+ paddingInline={12}
+ variant={'borderless'}
+ >
<Flexbox horizontal align={'center'} gap={8} justify={'space-between'}>
<Flexbox horizontal align={'center'} gap={8} style={{ flex: 1, minWidth: 0 }}>
<Skeleton.Avatar shape={'square'} size={16} style={{ borderRadius: 4, flex: 'none' }} />
diff --git a/src/features/AgentTasks/AgentTaskList/TaskListVisibilityFilter.tsx b/src/features/AgentTasks/AgentTaskList/TaskListVisibilityFilter.tsx
index 5a6eebe5c01..80e71cda295 100644
--- a/src/features/AgentTasks/AgentTaskList/TaskListVisibilityFilter.tsx
+++ b/src/features/AgentTasks/AgentTaskList/TaskListVisibilityFilter.tsx
@@ -13,10 +13,10 @@ import { memo, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { useTaskStore } from '@/store/task';
import { taskListSelectors } from '@/store/task/selectors';
import type { TaskListVisibilityFilter as Filter } from '@/store/task/slices/list/initialState';
+import { useHeaderActionSize } from '@/styles/density';
import { renderMenuCheck } from '../features/menuExtra';
@@ -46,6 +46,7 @@ const FILTER_OPTIONS: Array<{ icon: typeof Globe; key: Filter; labelKey: string
*/
const TaskListVisibilityFilter = memo(() => {
const { t } = useTranslation('chat');
+ const headerActionSmallSize = useHeaderActionSize(true);
const activeWorkspaceId = useActiveWorkspaceId();
const visibility = useTaskStore(taskListSelectors.listVisibility);
const setListVisibility = useTaskStore((s) => s.setListVisibility);
@@ -80,7 +81,7 @@ const TaskListVisibilityFilter = memo(() => {
<DropdownMenu items={menuItems} open={open} onOpenChange={setOpen}>
<ActionIcon
icon={CurrentIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={`${t('taskList.visibility.label', { defaultValue: 'Visibility' })}: ${currentLabel}`}
/>
</DropdownMenu>
diff --git a/src/features/AgentTasks/AgentTaskList/TasksGroupConfig.tsx b/src/features/AgentTasks/AgentTaskList/TasksGroupConfig.tsx
index 2ea80b29300..9f9055bf966 100644
--- a/src/features/AgentTasks/AgentTaskList/TasksGroupConfig.tsx
+++ b/src/features/AgentTasks/AgentTaskList/TasksGroupConfig.tsx
@@ -19,13 +19,13 @@ import {
import { memo, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { useFetchTaskLabels } from '@/hooks/useFetchTaskLabels';
import { useGlobalStore } from '@/store/global';
import type { TaskViewMode } from '@/store/global/initialState';
import { systemStatusSelectors } from '@/store/global/selectors';
import { useTaskStore } from '@/store/task';
import { taskLabelSelectors } from '@/store/task/selectors';
+import { useHeaderActionSize } from '@/styles/density';
import type {
TaskCompletedFilter,
@@ -68,6 +68,7 @@ const TasksGroupConfig = memo<TasksHeaderProps>(
const [isViewConfigOpen, setIsViewConfigOpen] = useState(false);
const isPinned = (option: TaskListPinnedOption) => !!pinnedOptions?.includes(option);
const { t } = useTranslation('chat');
+ const headerActionSmallSize = useHeaderActionSize(true);
const viewMode = useGlobalStore(systemStatusSelectors.taskListViewMode);
const updateSystemStatus = useGlobalStore((s) => s.updateSystemStatus);
const form = useForm();
@@ -319,7 +320,7 @@ const TasksGroupConfig = memo<TasksHeaderProps>(
trigger={['click']}
onOpenChange={setIsViewConfigOpen}
>
- <ActionIcon icon={Settings2Icon} size={DESKTOP_HEADER_ICON_SMALL_SIZE} />
+ <ActionIcon icon={Settings2Icon} size={headerActionSmallSize} />
</Popover>
);
},
diff --git a/src/features/AgentTasks/AgentTaskList/filter/TaskFilterButton.tsx b/src/features/AgentTasks/AgentTaskList/filter/TaskFilterButton.tsx
index 651b9f83194..83ca6ab8549 100644
--- a/src/features/AgentTasks/AgentTaskList/filter/TaskFilterButton.tsx
+++ b/src/features/AgentTasks/AgentTaskList/filter/TaskFilterButton.tsx
@@ -17,10 +17,10 @@ import type { KeyboardEvent } from 'react';
import { memo, useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { useHotkeyById } from '@/hooks/useHotkeys/useHotkeyById';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/selectors';
+import { useHeaderActionSize } from '@/styles/density';
import {
isTaskFilterValueSelected,
@@ -68,6 +68,7 @@ const matches = (text: string, query: string) => text.toLowerCase().includes(que
*/
const TaskFilterButton = memo<TaskFilterButtonProps>(({ fields, filter, setFilter }) => {
const { t } = useTranslation('chat');
+ const headerActionSmallSize = useHeaderActionSize(true);
const [open, setOpen] = useState(false);
const [search, setSearch] = useState('');
@@ -203,7 +204,7 @@ const TaskFilterButton = memo<TaskFilterButtonProps>(({ fields, filter, setFilte
<ActionIcon
active={open}
icon={ListFilterIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={t('taskList.filter.add')}
tooltipProps={{ hotkey }}
/>
diff --git a/src/features/AgentTasks/AgentTaskList/filter/TaskListFind.tsx b/src/features/AgentTasks/AgentTaskList/filter/TaskListFind.tsx
index e57a614c3a1..96ca9fd9156 100644
--- a/src/features/AgentTasks/AgentTaskList/filter/TaskListFind.tsx
+++ b/src/features/AgentTasks/AgentTaskList/filter/TaskListFind.tsx
@@ -7,10 +7,10 @@ import type { KeyboardEvent } from 'react';
import { memo, useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { useHotkeyById } from '@/hooks/useHotkeys/useHotkeyById';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/selectors';
+import { useHeaderActionSize } from '@/styles/density';
import { useTaskListFind } from './useTaskListFind';
@@ -32,6 +32,7 @@ interface TaskListFindProps {
*/
const TaskListFind = memo<TaskListFindProps>(({ content, onChange }) => {
const { t } = useTranslation('chat');
+ const headerActionSmallSize = useHeaderActionSize(true);
const findHotkey = useUserStore(settingsSelectors.getHotkeyById(HotkeyEnum.FindInTopic));
const inputRef = useRef<HTMLInputElement>(null);
const { blur, clearAndClose, commit, draft, expanded, focus, focusRequest, openFind, setDraft } =
@@ -73,7 +74,7 @@ const TaskListFind = memo<TaskListFindProps>(({ content, onChange }) => {
return (
<ActionIcon
icon={SearchIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={t('taskList.find.open')}
tooltipProps={{ hotkey: findHotkey, placement: 'bottom' }}
onClick={openFind}
diff --git a/src/features/AgentTasks/features/AgentTaskItem.test.tsx b/src/features/AgentTasks/features/AgentTaskItem.test.tsx
index cd9c6b843ae..446a3bb29f5 100644
--- a/src/features/AgentTasks/features/AgentTaskItem.test.tsx
+++ b/src/features/AgentTasks/features/AgentTaskItem.test.tsx
@@ -145,6 +145,7 @@ vi.mock('@/store/user', () => ({
vi.mock('@/store/user/selectors', () => ({
labPreferSelectors: { enableProjects: () => mocks.projectsEnabled },
+ userGeneralSettingsSelectors: { interfaceDensity: () => 'loose' },
}));
vi.mock('@/features/Projects/ProjectAvatar', () => ({
diff --git a/src/features/AgentTasks/features/AgentTaskItem.tsx b/src/features/AgentTasks/features/AgentTaskItem.tsx
index 72fc247f00f..8d51938ed66 100644
--- a/src/features/AgentTasks/features/AgentTaskItem.tsx
+++ b/src/features/AgentTasks/features/AgentTaskItem.tsx
@@ -9,6 +9,7 @@ import TaskLabelChips from '@/features/TaskLabels/TaskLabelChips';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useTaskStore } from '@/store/task';
import type { TaskListItem } from '@/store/task/slices/list/initialState';
+import { useDensityTokens } from '@/styles/density';
import { shouldShowMemberAssignee } from '../shared/memberAssigneeMode';
import { taskDetailPath } from '../shared/taskDetailPath';
@@ -54,6 +55,7 @@ const toTaskStatus = (status: string): TaskStatus =>
TASK_STATUS_SET.has(status as TaskStatus) ? (status as TaskStatus) : 'backlog';
const AgentTaskItem = memo<TaskItemProps>((props) => {
+ const { fontSize: rowFontSize, listRowHeight } = useDensityTokens();
const { className, hideProject, task, routeScope = 'agent', variant = 'default' } = props;
const { t, i18n } = useTranslation('common');
const { t: tChat } = useTranslation('chat');
@@ -139,15 +141,15 @@ const AgentTaskItem = memo<TaskItemProps>((props) => {
{archivedBadge}
{hasName ? (
<>
- <Text style={{ flex: 'none' }} type={'secondary'}>
+ <Text fontSize={rowFontSize} style={{ flex: 'none' }} type={'secondary'}>
{task.identifier}
</Text>
- <Text ellipsis style={{ minWidth: 0 }} weight={500}>
+ <Text ellipsis fontSize={rowFontSize} style={{ minWidth: 0 }} weight={500}>
{task.name}
</Text>
</>
) : (
- <Text ellipsis style={{ minWidth: 0 }} weight={500}>
+ <Text ellipsis fontSize={rowFontSize} style={{ minWidth: 0 }} weight={500}>
{task.identifier}
</Text>
)}
@@ -273,7 +275,8 @@ const AgentTaskItem = memo<TaskItemProps>((props) => {
clickable
className={className}
gap={4}
- padding={12}
+ paddingBlock={(listRowHeight - 24) / 2}
+ paddingInline={12}
variant={'borderless'}
onClick={handleClick}
>
diff --git a/src/features/AgentTopicManager/Toolbar.tsx b/src/features/AgentTopicManager/Toolbar.tsx
index 025b7724842..803642aa79c 100644
--- a/src/features/AgentTopicManager/Toolbar.tsx
+++ b/src/features/AgentTopicManager/Toolbar.tsx
@@ -41,6 +41,8 @@ import { getPlatformIcon } from '@/features/AgentChannel/const';
import { useChannelsEnabled } from '@/features/Channels/useChannelsEnabled';
import { useChatStore } from '@/store/chat';
import { topicSelectors } from '@/store/chat/selectors';
+import { useDensityTokens } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
import { useTopicsViewStore } from './store';
import type {
@@ -52,7 +54,6 @@ import type {
TriggerFilter,
} from './types';
-const CONTROL_HEIGHT = 32;
const THREE_MONTHS_MS = 90 * 24 * 60 * 60 * 1000;
const styles = createStaticStyles(({ css }) => ({
@@ -64,10 +65,10 @@ const styles = createStaticStyles(({ css }) => ({
gap: 6px;
align-items: center;
- height: ${CONTROL_HEIGHT}px;
+ height: ${sidebarRow.controlHeight};
padding-inline: 12px;
border: 1px dashed ${cssVar.colorBorder};
- border-radius: ${CONTROL_HEIGHT / 2}px;
+ border-radius: calc(${sidebarRow.controlHeight} / 2);
font-size: 13px;
color: ${cssVar.colorTextSecondary};
@@ -83,9 +84,9 @@ const styles = createStaticStyles(({ css }) => ({
display: inline-flex;
align-items: stretch;
- height: ${CONTROL_HEIGHT}px;
+ height: ${sidebarRow.controlHeight};
border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${CONTROL_HEIGHT / 2}px;
+ border-radius: calc(${sidebarRow.controlHeight} / 2);
background: ${cssVar.colorFillTertiary};
@@ -104,8 +105,8 @@ const styles = createStaticStyles(({ css }) => ({
align-items: center;
padding-inline: 8px 12px;
- border-start-end-radius: ${CONTROL_HEIGHT / 2}px;
- border-end-end-radius: ${CONTROL_HEIGHT / 2}px;
+ border-start-end-radius: calc(${sidebarRow.controlHeight} / 2);
+ border-end-end-radius: calc(${sidebarRow.controlHeight} / 2);
color: ${cssVar.colorTextTertiary};
@@ -145,9 +146,9 @@ const styles = createStaticStyles(({ css }) => ({
gap: 6px;
align-items: center;
- height: ${CONTROL_HEIGHT}px;
+ height: ${sidebarRow.controlHeight};
padding-inline: 12px;
- border-radius: ${CONTROL_HEIGHT / 2}px;
+ border-radius: calc(${sidebarRow.controlHeight} / 2);
font-size: 13px;
color: ${cssVar.colorText};
@@ -240,6 +241,7 @@ const FilterChip = memo<FilterChipProps>(({ icon, iconNode, label, value, items,
const Toolbar = memo<ToolbarProps>(({ projects, statusCounts, botChannelOptions }) => {
const { t } = useTranslation('topic');
+ const { controlHeight, iconSize } = useDensityTokens();
const topics = useChatStore(topicSelectors.agentTopicsViewTopics);
const updateTopicStatus = useChatStore((s) => s.updateTopicStatus);
@@ -622,7 +624,7 @@ const Toolbar = memo<ToolbarProps>(({ projects, statusCounts, botChannelOptions
<DropdownMenu items={overflowItems} placement={'bottomRight'}>
<ActionIcon
icon={MoreHorizontal}
- size={{ blockSize: CONTROL_HEIGHT, size: 18 }}
+ size={{ blockSize: controlHeight, size: iconSize }}
title={t('management.actionsMenu.title')}
/>
</DropdownMenu>
diff --git a/src/features/AgentViewAll/ListConfig.tsx b/src/features/AgentViewAll/ListConfig.tsx
index 6bd30b4ceee..79fbb502c2d 100644
--- a/src/features/AgentViewAll/ListConfig.tsx
+++ b/src/features/AgentViewAll/ListConfig.tsx
@@ -21,7 +21,7 @@ import {
import { memo, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
+import { useHeaderActionSize } from '@/styles/density';
import type { AgentGroupBy, AgentListViewOptions, AgentOrderBy } from './listViewOptions';
@@ -53,6 +53,7 @@ const ListConfig = memo<ListConfigProps>(
const [open, setOpen] = useState(false);
const form = useForm();
const { t } = useTranslation('common');
+ const headerActionSmallSize = useHeaderActionSize(true);
const groupingOptions = useMemo<Array<{ label: string; value: AgentGroupBy }>>(
() => [
@@ -168,7 +169,7 @@ const ListConfig = memo<ListConfigProps>(
trigger={['click']}
onOpenChange={setOpen}
>
- <ActionIcon icon={Settings2Icon} size={DESKTOP_HEADER_ICON_SMALL_SIZE} />
+ <ActionIcon icon={Settings2Icon} size={headerActionSmallSize} />
</Popover>
);
},
diff --git a/src/features/Channels/ChannelList.tsx b/src/features/Channels/ChannelList.tsx
index 03c211f316b..2bb947ecc16 100644
--- a/src/features/Channels/ChannelList.tsx
+++ b/src/features/Channels/ChannelList.tsx
@@ -12,7 +12,6 @@ import {
type DropdownItem,
DropdownMenu,
Flexbox,
- Text,
} from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
@@ -25,6 +24,7 @@ import { useActiveWorkspaceSlug } from '@/business/client/hooks/useActiveWorkspa
import AsyncError from '@/components/AsyncError';
import EmptyNavItem from '@/features/NavPanel/components/EmptyNavItem';
import NavItem from '@/features/NavPanel/components/NavItem';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { buildWorkspaceAwarePath } from '@/features/Workspace/workspaceAwarePath';
@@ -202,6 +202,7 @@ interface ChannelSectionProps {
*/
const EnabledChannelSection = ({ itemKey = 'channels', projectId }: ChannelSectionProps) => {
const { t } = useTranslation('channel');
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { pathname } = useActiveLocation();
const navigate = useWorkspaceAwareNavigate();
const slug = useActiveWorkspaceSlug();
@@ -326,10 +327,8 @@ const EnabledChannelSection = ({ itemKey = 'channels', projectId }: ChannelSecti
return (
<AccordionItem value={itemKey}>
<AccordionHeader>
- <AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
- <Text ellipsis fontSize={12} type="secondary" weight={500}>
- {t('title')}
- </Text>
+ <AccordionTrigger style={sectionTriggerStyle}>
+ <SectionTitle>{t('title')}</SectionTitle>
</AccordionTrigger>
<Flexbox
horizontal
diff --git a/src/features/Channels/ChannelMessage.test.tsx b/src/features/Channels/ChannelMessage.test.tsx
index 390c71bb995..e33d57acf9d 100644
--- a/src/features/Channels/ChannelMessage.test.tsx
+++ b/src/features/Channels/ChannelMessage.test.tsx
@@ -91,6 +91,7 @@ vi.mock('@/store/user', () => ({
useUserStore: (selector: (s: unknown) => unknown) => selector({}),
}));
vi.mock('@/store/user/selectors', () => ({
+ userGeneralSettingsSelectors: { interfaceDensity: () => 'loose' },
userProfileSelectors: { userId: () => 'user-self' },
}));
vi.mock('./MessageAttachments', () => ({ MessageAttachments: () => null }));
diff --git a/src/features/Conversation/WorkingSidebar/Browser/index.tsx b/src/features/Conversation/WorkingSidebar/Browser/index.tsx
index 77e6f9d398d..eaa773842fd 100644
--- a/src/features/Conversation/WorkingSidebar/Browser/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/Browser/index.tsx
@@ -18,13 +18,14 @@ import { memo, useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { BrowserIcon } from '@/components/BrowserIcon';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { useLocalStorageState } from '@/hooks/useLocalStorageState';
import { electronBrowserSidebarService } from '@/services/electron/browserSidebar';
import { browserWebviewRegistry } from '@/services/electron/browserWebviewRegistry';
import { useChatStore } from '@/store/chat';
import { useFileStore } from '@/store/file';
import { useGlobalStore } from '@/store/global';
+import { useHeaderActionSize } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
import type { ComposerTarget } from '../../types';
import { BROWSER_IMPORT_BANNER_DISMISSED_STORAGE_KEY } from './const';
@@ -86,6 +87,12 @@ const styles = stylex.create({
borderBlockEndStyle: 'solid',
borderBlockEndColor: cssVar.colorBorderSecondary,
},
+ toolbarCompact: {
+ height: sidebarRow.toolbarHeight,
+ minHeight: sidebarRow.toolbarHeight,
+ paddingInlineStart: sidebarRow.toolbarPaddingInlineStart,
+ paddingInlineEnd: sidebarRow.toolbarPaddingInlineEnd,
+ },
address: {
flex: '1',
minWidth: 0,
@@ -122,6 +129,8 @@ const styles = stylex.create({
interface BrowserPaneProps {
/** The conversation the chat input belongs to — screenshots are attached there. */
agentId?: string;
+ /** The WorkingSidebar pane toolbar: density-driven height, small icon buttons and address field. */
+ compactToolbar?: boolean;
composerTarget: ComposerTarget;
onMetadataChange?: (metadata: { faviconUrl?: string; title: string; url: string }) => void;
/**
@@ -140,7 +149,16 @@ export interface BrowserOpenRequest {
}
const BrowserPane = memo<BrowserPaneProps>((props) => {
- const { agentId, composerTarget, onMetadataChange, onRequestConsumed, sessionId } = props;
+ const {
+ agentId,
+ compactToolbar,
+ composerTarget,
+ onMetadataChange,
+ onRequestConsumed,
+ sessionId,
+ } = props;
+ const headerActionSize = useHeaderActionSize(true);
+ const toolbarIconSize = compactToolbar ? 'small' : headerActionSize;
const { t } = useTranslation('chat');
const state = useBrowserSidebarState(sessionId);
const [address, setAddress] = useState('');
@@ -332,26 +350,31 @@ const BrowserPane = memo<BrowserPaneProps>((props) => {
return (
<Flexbox height={'100%'} width={'100%'}>
- <Flexbox horizontal align={'center'} {...stylex.props(styles.toolbar)} gap={4}>
+ <Flexbox
+ horizontal
+ align={'center'}
+ {...stylex.props(styles.toolbar, compactToolbar && styles.toolbarCompact)}
+ gap={4}
+ >
<Flexbox horizontal align={'center'} gap={4}>
<ActionIcon
disabled={!state.canGoBack}
icon={ChevronLeft}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={toolbarIconSize}
title={t('workingPanel.browser.actions.back')}
onClick={() => runAction(() => electronBrowserSidebarService.goBack({ sessionId }))}
/>
<ActionIcon
disabled={!state.canGoForward}
icon={ChevronRight}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={toolbarIconSize}
title={t('workingPanel.browser.actions.forward')}
onClick={() => runAction(() => electronBrowserSidebarService.goForward({ sessionId }))}
/>
<ActionIcon
disabled={!state.attached}
icon={state.isLoading ? XCircle : RefreshCw}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={toolbarIconSize}
title={
state.isLoading
? t('workingPanel.browser.actions.stop')
@@ -369,6 +392,7 @@ const BrowserPane = memo<BrowserPaneProps>((props) => {
<Input
{...stylex.props(styles.address)}
placeholder={t('workingPanel.browser.addressPlaceholder')}
+ size={compactToolbar ? 'small' : undefined}
value={address}
variant={'filled'}
onBlur={() => setIsEditing(false)}
@@ -387,7 +411,7 @@ const BrowserPane = memo<BrowserPaneProps>((props) => {
<ActionIcon
active
icon={SquareDashedMousePointer}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={toolbarIconSize}
title={t('workingPanel.browser.context.pickCancel')}
onClick={() =>
void electronBrowserSidebarService.cancelElementPick({ sessionId }).catch(() => {})
@@ -397,7 +421,7 @@ const BrowserPane = memo<BrowserPaneProps>((props) => {
<ActionIcon
disabled={!state.attached || state.isLoading || !composerTarget.writable}
icon={SquareDashedMousePointer}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={toolbarIconSize}
title={t('workingPanel.browser.context.pickElement')}
onClick={() => void pickElementContext()}
/>
@@ -405,7 +429,7 @@ const BrowserPane = memo<BrowserPaneProps>((props) => {
<ActionIcon
disabled={!state.attached}
icon={ExternalLink}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={toolbarIconSize}
title={t('workingPanel.browser.actions.openExternal')}
onClick={() =>
runAction(() => electronBrowserSidebarService.openExternal({ sessionId }))
@@ -415,7 +439,7 @@ const BrowserPane = memo<BrowserPaneProps>((props) => {
disabled={!state.attached || !agentId || !composerTarget.writable}
icon={Camera}
loading={isCapturing}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={toolbarIconSize}
title={t('workingPanel.browser.actions.capture')}
onClick={() => void addScreenshotToInput()}
/>
@@ -449,7 +473,7 @@ const BrowserPane = memo<BrowserPaneProps>((props) => {
</Button>
<ActionIcon
icon={XCircle}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
title={t('workingPanel.browser.import.dismiss')}
onClick={() => setIsImportBannerDismissed(true)}
/>
diff --git a/src/features/Conversation/WorkingSidebar/Canvas/CanvasPane.tsx b/src/features/Conversation/WorkingSidebar/Canvas/CanvasPane.tsx
index 31e0d4b65c9..0711293b312 100644
--- a/src/features/Conversation/WorkingSidebar/Canvas/CanvasPane.tsx
+++ b/src/features/Conversation/WorkingSidebar/Canvas/CanvasPane.tsx
@@ -1,4 +1,4 @@
-import { Empty, Flexbox, Skeleton, Tag, Text } from '@lobehub/ui';
+import { Center, Empty, Flexbox, Skeleton, Tag, Text } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
import { Loader2Icon, PanelsTopLeftIcon } from 'lucide-react';
@@ -6,6 +6,7 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import PortalMoreMenu from '@/features/Portal/components/PortalMoreMenu';
+import { sidebarRow } from '@/styles/density.stylex';
import CanvasFrame from './CanvasFrame';
import CanvasShareButton from './CanvasShareButton';
@@ -52,11 +53,21 @@ const styles = stylex.create({
animationName: spin,
animationTimingFunction: 'linear',
},
+ title: {
+ color: cssVar.colorTextTertiary,
+ flex: '1',
+ fontSize: sidebarRow.labelFontSize,
+ fontWeight: sidebarRow.labelFontWeight,
+ minWidth: 0,
+ },
toolbar: {
borderBlockEndColor: cssVar.colorBorderSecondary,
borderBlockEndStyle: 'solid',
borderBlockEndWidth: 1,
+ height: sidebarRow.toolbarHeight,
minWidth: 0,
+ paddingInlineEnd: sidebarRow.toolbarPaddingInlineEnd,
+ paddingInlineStart: sidebarRow.toolbarPaddingInlineStart,
},
});
@@ -86,22 +97,18 @@ const CanvasPane = memo<CanvasPaneProps>(({ canvasId }) => {
}
if (!data) {
- return <Empty description={t('canvas.notFound')} icon={PanelsTopLeftIcon} />;
+ return (
+ <Center paddingBlock={24}>
+ <Empty description={t('canvas.notFound')} icon={PanelsTopLeftIcon} />
+ </Center>
+ );
}
return (
<Flexbox flex={1} {...stylex.props(styles.body)}>
- <Flexbox
- horizontal
- align={'center'}
- flex={'none'}
- gap={8}
- height={36}
- paddingInline={12}
- {...stylex.props(styles.toolbar)}
- >
+ <Flexbox horizontal align={'center'} flex={'none'} gap={4} {...stylex.props(styles.toolbar)}>
<Tag size={'small'}>{`v${data.version}`}</Tag>
- <Text ellipsis fontSize={12} style={{ flex: 1, minWidth: 0 }} type={'secondary'}>
+ <Text ellipsis {...stylex.props(styles.title)}>
{data.title}
</Text>
{/* Two ghost icon buttons: their own padding is the separation, so the
diff --git a/src/features/Conversation/WorkingSidebar/DeferredSkeleton.tsx b/src/features/Conversation/WorkingSidebar/DeferredSkeleton.tsx
index 846c464f795..e37a4639841 100644
--- a/src/features/Conversation/WorkingSidebar/DeferredSkeleton.tsx
+++ b/src/features/Conversation/WorkingSidebar/DeferredSkeleton.tsx
@@ -1,6 +1,36 @@
+import { Flexbox } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import { useEffect, useState } from 'react';
-import SkeletonList from '@/features/NavPanel/components/SkeletonList';
+import { SkeletonItem } from '@/features/NavPanel/components/SkeletonList';
+import { useDensityTokens } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
+
+const styles = stylex.create({
+ pane: {
+ paddingBlockStart: sidebarRow.paneBlockStart,
+ paddingBlockEnd: sidebarRow.paneBlockEnd,
+ paddingInline: sidebarRow.paneInline,
+ },
+});
+
+export const SidebarRowSkeleton = ({ rows = 3 }: { rows?: number }) => {
+ const density = useDensityTokens();
+
+ return (
+ <Flexbox gap={1}>
+ {Array.from({ length: rows }).map((_, index) => (
+ <SkeletonItem
+ avatarSize={density.iconSize}
+ gap={density.gap}
+ height={density.rowHeight}
+ key={index}
+ padding={'0 8px'}
+ />
+ ))}
+ </Flexbox>
+ );
+};
/**
* The right panel's placeholder for a tab that has not mounted yet.
@@ -18,7 +48,11 @@ const DeferredSkeleton = () => {
}, []);
if (!show) return null;
- return <SkeletonList paddingBlock={8} paddingInline={8} rows={6} />;
+ return (
+ <div {...stylex.props(styles.pane)}>
+ <SidebarRowSkeleton rows={6} />
+ </div>
+ );
};
export default DeferredSkeleton;
diff --git a/src/features/Conversation/WorkingSidebar/DynamicTabPanes.tsx b/src/features/Conversation/WorkingSidebar/DynamicTabPanes.tsx
index bd692df2d7f..193bc57def0 100644
--- a/src/features/Conversation/WorkingSidebar/DynamicTabPanes.tsx
+++ b/src/features/Conversation/WorkingSidebar/DynamicTabPanes.tsx
@@ -164,6 +164,7 @@ const DynamicTabPanes = memo<DynamicTabPanesProps>(
return (
<Flexbox flex={1} key={sessionId} style={activeTab === tab ? PANE : HIDDEN_PANE}>
<BrowserPane
+ compactToolbar
agentId={agentId}
composerTarget={composerTarget}
sessionId={sessionId}
diff --git a/src/features/Conversation/WorkingSidebar/Files/fileTreeStyle.ts b/src/features/Conversation/WorkingSidebar/Files/fileTreeStyle.ts
index 0b52c6e1afb..0ec3a918ed6 100644
--- a/src/features/Conversation/WorkingSidebar/Files/fileTreeStyle.ts
+++ b/src/features/Conversation/WorkingSidebar/Files/fileTreeStyle.ts
@@ -1,4 +1,17 @@
import { FOLDER_ICON_CSS } from '@/features/ExplorerTree';
+import { sidebarRow } from '@/styles/density.stylex';
+
+// FOLDER_ICON_CSS draws folders at 18px with a 4px gap, heavier than the file
+// glyphs beside them. Folders take the file glyph's size, which ExplorerTree
+// fixes at 16px in every density, and the row gap; the CSS vars reach inside
+// pierre's shadow root because custom properties inherit through it.
+export const COMPACT_FOLDER_ICON_CSS = `
+[data-item-type="folder"] [data-item-section="content"]::before {
+ width: 16px;
+ height: 16px;
+ margin-inline-end: ${sidebarRow.gap};
+ background-size: 16px 16px;
+}`;
const IGNORED_FILE_OPACITY_CSS = `
[data-item-git-status='ignored'] > :where(
@@ -39,6 +52,7 @@ const RENAME_INPUT_FULL_WIDTH_CSS = `
export const FILE_TREE_UNSAFE_CSS = [
FOLDER_ICON_CSS,
+ COMPACT_FOLDER_ICON_CSS,
NO_FOCUS_RING_CSS,
IGNORED_FILE_OPACITY_CSS,
RENAME_INPUT_FULL_WIDTH_CSS,
diff --git a/src/features/Conversation/WorkingSidebar/Files/index.tsx b/src/features/Conversation/WorkingSidebar/Files/index.tsx
index 5facbdd1bd7..0eef0309ca5 100644
--- a/src/features/Conversation/WorkingSidebar/Files/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/Files/index.tsx
@@ -9,7 +9,6 @@ import {
Flexbox,
Icon,
Input,
- Spin,
stopPropagation,
} from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
@@ -31,6 +30,7 @@ import {
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { SkeletonList } from '@/components/Skeleton/NavPanel/List';
import type { ExplorerTreeNode } from '@/features/ExplorerTree';
import { ExplorerTree, getExplorerTreeStyleVars } from '@/features/ExplorerTree';
import type { ExplorerTreeHandle } from '@/features/ExplorerTree/types';
@@ -38,6 +38,8 @@ import { useClientDataSWR } from '@/libs/swr';
import { projectFileService } from '@/services/projectFile';
import { useGlobalStore } from '@/store/global';
import { isPersistedPartialIndex } from '@/store/projectFile';
+import { useDensityTokens } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
import { filterProjectFileEntries, mergeMissingDeletedEntries } from './fileFilter';
import { FILE_TREE_UNSAFE_CSS } from './fileTreeStyle';
@@ -79,22 +81,31 @@ const styles = stylex.create({
'--trees-fg-override': cssVar.colorTextSecondary,
'--trees-fg-muted-override': cssVar.colorTextSecondary,
'--trees-accent-override': cssVar.colorPrimary,
- '--trees-padding-inline-override': '0px',
- '--trees-font-size-override': '12px',
- '--trees-border-radius-override': '6px',
+ '--trees-padding-inline-override': sidebarRow.paneInline,
+ '--trees-item-margin-x-override': '0px',
+ '--trees-item-padding-x-override': sidebarRow.paddingInline,
+ '--trees-item-row-gap-override': sidebarRow.gap,
+ '--trees-font-size-override': sidebarRow.textFontSize,
+ '--trees-border-radius-override': sidebarRow.radius,
'flex': '1',
'minHeight': '0',
+ 'paddingBlockStart': sidebarRow.paneBlockStart,
},
subheader: {
display: 'flex',
flexShrink: 0,
gap: '4px',
alignItems: 'center',
- paddingBlockStart: '6px',
- paddingBlockEnd: '8px',
- paddingInline: '12px',
+ height: sidebarRow.toolbarHeight,
+ paddingInlineStart: sidebarRow.toolbarPaddingInlineStart,
+ paddingInlineEnd: sidebarRow.toolbarPaddingInlineEnd,
},
search: { flex: '1', minWidth: '0' },
+ skeleton: {
+ paddingBlockStart: sidebarRow.paneBlockStart,
+ paddingBlockEnd: sidebarRow.paneBlockEnd,
+ paddingInline: sidebarRow.paneInline,
+ },
truncated: {
flexShrink: 0,
paddingBlock: '4px',
@@ -221,6 +232,7 @@ const Files = memo<FilesProps>(
instanceId: sandboxInstanceId,
topicId: sandboxTopicId,
});
+ const density = useDensityTokens();
const projectSource = data?.source;
const projectRoot = data?.root ?? workingDirectory;
@@ -352,8 +364,12 @@ const Files = memo<FilesProps>(
[changedOnly, isFiltering, nodes],
);
const treeStyleVars = useMemo(
- () => getExplorerTreeStyleVars({ reserveChevronSlot: nodes.some((node) => node.isFolder) }),
- [nodes],
+ () =>
+ getExplorerTreeStyleVars({
+ reserveChevronSlot: nodes.some((node) => node.isFolder),
+ rowGap: density.gap,
+ }),
+ [density.gap, nodes],
);
useEffect(() => {
@@ -485,11 +501,7 @@ const Files = memo<FilesProps>(
const showsRefreshFailure = !!data && !!(error || gitError);
if (!data && isLoading) {
- return (
- <Center flex={1}>
- <Spin size="large" />
- </Center>
- );
+ return <SkeletonList compact className={stylex.props(styles.skeleton).className} rows={8} />;
}
return (
@@ -550,11 +562,9 @@ const Files = memo<FilesProps>(
</DropdownMenu>
</div>
{isEmpty && isFiltering && isSearching ? (
- <Center flex={1}>
- <Spin size="large" />
- </Center>
+ <SkeletonList compact className={stylex.props(styles.skeleton).className} rows={4} />
) : isEmpty && !actions.pendingCreate ? (
- <Center flex={1} gap={8} paddingBlock={24}>
+ <Center flex={1} paddingBlock={24}>
{/* A failed read and an empty directory look identical once the tree
is empty, and they are not the same thing to act on: one is
"nothing here yet", the other is "we could not find out". Saying
@@ -583,6 +593,7 @@ const Files = memo<FilesProps>(
getContextMenuItems={actions.getContextMenuItems}
gitStatus={gitStatus}
iconSet="complete"
+ itemHeight={density.treeItemHeight}
nodes={nodes}
ref={treeRef}
style={{ height: '100%' }}
diff --git a/src/features/Conversation/WorkingSidebar/GoalSection/GoalWorkflowCard.tsx b/src/features/Conversation/WorkingSidebar/GoalSection/GoalWorkflowCard.tsx
index 6c1dd626d0a..de87318eca8 100644
--- a/src/features/Conversation/WorkingSidebar/GoalSection/GoalWorkflowCard.tsx
+++ b/src/features/Conversation/WorkingSidebar/GoalSection/GoalWorkflowCard.tsx
@@ -1,17 +1,15 @@
'use client';
-import { Button, Flexbox, Icon, Skeleton } from '@lobehub/ui';
+import { Button, Flexbox, Icon } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
import {
ArrowUpRight,
CheckCircle2,
ChevronDown,
- ChevronUp,
CircleSlash,
Clock3,
LoaderCircle,
- Workflow,
} from 'lucide-react';
import { type KeyboardEvent, memo, useCallback, useId, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -19,8 +17,12 @@ import { useTranslation } from 'react-i18next';
import AsyncError from '@/components/AsyncError';
import AssigneeProfileAvatar from '@/features/AgentGoals/ProcessControl/AssigneeProfileAvatar';
import { useChatStore } from '@/store/chat';
+import { useDensityTokens } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
import { sx } from '@/styles/sx';
+import { SidebarRowSkeleton } from '../DeferredSkeleton';
+import { SectionHeader } from '../Overview/SectionHeader';
import {
buildGoalStepSegments,
type GoalWorkflowRow,
@@ -37,17 +39,6 @@ const stepPulse = stylex.keyframes({
const styles = stylex.create({
collapsed: { display: 'none' },
- count: {
- flexShrink: 0,
- paddingBlock: '1px',
- paddingInline: '6px',
- borderRadius: '4px',
- fontFamily: cssVar.fontFamilyCode,
- fontSize: '11px',
- color: cssVar.colorTextSecondary,
- backgroundColor: cssVar.colorFillSecondary,
- backgroundImage: 'none',
- },
decisionRow: {
cursor: 'pointer',
marginBlockStart: '2px',
@@ -57,28 +48,36 @@ const styles = stylex.create({
borderWidth: '1px',
borderStyle: 'solid',
borderColor: cssVar.colorWarningBorder,
- borderRadius: '6px',
+ borderRadius: sidebarRow.radius,
fontSize: '12px',
color: cssVar.colorWarning,
backgroundColor: { 'default': cssVar.colorWarningBg, ':hover': cssVar.colorWarningBorder },
backgroundImage: { 'default': 'none', ':hover': 'none' },
},
- footer: { paddingBlockStart: '6px', paddingBlockEnd: '2px', paddingInline: '10px' },
- headerRow: {
- cursor: 'pointer',
- userSelect: 'none',
- paddingBlockStart: '4px',
- paddingBlockEnd: '6px',
- paddingInline: '10px',
- borderRadius: '6px',
- transition: 'background-color 0.12s ease',
- backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
- backgroundImage: { 'default': null, ':hover': 'none' },
- outlineWidth: { 'default': null, ':focus-visible': '2px' },
- outlineStyle: { 'default': null, ':focus-visible': 'solid' },
- outlineColor: { 'default': null, ':focus-visible': cssVar.colorPrimaryBorder },
- outlineOffset: { 'default': null, ':focus-visible': '2px' },
+ footer: { paddingBlockStart: '6px', paddingBlockEnd: '2px', paddingInline: '6px' },
+ iconBox: {
+ display: 'grid',
+ flexShrink: 0,
+ placeItems: 'center',
+ width: sidebarRow.iconBox,
+ height: sidebarRow.iconBox,
+ },
+ phase: {
+ flexShrink: 0,
+ fontSize: sidebarRow.labelFontSize,
+ fontWeight: 400,
+ color: cssVar.colorTextTertiary,
+ },
+ rowTitle: {
+ overflow: 'hidden',
+ flex: '1',
+ minWidth: 0,
+ fontSize: sidebarRow.textFontSize,
+ lineHeight: sidebarRow.textLineHeight,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
},
+ rows: { display: 'flex', flexDirection: 'column', gap: '1px' },
lessRow: {
cursor: 'pointer',
justifyContent: 'center',
@@ -94,7 +93,7 @@ const styles = stylex.create({
borderWidth: '1px',
borderStyle: 'dashed',
borderColor: cssVar.colorBorder,
- borderRadius: '6px',
+ borderRadius: sidebarRow.radius,
fontSize: '12px',
color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
backgroundColor: { 'default': null, ':hover': cssVar.colorFillQuaternary },
@@ -117,9 +116,11 @@ const styles = stylex.create({
},
row: {
cursor: 'pointer',
- paddingBlock: '5px',
- paddingInline: '8px',
- borderRadius: '6px',
+ gap: sidebarRow.gap,
+ minHeight: sidebarRow.height,
+ paddingInline: sidebarRow.paddingInline,
+ borderRadius: sidebarRow.radius,
+ color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
backgroundImage: { 'default': null, ':hover': 'none' },
outlineWidth: { 'default': null, ':focus-visible': '2px' },
@@ -127,7 +128,7 @@ const styles = stylex.create({
outlineColor: { 'default': null, ':focus-visible': cssVar.colorPrimaryBorder },
outlineOffset: { 'default': null, ':focus-visible': '-2px' },
},
- loading: { paddingBlockStart: '4px', paddingBlockEnd: '8px', paddingInline: '10px' },
+ loading: { paddingBlockStart: '4px', paddingBlockEnd: '8px' },
segActive: {
backgroundColor: cssVar.colorInfo,
backgroundImage: 'none',
@@ -145,17 +146,7 @@ const styles = stylex.create({
height: '4px',
marginBlockStart: '2px',
marginBlockEnd: '8px',
- marginInline: '10px',
- },
- sectionTitle: {
- overflow: 'hidden',
- flex: '1',
- minWidth: 0,
- fontSize: '13px',
- fontWeight: 500,
- color: cssVar.colorText,
- textOverflow: 'ellipsis',
- whiteSpace: 'nowrap',
+ marginInline: '6px',
},
});
@@ -168,6 +159,7 @@ const STATE_VISUALS = {
const WorkflowRow = memo<{ onOpen: () => void; row: GoalWorkflowRow }>(({ row, onOpen }) => {
const visual = STATE_VISUALS[row.state];
+ const { iconSize } = useDensityTokens();
const handleKeyDown = useCallback(
(event: KeyboardEvent<HTMLDivElement>) => {
if (event.key !== 'Enter' && event.key !== ' ') return;
@@ -181,29 +173,19 @@ const WorkflowRow = memo<{ onOpen: () => void; row: GoalWorkflowRow }>(({ row, o
horizontal
align={'center'}
{...stylex.props(styles.row)}
- gap={8}
role={'button'}
tabIndex={0}
onClick={onOpen}
onKeyDown={handleKeyDown}
>
- {row.assigneeId ? (
- <AssigneeProfileAvatar agentId={row.assigneeId} size={20} />
- ) : (
- <CircleSlash size={14} style={{ color: cssVar.colorTextQuaternary, flexShrink: 0 }} />
- )}
- <span
- style={{
- flex: 1,
- fontSize: 13,
- minWidth: 0,
- overflow: 'hidden',
- textOverflow: 'ellipsis',
- whiteSpace: 'nowrap',
- }}
- >
- {row.title}
+ <span {...stylex.props(styles.iconBox)}>
+ {row.assigneeId ? (
+ <AssigneeProfileAvatar agentId={row.assigneeId} size={20} />
+ ) : (
+ <CircleSlash size={iconSize} style={{ color: cssVar.colorTextQuaternary }} />
+ )}
</span>
+ <span {...stylex.props(styles.rowTitle)}>{row.title}</span>
<Icon
icon={visual.icon}
size={14}
@@ -257,14 +239,6 @@ const GoalWorkflowCard = memo<{
const open = useCallback(() => openGoalPortal(goal.goalId), [goal.goalId, openGoalPortal]);
const toggleCollapsed = useCallback(() => setCollapsed((prev) => !prev), []);
- const handleHeaderKeyDown = useCallback(
- (event: KeyboardEvent<HTMLDivElement>) => {
- if (event.key !== 'Enter' && event.key !== ' ') return;
- event.preventDefault();
- toggleCollapsed();
- },
- [toggleCollapsed],
- );
const rows = sliceVisibleWorkflowRows(goal.rows, rowsExpanded);
const hiddenCount = goal.rows.length - rows.length;
@@ -276,51 +250,35 @@ const GoalWorkflowCard = memo<{
return (
<div>
- <Flexbox
- horizontal
- align={'center'}
- aria-controls={bodyId}
- aria-expanded={!collapsed}
- {...stylex.props(styles.headerRow)}
- gap={8}
- justify="space-between"
- role={'button'}
- tabIndex={0}
- onClick={toggleCollapsed}
- onKeyDown={handleHeaderKeyDown}
- >
- <Flexbox horizontal align={'center'} gap={8} style={{ flex: 1, minWidth: 0 }}>
- <Icon icon={Workflow} size={14} style={{ color: cssVar.colorTextSecondary }} />
- <span {...stylex.props(styles.sectionTitle)} title={title}>
- {title}
- </span>
- {hasSnapshot && goal.phase !== 'running' && (
- <span {...stylex.props(styles.count)}>{t(`goalTask.status.${goal.phase}`)}</span>
- )}
- {hasSnapshot && (
- <span {...stylex.props(styles.count)}>
- {goal.summary.done}/{goal.summary.total}
- </span>
- )}
- </Flexbox>
- <Icon
- icon={collapsed ? ChevronDown : ChevronUp}
- size={14}
- style={{ color: cssVar.colorTextTertiary, flexShrink: 0 }}
- />
- </Flexbox>
+ <SectionHeader
+ collapsed={collapsed}
+ controls={bodyId}
+ count={hasSnapshot ? `${goal.summary.done}/${goal.summary.total}` : undefined}
+ title={title}
+ titleAttr={title}
+ meta={
+ hasSnapshot &&
+ goal.phase !== 'running' && (
+ <span {...stylex.props(styles.phase)}>{t(`goalTask.status.${goal.phase}`)}</span>
+ )
+ }
+ onToggle={toggleCollapsed}
+ />
<div hidden={collapsed} {...stylex.props(collapsed && styles.collapsed)} id={bodyId}>
{goal.error ? (
<div {...stylex.props(styles.loading)}>
- <AsyncError error={goal.error} variant={'inline'} onRetry={goal.retry} />
+ <AsyncError
+ align={'start'}
+ error={goal.error}
+ variant={'inline'}
+ onRetry={goal.retry}
+ />
</div>
) : goal.loading ? (
- <Flexbox {...stylex.props(styles.loading)} data-testid={'goal-workflow-loading'} gap={8}>
- <Skeleton height={12} radius={4} />
- <Skeleton height={28} radius={6} />
- <Skeleton height={28} radius={6} />
- </Flexbox>
+ <div data-testid={'goal-workflow-loading'}>
+ <SidebarRowSkeleton rows={3} />
+ </div>
) : (
<>
<StepTrack rows={goal.rows} />
@@ -346,7 +304,7 @@ const GoalWorkflowCard = memo<{
</Flexbox>
)}
- <div style={{ paddingInline: 4 }}>
+ <div {...stylex.props(styles.rows)}>
{rows.map((row) => (
<WorkflowRow key={row.id} row={row} onOpen={open} />
))}
diff --git a/src/features/Conversation/WorkingSidebar/GoalSection/index.tsx b/src/features/Conversation/WorkingSidebar/GoalSection/index.tsx
index 234a3d951b5..8a40ae2ffbc 100644
--- a/src/features/Conversation/WorkingSidebar/GoalSection/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/GoalSection/index.tsx
@@ -1,5 +1,8 @@
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
+import { sidebarRow } from '@/styles/density.stylex';
+
import GoalWorkflowCardContainer from './GoalWorkflowCard';
import { useTopicOperationGoals } from './useGoalSection';
@@ -9,6 +12,10 @@ import { useTopicOperationGoals } from './useGoalSection';
* card open by default, so the panel leads with what just moved. Topics that
* created no goal render nothing.
*/
+const styles = stylex.create({
+ cards: { display: 'flex', flexDirection: 'column', gap: sidebarRow.sectionGap },
+});
+
const GoalSection = memo<{ className?: string }>(({ className }) => {
const goals = useTopicOperationGoals();
@@ -16,15 +23,17 @@ const GoalSection = memo<{ className?: string }>(({ className }) => {
return (
<div className={className}>
- {goals.map((goal, index) => (
- <GoalWorkflowCardContainer
- criteriaCount={goal.criteriaCount}
- goalId={goal.goalId}
- initialCollapsed={index < goals.length - 1}
- key={goal.goalId}
- name={goal.name}
- />
- ))}
+ <div {...stylex.props(styles.cards)}>
+ {goals.map((goal, index) => (
+ <GoalWorkflowCardContainer
+ criteriaCount={goal.criteriaCount}
+ goalId={goal.goalId}
+ initialCollapsed={index < goals.length - 1}
+ key={goal.goalId}
+ name={goal.name}
+ />
+ ))}
+ </div>
</div>
);
});
diff --git a/src/features/Conversation/WorkingSidebar/Memory/MemoryPane.tsx b/src/features/Conversation/WorkingSidebar/Memory/MemoryPane.tsx
index c23eed62bfa..0cbc50e0986 100644
--- a/src/features/Conversation/WorkingSidebar/Memory/MemoryPane.tsx
+++ b/src/features/Conversation/WorkingSidebar/Memory/MemoryPane.tsx
@@ -8,8 +8,11 @@ import { memo, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import AsyncBoundary from '@/components/AsyncBoundary';
+import { SkeletonList } from '@/components/Skeleton/NavPanel/List';
import { SkillSection } from '@/features/SkillsList';
import { useChatStore } from '@/store/chat';
+import { useDensityTokens } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
import { groupMemoryFiles, memoryFilePortalTarget } from './memoryView';
import { useClaudeCodeMemory } from './useClaudeCodeMemory';
@@ -17,43 +20,62 @@ import { useClaudeCodeMemory } from './useClaudeCodeMemory';
const styles = stylex.create({
description: {
color: cssVar.colorTextTertiary,
- fontSize: 12,
- lineHeight: 1.5,
- paddingInlineStart: 20,
+ fontSize: sidebarRow.metaFontSize,
+ lineHeight: '18px',
},
item: {
+ alignItems: 'flex-start',
backgroundColor: {
':focus-visible': cssVar.colorFillTertiary,
':hover': cssVar.colorFillTertiary,
'default': 'transparent',
},
- borderRadius: 6,
+ borderRadius: sidebarRow.radius,
borderStyle: 'none',
- color: {
- ':focus-visible': cssVar.colorText,
- ':hover': cssVar.colorText,
- 'default': cssVar.colorTextSecondary,
- },
+ color: cssVar.colorText,
cursor: 'pointer',
display: 'flex',
- flexDirection: 'column',
- fontSize: 13,
- gap: 2,
- paddingBlock: 6,
- paddingInlineEnd: 8,
- paddingInlineStart: 4,
+ fontSize: sidebarRow.textFontSize,
+ gap: sidebarRow.gap,
+ lineHeight: sidebarRow.textLineHeight,
+ paddingBlock: 5,
+ paddingInline: sidebarRow.paddingInline,
textAlign: 'start',
width: '100%',
},
itemIcon: {
+ alignItems: 'center',
color: cssVar.colorTextTertiary,
+ display: 'flex',
flexShrink: 0,
+ height: sidebarRow.textLineHeight,
+ justifyContent: 'center',
+ width: sidebarRow.iconBox,
+ },
+ itemText: {
+ display: 'flex',
+ flex: '1',
+ flexDirection: 'column',
+ minWidth: 0,
+ },
+ list: {
+ minHeight: 0,
+ paddingBlockEnd: sidebarRow.paneBlockEnd,
+ paddingBlockStart: sidebarRow.paneBlockStart,
+ paddingInline: sidebarRow.paneInline,
},
location: {
+ color: cssVar.colorTextTertiary,
flex: '1',
- fontSize: 12,
+ fontSize: sidebarRow.labelFontSize,
minWidth: 0,
},
+ toolbar: {
+ flexShrink: 0,
+ height: sidebarRow.toolbarHeight,
+ paddingInlineEnd: sidebarRow.toolbarPaddingInlineEnd,
+ paddingInlineStart: sidebarRow.toolbarPaddingInlineStart,
+ },
});
interface MemoryRowProps {
@@ -64,6 +86,7 @@ interface MemoryRowProps {
const MemoryRow = memo<MemoryRowProps>(({ file, indexHint, onOpen }) => {
const description = file.description ?? (file.isIndex ? indexHint : undefined);
+ const { iconSize } = useDensityTokens();
return (
<button
@@ -72,17 +95,19 @@ const MemoryRow = memo<MemoryRowProps>(({ file, indexHint, onOpen }) => {
type="button"
onClick={() => onOpen(file)}
>
- <Flexbox horizontal align={'center'} gap={6} width={'100%'}>
- <Icon {...stylex.props(styles.itemIcon)} icon={FileTextIcon} size={14} />
- <Text ellipsis style={{ color: 'inherit', flex: 1, minWidth: 0 }}>
+ <span {...stylex.props(styles.itemIcon)}>
+ <Icon icon={FileTextIcon} size={iconSize} />
+ </span>
+ <span {...stylex.props(styles.itemText)}>
+ <Text ellipsis style={{ color: 'inherit', fontSize: 'inherit', lineHeight: 'inherit' }}>
{file.isIndex ? file.relativePath : file.name}
</Text>
- </Flexbox>
- {description && (
- <Text {...stylex.props(styles.description)} ellipsis={{ rows: 2 }}>
- {description}
- </Text>
- )}
+ {description && (
+ <Text {...stylex.props(styles.description)} ellipsis={{ rows: 2 }}>
+ {description}
+ </Text>
+ )}
+ </span>
</button>
);
});
@@ -104,6 +129,7 @@ interface MemoryPaneProps {
*/
export const MemoryPane = memo<MemoryPaneProps>(({ agentId, deviceId, workingDirectory }) => {
const { t } = useTranslation('chat');
+ const { sectionGap } = useDensityTokens();
const openLocalFile = useChatStore((s) => s.openLocalFile);
const { data, error, isLoading, isValidating, mutate } = useClaudeCodeMemory({
agentId,
@@ -123,18 +149,11 @@ export const MemoryPane = memo<MemoryPaneProps>(({ agentId, deviceId, workingDir
const refresh = useCallback(() => void mutate(), [mutate]);
return (
- <Flexbox
- data-testid={'workspace-memory'}
- flex={1}
- gap={12}
- paddingBlock={8}
- paddingInline={'8px 12px'}
- style={{ minHeight: 0 }}
- >
+ <Flexbox data-testid={'workspace-memory'} flex={1} style={{ minHeight: 0 }}>
{/* Outside the boundary so an empty memory can still be re-read once Claude writes one. */}
{memoryDir && (
- <Flexbox horizontal align={'center'} gap={4} paddingInline={4}>
- <Text ellipsis {...stylex.props(styles.location)} title={memoryDir} type={'secondary'}>
+ <Flexbox horizontal align={'center'} gap={4} {...stylex.props(styles.toolbar)}>
+ <Text ellipsis {...stylex.props(styles.location)} title={memoryDir}>
{t('workingPanel.claudeMemory.location', { path: memoryDir })}
</Text>
<ActionIcon
@@ -147,42 +166,46 @@ export const MemoryPane = memo<MemoryPaneProps>(({ agentId, deviceId, workingDir
/>
</Flexbox>
)}
- <AsyncBoundary
- data={data}
- error={error}
- errorVariant={'inline'}
- isEmpty={!error && files.length === 0}
- isLoading={isLoading}
- empty={
- <Center flex={1} paddingBlock={24}>
- <Empty
- description={t('workingPanel.claudeMemory.empty.description')}
- icon={BrainIcon}
- title={t('workingPanel.claudeMemory.empty.title')}
- />
- </Center>
- }
- onRetry={refresh}
- >
- {groups.map((group) => (
- <SkillSection
- key={group.key}
- sectionHeader={{
- count: group.files.length,
- title: t(`workingPanel.claudeMemory.group.${group.key}`),
- }}
- >
- {group.files.map((file) => (
- <MemoryRow
- file={file}
- indexHint={t('workingPanel.claudeMemory.indexHint')}
- key={file.path}
- onOpen={openMemory}
+ <Flexbox flex={1} gap={sectionGap} {...stylex.props(styles.list)}>
+ <AsyncBoundary
+ data={data}
+ error={error}
+ errorVariant={'inline'}
+ isEmpty={!error && files.length === 0}
+ isLoading={isLoading}
+ loading={<SkeletonList compact rows={4} />}
+ empty={
+ <Center flex={1} paddingBlock={24}>
+ <Empty
+ description={t('workingPanel.claudeMemory.empty.description')}
+ icon={BrainIcon}
+ title={t('workingPanel.claudeMemory.empty.title')}
/>
- ))}
- </SkillSection>
- ))}
- </AsyncBoundary>
+ </Center>
+ }
+ onRetry={refresh}
+ >
+ {groups.map((group) => (
+ <SkillSection
+ compact
+ key={group.key}
+ sectionHeader={{
+ count: group.files.length,
+ title: t(`workingPanel.claudeMemory.group.${group.key}`),
+ }}
+ >
+ {group.files.map((file) => (
+ <MemoryRow
+ file={file}
+ indexHint={t('workingPanel.claudeMemory.indexHint')}
+ key={file.path}
+ onOpen={openMemory}
+ />
+ ))}
+ </SkillSection>
+ ))}
+ </AsyncBoundary>
+ </Flexbox>
</Flexbox>
);
});
diff --git a/src/features/Conversation/WorkingSidebar/Overview/BackgroundTasks/BackgroundTaskRow.tsx b/src/features/Conversation/WorkingSidebar/Overview/BackgroundTasks/BackgroundTaskRow.tsx
index 2dbe39af7d3..331b9e92eea 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/BackgroundTasks/BackgroundTaskRow.tsx
+++ b/src/features/Conversation/WorkingSidebar/Overview/BackgroundTasks/BackgroundTaskRow.tsx
@@ -105,37 +105,43 @@ export const BackgroundTaskRow = ({
!running && task.summary && task.summary !== task.description ? task.summary : undefined;
const visual = running ? undefined : STATUS_VISUAL[status as keyof typeof STATUS_VISUAL];
const outputFile = task.outputFile;
+ const hasActions = (!!outputFile && !!onViewOutput) || canStop;
return (
<OverviewRow
icon={TOOL_ICONS[task.toolName] ?? SquareTerminalIcon}
- iconSize={15}
title={[task.description, summary].filter(Boolean).join('\n')}
+ actions={
+ hasActions ? (
+ <>
+ {outputFile && onViewOutput && (
+ <ActionIcon
+ icon={FileTextIcon}
+ size={'small'}
+ title={t('workingPanel.overview.backgroundTasks.viewOutput')}
+ onClick={stopClick(() => onViewOutput(outputFile))}
+ />
+ )}
+ {canStop && (
+ <ActionIcon
+ disabled={stopping}
+ icon={SquareIcon}
+ loading={stopping}
+ size={'small'}
+ title={
+ stopping
+ ? t('workingPanel.overview.backgroundTasks.stopping')
+ : t('workingPanel.overview.backgroundTasks.stop')
+ }
+ onClick={stopClick(() => void stop())}
+ />
+ )}
+ </>
+ ) : undefined
+ }
trailing={
<>
<span>{elapsed}</span>
- {outputFile && onViewOutput && (
- <ActionIcon
- icon={FileTextIcon}
- size={'small'}
- title={t('workingPanel.overview.backgroundTasks.viewOutput')}
- onClick={stopClick(() => onViewOutput(outputFile))}
- />
- )}
- {canStop && (
- <ActionIcon
- disabled={stopping}
- icon={SquareIcon}
- loading={stopping}
- size={'small'}
- title={
- stopping
- ? t('workingPanel.overview.backgroundTasks.stopping')
- : t('workingPanel.overview.backgroundTasks.stop')
- }
- onClick={stopClick(() => void stop())}
- />
- )}
<Tooltip title={statusLabel}>
<span aria-label={statusLabel} role={'img'}>
{running ? (
diff --git a/src/features/Conversation/WorkingSidebar/Overview/BackgroundTasks/index.tsx b/src/features/Conversation/WorkingSidebar/Overview/BackgroundTasks/index.tsx
index 8ab1d78ab4f..745ea089a63 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/BackgroundTasks/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/Overview/BackgroundTasks/index.tsx
@@ -1,7 +1,6 @@
'use client';
import { Button, Flexbox } from '@lobehub/ui';
-import * as stylex from '@stylexjs/stylex';
import { useCallback, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -12,7 +11,8 @@ import { getLocalBackgroundTaskStopper } from '@/store/chat/slices/agentRun/acti
import { useUserStore } from '@/store/user';
import { labPreferSelectors } from '@/store/user/selectors';
-import { sectionProps, sectionStyles } from '../sectionStyles';
+import { SectionHeader } from '../SectionHeader';
+import { sectionProps } from '../sectionStyles';
import {
type BackgroundTaskItem,
groupBackgroundTasks,
@@ -88,12 +88,10 @@ const BackgroundTasksBody = ({
return (
<Flexbox {...sectionProps(afterBreak)}>
- <Flexbox horizontal align={'center'} {...stylex.props(sectionStyles.sectionHeader)} gap={6}>
- <span {...stylex.props(sectionStyles.sectionTitle)}>
- {t('workingPanel.overview.backgroundTasks.title')}
- </span>
- {running.length > 0 && <span {...stylex.props(sectionStyles.count)}>{running.length}</span>}
- </Flexbox>
+ <SectionHeader
+ count={running.length > 0 ? running.length : undefined}
+ title={t('workingPanel.overview.backgroundTasks.title')}
+ />
{running.map(renderRow)}
{finished.map(renderRow)}
{(hiddenCount > 0 || showAllFinished) && (
diff --git a/src/features/Conversation/WorkingSidebar/Overview/DeviceStatusSection.tsx b/src/features/Conversation/WorkingSidebar/Overview/DeviceStatusSection.tsx
index b898facdfc4..d8b213fd4cc 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/DeviceStatusSection.tsx
+++ b/src/features/Conversation/WorkingSidebar/Overview/DeviceStatusSection.tsx
@@ -1,13 +1,13 @@
'use client';
import type { DeviceListItem, DeviceMetricSeries } from '@lobechat/types';
-import { Button, Flexbox, Icon, Skeleton, Text } from '@lobehub/ui';
+import { Flexbox, Text } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
-import { RefreshCwIcon, TriangleAlertIcon } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
+import AsyncError from '@/components/AsyncError';
import { DeviceRunningSummaryValue } from '@/features/DeviceManager/DeviceActivity/RunningUsers';
import { useDeviceMetricSeries } from '@/features/DeviceManager/DeviceHealth/shared';
import UsageMeter, {
@@ -17,13 +17,15 @@ import UsageMeter, {
import { latestUsageView } from '@/features/DeviceManager/DeviceHealth/viewState';
import { getDeviceIcon, getPlatformLabel } from '@/features/DeviceManager/getDeviceIcon';
import { useDeviceActivityText } from '@/features/DeviceManager/useDeviceActivityText';
+import { useDensityTokens } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
-import { OverviewRow } from './OverviewRow';
-import { sectionProps, sectionStyles } from './sectionStyles';
+import { SidebarRowSkeleton } from '../DeferredSkeleton';
+import { sectionProps } from './sectionStyles';
import { useBoundDevice } from './useBoundDevice';
const styles = stylex.create({
- body: { paddingBlock: '4px', paddingInline: '8px' },
+ body: { paddingBlock: '4px', paddingInline: '6px' },
code: {
overflow: 'hidden',
fontFamily: cssVar.fontFamilyCode,
@@ -34,9 +36,9 @@ const styles = stylex.create({
infoGrid: { display: 'grid', gridTemplateColumns: 'minmax(0, 1fr) minmax(0, 1fr)', gap: '12px' },
name: {
overflow: 'hidden',
- fontSize: '13px',
+ fontSize: sidebarRow.textFontSize,
fontWeight: 600,
- lineHeight: '18px',
+ lineHeight: sidebarRow.textLineHeight,
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
},
@@ -44,7 +46,7 @@ const styles = stylex.create({
sub: {
overflow: 'hidden',
fontSize: '12px',
- lineHeight: '16px',
+ lineHeight: '18px',
color: cssVar.colorTextTertiary,
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
@@ -53,12 +55,12 @@ const styles = stylex.create({
display: 'grid',
flexShrink: 0,
placeItems: 'center',
- width: '32px',
- height: '32px',
+ width: '28px',
+ height: '28px',
borderWidth: '1px',
borderStyle: 'solid',
borderColor: cssVar.colorBorderSecondary,
- borderRadius: '9px',
+ borderRadius: '8px',
color: cssVar.colorTextSecondary,
backgroundColor: cssVar.colorFillTertiary,
backgroundImage: 'none',
@@ -78,7 +80,6 @@ interface DeviceStatusSectionProps {
*/
const DeviceStatusSection = memo<DeviceStatusSectionProps>(({ active, deviceId }) => {
const { t } = useTranslation('chat');
- const { t: tCommon } = useTranslation('common');
const bound = useBoundDevice(deviceId, active);
const device = bound.status === 'ready' ? bound.device : undefined;
const { data, error } = useDeviceMetricSeries(deviceId, device?.scope, active && !!device);
@@ -86,9 +87,7 @@ const DeviceStatusSection = memo<DeviceStatusSectionProps>(({ active, deviceId }
if (bound.status === 'loading')
return (
<Flexbox {...sectionProps()}>
- <div {...stylex.props(sectionStyles.skeleton)}>
- <Skeleton.Text rows={2} />
- </div>
+ <SidebarRowSkeleton rows={2} />
</Flexbox>
);
@@ -96,20 +95,11 @@ const DeviceStatusSection = memo<DeviceStatusSectionProps>(({ active, deviceId }
if (bound.status === 'error')
return (
<Flexbox {...sectionProps()}>
- <OverviewRow
- danger
- icon={TriangleAlertIcon}
- iconColor={cssVar.colorError}
- value={t('workingPanel.overview.deviceError')}
- trailing={
- <Button
- icon={<Icon icon={RefreshCwIcon} size={12} />}
- size={'small'}
- onClick={bound.retry}
- >
- {tCommon('retry')}
- </Button>
- }
+ <AsyncError
+ align={'start'}
+ title={t('workingPanel.overview.deviceError')}
+ variant={'inline'}
+ onRetry={bound.retry}
/>
</Flexbox>
);
@@ -131,6 +121,7 @@ interface DeviceStatusContentProps {
const DeviceStatusContent = ({ data, device, error }: DeviceStatusContentProps) => {
const { t } = useTranslation('setting');
const activityText = useDeviceActivityText(device);
+ const { gap } = useDensityTokens();
const online = (device.channels ?? []).length > 0;
const usage = latestUsageView({ data, error });
const platformLabel = getPlatformLabel(device.platform, device.architecture);
@@ -138,8 +129,8 @@ const DeviceStatusContent = ({ data, device, error }: DeviceStatusContentProps)
return (
<Flexbox {...sectionProps()} data-testid={'overview-device-status'}>
- <Flexbox className={stylex.props(styles.body).className} gap={14}>
- <Flexbox horizontal align={'center'} gap={10}>
+ <Flexbox className={stylex.props(styles.body).className} gap={12}>
+ <Flexbox horizontal align={'center'} gap={gap}>
<span {...stylex.props(styles.tile)}>{getDeviceIcon(device.platform, 16)}</span>
<Flexbox flex={1} gap={1} style={{ minWidth: 0 }}>
<span {...stylex.props(styles.name)} title={displayName}>
diff --git a/src/features/Conversation/WorkingSidebar/Overview/KeptWorktreeRows.tsx b/src/features/Conversation/WorkingSidebar/Overview/KeptWorktreeRows.tsx
index 0c91e6249be..1a68a643982 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/KeptWorktreeRows.tsx
+++ b/src/features/Conversation/WorkingSidebar/Overview/KeptWorktreeRows.tsx
@@ -16,6 +16,7 @@ import { useSingleton } from '@/hooks/useSingleton';
import { useClientDataSWR } from '@/libs/swr';
import { discardOwnedWorktree, keepOwnedWorktree } from '@/services/ownedWorktree';
import { topicService } from '@/services/topic';
+import { sidebarRow } from '@/styles/density.stylex';
import {
findRemovedWorktree,
@@ -26,7 +27,12 @@ import { OverviewRow } from './OverviewRow';
const styles = stylex.create({
// Lines up with the row's text, past its icon.
- reason: { paddingInlineStart: '36px', paddingInlineEnd: '8px', wordBreak: 'break-word' },
+ actions: { paddingInline: sidebarRow.paddingInline },
+ reason: {
+ paddingInlineStart: `calc(${sidebarRow.paddingInline} + ${sidebarRow.iconBox} + ${sidebarRow.gap})`,
+ paddingInlineEnd: sidebarRow.paddingInline,
+ wordBreak: 'break-word',
+ },
});
/**
@@ -178,7 +184,6 @@ const KeptWorktreeRows = memo<KeptWorktreeRowsProps>(({ entries, onChange, topic
<OverviewRow
icon={TriangleAlertIcon}
iconColor={cssVar.colorWarning}
- iconSize={14}
title={entry.path}
value={
entry.cleanup?.state === 'failed'
@@ -197,7 +202,12 @@ const KeptWorktreeRows = memo<KeptWorktreeRowsProps>(({ entries, onChange, topic
{entry.cleanup.reason}
</Text>
)}
- <Flexbox horizontal gap={4} justify={'flex-end'} paddingInline={8}>
+ <Flexbox
+ horizontal
+ className={stylex.props(styles.actions).className}
+ gap={4}
+ justify={'flex-end'}
+ >
{entry.cleanup?.state === 'failed' && entry.cleanup.reason && (
<Button
size={'small'}
@@ -250,7 +260,6 @@ export const RemovedWorktreeRow = memo<{ entry: OwnedWorktree }>(({ entry }) =>
return (
<OverviewRow
icon={GitBranchIcon}
- iconSize={14}
title={t('workingPanel.overview.keptWorktree.removedHint')}
value={t('workingPanel.overview.keptWorktree.removed', { branch: entry.branch ?? '' })}
/>
diff --git a/src/features/Conversation/WorkingSidebar/Overview/LinkPullRequestRow.tsx b/src/features/Conversation/WorkingSidebar/Overview/LinkPullRequestRow.tsx
index ada799bd51f..8d395e868e4 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/LinkPullRequestRow.tsx
+++ b/src/features/Conversation/WorkingSidebar/Overview/LinkPullRequestRow.tsx
@@ -16,9 +16,7 @@ export const LinkPullRequestRow = memo<LinkPullRequestRowProps>(({ onLink }) =>
return (
<OverviewRow
- weak
icon={LinkIcon}
- iconSize={14}
value={t('workingPanel.overview.pr.link')}
onClick={() => openLinkPullRequestModal(onLink)}
/>
diff --git a/src/features/Conversation/WorkingSidebar/Overview/OverviewHeader.tsx b/src/features/Conversation/WorkingSidebar/Overview/OverviewHeader.tsx
index 92c76d4e999..aaf4fc83281 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/OverviewHeader.tsx
+++ b/src/features/Conversation/WorkingSidebar/Overview/OverviewHeader.tsx
@@ -2,10 +2,12 @@ import { Github } from '@lobehub/icons';
import { Flexbox, Icon } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
-import { FolderGit2Icon, FolderIcon } from 'lucide-react';
+import { ChevronRightIcon, FolderGit2Icon, FolderIcon } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
+import { sidebarRow } from '@/styles/density.stylex';
+
const styles = stylex.create({
dot: {
flexShrink: 0,
@@ -15,27 +17,41 @@ const styles = stylex.create({
backgroundColor: cssVar.colorSuccess,
backgroundImage: 'none',
},
+ chevron: {
+ display: 'grid',
+ flexShrink: 0,
+ placeItems: 'center',
+ width: sidebarRow.iconBox,
+ height: sidebarRow.iconBox,
+ color: cssVar.colorTextTertiary,
+ },
header: {
cursor: 'pointer',
flexShrink: 0,
- paddingBlockStart: '14px',
- paddingBlockEnd: '2px',
- paddingInlineStart: '16px',
- paddingInlineEnd: '14px',
+ gap: sidebarRow.gap,
+ minHeight: '40px',
+ marginBlockStart: '4px',
+ marginBlockEnd: '8px',
+ paddingBlock: '6px',
+ paddingInline: '6px',
+ borderRadius: sidebarRow.radius,
+ transition: 'background-color 0.12s ease',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
},
identity: {
overflow: 'hidden',
display: 'flex',
flex: '1',
flexDirection: 'column',
- gap: '1px',
minWidth: '0',
},
name: {
overflow: 'hidden',
- fontSize: '14px',
+ fontSize: sidebarRow.textFontSize,
fontWeight: 600,
- lineHeight: '18px',
+ lineHeight: sidebarRow.textLineHeight,
+ color: cssVar.colorText,
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
},
@@ -45,7 +61,7 @@ const styles = stylex.create({
gap: '6px',
alignItems: 'center',
fontSize: '12px',
- lineHeight: '16px',
+ lineHeight: '18px',
color: cssVar.colorTextTertiary,
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
@@ -55,12 +71,12 @@ const styles = stylex.create({
display: 'grid',
flexShrink: 0,
placeItems: 'center',
- width: '32px',
- height: '32px',
+ width: '28px',
+ height: '28px',
borderWidth: '1px',
borderStyle: 'solid',
borderColor: cssVar.colorBorderSecondary,
- borderRadius: '9px',
+ borderRadius: '8px',
color: cssVar.colorText,
backgroundColor: cssVar.colorFillTertiary,
backgroundImage: 'none',
@@ -86,16 +102,15 @@ const OverviewHeader = memo<OverviewHeaderProps>(
horizontal
align={'center'}
className={stylex.props(styles.header).className}
- gap={10}
role={'button'}
title={path}
onClick={onClick}
>
<span {...stylex.props(styles.tile)}>
{repoType === 'github' ? (
- <Github size={18} />
+ <Github size={16} />
) : (
- <Icon icon={repoType ? FolderGit2Icon : FolderIcon} size={18} />
+ <Icon icon={repoType ? FolderGit2Icon : FolderIcon} size={16} />
)}
</span>
<span {...stylex.props(styles.identity)}>
@@ -116,6 +131,9 @@ const OverviewHeader = memo<OverviewHeaderProps>(
</span>
</span>
</span>
+ <span {...stylex.props(styles.chevron)}>
+ <Icon icon={ChevronRightIcon} size={14} />
+ </span>
</Flexbox>
);
},
diff --git a/src/features/Conversation/WorkingSidebar/Overview/OverviewRow.tsx b/src/features/Conversation/WorkingSidebar/Overview/OverviewRow.tsx
index 27bbcb2d487..033921e7c9d 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/OverviewRow.tsx
+++ b/src/features/Conversation/WorkingSidebar/Overview/OverviewRow.tsx
@@ -4,12 +4,46 @@ import * as stylex from '@stylexjs/stylex';
import { ChevronRightIcon, ChevronsUpDownIcon } from 'lucide-react';
import { memo, type ReactNode } from 'react';
+import { useDensityTokens } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
import { sx } from '@/styles/sx';
+import { overviewRowMarker } from './markers.stylex';
+
export const rowStyles = stylex.create({
+ actions: {
+ position: 'absolute',
+ insetBlockStart: '50%',
+ insetInlineEnd: '2px',
+ transform: 'translateY(-50%)',
+ display: 'flex',
+ gap: '2px',
+ alignItems: 'center',
+ opacity: {
+ 'default': 0,
+ [stylex.when.ancestor(':hover', overviewRowMarker)]: 1,
+ [stylex.when.ancestor(':focus-within', overviewRowMarker)]: 1,
+ ':has([aria-expanded="true"])': 1,
+ },
+ pointerEvents: {
+ 'default': 'none',
+ [stylex.when.ancestor(':hover', overviewRowMarker)]: 'auto',
+ [stylex.when.ancestor(':focus-within', overviewRowMarker)]: 'auto',
+ ':has([aria-expanded="true"])': 'auto',
+ },
+ transition: 'opacity 0.12s ease',
+ },
changeAdditions: { fontVariantNumeric: 'tabular-nums', color: cssVar.colorSuccess },
changeDeletions: { fontVariantNumeric: 'tabular-nums', color: cssVar.colorError },
icon: { flexShrink: 0, color: cssVar.colorTextTertiary },
+ iconBox: {
+ display: 'grid',
+ flexShrink: 0,
+ placeItems: 'center',
+ width: sidebarRow.iconBox,
+ height: sidebarRow.iconBox,
+ color: cssVar.colorTextTertiary,
+ },
num: {
marginInlineEnd: '5px',
fontFamily: cssVar.fontFamilyCode,
@@ -19,11 +53,14 @@ export const rowStyles = stylex.create({
},
row: {
cursor: 'pointer',
+ position: 'relative',
flexShrink: 0,
- minHeight: '32px',
- paddingBlock: '5px',
- paddingInline: '8px',
- borderRadius: '8px',
+ gap: sidebarRow.gap,
+ minHeight: sidebarRow.height,
+ paddingBlock: 0,
+ paddingInline: sidebarRow.paddingInline,
+ borderRadius: sidebarRow.radius,
+ color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
transition: 'background-color 0.12s ease',
backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
backgroundImage: { 'default': null, ':hover': 'none' },
@@ -31,6 +68,7 @@ export const rowStyles = stylex.create({
rowAction: { fontSize: '12px', fontWeight: 500, color: cssVar.colorTextSecondary },
rowStatic: {
cursor: 'default',
+ color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorTextSecondary },
backgroundColor: { 'default': null, ':hover': 'transparent' },
backgroundImage: { 'default': null, ':hover': 'none' },
},
@@ -39,84 +77,92 @@ export const rowStyles = stylex.create({
flexShrink: 0,
gap: '6px',
alignItems: 'center',
- fontSize: '12px',
+ fontSize: sidebarRow.metaFontSize,
fontVariantNumeric: 'tabular-nums',
lineHeight: '18px',
color: cssVar.colorTextTertiary,
},
+ rowTrailingConcealed: {
+ visibility: {
+ default: null,
+ [stylex.when.ancestor(':hover', overviewRowMarker)]: 'hidden',
+ [stylex.when.ancestor(':focus-within', overviewRowMarker)]: 'hidden',
+ },
+ },
rowValue: {
overflow: 'hidden',
flex: '1',
minWidth: '0',
- fontSize: '13px',
- lineHeight: '20px',
- color: cssVar.colorText,
+ fontSize: sidebarRow.textFontSize,
+ lineHeight: sidebarRow.textLineHeight,
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
},
rowValueDanger: { color: cssVar.colorError },
- rowValueWeak: { fontSize: '12.5px', color: cssVar.colorTextSecondary },
});
export interface OverviewRowProps {
+ actions?: ReactNode;
danger?: boolean;
icon?: IconProps['icon'];
iconColor?: string;
iconNode?: ReactNode;
- iconSize?: number;
interactive?: boolean;
onClick?: () => void;
spin?: boolean;
title?: string;
trailing?: ReactNode;
value: ReactNode;
- weak?: boolean;
}
export const OverviewRow = memo<OverviewRowProps>(
({
+ actions,
danger,
icon,
iconColor,
iconNode,
- iconSize = 16,
interactive,
onClick,
spin,
title,
trailing,
value,
- weak,
- }) => (
- <Flexbox
- horizontal
- align={'center'}
- {...stylex.props(rowStyles.row, !onClick && !interactive && rowStyles.rowStatic)}
- gap={10}
- role={onClick || interactive ? 'button' : undefined}
- onClick={onClick}
- >
- {iconNode ?? (
- <Icon
- icon={icon!}
- size={iconSize}
- spin={spin}
- {...sx(rowStyles.icon, iconColor ? { color: iconColor } : undefined)}
- />
- )}
- <span
- title={title}
+ }) => {
+ const { iconSize } = useDensityTokens();
+
+ return (
+ <Flexbox
+ horizontal
+ align={'center'}
{...stylex.props(
- rowStyles.rowValue,
- danger && rowStyles.rowValueDanger,
- weak && rowStyles.rowValueWeak,
+ rowStyles.row,
+ !onClick && !interactive && rowStyles.rowStatic,
+ overviewRowMarker,
)}
+ role={onClick || interactive ? 'button' : undefined}
+ onClick={onClick}
>
- {value}
- </span>
- {trailing ? <span {...stylex.props(rowStyles.rowTrailing)}>{trailing}</span> : null}
- </Flexbox>
- ),
+ <span {...sx(rowStyles.iconBox, iconColor ? { color: iconColor } : undefined)}>
+ {iconNode ?? <Icon icon={icon!} size={iconSize} spin={spin} />}
+ </span>
+ <span
+ title={title}
+ {...stylex.props(rowStyles.rowValue, danger && rowStyles.rowValueDanger)}
+ >
+ {value}
+ </span>
+ {trailing ? (
+ <span
+ {...stylex.props(rowStyles.rowTrailing, !!actions && rowStyles.rowTrailingConcealed)}
+ >
+ {trailing}
+ </span>
+ ) : null}
+ {actions ? <span {...stylex.props(rowStyles.actions)}>{actions}</span> : null}
+ </Flexbox>
+ );
+ },
);
OverviewRow.displayName = 'OverviewRow';
diff --git a/src/features/Conversation/WorkingSidebar/Overview/PullRequestRow.tsx b/src/features/Conversation/WorkingSidebar/Overview/PullRequestRow.tsx
index 9e138a54934..58ee44ca72a 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/PullRequestRow.tsx
+++ b/src/features/Conversation/WorkingSidebar/Overview/PullRequestRow.tsx
@@ -11,11 +11,11 @@ import {
getPullRequestState,
PR_STATE_VISUAL,
} from '@/features/AgentSidebar/Topic/List/Item/metaCardData';
-import { sx } from '@/styles/sx';
import { shouldShowCiLabel } from './overviewData';
import { OverviewRow, rowStyles } from './OverviewRow';
import { sectionStyles } from './sectionStyles';
+import { statusTint } from './statusTint';
interface PullRequestRowProps {
/** Better Coding Experience: the row's "⋯" menu, after the CI pill. */
@@ -40,6 +40,7 @@ const PullRequestRow = memo<PullRequestRowProps>(
<Tooltip title={tooltip ?? `#${pullRequest.number} ${pullRequest.title}`}>
<div>
<OverviewRow
+ actions={actions}
icon={prVisual.icon}
iconColor={prVisual.color}
trailing={
@@ -50,15 +51,15 @@ const PullRequestRow = memo<PullRequestRowProps>(
aria-label={t('workingPanel.overview.pr.unvouched')}
color={cssVar.colorWarning}
icon={TriangleAlertIcon}
- size={13}
+ size={14}
/>
</Tooltip>
)}
<span
- {...sx(sectionStyles.pill, {
- background: `color-mix(in srgb, 12%, transparent)`,
- color: ci.color,
- })}
+ {...stylex.props(
+ sectionStyles.pill,
+ sectionStyles.pillTone(ci.color, statusTint(ci.color)),
+ )}
>
<Icon icon={ci.icon} size={12} />
{shouldShowCiLabel(ciStatus)
@@ -67,7 +68,6 @@ const PullRequestRow = memo<PullRequestRowProps>(
)
: null}
</span>
- {actions}
</>
}
value={
diff --git a/src/features/Conversation/WorkingSidebar/Overview/SectionHeader.tsx b/src/features/Conversation/WorkingSidebar/Overview/SectionHeader.tsx
new file mode 100644
index 00000000000..3d2914d4df4
--- /dev/null
+++ b/src/features/Conversation/WorkingSidebar/Overview/SectionHeader.tsx
@@ -0,0 +1,60 @@
+import { Icon } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
+import { ChevronDownIcon } from 'lucide-react';
+import { memo, type ReactNode } from 'react';
+
+import { sectionHeaderMarker } from './markers.stylex';
+import { sectionStyles } from './sectionStyles';
+
+interface SectionHeaderProps {
+ actions?: ReactNode;
+ collapsed?: boolean;
+ controls?: string;
+ count?: ReactNode;
+ meta?: ReactNode;
+ onToggle?: () => void;
+ title: ReactNode;
+ titleAttr?: string;
+}
+
+export const SectionHeader = memo<SectionHeaderProps>(
+ ({ actions, collapsed = false, controls, count, meta, onToggle, title, titleAttr }) => {
+ const label = (
+ <>
+ <span {...stylex.props(sectionStyles.sectionTitle)} title={titleAttr}>
+ {title}
+ </span>
+ {meta}
+ {count !== undefined && count !== null && (
+ <span {...stylex.props(sectionStyles.count)}>{count}</span>
+ )}
+ </>
+ );
+
+ return (
+ <div {...stylex.props(sectionStyles.sectionHeader, sectionHeaderMarker)}>
+ {onToggle ? (
+ <button
+ aria-controls={controls}
+ aria-expanded={!collapsed}
+ type={'button'}
+ {...stylex.props(sectionStyles.toggle)}
+ onClick={onToggle}
+ >
+ {label}
+ <span
+ {...stylex.props(sectionStyles.chevron, collapsed && sectionStyles.chevronCollapsed)}
+ >
+ <Icon icon={ChevronDownIcon} size={12} />
+ </span>
+ </button>
+ ) : (
+ label
+ )}
+ {actions && <span {...stylex.props(sectionStyles.actions)}>{actions}</span>}
+ </div>
+ );
+ },
+);
+
+SectionHeader.displayName = 'OverviewSectionHeader';
diff --git a/src/features/Conversation/WorkingSidebar/Overview/TerminalRow.tsx b/src/features/Conversation/WorkingSidebar/Overview/TerminalRow.tsx
index a854f1ab6ad..82336e936b7 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/TerminalRow.tsx
+++ b/src/features/Conversation/WorkingSidebar/Overview/TerminalRow.tsx
@@ -17,9 +17,7 @@ export const TerminalRow = memo(() => {
return (
<OverviewRow
- weak
icon={SquareTerminalIcon}
- iconSize={15}
trailing={<ChevronRight />}
value={t('terminalPanel.title')}
onClick={() => toggleTerminalPanel(true)}
diff --git a/src/features/Conversation/WorkingSidebar/Overview/__tests__/statusTint.test.ts b/src/features/Conversation/WorkingSidebar/Overview/__tests__/statusTint.test.ts
new file mode 100644
index 00000000000..4a4f0bacd3d
--- /dev/null
+++ b/src/features/Conversation/WorkingSidebar/Overview/__tests__/statusTint.test.ts
@@ -0,0 +1,13 @@
+import { describe, expect, it } from 'vitest';
+
+import { getCiVisual } from '@/features/AgentSidebar/Topic/List/Item/metaCardData';
+
+import { statusTint } from '../statusTint';
+
+describe('statusTint', () => {
+ it('mixes the status color into the chip background', () => {
+ const { color } = getCiVisual('failure');
+
+ expect(statusTint(color)).toBe(`color-mix(in srgb, ${color} 14%, transparent)`);
+ });
+});
diff --git a/src/features/Conversation/WorkingSidebar/Overview/index.tsx b/src/features/Conversation/WorkingSidebar/Overview/index.tsx
index adf3da60d24..59e8077e4c9 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/Overview/index.tsx
@@ -1,7 +1,7 @@
'use client';
import type { DeviceGitLinkedPullRequest } from '@lobechat/types';
-import { Button, Empty, Flexbox, Icon, Skeleton, toast } from '@lobehub/ui';
+import { Button, Center, Empty, Flexbox, toast } from '@lobehub/ui';
import { SkillsIcon } from '@lobehub/ui/icons';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
@@ -15,12 +15,11 @@ import {
GitBranchIcon,
GitForkIcon,
LaptopIcon,
- RefreshCwIcon,
- TriangleAlertIcon,
} from 'lucide-react';
import { memo, useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import AsyncError from '@/components/AsyncError';
import RingLoadingIcon from '@/components/RingLoading';
import ThreadListSection from '@/features/AgentSidebar/Topic/TopicListContent/ThreadList/ThreadListSection';
import { TopicBackgroundActivity } from '@/features/BackgroundActivity/TopicSection';
@@ -42,7 +41,9 @@ import {
} from '@/store/device';
import { useUserStore } from '@/store/user';
import { labPreferSelectors } from '@/store/user/selectors';
+import { sidebarRow } from '@/styles/density.stylex';
+import { SidebarRowSkeleton } from '../DeferredSkeleton';
import GoalSection from '../GoalSection';
import ProgressSection from '../ProgressSection';
import { toLinkedPullRequest } from '../PullRequest/useSidebarPullRequests';
@@ -60,16 +61,16 @@ import { ChevronRight, OverviewRow, PickerGlyph, rowStyles } from './OverviewRow
import PortSwitcher from './PortSwitcher';
import PullRequestRow from './PullRequestRow';
import PullRequestRowMenu from './PullRequestRowMenu';
-import { sectionProps, sectionStyles } from './sectionStyles';
+import { SectionHeader } from './SectionHeader';
+import { sectionProps } from './sectionStyles';
import { TerminalRow } from './TerminalRow';
const styles = stylex.create({
- body: { overflowY: 'auto' },
- emptyWorkspace: {
- flexShrink: 0,
- paddingBlockStart: '28px',
- paddingBlockEnd: '30px',
- paddingInline: '20px',
+ body: {
+ overflowY: 'auto',
+ paddingBlockStart: sidebarRow.paneBlockStart,
+ paddingBlockEnd: sidebarRow.paneBlockEnd,
+ paddingInline: sidebarRow.paneInline,
},
});
@@ -123,7 +124,6 @@ const Overview = memo<OverviewProps>(
}) => {
const { t } = useTranslation('chat');
const { t: tDevice } = useTranslation('device');
- const { t: tCommon } = useTranslation('common');
const isHetero = useAgentStore(agentSelectors.isCurrentAgentHeterogeneous);
const tunnelsEnabled = useUserStore(labPreferSelectors.enableDeviceTunnel);
const topicId = useChatStore((s) => s.activeTopicId);
@@ -359,7 +359,6 @@ const Overview = memo<OverviewProps>(
<OverviewRow
icon={ArrowDownIcon}
iconColor={cssVar.colorError}
- iconSize={14}
value={t('workingPanel.overview.sync.behind', { count: aheadBehind!.behind })}
trailing={
pulling ? (
@@ -377,7 +376,6 @@ const Overview = memo<OverviewProps>(
<OverviewRow
icon={ArrowUpIcon}
iconColor={cssVar.colorInfo}
- iconSize={14}
value={t('workingPanel.overview.sync.ahead', { count: aheadBehind!.ahead })}
trailing={
pushing ? (
@@ -448,24 +446,14 @@ const Overview = memo<OverviewProps>(
const workspaceSection = repoType ? (
isGitLoading ? (
- <div {...stylex.props(sectionStyles.skeleton)}>
- <Skeleton.Text rows={3} />
- </div>
+ <SidebarRowSkeleton rows={3} />
) : gitError ? (
- <OverviewRow
- danger
- icon={TriangleAlertIcon}
- iconColor={cssVar.colorError}
- value={t('workingPanel.overview.environmentError')}
- trailing={
- <Button
- icon={<Icon icon={RefreshCwIcon} size={12} />}
- size={'small'}
- onClick={() => void refreshGit()}
- >
- {tCommon('retry')}
- </Button>
- }
+ <AsyncError
+ align={'start'}
+ error={gitError}
+ title={t('workingPanel.overview.environmentError')}
+ variant={'inline'}
+ onRetry={() => void refreshGit()}
/>
) : (
gitRows
@@ -517,12 +505,13 @@ const Overview = memo<OverviewProps>(
<TopicBackgroundActivity topicId={topicId} />
{showEmptyWorkspace && (
- <Empty
- className={stylex.props(styles.emptyWorkspace).className}
- description={t('workingPanel.overview.workspace.emptyDesc')}
- icon={LaptopIcon}
- title={t('workingPanel.overview.workspace.empty')}
- />
+ <Center paddingBlock={24}>
+ <Empty
+ description={t('workingPanel.overview.workspace.emptyDesc')}
+ icon={LaptopIcon}
+ title={t('workingPanel.overview.workspace.empty')}
+ />
+ </Center>
)}
<GoalSection className={sectionProps(showEmptyWorkspace).className} />
@@ -530,24 +519,14 @@ const Overview = memo<OverviewProps>(
{visibleWorks.length > 0 && (
<Flexbox {...sectionProps(showEmptyWorkspace)}>
- <Flexbox
- horizontal
- align={'center'}
- {...stylex.props(sectionStyles.sectionHeader)}
- justify={'space-between'}
- >
- <span {...stylex.props(sectionStyles.sectionTitle)}>
- {t('workingPanel.overview.outputs')}
- </span>
- <Button
- outdent={'end'}
- size={'small'}
- type={'text'}
- onClick={() => onOpenTab('works')}
- >
- {t('workingPanel.overview.viewAll')}
- </Button>
- </Flexbox>
+ <SectionHeader
+ title={t('workingPanel.overview.outputs')}
+ actions={
+ <Button size={'small'} type={'text'} onClick={() => onOpenTab('works')}>
+ {t('workingPanel.overview.viewAll')}
+ </Button>
+ }
+ />
{visibleWorks.map((work) => (
<WorkSummaryCard item={work} key={work.id} variant={'inline'} />
))}
@@ -555,12 +534,13 @@ const Overview = memo<OverviewProps>(
)}
{!environmentAvailable && !topicId && visibleWorks.length === 0 && (
- <Empty
- className={sectionProps().className}
- description={t('workingPanel.overview.empty')}
- icon={BoxesIcon}
- title={t('workingPanel.overview.emptyTitle')}
- />
+ <Center {...sectionProps()} paddingBlock={24}>
+ <Empty
+ description={t('workingPanel.overview.empty')}
+ icon={BoxesIcon}
+ title={t('workingPanel.overview.emptyTitle')}
+ />
+ </Center>
)}
{/* Claude Code background tasks; async subagents stay in the thread list below. */}
@@ -577,27 +557,21 @@ const Overview = memo<OverviewProps>(
<Flexbox {...sectionProps(showEmptyWorkspace)}>
{hasWorkspace && (
<OverviewRow
- weak
icon={FilesIcon}
- iconSize={15}
trailing={<ChevronRight />}
value={t('workingPanel.overview.files')}
onClick={() => onOpenTab('files')}
/>
)}
<OverviewRow
- weak
icon={SkillsIcon}
- iconSize={15}
trailing={<ChevronRight />}
value={t('workingPanel.resources.filter.skills')}
onClick={() => onOpenTab('skills')}
/>
{!isHetero && (
<OverviewRow
- weak
icon={FileTextIcon}
- iconSize={15}
trailing={<ChevronRight />}
value={t('workingPanel.resources.filter.documents')}
onClick={() => onOpenTab('documents')}
diff --git a/src/features/Conversation/WorkingSidebar/Overview/markers.stylex.ts b/src/features/Conversation/WorkingSidebar/Overview/markers.stylex.ts
index c6512470f6f..70fd34db16d 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/markers.stylex.ts
+++ b/src/features/Conversation/WorkingSidebar/Overview/markers.stylex.ts
@@ -2,3 +2,5 @@ import * as stylex from '@stylexjs/stylex';
export const sectionMarker = stylex.defineMarker();
export const sectionAfterBreakMarker = stylex.defineMarker();
+export const sectionHeaderMarker = stylex.defineMarker();
+export const overviewRowMarker = stylex.defineMarker();
diff --git a/src/features/Conversation/WorkingSidebar/Overview/sectionStyles.ts b/src/features/Conversation/WorkingSidebar/Overview/sectionStyles.ts
index b1cb0c6133b..735b63fcc0c 100644
--- a/src/features/Conversation/WorkingSidebar/Overview/sectionStyles.ts
+++ b/src/features/Conversation/WorkingSidebar/Overview/sectionStyles.ts
@@ -1,72 +1,122 @@
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
+import { sidebarRow } from '@/styles/density.stylex';
import { sx } from '@/styles/sx';
-import { sectionAfterBreakMarker, sectionMarker } from './markers.stylex';
+import { sectionAfterBreakMarker, sectionHeaderMarker, sectionMarker } from './markers.stylex';
export const sectionStyles = stylex.create({
+ actions: {
+ display: 'flex',
+ flexShrink: 0,
+ gap: '2px',
+ alignItems: 'center',
+ marginInlineStart: 'auto',
+ opacity: {
+ default: 0,
+ [stylex.when.ancestor(':hover', sectionHeaderMarker)]: 1,
+ [stylex.when.ancestor(':focus-within', sectionHeaderMarker)]: 1,
+ },
+ transition: 'opacity 0.12s ease',
+ },
+ chevron: {
+ display: 'flex',
+ flexShrink: 0,
+ opacity: {
+ default: 0,
+ [stylex.when.ancestor(':hover', sectionHeaderMarker)]: 1,
+ [stylex.when.ancestor(':focus-within', sectionHeaderMarker)]: 1,
+ },
+ transition: 'opacity 0.15s, transform 0.15s cubic-bezier(0.2, 0, 0, 1)',
+ },
+ chevronCollapsed: { transform: 'rotate(-90deg)', opacity: 1 },
count: {
- paddingBlock: '1px',
- paddingInline: '6px',
- borderRadius: '4px',
- fontFamily: cssVar.fontFamilyCode,
- fontSize: '11px',
- fontWeight: 500,
- color: cssVar.colorTextSecondary,
+ flexShrink: 0,
+ fontSize: sidebarRow.labelFontSize,
+ fontWeight: 400,
+ fontVariantNumeric: 'tabular-nums',
+ color: cssVar.colorTextTertiary,
textTransform: 'none',
letterSpacing: 0,
- backgroundColor: cssVar.colorFillSecondary,
- backgroundImage: 'none',
},
pill: {
display: 'inline-flex',
+ flexShrink: 0,
gap: '4px',
alignItems: 'center',
height: '20px',
- paddingInline: '7px',
- borderRadius: '6px',
- fontSize: '11.5px',
+ paddingInline: '6px',
+ borderRadius: '4px',
+ fontSize: '11px',
fontWeight: 500,
lineHeight: '20px',
},
+ pillTone: (color: string, backgroundColor: string) => ({
+ color,
+ backgroundColor,
+ }),
// Emotion's `& + &` divided a section from the one directly before it. StyleX only has
// `~`, so a section that follows a non-section sibling (a header, an empty state) passes
- // `afterBreak` and keys its divider on a marker no section before that break carries.
+ // `afterBreak` and keys its spacing on a marker no section before that break carries.
section: {
+ display: 'flex',
+ flexDirection: 'column',
flexShrink: 0,
- paddingBlock: '8px',
- paddingInline: '8px',
- borderBlockStartWidth: {
+ gap: '1px',
+ marginBlockStart: {
default: null,
- [stylex.when.siblingBefore(':is(*)', sectionMarker)]: '1px',
- },
- borderBlockStartStyle: {
- default: null,
- [stylex.when.siblingBefore(':is(*)', sectionMarker)]: 'solid',
- },
- borderBlockStartColor: {
- default: null,
- [stylex.when.siblingBefore(':is(*)', sectionMarker)]: cssVar.colorBorderSecondary,
+ [stylex.when.siblingBefore(':is(*)', sectionMarker)]: sidebarRow.sectionGap,
},
},
sectionAfterBreak: {
- borderBlockStartWidth: {
- default: null,
- [stylex.when.siblingBefore(':is(*)', sectionAfterBreakMarker)]: '1px',
- },
- borderBlockStartStyle: {
+ marginBlockStart: {
default: null,
- [stylex.when.siblingBefore(':is(*)', sectionAfterBreakMarker)]: 'solid',
- },
- borderBlockStartColor: {
- default: null,
- [stylex.when.siblingBefore(':is(*)', sectionAfterBreakMarker)]: cssVar.colorBorderSecondary,
+ [stylex.when.siblingBefore(':is(*)', sectionAfterBreakMarker)]: sidebarRow.sectionGap,
},
},
- sectionHeader: { paddingBlockStart: 0, paddingBlockEnd: '4px', paddingInline: '8px' },
- sectionTitle: { fontSize: '10.5px', fontWeight: 600, color: cssVar.colorTextTertiary },
- skeleton: { paddingBlock: '4px', paddingInline: '8px' },
+ sectionHeader: {
+ display: 'flex',
+ flexDirection: 'row',
+ flexShrink: 0,
+ gap: '4px',
+ alignItems: 'center',
+ height: sidebarRow.sectionHeaderHeight,
+ paddingInline: '6px',
+ },
+ sectionTitle: {
+ overflow: 'hidden',
+ fontSize: sidebarRow.labelFontSize,
+ fontWeight: sidebarRow.labelFontWeight,
+ lineHeight: sidebarRow.textLineHeight,
+ color: cssVar.colorTextTertiary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ toggle: {
+ cursor: 'pointer',
+ display: 'flex',
+ flex: '1',
+ gap: '4px',
+ alignItems: 'center',
+ minWidth: 0,
+ height: '100%',
+ margin: 0,
+ padding: 0,
+ borderWidth: 0,
+ borderStyle: 'none',
+ borderColor: 'currentcolor',
+ font: 'inherit',
+ color: 'inherit',
+ textAlign: 'start',
+ backgroundColor: 'transparent',
+ backgroundImage: 'none',
+ borderRadius: sidebarRow.radius,
+ outlineWidth: { 'default': null, ':focus-visible': '2px' },
+ outlineStyle: { 'default': null, ':focus-visible': 'solid' },
+ outlineColor: { 'default': null, ':focus-visible': cssVar.colorPrimaryBorder },
+ outlineOffset: { 'default': null, ':focus-visible': '-2px' },
+ },
});
export const sectionProps = (afterBreak = false) =>
diff --git a/src/features/Conversation/WorkingSidebar/Overview/statusTint.ts b/src/features/Conversation/WorkingSidebar/Overview/statusTint.ts
new file mode 100644
index 00000000000..801b0ad47e0
--- /dev/null
+++ b/src/features/Conversation/WorkingSidebar/Overview/statusTint.ts
@@ -0,0 +1 @@
+export const statusTint = (color: string) => `color-mix(in srgb, ${color} 14%, transparent)`;
diff --git a/src/features/Conversation/WorkingSidebar/ProgressSection/index.tsx b/src/features/Conversation/WorkingSidebar/ProgressSection/index.tsx
index a00548aa694..bcb9d705b3d 100644
--- a/src/features/Conversation/WorkingSidebar/ProgressSection/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/ProgressSection/index.tsx
@@ -1,18 +1,21 @@
-import { Checkbox, Flexbox, Icon } from '@lobehub/ui';
+import { Checkbox, Icon } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
-import { ChevronDown, ChevronUp, CircleArrowRight } from 'lucide-react';
-import { type KeyboardEvent, memo, useCallback, useId, useMemo, useState } from 'react';
+import { CircleArrowRight } from 'lucide-react';
+import { memo, useCallback, useId, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useChatStore } from '@/store/chat';
import { selectCurrentTurnTodosFromMessages } from '@/store/chat/slices/message/selectors/dbMessage';
import { messageMapKey } from '@/store/chat/utils/messageMapKey';
+import { useDensityTokens } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
import { useAgentContext } from '../../useAgentContext';
+import { SectionHeader } from '../Overview/SectionHeader';
import { normalizeTaskProgress } from './taskProgressAdapter';
-const RING_SIZE = 14;
+const RING_SIZE = 12;
const RING_STROKE = 2;
const RING_RADIUS = (RING_SIZE - RING_STROKE) / 2;
const RING_CIRCUM = 2 * Math.PI * RING_RADIUS;
@@ -25,46 +28,19 @@ const styles = stylex.create({
paddingBlockEnd: 0,
opacity: 0,
},
- count: {
- flexShrink: 0,
- paddingBlock: '1px',
- paddingInline: '6px',
- borderRadius: '4px',
- fontFamily: cssVar.fontFamilyCode,
- fontSize: '11px',
- color: cssVar.colorTextSecondary,
- backgroundColor: cssVar.colorFillSecondary,
- backgroundImage: 'none',
- },
expanded: { gridTemplateRows: '1fr', opacity: 1 },
- header: { fontSize: '10.5px', fontWeight: 600, color: cssVar.colorTextSecondary },
- headerRow: {
- cursor: 'pointer',
- userSelect: 'none',
- paddingBlockStart: '4px',
- paddingBlockEnd: '6px',
- paddingInline: '10px',
- borderRadius: '6px',
- transition: 'background-color 0.12s ease',
- backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
- backgroundImage: { 'default': null, ':hover': 'none' },
- outlineWidth: { 'default': null, ':focus-visible': '2px' },
- outlineStyle: { 'default': null, ':focus-visible': 'solid' },
- outlineColor: { 'default': null, ':focus-visible': cssVar.colorPrimaryBorder },
- outlineOffset: { 'default': null, ':focus-visible': '2px' },
- },
itemRow: {
- paddingBlock: '6px',
- paddingInline: '4px',
- borderBlockEndWidth: '1px',
- borderBlockEndStyle: { 'default': 'dashed', ':last-child': 'none' },
- borderBlockEndColor: cssVar.colorBorderSecondary,
- fontSize: '13px',
+ gap: sidebarRow.gap,
+ alignItems: 'center',
+ minHeight: sidebarRow.height,
+ paddingInline: '8px',
+ fontSize: sidebarRow.textFontSize,
+ lineHeight: sidebarRow.textLineHeight,
},
listContainer: {
display: 'grid',
- paddingBlock: '4px',
- paddingInline: '10px',
+ paddingBlock: 0,
+ paddingInline: 0,
transition: `grid-template-rows 0.25s ${cssVar.motionEaseInOut}, opacity 0.2s ${cssVar.motionEaseInOut}, padding 0.2s ${cssVar.motionEaseInOut}`,
},
listInner: {
@@ -75,8 +51,8 @@ const styles = stylex.create({
flexDirection: 'column',
minHeight: 0,
},
- processingRow: { display: 'flex', gap: '6px', alignItems: 'center' },
- ring: { transform: 'rotate(-90deg)', flexShrink: 0 },
+ processingRow: { display: 'flex' },
+ ring: { flexShrink: 0, transform: 'rotate(-90deg)' },
ringProgress: { transition: 'stroke-dashoffset 240ms ease, stroke 240ms ease' },
ringTrack: { stroke: cssVar.colorFillSecondary },
textCompleted: { color: cssVar.colorTextQuaternary, textDecoration: 'line-through' },
@@ -87,6 +63,7 @@ const styles = stylex.create({
const ProgressSection = memo<{ className?: string }>(({ className }) => {
const { t } = useTranslation('chat');
const [expanded, setExpanded] = useState(true);
+ const { iconSize } = useDensityTokens();
const context = useAgentContext();
const chatKey = messageMapKey(context);
const dbMessages = useChatStore((s) => s.dbMessagesMap[chatKey]);
@@ -102,15 +79,6 @@ const ProgressSection = memo<{ className?: string }>(({ className }) => {
const completed = items.filter((item) => item.status === 'completed').length;
const toggleExpanded = useCallback(() => setExpanded((prev) => !prev), []);
- const handleHeaderKeyDown = useCallback(
- (event: KeyboardEvent<HTMLDivElement>) => {
- if (event.key === 'Enter' || event.key === ' ') {
- event.preventDefault();
- toggleExpanded();
- }
- },
- [toggleExpanded],
- );
if (total === 0) return null;
@@ -120,20 +88,12 @@ const ProgressSection = memo<{ className?: string }>(({ className }) => {
return (
<div className={className} data-testid="workspace-progress">
- <Flexbox
- horizontal
- align="center"
- aria-controls={listId}
- aria-expanded={expanded}
- {...stylex.props(styles.headerRow)}
- gap={8}
- justify="space-between"
- role="button"
- tabIndex={0}
- onClick={toggleExpanded}
- onKeyDown={handleHeaderKeyDown}
- >
- <Flexbox horizontal align="center" gap={8} style={{ flex: 1, minWidth: 0 }}>
+ <SectionHeader
+ collapsed={!expanded}
+ controls={listId}
+ count={`${completed}/${total}`}
+ title={t('workingPanel.progress')}
+ meta={
<svg {...stylex.props(styles.ring)} height={RING_SIZE} width={RING_SIZE}>
<circle
{...stylex.props(styles.ringTrack)}
@@ -156,17 +116,9 @@ const ProgressSection = memo<{ className?: string }>(({ className }) => {
strokeWidth={RING_STROKE}
/>
</svg>
- <span {...stylex.props(styles.header)}>{t('workingPanel.progress')}</span>
- <span {...stylex.props(styles.count)}>
- {completed}/{total}
- </span>
- </Flexbox>
- <Icon
- icon={expanded ? ChevronUp : ChevronDown}
- size={14}
- style={{ color: cssVar.colorTextTertiary, flexShrink: 0 }}
- />
- </Flexbox>
+ }
+ onToggle={toggleExpanded}
+ />
<div
{...stylex.props(styles.listContainer, expanded ? styles.expanded : styles.collapsed)}
@@ -182,7 +134,7 @@ const ProgressSection = memo<{ className?: string }>(({ className }) => {
<div {...stylex.props(styles.itemRow, styles.processingRow)} key={item.id ?? index}>
<Icon
icon={CircleArrowRight}
- size={17}
+ size={iconSize}
style={{ color: cssVar.colorTextSecondary }}
/>
<span {...stylex.props(styles.textProcessing)}>{item.text}</span>
diff --git a/src/features/Conversation/WorkingSidebar/PullRequest/ActivityTimeline.tsx b/src/features/Conversation/WorkingSidebar/PullRequest/ActivityTimeline.tsx
index bb12b294470..d2555fadad1 100644
--- a/src/features/Conversation/WorkingSidebar/PullRequest/ActivityTimeline.tsx
+++ b/src/features/Conversation/WorkingSidebar/PullRequest/ActivityTimeline.tsx
@@ -12,6 +12,8 @@ import { CheckIcon, CircleSlashIcon, EyeIcon, GitCommitHorizontalIcon, XIcon } f
import { memo, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { useDensityTokens } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
import { sx } from '@/styles/sx';
import { openTrustedExternalUrl } from '@/utils/openTrustedExternalUrl';
@@ -23,23 +25,23 @@ const styles = stylex.create({
comment: {
paddingBlock: '6px',
paddingInline: '8px',
- borderRadius: '8px',
+ borderRadius: sidebarRow.radius,
backgroundColor: { 'default': null, ':hover': cssVar.colorFillQuaternary },
backgroundImage: { 'default': null, ':hover': 'none' },
},
commentBody: {
overflow: 'hidden',
minWidth: 0,
- fontSize: '13px',
- lineHeight: '20px',
+ fontSize: sidebarRow.textFontSize,
+ lineHeight: sidebarRow.textLineHeight,
overflowWrap: 'anywhere',
},
commentBodyWrap: { overflow: 'hidden', minWidth: 0, paddingInlineStart: '26px' },
commentHead: { fontSize: '12px', color: cssVar.colorTextTertiary },
commentHeadAuthor: { fontWeight: 500, color: cssVar.colorText },
- composer: { paddingBlockStart: '4px', paddingBlockEnd: 0, paddingInline: '8px' },
+ composer: { paddingBlockStart: '4px', paddingBlockEnd: 0, paddingInline: '4px' },
event: {
- minHeight: '28px',
+ minHeight: sidebarRow.height,
paddingBlock: '2px',
paddingInline: '8px',
fontSize: '12px',
@@ -136,6 +138,7 @@ const ActivityTimeline = memo<ActivityTimelineProps>(
({ actionsDisabled, busy, detail, onAction }) => {
const { t } = useTranslation('chat');
const tr = t as unknown as TranslateKey;
+ const density = useDensityTokens();
const [draft, setDraft] = useState('');
const timeline = useMemo(() => buildTimeline(detail), [detail]);
@@ -158,7 +161,7 @@ const ActivityTimeline = memo<ActivityTimelineProps>(
</Flexbox>
<div {...stylex.props(styles.commentBodyWrap)}>
<Markdown
- fontSize={13}
+ fontSize={density.fontSize}
variant={'chat'}
{...sx(styles.commentBody, fallback.commentBody)}
>
@@ -180,12 +183,12 @@ const ActivityTimeline = memo<ActivityTimelineProps>(
horizontal
align={'center'}
{...stylex.props(styles.event)}
- gap={8}
+ gap={12}
key={entry.kind === 'commit' ? entry.sha : `review:${entry.author}:${entry.at}`}
>
<Icon
icon={visual.icon}
- size={14}
+ size={density.iconSize}
style={visual.tone === 'neutral' ? undefined : { color: TONE_COLOR[visual.tone] }}
/>
<span>
diff --git a/src/features/Conversation/WorkingSidebar/PullRequest/ChecksList.tsx b/src/features/Conversation/WorkingSidebar/PullRequest/ChecksList.tsx
index fb9a85a123f..62bbd381ab8 100644
--- a/src/features/Conversation/WorkingSidebar/PullRequest/ChecksList.tsx
+++ b/src/features/Conversation/WorkingSidebar/PullRequest/ChecksList.tsx
@@ -13,7 +13,7 @@ import { formatCheckDuration, getCheckVisual, TONE_COLOR } from './prVisual';
const styles = stylex.create({
duration: { fontFamily: cssVar.fontFamilyCode },
- list: { paddingInlineStart: '18px' },
+ list: { display: 'flex', flexDirection: 'column', gap: '1px' },
});
interface ChecksListProps {
@@ -34,7 +34,6 @@ const ChecksList = memo<ChecksListProps>(({ checks }) => {
: formatCheckDuration(check);
return (
<OverviewRow
- weak
icon={visual.icon}
iconColor={TONE_COLOR[visual.tone]}
key={`${check.name}:${index}`}
diff --git a/src/features/Conversation/WorkingSidebar/PullRequest/Head.tsx b/src/features/Conversation/WorkingSidebar/PullRequest/Head.tsx
index 9b66095f3ad..7103a20b358 100644
--- a/src/features/Conversation/WorkingSidebar/PullRequest/Head.tsx
+++ b/src/features/Conversation/WorkingSidebar/PullRequest/Head.tsx
@@ -6,10 +6,9 @@ import type { ReactNode } from 'react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-import { sx } from '@/styles/sx';
-
import { rowStyles } from '../Overview/OverviewRow';
import { sectionStyles } from '../Overview/sectionStyles';
+import { statusTint } from '../Overview/statusTint';
import { getDetailVisual } from './prVisual';
export const headStyles = stylex.create({
@@ -46,14 +45,14 @@ export const headStyles = stylex.create({
backgroundColor: { 'default': cssVar.colorFillSecondary, ':hover': cssVar.colorFillTertiary },
backgroundImage: { 'default': 'none', ':hover': 'none' },
},
- root: { paddingBlockStart: '10px', paddingBlockEnd: '8px', paddingInline: '8px' },
+ root: { paddingBlockStart: 0, paddingBlockEnd: '8px', paddingInline: '6px' },
stats: { fontVariantNumeric: 'tabular-nums' },
title: {
flex: '1',
minWidth: '0',
- fontSize: '15px',
+ fontSize: '14px',
fontWeight: 600,
- lineHeight: '22px',
+ lineHeight: '20px',
color: cssVar.colorText,
overflowWrap: 'anywhere',
},
@@ -75,10 +74,10 @@ export const PrStatePill = memo<{
const visual = getDetailVisual(pr);
return (
<span
- {...sx(sectionStyles.pill, {
- background: `color-mix(in srgb, ${visual.color} 12%, transparent)`,
- color: visual.color,
- })}
+ {...stylex.props(
+ sectionStyles.pill,
+ sectionStyles.pillTone(visual.color, statusTint(visual.color)),
+ )}
>
<Icon icon={visual.icon} size={12} />
{t(`workingPanel.pr.state.${visual.state}`)}
diff --git a/src/features/Conversation/WorkingSidebar/PullRequest/MergeDock.tsx b/src/features/Conversation/WorkingSidebar/PullRequest/MergeDock.tsx
index 1f42e0e1661..88774b2bec8 100644
--- a/src/features/Conversation/WorkingSidebar/PullRequest/MergeDock.tsx
+++ b/src/features/Conversation/WorkingSidebar/PullRequest/MergeDock.tsx
@@ -6,6 +6,7 @@ import { ArrowUpIcon, ChevronRightIcon } from 'lucide-react';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { sidebarRow } from '@/styles/density.stylex';
import { sx } from '@/styles/sx';
import ChecksList from './ChecksList';
@@ -51,7 +52,7 @@ const styles = stylex.create({
flexShrink: 0,
paddingBlockStart: '10px',
paddingBlockEnd: '12px',
- paddingInline: '16px',
+ paddingInline: '12px',
borderBlockStartWidth: '1px',
borderBlockStartStyle: 'solid',
borderBlockStartColor: cssVar.colorBorderSecondary,
@@ -62,9 +63,9 @@ const styles = stylex.create({
overflow: 'hidden',
flex: '1',
minWidth: 0,
- fontSize: '13px',
+ fontSize: sidebarRow.textFontSize,
fontWeight: 600,
- lineHeight: '20px',
+ lineHeight: sidebarRow.textLineHeight,
color: cssVar.colorText,
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
@@ -74,7 +75,7 @@ const styles = stylex.create({
local: {
flexShrink: 0,
paddingBlock: '10px',
- paddingInline: '16px',
+ paddingInline: '12px',
borderBlockStartWidth: '1px',
borderBlockStartStyle: 'solid',
borderBlockStartColor: cssVar.colorBorderSecondary,
diff --git a/src/features/Conversation/WorkingSidebar/PullRequest/Sections.tsx b/src/features/Conversation/WorkingSidebar/PullRequest/Sections.tsx
index 8f6b0c2ea22..5f77d5bfc53 100644
--- a/src/features/Conversation/WorkingSidebar/PullRequest/Sections.tsx
+++ b/src/features/Conversation/WorkingSidebar/PullRequest/Sections.tsx
@@ -4,23 +4,22 @@ import type {
DeviceGitPullRequestDetail,
} from '@lobechat/types';
// oxlint-disable-next-line stylex-migration/no-emotion-styles -- Markdown output gets no className
-import { Button, createStaticStyles, Flexbox, Icon, Markdown, Skeleton } from '@lobehub/ui';
+import { createStaticStyles, Flexbox, Markdown } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
-import {
- ChevronDownIcon,
- ChevronRightIcon,
- FolderOpenIcon,
- GitCommitHorizontalIcon,
-} from 'lucide-react';
-import { memo, type ReactNode, useState } from 'react';
+import { FolderOpenIcon, GitCommitHorizontalIcon } from 'lucide-react';
+import { memo, type ReactNode, useId, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import AsyncError from '@/components/AsyncError';
import type { GitReplicaReadResult } from '@/store/device';
+import { useDensityTokens } from '@/styles/density';
import { sx } from '@/styles/sx';
+import { SidebarRowSkeleton } from '../DeferredSkeleton';
import { ChevronRight, OverviewRow, rowStyles } from '../Overview/OverviewRow';
-import { sectionProps, sectionStyles } from '../Overview/sectionStyles';
+import { SectionHeader } from '../Overview/SectionHeader';
+import { sectionProps } from '../Overview/sectionStyles';
import ActivityTimeline from './ActivityTimeline';
import ChecksList from './ChecksList';
import { timeAgo } from './prVisual';
@@ -32,10 +31,9 @@ const styles = stylex.create({
minWidth: 0,
paddingBlockStart: '2px',
paddingBlockEnd: '6px',
- paddingInline: '8px',
+ paddingInline: '6px',
overflowWrap: 'anywhere',
},
- header: { cursor: 'pointer', userSelect: 'none', gap: '6px' },
sha: { fontFamily: cssVar.fontFamilyCode },
});
@@ -67,26 +65,25 @@ interface SectionProps {
title: string;
}
-const Section = memo<SectionProps>(({ children, count, onToggle, open = true, title }) => (
- <Flexbox {...sectionProps(true)}>
- <Flexbox
- horizontal
- align={'center'}
- role={onToggle ? 'button' : undefined}
- {...stylex.props(
- sectionStyles.sectionHeader,
- sectionStyles.sectionTitle,
- onToggle && styles.header,
+const Section = memo<SectionProps>(({ children, count, onToggle, open = true, title }) => {
+ const bodyId = useId();
+ return (
+ <Flexbox {...sectionProps(true)}>
+ <SectionHeader
+ collapsed={!open}
+ controls={onToggle ? bodyId : undefined}
+ count={count}
+ title={title}
+ onToggle={onToggle}
+ />
+ {open && (
+ <Flexbox gap={1} id={bodyId}>
+ {children}
+ </Flexbox>
)}
- onClick={onToggle}
- >
- {onToggle && <Icon icon={open ? ChevronDownIcon : ChevronRightIcon} size={12} />}
- {title}
- {count !== undefined && <span {...stylex.props(sectionStyles.count)}>{count}</span>}
</Flexbox>
- {open && children}
- </Flexbox>
-));
+ );
+});
Section.displayName = 'PullRequestSection';
@@ -105,16 +102,18 @@ interface SectionsProps {
const Sections = memo<SectionsProps>(
({ actionsDisabled, activity, busy, detail, onAction, onOpenTab }) => {
const { t } = useTranslation('chat');
- const { t: tCommon } = useTranslation('common');
+ const density = useDensityTokens();
const activityPlaceholder = activity.error ? (
- <Flexbox gap={8}>
- <span>{t('workingPanel.pr.error.load')}</span>
- <Button loading={activity.isValidating} onClick={() => void activity.mutate()}>
- {tCommon('retry')}
- </Button>
- </Flexbox>
+ <AsyncError
+ align={'start'}
+ error={activity.error}
+ retrying={activity.isValidating}
+ title={t('workingPanel.pr.error.load')}
+ variant={'inline'}
+ onRetry={() => void activity.mutate()}
+ />
) : (
- <Skeleton.Text rows={3} />
+ <SidebarRowSkeleton rows={3} />
);
const [open, setOpen] = useState({
activity: true,
@@ -152,7 +151,11 @@ const Sections = memo<SectionsProps>(
title={t('workingPanel.pr.section.description')}
onToggle={toggle('description')}
>
- <Markdown fontSize={13} variant={'chat'} {...sx(styles.body, fallback.body)}>
+ <Markdown
+ fontSize={density.fontSize}
+ variant={'chat'}
+ {...sx(styles.body, fallback.body)}
+ >
{detail.body}
</Markdown>
</Section>
@@ -191,7 +194,6 @@ const Sections = memo<SectionsProps>(
? activityPlaceholder
: commits.map((commit) => (
<OverviewRow
- weak
icon={GitCommitHorizontalIcon}
key={commit.sha}
title={commit.message}
diff --git a/src/features/Conversation/WorkingSidebar/PullRequest/Skeleton.tsx b/src/features/Conversation/WorkingSidebar/PullRequest/Skeleton.tsx
index 4edd0c0e999..333403368ec 100644
--- a/src/features/Conversation/WorkingSidebar/PullRequest/Skeleton.tsx
+++ b/src/features/Conversation/WorkingSidebar/PullRequest/Skeleton.tsx
@@ -4,31 +4,39 @@ import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
+import { useDensityTokens } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
+
import { sectionProps, sectionStyles } from '../Overview/sectionStyles';
import PrHead, { PrStatePill, PrTitle } from './Head';
const styles = stylex.create({
dock: {
flexShrink: 0,
- paddingBlockStart: '8px',
- paddingBlockEnd: '10px',
- paddingInline: '8px',
+ paddingBlockStart: '10px',
+ paddingBlockEnd: '12px',
+ paddingInline: '4px',
borderBlockStartWidth: '1px',
borderBlockStartStyle: 'solid',
borderBlockStartColor: cssVar.colorBorderSecondary,
},
+ content: { paddingBlockStart: '8px', paddingInline: sidebarRow.paneInline },
root: { flex: '1', minHeight: '0' },
- row: { minHeight: '32px', paddingBlock: '5px', paddingInline: '8px' },
- sectionBody: { paddingBlockStart: '2px', paddingBlockEnd: '6px', paddingInline: '8px' },
+ row: { minHeight: sidebarRow.height, paddingInline: '8px' },
+ sectionBody: { paddingBlockStart: '2px', paddingBlockEnd: '6px', paddingInline: '6px' },
});
-const Row = ({ trailing = 48 }: { trailing?: number }) => (
- <Flexbox horizontal align={'center'} className={stylex.props(styles.row).className} gap={8}>
- <Skeleton height={14} radius={4} width={14} />
- <Skeleton.Text width={'55%'} />
- <Skeleton height={12} radius={4} style={{ marginInlineStart: 'auto' }} width={trailing} />
- </Flexbox>
-);
+const Row = ({ trailing = 48 }: { trailing?: number }) => {
+ const { iconSize } = useDensityTokens();
+
+ return (
+ <Flexbox horizontal align={'center'} className={stylex.props(styles.row).className} gap={12}>
+ <Skeleton height={iconSize} radius={4} width={iconSize} />
+ <Skeleton.Text width={'55%'} />
+ <Skeleton height={12} radius={4} style={{ marginInlineStart: 'auto' }} width={trailing} />
+ </Flexbox>
+ );
+};
const SectionTitle = ({ width = 64 }: { width?: number }) => (
<div {...stylex.props(sectionStyles.sectionHeader)}>
@@ -37,9 +45,11 @@ const SectionTitle = ({ width = 64 }: { width?: number }) => (
);
const PullRequestSkeleton = memo(({ summary }: { summary?: DeviceGitLinkedPullRequest }) => {
+ const density = useDensityTokens();
+
return (
<Flexbox className={stylex.props(styles.root).className}>
- <Flexbox className={stylex.props(styles.root).className}>
+ <Flexbox {...stylex.props(styles.root, styles.content)}>
<PrHead
meta={
<>
@@ -56,14 +66,14 @@ const PullRequestSkeleton = memo(({ summary }: { summary?: DeviceGitLinkedPullRe
summary ? (
<PrTitle number={summary.number} title={summary.title} />
) : (
- <Skeleton.Text fontSize={15} rows={2} width={['92%', '60%']} />
+ <Skeleton.Text fontSize={14} rows={2} width={['92%', '60%']} />
)
}
/>
<Flexbox {...sectionProps()}>
<SectionTitle width={72} />
<div {...stylex.props(styles.sectionBody)}>
- <Skeleton.Text fontSize={13} rows={3} width={['100%', '88%', '46%']} />
+ <Skeleton.Text fontSize={density.fontSize} rows={3} width={['100%', '88%', '46%']} />
</div>
</Flexbox>
<Flexbox {...sectionProps()}>
@@ -85,7 +95,7 @@ const PullRequestSkeleton = memo(({ summary }: { summary?: DeviceGitLinkedPullRe
horizontal
align={'center'}
gap={8}
- style={{ paddingBlock: '6px 0', paddingInline: 8 }}
+ style={{ paddingBlock: '10px 0', paddingInline: 8 }}
>
<Skeleton height={24} radius={6} width={'100%'} />
</Flexbox>
diff --git a/src/features/Conversation/WorkingSidebar/PullRequest/index.tsx b/src/features/Conversation/WorkingSidebar/PullRequest/index.tsx
index 5acb27f8ff3..1c5e7498eaf 100644
--- a/src/features/Conversation/WorkingSidebar/PullRequest/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/PullRequest/index.tsx
@@ -1,20 +1,21 @@
import type { DeviceGitLinkedPullRequest } from '@lobechat/types';
-import { Button, Empty, Flexbox, Icon, ScrollArea } from '@lobehub/ui';
+import { Button, Center, Empty, Flexbox, Icon, ScrollArea } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
-import { GlobeIcon, RefreshCwIcon, TriangleAlertIcon } from 'lucide-react';
+import { GlobeIcon, TriangleAlertIcon } from 'lucide-react';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
+import AsyncError from '@/components/AsyncError';
import {
useFetchGitAheadBehind,
useFetchGitPullRequestActivity,
useFetchGitPullRequestDetail,
useFetchGitPullRequestMergeContext,
} from '@/store/device';
+import { sidebarRow } from '@/styles/density.stylex';
import { openTrustedExternalUrl } from '@/utils/openTrustedExternalUrl';
-import { OverviewRow } from '../Overview/OverviewRow';
import { sectionProps } from '../Overview/sectionStyles';
import { resolvePullRequestActionLock } from './actionLock';
import Header from './Header';
@@ -27,7 +28,11 @@ import { usePullRequestActions } from './usePullRequestActions';
const styles = stylex.create({
root: { flex: '1', minHeight: '0' },
scroll: { overflow: 'hidden', flex: '1', minHeight: '0' },
- scrollContent: { paddingBlockStart: '0', paddingBlockEnd: '10px' },
+ scrollContent: {
+ paddingBlockStart: '8px',
+ paddingBlockEnd: sidebarRow.paneBlockEnd,
+ paddingInline: sidebarRow.paneInline,
+ },
viewport: { overflowX: 'hidden' },
});
@@ -66,7 +71,6 @@ const PullRequest = memo<PullRequestProps>(
workingDirectory,
}) => {
const { t } = useTranslation('chat');
- const { t: tCommon } = useTranslation('common');
const readPath = repositoryPath ?? workingDirectory;
const {
data,
@@ -134,17 +138,13 @@ const PullRequest = memo<PullRequestProps>(
const externalUrl = detail?.url ?? url;
const loadError = (error: unknown, onRetry: () => void) => (
<Flexbox {...sectionProps()}>
- <OverviewRow
- danger
- icon={TriangleAlertIcon}
- iconColor={cssVar.colorError}
- title={error instanceof Error ? error.message : undefined}
- value={t('workingPanel.pr.error.load')}
- trailing={
- <Button icon={<Icon icon={RefreshCwIcon} size={12} />} size={'small'} onClick={onRetry}>
- {tCommon('retry')}
- </Button>
- }
+ <AsyncError
+ align={'start'}
+ details={error instanceof Error ? error.message : undefined}
+ error={error}
+ title={t('workingPanel.pr.error.load')}
+ variant={'inline'}
+ onRetry={onRetry}
/>
</Flexbox>
);
@@ -153,28 +153,29 @@ const PullRequest = memo<PullRequestProps>(
if (data?.status === 'gh-missing')
return (
- <Empty
- description={t('workingPanel.pr.ghMissing.desc')}
- icon={TriangleAlertIcon}
- iconColor={cssVar.colorWarning}
- title={t('workingPanel.pr.ghMissing.title')}
- action={
- <Flexbox horizontal gap={6}>
- <Button size={'small'} type={'primary'} onClick={() => void mutate()}>
- {t('workingPanel.pr.ghMissing.retry')}
- </Button>
- {externalUrl && (
- <Button
- icon={<Icon icon={GlobeIcon} size={12} />}
- size={'small'}
- onClick={() => openTrustedExternalUrl(externalUrl)}
- >
- {t('workingPanel.pr.ghMissing.open')}
+ <Center paddingBlock={24}>
+ <Empty
+ description={t('workingPanel.pr.ghMissing.desc')}
+ icon={TriangleAlertIcon}
+ iconColor={cssVar.colorWarning}
+ title={t('workingPanel.pr.ghMissing.title')}
+ action={
+ <Flexbox horizontal gap={6}>
+ <Button type={'primary'} onClick={() => void mutate()}>
+ {t('workingPanel.pr.ghMissing.retry')}
</Button>
- )}
- </Flexbox>
- }
- />
+ {externalUrl && (
+ <Button
+ icon={<Icon icon={GlobeIcon} size={12} />}
+ onClick={() => openTrustedExternalUrl(externalUrl)}
+ >
+ {t('workingPanel.pr.ghMissing.open')}
+ </Button>
+ )}
+ </Flexbox>
+ }
+ />
+ </Center>
);
if (!detail) return loadError(fetchError, () => void mutate());
diff --git a/src/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.test.tsx b/src/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.test.tsx
index 2a08f812772..44fa9ccf1bf 100644
--- a/src/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.test.tsx
+++ b/src/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.test.tsx
@@ -341,7 +341,10 @@ describe('AgentDocumentsGroup', () => {
expect(header.contains(settings)).toBe(false);
fireEvent.click(header);
expect(header).toHaveAttribute('aria-expanded', 'false');
- expect(settings).toBeVisible();
+ // The action stays mounted and focusable while collapsed; the compact header
+ // only reveals it on hover / focus-within.
+ expect(settings).toBeInTheDocument();
+ expect(settings).toBeEnabled();
fireEvent.click(header);
expect(header).toHaveAttribute('aria-expanded', 'true');
fireEvent.click(header);
diff --git a/src/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.tsx b/src/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.tsx
index 462fdd15600..667871ccf81 100644
--- a/src/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.tsx
+++ b/src/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.tsx
@@ -19,6 +19,7 @@ import { useParams } from 'react-router';
import AsyncError from '@/components/AsyncError';
import { withErrorBoundary } from '@/components/ErrorBoundary';
+import { SkeletonList } from '@/components/Skeleton/NavPanel/List';
import { buildAgentDocumentPath } from '@/features/AgentDocumentPage/navigation';
import {
type AgentDocumentListMutator,
@@ -45,9 +46,12 @@ import {
useAgentDocumentStore,
} from '@/store/agentDocument';
import { useChatStore } from '@/store/chat';
+import { useDensityTokens } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
import { standardizeIdentifier } from '@/utils/identifier';
import DeviceLevelSkills from './DeviceLevelSkills';
+import { webDocumentRowMarker } from './markers.stylex';
import ProjectLevelSkills from './ProjectLevelSkills';
import { useCanManageUserSkills } from './useCanManageUserSkills';
import UserLevelSkills, { useUserSkills } from './UserLevelSkills';
@@ -59,15 +63,67 @@ export type ResourceFilter = 'skills' | 'documents' | 'web';
type DocumentOpenMode = 'portal' | 'route';
const styles = stylex.create({
- container: {
+ row: {
cursor: 'pointer',
- padding: '12px',
- borderRadius: '8px',
- backgroundColor: { 'default': cssVar.colorFillTertiary, ':hover': cssVar.colorFillSecondary },
+ position: 'relative',
+ display: 'flex',
+ gap: sidebarRow.gap,
+ alignItems: 'flex-start',
+ paddingBlock: '5px',
+ paddingInline: sidebarRow.paddingInline,
+ borderRadius: sidebarRow.radius,
+ color: cssVar.colorText,
+ backgroundColor: { 'default': 'transparent', ':hover': cssVar.colorFillTertiary },
backgroundImage: { 'default': 'none', ':hover': 'none' },
},
- description: { fontSize: '12px', lineHeight: 1.5, color: cssVar.colorTextSecondary },
- meta: { fontSize: '12px', color: cssVar.colorTextTertiary },
+ rowActive: {
+ backgroundColor: { 'default': cssVar.colorFillSecondary, ':hover': cssVar.colorFillSecondary },
+ },
+ rowIcon: {
+ display: 'flex',
+ flex: 'none',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: sidebarRow.iconBox,
+ height: sidebarRow.textLineHeight,
+ color: cssVar.colorTextTertiary,
+ },
+ rowText: { display: 'flex', flex: '1', flexDirection: 'column', minWidth: 0 },
+ rowTitle: {
+ overflow: 'hidden',
+ paddingInlineEnd: {
+ default: 0,
+ [stylex.when.ancestor(':hover', webDocumentRowMarker)]:
+ `calc(24px + ${sidebarRow.paddingInline})`,
+ [stylex.when.ancestor(':focus-within', webDocumentRowMarker)]:
+ `calc(24px + ${sidebarRow.paddingInline})`,
+ },
+ fontSize: sidebarRow.textFontSize,
+ lineHeight: sidebarRow.textLineHeight,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ rowMeta: {
+ fontSize: sidebarRow.metaFontSize,
+ lineHeight: '18px',
+ color: cssVar.colorTextTertiary,
+ },
+ rowActions: {
+ position: 'absolute',
+ insetBlockStart: '3px',
+ insetInlineEnd: sidebarRow.paddingInline,
+ pointerEvents: {
+ default: 'none',
+ [stylex.when.ancestor(':hover', webDocumentRowMarker)]: 'auto',
+ [stylex.when.ancestor(':focus-within', webDocumentRowMarker)]: 'auto',
+ },
+ opacity: {
+ default: 0,
+ [stylex.when.ancestor(':hover', webDocumentRowMarker)]: 1,
+ [stylex.when.ancestor(':focus-within', webDocumentRowMarker)]: 1,
+ },
+ transition: 'opacity 0.12s',
+ },
pillActive: {
fontWeight: 500,
color: cssVar.colorText,
@@ -88,7 +144,6 @@ const styles = stylex.create({
transition: `background ${cssVar.motionDurationFast} ${cssVar.motionEaseInOut},
color ${cssVar.motionDurationFast} ${cssVar.motionEaseInOut}`,
},
- title: { fontWeight: 500 },
});
const FILTER_OPTIONS = [
@@ -125,6 +180,7 @@ const DocumentItem = memo<DocumentItemProps>(
onOpenDocument,
}) => {
const { t } = useTranslation(['chat', 'common']);
+ const { iconSize } = useDensityTokens();
const [deleting, setDeleting] = useState(false);
@@ -179,40 +235,38 @@ const DocumentItem = memo<DocumentItemProps>(
});
};
+ const meta = [description, updatedAtLabel].filter(Boolean).join(' · ');
+
return (
- <Flexbox
- horizontal
- align={'flex-start'}
- className={stylex.props(styles.container).className}
- gap={8}
+ <div
+ {...stylex.props(styles.row, isActive && styles.rowActive, webDocumentRowMarker)}
onClick={handleOpen}
>
- <IconComponent size={16} style={{ flexShrink: 0, marginTop: 2 }} />
- <Flexbox gap={4} style={{ flex: 1, minWidth: 0 }}>
- <Flexbox horizontal align={'center'} distribution={'space-between'}>
- <Text ellipsis className={stylex.props(styles.title).className}>
- {title}
- </Text>
- {!hideDelete && (
- <ActionIcon
- icon={Trash2Icon}
- loading={deleting}
- size={'small'}
- title={t('delete', { ns: 'common' })}
- onClick={handleDelete}
- />
- )}
- </Flexbox>
- {description && (
- <Text className={stylex.props(styles.description).className} ellipsis={{ rows: 2 }}>
- {description}
+ <span {...stylex.props(styles.rowIcon)}>
+ <IconComponent size={iconSize} />
+ </span>
+ <span {...stylex.props(styles.rowText)}>
+ <span {...stylex.props(styles.rowTitle)} title={title}>
+ {title}
+ </span>
+ {meta && (
+ <Text className={stylex.props(styles.rowMeta).className} ellipsis={{ rows: 2 }}>
+ {meta}
</Text>
)}
- {updatedAtLabel && (
- <Text className={stylex.props(styles.meta).className}>{updatedAtLabel}</Text>
- )}
- </Flexbox>
- </Flexbox>
+ </span>
+ {!hideDelete && (
+ <span {...stylex.props(styles.rowActions)}>
+ <ActionIcon
+ icon={Trash2Icon}
+ loading={deleting}
+ size={'small'}
+ title={t('delete', { ns: 'common' })}
+ onClick={handleDelete}
+ />
+ </span>
+ )}
+ </div>
);
},
);
@@ -261,6 +315,8 @@ const buildSkillBundleViews = (data: AgentDocumentListItem[]): SkillBundleView[]
interface AgentDocumentsGroupProps {
activeFilter?: ResourceFilter;
+ /** The WorkingSidebar row system for the document tree and the loading / error states. */
+ compact?: boolean;
/** Bound remote device id (device mode); skills are then scanned over RPC. */
deviceId?: string;
/**
@@ -280,6 +336,7 @@ interface AgentDocumentsGroupProps {
const AgentDocumentsGroup = memo<AgentDocumentsGroupProps>(
({
activeFilter: controlledFilter,
+ compact,
deviceId,
enabled = true,
openMode,
@@ -455,6 +512,7 @@ const AgentDocumentsGroup = memo<AgentDocumentsGroupProps>(
if (!agentId) return null;
if (isLoading) {
+ if (compact) return <SkeletonList compact rows={6} />;
return (
<Center flex={1} paddingBlock={24}>
<Spin size="large" />
@@ -463,6 +521,17 @@ const AgentDocumentsGroup = memo<AgentDocumentsGroupProps>(
}
if (error) {
+ if (compact)
+ return (
+ <AsyncError
+ align={'start'}
+ error={error}
+ variant={'inline'}
+ onRetry={() => {
+ void mutate();
+ }}
+ />
+ );
return (
<Center flex={1} paddingBlock={24}>
<AsyncError
@@ -483,6 +552,7 @@ const AgentDocumentsGroup = memo<AgentDocumentsGroupProps>(
const renderAgentSkillsList = () => (
<SkillsList
+ compact
items={matchedSkillItems}
onOpenFile={openAgentSkillFile}
onOpenSkill={openAgentSkill}
@@ -509,25 +579,17 @@ const AgentDocumentsGroup = memo<AgentDocumentsGroupProps>(
if (activeCount === 0) {
if (showProjectSkills && projectSkillsError) {
- return (
- <Center flex={1} paddingBlock={24}>
- <AsyncError error={projectSkillsError} variant={'block'} />
- </Center>
- );
+ return <AsyncError align={'start'} error={projectSkillsError} variant={'inline'} />;
}
// Project skills refetch on a working-directory switch (new SWR key →
// empty items while in flight). Show the loader instead of flashing the
// empty placeholder when there's nothing else to render yet.
if (showProjectSkills && isProjectSkillsLoading) {
- return (
- <Center flex={1} paddingBlock={24}>
- <Spin size="large" />
- </Center>
- );
+ return <SkeletonList compact rows={6} />;
}
return (
- <Center flex={1} gap={8} paddingBlock={24}>
+ <Center flex={1} paddingBlock={24}>
<Empty description={t('workingPanel.skills.empty')} icon={SkillsIcon} />
</Center>
);
@@ -544,10 +606,10 @@ const AgentDocumentsGroup = memo<AgentDocumentsGroupProps>(
const hasMatch = hasMatchedAgent || hasMatchedProject || hasMatchedDevice || hasMatchedUser;
return (
- <Flexbox gap={16} style={{ paddingBottom: 16 }}>
+ <Flexbox gap={12}>
<SkillsSearchBar onSearch={setSkillSearchQuery} />
{!hasMatch && !(hasUser && canManageSkills) && (
- <Center flex={1} gap={8} paddingBlock={24}>
+ <Center flex={1} paddingBlock={24}>
<Empty description={t('workingPanel.skills.noSearchResults')} icon={SkillsIcon} />
</Center>
)}
@@ -556,6 +618,7 @@ const AgentDocumentsGroup = memo<AgentDocumentsGroupProps>(
renderAgentSkillsList()
) : (
<SkillSection
+ compact
sectionHeader={{
count: matchedSkillItems.length,
title: t('workingPanel.skills.section.agent'),
@@ -602,6 +665,7 @@ const AgentDocumentsGroup = memo<AgentDocumentsGroupProps>(
<DocumentExplorerTree
agentId={agentId}
data={documentsData}
+ density={compact ? 'compact' : 'default'}
mutate={mutate}
style={{ height: '100%' }}
onDocumentDragStart={handleDocumentDragStart}
@@ -613,13 +677,13 @@ const AgentDocumentsGroup = memo<AgentDocumentsGroupProps>(
const renderWeb = () => {
if (webData.length === 0) {
return (
- <Center flex={1} gap={8} paddingBlock={24}>
+ <Center flex={1} paddingBlock={24}>
<Empty description={t('workingPanel.resources.empty')} icon={GlobeIcon} />
</Center>
);
}
return (
- <Flexbox gap={8}>
+ <Flexbox gap={1}>
{webData.map((doc) => (
<DocumentItem
activeDocumentIdentifier={activeDocumentIdentifier}
diff --git a/src/features/Conversation/WorkingSidebar/ResourcesSection/DeviceLevelSkills.tsx b/src/features/Conversation/WorkingSidebar/ResourcesSection/DeviceLevelSkills.tsx
index caee862c04e..c08182d2797 100644
--- a/src/features/Conversation/WorkingSidebar/ResourcesSection/DeviceLevelSkills.tsx
+++ b/src/features/Conversation/WorkingSidebar/ResourcesSection/DeviceLevelSkills.tsx
@@ -47,9 +47,10 @@ const DeviceLevelSkills = memo<DeviceLevelSkillsProps>(
if (deviceItems.length === 0) {
if (!error) return null;
- if (hideHeader) return <SkillSection isEmpty error={error} onRetry={mutate} />;
+ if (hideHeader) return <SkillSection compact isEmpty error={error} onRetry={mutate} />;
return (
<SkillSection
+ compact
isEmpty
error={error}
sectionHeader={{ title: t('workingPanel.skills.section.device') }}
@@ -62,6 +63,7 @@ const DeviceLevelSkills = memo<DeviceLevelSkillsProps>(
const list = (
<SkillsList
+ compact
items={items}
onSelectSkill={onSelectSkill}
onSkillDragStart={handleSkillDragStart}
@@ -72,6 +74,7 @@ const DeviceLevelSkills = memo<DeviceLevelSkillsProps>(
return (
<SkillSection
+ compact
sectionHeader={{
count: items.length,
title: t('workingPanel.skills.section.device'),
diff --git a/src/features/Conversation/WorkingSidebar/ResourcesSection/ProjectLevelSkills.tsx b/src/features/Conversation/WorkingSidebar/ResourcesSection/ProjectLevelSkills.tsx
index 273e7e3f0ea..a56be9d08b1 100644
--- a/src/features/Conversation/WorkingSidebar/ResourcesSection/ProjectLevelSkills.tsx
+++ b/src/features/Conversation/WorkingSidebar/ResourcesSection/ProjectLevelSkills.tsx
@@ -51,9 +51,10 @@ const ProjectLevelSkills = memo<ProjectLevelSkillsProps>(
// §1.1). Only genuinely-empty (no error) keeps the "hide the section" behavior.
if (projectItems.length === 0) {
if (!error) return null;
- if (hideHeader) return <SkillSection isEmpty error={error} onRetry={mutate} />;
+ if (hideHeader) return <SkillSection compact isEmpty error={error} onRetry={mutate} />;
return (
<SkillSection
+ compact
isEmpty
error={error}
sectionHeader={{ title: t('workingPanel.skills.section.project') }}
@@ -66,6 +67,7 @@ const ProjectLevelSkills = memo<ProjectLevelSkillsProps>(
const list = (
<SkillsList
+ compact
items={items}
onSelectSkill={onSelectSkill}
onSkillDragStart={handleSkillDragStart}
@@ -76,6 +78,7 @@ const ProjectLevelSkills = memo<ProjectLevelSkillsProps>(
return (
<SkillSection
+ compact
sectionHeader={{
count: items.length,
title: t('workingPanel.skills.section.project'),
diff --git a/src/features/Conversation/WorkingSidebar/ResourcesSection/SkillsGroup.tsx b/src/features/Conversation/WorkingSidebar/ResourcesSection/SkillsGroup.tsx
index 93ac9c22ddd..543ccea2211 100644
--- a/src/features/Conversation/WorkingSidebar/ResourcesSection/SkillsGroup.tsx
+++ b/src/features/Conversation/WorkingSidebar/ResourcesSection/SkillsGroup.tsx
@@ -47,6 +47,7 @@ const SkillsGroup = memo<SkillsGroupProps>(({ deviceId, workingDirectory }) => {
const renderList = (items: typeof projectItems) => (
<SkillsList
+ compact
items={items}
onSelectSkill={onSelectSkill}
onSkillDragStart={handleSkillDragStart}
@@ -66,10 +67,11 @@ const SkillsGroup = memo<SkillsGroupProps>(({ deviceId, workingDirectory }) => {
<>
<SkillsSearchBar onSearch={setSearchQuery} />
{!hasMatchedProject && !hasMatchedDevice && (
- <SkillSection isEmpty emptyText={t('workingPanel.skills.noSearchResults')} />
+ <SkillSection compact isEmpty emptyText={t('workingPanel.skills.noSearchResults')} />
)}
{hasMatchedProject && (
<SkillSection
+ compact
sectionHeader={{
collapsible: false,
count: matchedProjectItems.length,
@@ -81,6 +83,7 @@ const SkillsGroup = memo<SkillsGroupProps>(({ deviceId, workingDirectory }) => {
)}
{hasMatchedDevice && (
<SkillSection
+ compact
sectionHeader={{
collapsible: false,
count: matchedDeviceItems.length,
@@ -96,6 +99,7 @@ const SkillsGroup = memo<SkillsGroupProps>(({ deviceId, workingDirectory }) => {
return (
<SkillSection
+ compact
isEmpty
emptyText={t('workingPanel.skills.empty')}
error={error}
diff --git a/src/features/Conversation/WorkingSidebar/ResourcesSection/UserLevelSkills.tsx b/src/features/Conversation/WorkingSidebar/ResourcesSection/UserLevelSkills.tsx
index ed6ee6d611e..f21c13de0ca 100644
--- a/src/features/Conversation/WorkingSidebar/ResourcesSection/UserLevelSkills.tsx
+++ b/src/features/Conversation/WorkingSidebar/ResourcesSection/UserLevelSkills.tsx
@@ -88,6 +88,7 @@ const UserLevelSkills = memo<UserLevelSkillsProps>(({ hideHeader, onManage, sear
const list = (
<SkillsList
+ compact
items={items}
onSelectSkill={onSelectSkill}
onSkillDragStart={handleSkillDragStart}
@@ -98,6 +99,7 @@ const UserLevelSkills = memo<UserLevelSkillsProps>(({ hideHeader, onManage, sear
return (
<SkillSection
+ compact
isEmpty={items.length === 0}
emptyText={t(
searchQuery
diff --git a/src/features/Conversation/WorkingSidebar/ResourcesSection/index.tsx b/src/features/Conversation/WorkingSidebar/ResourcesSection/index.tsx
index 6bfc9eb555b..98c56a866b7 100644
--- a/src/features/Conversation/WorkingSidebar/ResourcesSection/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/ResourcesSection/index.tsx
@@ -1,13 +1,24 @@
import { Flexbox } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
import { useEffectiveWorkingDirectory } from '@/hooks/useEffectiveWorkingDirectory';
import { useAgentStore } from '@/store/agent';
import { agentSelectors } from '@/store/agent/selectors';
+import { useDensityTokens } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
import AgentDocumentsGroup, { type ResourceFilter } from './AgentDocumentsGroup';
import SkillsGroup from './SkillsGroup';
+const styles = stylex.create({
+ pane: {
+ paddingBlockStart: sidebarRow.paneBlockStart,
+ paddingBlockEnd: sidebarRow.paneBlockEnd,
+ paddingInline: sidebarRow.paneInline,
+ },
+});
+
interface ResourcesSectionProps {
/** Bound remote device id (device mode); skills are then scanned over RPC. */
deviceId?: string;
@@ -30,16 +41,16 @@ const ResourcesSection = memo<ResourcesSectionProps>(({ deviceId, enabled = true
// device-bound agent resolved to `undefined` here and the skills fetch never
// fired even though `deviceId` was set.
const workingDirectory = useEffectiveWorkingDirectory(activeAgentId);
+ const { sectionGap } = useDensityTokens();
return (
<Flexbox
+ // The document tree owns its insets: its toolbar follows the pane toolbar
+ // and its rows sit inside pierre's own inline padding.
+ className={filter === 'documents' ? undefined : stylex.props(styles.pane).className}
data-testid={`workspace-${filter}`}
flex={1}
- gap={16}
- paddingBlock={8}
- // The document tree's row fill spans the content edges, so it takes the
- // header's 4px gutter: a selected row then lines up with the tabs above.
- paddingInline={filter === 'documents' ? 4 : '8px 12px'}
+ gap={sectionGap}
style={{ minHeight: 0 }}
>
{isHetero && workingDirectory && filter === 'skills' && (
@@ -47,6 +58,7 @@ const ResourcesSection = memo<ResourcesSectionProps>(({ deviceId, enabled = true
)}
{!isHetero && (
<AgentDocumentsGroup
+ compact
activeFilter={filter}
deviceId={deviceId}
enabled={enabled}
diff --git a/src/features/Conversation/WorkingSidebar/ResourcesSection/markers.stylex.ts b/src/features/Conversation/WorkingSidebar/ResourcesSection/markers.stylex.ts
new file mode 100644
index 00000000000..d31de058f95
--- /dev/null
+++ b/src/features/Conversation/WorkingSidebar/ResourcesSection/markers.stylex.ts
@@ -0,0 +1,3 @@
+import * as stylex from '@stylexjs/stylex';
+
+export const webDocumentRowMarker = stylex.defineMarker();
diff --git a/src/features/Conversation/WorkingSidebar/Review/FileItem.tsx b/src/features/Conversation/WorkingSidebar/Review/FileItem.tsx
index 35fc0fd1da2..a8d4f14a9d0 100644
--- a/src/features/Conversation/WorkingSidebar/Review/FileItem.tsx
+++ b/src/features/Conversation/WorkingSidebar/Review/FileItem.tsx
@@ -19,11 +19,15 @@ import path from 'path-browserify-esm';
import { memo, type MouseEvent, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
+import FileIcon from '@/components/FileIcon';
import { gitService } from '@/services/git';
import { useFileStore } from '@/store/file';
import { useGlobalStore } from '@/store/global';
+import { useDensityTokens } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
import type { ComposerTarget } from '../../types';
+import { reviewFileRowMarker } from './markers.stylex';
import type { DiffSelectedLineRange } from './selection';
import { buildCodeContextSelection } from './selection';
@@ -32,16 +36,24 @@ const styles = stylex.create({
// Hover-revealed row actions, anchored to the right edge with a gradient
// mask that fades in from transparent → row hover-bg so any path/stats
// text behind the icons softly disappears instead of being abruptly
- // overlapped. The row (FileRow) is the hover marker.
+ // overlapped. The row (FileRow) carries the marker.
actions: {
- pointerEvents: { default: 'none', [stylex.when.ancestor(':hover')]: 'auto' },
+ pointerEvents: {
+ default: 'none',
+ [stylex.when.ancestor(':hover', reviewFileRowMarker)]: 'auto',
+ [stylex.when.ancestor(':focus-within', reviewFileRowMarker)]: 'auto',
+ },
position: 'absolute',
insetBlock: 0,
- insetInlineEnd: '-8px',
+ insetInlineEnd: '-2px',
alignItems: 'center',
paddingInlineStart: '28px',
paddingInlineEnd: 0,
- opacity: { default: 0, [stylex.when.ancestor(':hover')]: 1 },
+ opacity: {
+ default: 0,
+ [stylex.when.ancestor(':hover', reviewFileRowMarker)]: 1,
+ [stylex.when.ancestor(':focus-within', reviewFileRowMarker)]: 1,
+ },
backgroundImage: `linear-gradient(to right, transparent 0, ${cssVar.colorFillTertiary} 28px), linear-gradient(to right, transparent 0, ${cssVar.colorBgContainer} 28px)`,
transition: 'opacity 0.15s',
},
@@ -72,14 +84,23 @@ const styles = stylex.create({
whiteSpace: 'nowrap',
},
fileName: { flex: 'none', color: cssVar.colorText, whiteSpace: 'nowrap' },
+ fileIcon: {
+ display: 'flex',
+ flex: 'none',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: sidebarRow.iconBox,
+ height: sidebarRow.iconBox,
+ },
header: {
position: 'relative',
display: 'flex',
- gap: '8px',
+ gap: sidebarRow.gap,
alignItems: 'center',
width: '100%',
minWidth: 0,
- fontSize: '12px',
+ fontSize: sidebarRow.textFontSize,
+ lineHeight: sidebarRow.textLineHeight,
},
pathWrapper: {
overflow: 'hidden',
@@ -95,7 +116,7 @@ const styles = stylex.create({
stats: {
flex: 'none',
fontFamily: cssVar.fontFamilyCode,
- fontSize: '12px',
+ fontSize: sidebarRow.metaFontSize,
fontVariantNumeric: 'tabular-nums',
},
});
@@ -177,6 +198,7 @@ interface FileItemHeaderProps {
export const FileItemHeader = memo<FileItemHeaderProps>(
({ filePath, additions, deletions, hideDir, revertContext, revertDisabled, onReverted }) => {
const { t } = useTranslation('chat');
+ const { iconSize } = useDensityTokens();
const revealInFilesTab = useGlobalStore((s) => s.revealInFilesTab);
const lastSlash = filePath.lastIndexOf('/');
@@ -243,6 +265,9 @@ export const FileItemHeader = memo<FileItemHeaderProps>(
return (
<div {...stylex.props(styles.header)}>
+ <span {...stylex.props(styles.fileIcon)}>
+ <FileIcon fileName={fileName} size={iconSize} />
+ </span>
<span {...stylex.props(styles.pathWrapper)} title={filePath}>
{!hideDir && dir && (
// bdi keeps the dir's visual order LTR while the span is
diff --git a/src/features/Conversation/WorkingSidebar/Review/FileRow.tsx b/src/features/Conversation/WorkingSidebar/Review/FileRow.tsx
index 0462be6a1a6..1a18b0bfdf9 100644
--- a/src/features/Conversation/WorkingSidebar/Review/FileRow.tsx
+++ b/src/features/Conversation/WorkingSidebar/Review/FileRow.tsx
@@ -8,10 +8,12 @@ import { AnimatePresence } from 'motion/react';
import * as m from 'motion/react-m';
import { type KeyboardEvent, memo, useCallback } from 'react';
-import { sx } from '@/styles/sx';
+import { useDensityTokens } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
import type { ComposerTarget } from '../../types';
import FileItemBody, { FileItemHeader } from './FileItem';
+import { reviewFileRowMarker } from './markers.stylex';
import type { ReviewMode } from './useReviewPatches';
const styles = stylex.create({
@@ -19,7 +21,7 @@ const styles = stylex.create({
// Skip layout/paint of off-screen rows. Preserved from the previous
// implementation.
contentVisibility: 'auto',
- containIntrinsicSize: 'auto 32px',
+ containIntrinsicSize: `auto ${sidebarRow.height}`,
flex: 'none',
// Every row carries its own top border — separates file-from-file AND
// file-from-header without doubling up when a group is collapsed. The first
@@ -35,11 +37,13 @@ const styles = stylex.create({
cursor: 'pointer',
userSelect: 'none',
display: 'flex',
- gap: '6px',
+ gap: sidebarRow.gap,
alignItems: 'center',
width: '100%',
- paddingBlock: '5px',
- paddingInline: '10px',
+ minHeight: sidebarRow.height,
+ paddingInline: sidebarRow.paddingInline,
+ fontSize: sidebarRow.textFontSize,
+ lineHeight: sidebarRow.textLineHeight,
transition: 'background 0.12s',
backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
backgroundImage: { 'default': null, ':hover': 'none' },
@@ -48,6 +52,15 @@ const styles = stylex.create({
outlineColor: { 'default': null, ':focus-visible': cssVar.colorPrimary },
outlineOffset: { 'default': null, ':focus-visible': '-2px' },
},
+ indent: (paddingInlineStart: number) => ({ paddingInlineStart }),
+ chevronBox: {
+ display: 'flex',
+ flex: 'none',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '16px',
+ height: sidebarRow.textLineHeight,
+ },
chevron: {
flex: 'none',
color: cssVar.colorTextTertiary,
@@ -105,6 +118,7 @@ const FileRow = memo<FileRowProps>(
viewMode,
wordWrap,
}) => {
+ const { paddingInline } = useDensityTokens();
const onKeyDown = useCallback(
(e: KeyboardEvent<HTMLDivElement>) => {
if (e.key === 'Enter' || e.key === ' ') {
@@ -120,20 +134,22 @@ const FileRow = memo<FileRowProps>(
data-review-row
aria-expanded={expanded}
role={'button'}
- {...sx(
+ {...stylex.props(
styles.row,
- stylex.defaultMarker(),
- indent ? { paddingInlineStart: 10 + indent } : undefined,
+ reviewFileRowMarker,
+ !!indent && styles.indent(paddingInline + indent),
)}
tabIndex={0}
onClick={onToggle}
onKeyDown={onKeyDown}
>
- <ChevronRightIcon
- {...stylex.props(styles.chevron)}
- data-expanded={expanded ? 'true' : 'false'}
- size={14}
- />
+ <span {...stylex.props(styles.chevronBox)}>
+ <ChevronRightIcon
+ {...stylex.props(styles.chevron)}
+ data-expanded={expanded ? 'true' : 'false'}
+ size={12}
+ />
+ </span>
<FileItemHeader
additions={entry.additions}
deletions={entry.deletions}
diff --git a/src/features/Conversation/WorkingSidebar/Review/FileTreeNav.tsx b/src/features/Conversation/WorkingSidebar/Review/FileTreeNav.tsx
index 57132cf3841..7628d3f36b1 100644
--- a/src/features/Conversation/WorkingSidebar/Review/FileTreeNav.tsx
+++ b/src/features/Conversation/WorkingSidebar/Review/FileTreeNav.tsx
@@ -10,10 +10,17 @@ import {
getExplorerTreeStyleVars,
HIDE_POINTER_FOCUS_RING_CSS,
} from '@/features/ExplorerTree';
+import { useDensityTokens } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
+import { COMPACT_FOLDER_ICON_CSS } from '../Files/fileTreeStyle';
import { buildReviewTreeNodes, type ReviewTreeData, type ReviewTreeGroup } from './reviewTreeNodes';
-const FILE_TREE_UNSAFE_CSS = `${FOLDER_ICON_CSS}\n${HIDE_POINTER_FOCUS_RING_CSS}`;
+const FILE_TREE_UNSAFE_CSS = [
+ FOLDER_ICON_CSS,
+ COMPACT_FOLDER_ICON_CSS,
+ HIDE_POINTER_FOCUS_RING_CSS,
+].join('\n');
const styles = stylex.create({
tree: {
@@ -25,9 +32,12 @@ const styles = stylex.create({
'--trees-fg-override': cssVar.colorTextSecondary,
'--trees-fg-muted-override': cssVar.colorTextSecondary,
'--trees-accent-override': cssVar.colorPrimary,
- '--trees-padding-inline-override': '0px',
- '--trees-font-size-override': '12px',
- '--trees-border-radius-override': '6px',
+ '--trees-padding-inline-override': sidebarRow.paneInline,
+ '--trees-item-margin-x-override': '0px',
+ '--trees-item-padding-x-override': sidebarRow.paddingInline,
+ '--trees-item-row-gap-override': sidebarRow.gap,
+ '--trees-font-size-override': sidebarRow.textFontSize,
+ '--trees-border-radius-override': sidebarRow.radius,
'flex': '1',
'minHeight': '0',
},
@@ -49,6 +59,7 @@ interface FileTreeNavProps {
*/
const FileTreeNav = memo<FileTreeNavProps>(
({ activeFileKey, groups, onSelectFile, showGroupHeaders }) => {
+ const density = useDensityTokens();
const nodes = useMemo(
() => buildReviewTreeNodes(groups, showGroupHeaders),
[groups, showGroupHeaders],
@@ -64,8 +75,12 @@ const FileTreeNav = memo<FileTreeNavProps>(
[nodes, activeFileKey],
);
const treeStyleVars = useMemo(
- () => getExplorerTreeStyleVars({ reserveChevronSlot: nodes.some((node) => node.isFolder) }),
- [nodes],
+ () =>
+ getExplorerTreeStyleVars({
+ reserveChevronSlot: nodes.some((node) => node.isFolder),
+ rowGap: density.gap,
+ }),
+ [density.gap, nodes],
);
return (
@@ -74,6 +89,7 @@ const FileTreeNav = memo<FileTreeNavProps>(
iconsColored
defaultExpandedIds={defaultExpandedIds}
iconSet="complete"
+ itemHeight={density.treeItemHeight}
nodes={nodes}
selectedIds={selectedIds}
style={{ height: '100%' }}
diff --git a/src/features/Conversation/WorkingSidebar/Review/GroupHeader.tsx b/src/features/Conversation/WorkingSidebar/Review/GroupHeader.tsx
index 9ba8f7810c6..49a31898630 100644
--- a/src/features/Conversation/WorkingSidebar/Review/GroupHeader.tsx
+++ b/src/features/Conversation/WorkingSidebar/Review/GroupHeader.tsx
@@ -3,19 +3,21 @@
import { ActionIcon } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
-import { ChevronRightIcon, FoldVerticalIcon, UnfoldVerticalIcon } from 'lucide-react';
+import { ChevronDownIcon, FoldVerticalIcon, UnfoldVerticalIcon } from 'lucide-react';
import { type KeyboardEvent, memo, type MouseEvent, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
+import { sidebarRow } from '@/styles/density.stylex';
+
+import { reviewGroupHeaderMarker } from './markers.stylex';
+
const styles = stylex.create({
- // Sticky group header — appears once per repo (parent + each dirty submodule)
- // when the working tree spans multiple repositories. Mirrors WebStorm's
- // per-repo grouping: collapse chevron + name + file count + totals + branch
- // all left-aligned. Position: sticky keeps the header pinned while scrolling
- // within its group's rows. The whole header is a button — click anywhere to
- // collapse/expand the group's rows. Top-only border (no bottom border) so
- // collapsing a group can't produce a doubled-up line against the next
- // header's top border.
+ // Sticky group header, once per repo (parent + each dirty submodule) when the
+ // working tree spans several repositories. Sticky keeps it pinned while its
+ // group's rows scroll, so it needs an opaque fill. The whole header is a
+ // button: click anywhere to collapse/expand the group's rows. The fixed
+ // height fits the fold ActionIcon, so the header does not jitter when that
+ // button toggles between rendered and not.
header: {
cursor: 'pointer',
userSelect: 'none',
@@ -24,27 +26,16 @@ const styles = stylex.create({
insetBlockStart: 0,
display: 'flex',
flex: 'none',
- gap: '6px',
+ gap: '4px',
alignItems: 'center',
- // Fixed height accommodates the ActionIcon (size='small' is ~24px tall)
- // so the header stays the same size whether or not the fold button is
- // rendered. Without this, expanding/collapsing a group would jitter the
- // sticky header height because the button toggles between rendered and
- // not. flex:none keeps the column flex list from compressing the sticky
- // header during expand/collapse. padding-inline keeps the left-edge
- // alignment with file rows.
- blockSize: '32px',
- paddingInline: '10px',
- fontSize: '12px',
- color: cssVar.colorTextSecondary,
- transition: 'background 0.12s',
- backgroundColor: { 'default': cssVar.colorFillQuaternary, ':hover': cssVar.colorFillTertiary },
- backgroundImage: { 'default': 'none', ':hover': 'none' },
- // Separate non-first groups from the preceding group's last row.
- // The first header sits against the list's own top border.
- borderBlockStartWidth: { 'default': null, ':not(:first-child)': '1px' },
- borderBlockStartStyle: { 'default': null, ':not(:first-child)': 'solid' },
- borderBlockStartColor: { 'default': null, ':not(:first-child)': cssVar.colorBorderSecondary },
+ blockSize: sidebarRow.sectionHeaderHeight,
+ paddingInlineStart: sidebarRow.paddingInline,
+ paddingInlineEnd: sidebarRow.paddingInline,
+ fontSize: sidebarRow.labelFontSize,
+ color: cssVar.colorTextTertiary,
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ marginBlockStart: { 'default': null, ':not(:first-child)': sidebarRow.sectionGap },
outlineWidth: { 'default': null, ':focus-visible': '2px' },
outlineStyle: { 'default': null, ':focus-visible': 'solid' },
outlineColor: { 'default': null, ':focus-visible': cssVar.colorPrimary },
@@ -53,16 +44,21 @@ const styles = stylex.create({
chevron: {
flex: 'none',
color: cssVar.colorTextTertiary,
- transition: 'transform 0.2s',
- transform: { 'default': null, "[data-expanded='true']": 'rotate(90deg)' },
+ opacity: {
+ default: 0,
+ [stylex.when.ancestor(':hover', reviewGroupHeaderMarker)]: 1,
+ [stylex.when.ancestor(':focus-visible', reviewGroupHeaderMarker)]: 1,
+ },
+ transition: 'opacity 0.15s, transform 0.15s',
},
+ chevronCollapsed: { opacity: 1, transform: 'rotate(-90deg)' },
meta: {
overflow: 'hidden',
display: 'inline-flex',
flexGrow: '1',
flexShrink: '1',
flexBasis: 'auto',
- gap: '6px',
+ gap: '4px',
alignItems: 'center',
minWidth: 0,
},
@@ -72,23 +68,23 @@ const styles = stylex.create({
flexShrink: '1',
flexBasis: 'auto',
minWidth: 0,
- fontWeight: 600,
- color: cssVar.colorText,
+ fontWeight: sidebarRow.labelFontWeight,
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
},
fileCount: {
flexShrink: 0,
+ fontWeight: 400,
fontVariantNumeric: 'tabular-nums',
- color: cssVar.colorTextTertiary,
},
stats: {
display: 'inline-flex',
flexShrink: 0,
gap: '6px',
alignItems: 'center',
+ marginInlineStart: '2px',
fontFamily: cssVar.fontFamilyCode,
- fontSize: '12px',
+ fontSize: sidebarRow.metaFontSize,
fontVariantNumeric: 'tabular-nums',
},
additions: { color: cssVar.colorSuccess },
@@ -99,20 +95,17 @@ const styles = stylex.create({
flexShrink: '1',
flexBasis: 'auto',
minWidth: 0,
+ marginInlineStart: '2px',
fontFamily: cssVar.fontFamilyCode,
- color: cssVar.colorTextTertiary,
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
},
- // Hover-revealed fold-all-diffs button. Uses the standard ActionIcon, so
- // hover/focus visuals match the rest of the panel — we just gate visibility
- // via opacity bound to the parent header's hover/focus-within state.
foldButton: {
marginInlineStart: 'auto',
opacity: {
default: 0,
- [stylex.when.ancestor(':hover')]: 1,
- [stylex.when.ancestor(':focus-within')]: 1,
+ [stylex.when.ancestor(':hover', reviewGroupHeaderMarker)]: 1,
+ [stylex.when.ancestor(':focus-within', reviewGroupHeaderMarker)]: 1,
},
transition: 'opacity 0.15s',
},
@@ -170,7 +163,7 @@ const GroupHeader = memo<GroupHeaderProps>(
return (
<div
aria-expanded={!collapsed}
- {...stylex.props(styles.header, stylex.defaultMarker())}
+ {...stylex.props(styles.header, reviewGroupHeaderMarker)}
data-review-group-header={''}
role={'button'}
tabIndex={0}
@@ -178,15 +171,14 @@ const GroupHeader = memo<GroupHeaderProps>(
onKeyDown={handleKeyDown}
>
<div {...stylex.props(styles.meta)}>
- <ChevronRightIcon
- {...stylex.props(styles.chevron)}
- data-expanded={collapsed ? 'false' : 'true'}
- size={14}
- />
<span {...stylex.props(styles.name)}>{name}</span>
<span {...stylex.props(styles.fileCount)}>
{t('workingPanel.review.group.fileCount', { count: patchCount })}
</span>
+ <ChevronDownIcon
+ {...stylex.props(styles.chevron, collapsed && styles.chevronCollapsed)}
+ size={12}
+ />
{(totalAdditions > 0 || totalDeletions > 0) && (
<span {...stylex.props(styles.stats)}>
{totalAdditions > 0 && (
diff --git a/src/features/Conversation/WorkingSidebar/Review/index.tsx b/src/features/Conversation/WorkingSidebar/Review/index.tsx
index 39ad69b9ac4..3bf2b5276f7 100644
--- a/src/features/Conversation/WorkingSidebar/Review/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/Review/index.tsx
@@ -1,15 +1,7 @@
'use client';
import type { GitWorkingTreePatch } from '@lobechat/electron-client-ipc';
-import {
- ActionIcon,
- Center,
- type DropdownItem,
- DropdownMenu,
- Empty,
- Flexbox,
- Spin,
-} from '@lobehub/ui';
+import { ActionIcon, Center, type DropdownItem, DropdownMenu, Empty, Flexbox } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
import {
@@ -32,8 +24,10 @@ import path from 'path-browserify-esm';
import { Fragment, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { SkeletonList } from '@/components/Skeleton/NavPanel/List';
import { useLocalStorageState } from '@/hooks/useLocalStorageState';
import { useFetchGitBranch } from '@/store/device';
+import { sidebarRow } from '@/styles/density.stylex';
import { sx } from '@/styles/sx';
import type { ComposerTarget } from '../../types';
@@ -188,12 +182,17 @@ const styles = stylex.create({
subheader: {
display: 'flex',
flexShrink: 0,
- gap: '8px',
+ gap: '4px',
alignItems: 'center',
justifyContent: 'space-between',
- paddingBlockStart: '4px',
- paddingBlockEnd: '8px',
- paddingInline: '8px',
+ height: sidebarRow.toolbarHeight,
+ paddingInlineStart: sidebarRow.toolbarPaddingInlineStart,
+ paddingInlineEnd: sidebarRow.toolbarPaddingInlineEnd,
+ },
+ skeleton: {
+ paddingBlockStart: sidebarRow.paneBlockStart,
+ paddingBlockEnd: sidebarRow.paneBlockEnd,
+ paddingInline: sidebarRow.paneInline,
},
// Empty submodule group — pointer-only bump where the submodule's own
// working tree is clean. We still surface the group so the user knows the
@@ -202,7 +201,7 @@ const styles = stylex.create({
groupEmpty: {
paddingBlockStart: '6px',
paddingBlockEnd: '10px',
- paddingInline: '10px',
+ paddingInline: sidebarRow.paddingInline,
borderBlockStartWidth: { 'default': '1px', ':first-child': 'medium' },
borderBlockStartStyle: { 'default': 'solid', ':first-child': 'none' },
borderBlockStartColor: {
@@ -386,11 +385,7 @@ const Review = memo<ReviewProps>(
};
if (!data && isLoading) {
- return (
- <Center flex={1}>
- <Spin size="large" />
- </Center>
- );
+ return <SkeletonList compact className={stylex.props(styles.skeleton).className} rows={6} />;
}
const totalEntryCount = allEntries.length;
@@ -587,7 +582,7 @@ const Review = memo<ReviewProps>(
</Flexbox>
</div>
{isEmpty ? (
- <Center flex={1} gap={8} paddingBlock={24}>
+ <Center flex={1} paddingBlock={24}>
<Empty description={emptyText} icon={GitCompareIcon} />
</Center>
) : (
diff --git a/src/features/Conversation/WorkingSidebar/Review/markers.stylex.ts b/src/features/Conversation/WorkingSidebar/Review/markers.stylex.ts
new file mode 100644
index 00000000000..e2f525ffd1a
--- /dev/null
+++ b/src/features/Conversation/WorkingSidebar/Review/markers.stylex.ts
@@ -0,0 +1,4 @@
+import * as stylex from '@stylexjs/stylex';
+
+export const reviewFileRowMarker = stylex.defineMarker();
+export const reviewGroupHeaderMarker = stylex.defineMarker();
diff --git a/src/features/Conversation/WorkingSidebar/Search/index.tsx b/src/features/Conversation/WorkingSidebar/Search/index.tsx
index af9ae4e026f..9cec2525d16 100644
--- a/src/features/Conversation/WorkingSidebar/Search/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/Search/index.tsx
@@ -4,12 +4,13 @@ import { TOPIC_MESSAGE_SEARCH_LIMIT } from '@lobechat/const';
import type { TopicMessageSearchMatch } from '@lobechat/types';
import {
ActionIcon,
+ Button,
+ Center,
cssVar as lobeCssVar,
+ Empty,
Flexbox,
Icon,
Input,
- Skeleton,
- Text,
} from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
@@ -20,9 +21,12 @@ import type { KeyboardEvent } from 'react';
import { memo, useEffect, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import AsyncError from '@/components/AsyncError';
+import { SkeletonList } from '@/components/Skeleton/NavPanel/List';
import { useAgentStore } from '@/store/agent';
import { agentSelectors } from '@/store/agent/selectors';
import { useGlobalStore } from '@/store/global';
+import { sidebarRow } from '@/styles/density.stylex';
import { TOPIC_SEARCH_HIGHLIGHT } from './conversationHighlights';
import { splitHighlightSegments } from './highlightSegments';
@@ -43,17 +47,20 @@ const HIGHLIGHT_SHEET = `
const styles = stylex.create({
header: {
- borderBlockEndColor: cssVar.colorBorderSecondary,
- borderBlockEndStyle: 'solid',
- borderBlockEndWidth: 1,
- paddingBlock: 8,
- paddingInline: 12,
+ display: 'flex',
+ flexShrink: 0,
+ alignItems: 'center',
+ height: sidebarRow.toolbarHeight,
+ paddingInlineStart: sidebarRow.toolbarPaddingInlineStart,
+ paddingInlineEnd: sidebarRow.toolbarPaddingInlineEnd,
},
item: {
- borderRadius: 6,
cursor: 'pointer',
- paddingBlock: 6,
- paddingInline: 8,
+ display: 'flex',
+ flexDirection: 'column',
+ paddingBlock: 5,
+ paddingInline: sidebarRow.paddingInline,
+ borderRadius: sidebarRow.radius,
backgroundColor: {
':hover': cssVar.colorFillTertiary,
'default': 'transparent',
@@ -69,8 +76,16 @@ const styles = stylex.create({
flex: '1',
minHeight: 0,
overflowY: 'auto',
- paddingBlock: 6,
- paddingInline: 6,
+ paddingBlockStart: sidebarRow.paneBlockStart,
+ paddingBlockEnd: sidebarRow.paneBlockEnd,
+ paddingInline: sidebarRow.paneInline,
+ },
+ listNote: {
+ paddingBlock: 4,
+ paddingInline: sidebarRow.paddingInline,
+ color: cssVar.colorTextTertiary,
+ fontSize: sidebarRow.metaFontSize,
+ lineHeight: '18px',
},
mark: {
backgroundColor: cssVar.colorWarningBgHover,
@@ -79,7 +94,9 @@ const styles = stylex.create({
},
meta: {
color: cssVar.colorTextTertiary,
- fontSize: 12,
+ fontSize: sidebarRow.metaFontSize,
+ fontVariantNumeric: 'tabular-nums',
+ lineHeight: '18px',
},
position: {
color: cssVar.colorTextTertiary,
@@ -88,9 +105,13 @@ const styles = stylex.create({
whiteSpace: 'nowrap',
},
snippet: {
+ WebkitBoxOrient: 'vertical',
+ WebkitLineClamp: 2,
+ display: '-webkit-box',
+ overflow: 'hidden',
color: cssVar.colorText,
- fontSize: 13,
- lineHeight: 1.5,
+ fontSize: sidebarRow.textFontSize,
+ lineHeight: sidebarRow.textLineHeight,
overflowWrap: 'anywhere',
},
});
@@ -192,26 +213,36 @@ export const TopicSearchPane = memo<TopicSearchPaneProps>(({ active, topicId })
const renderBody = () => {
if (!keyword)
return (
- <Text fontSize={12} type={'secondary'}>
- {t('workingPanel.search.hint')}
- </Text>
+ <Center paddingBlock={24}>
+ <Empty description={t('workingPanel.search.hint')} icon={SearchIcon} />
+ </Center>
);
if (failed)
return (
- <Text fontSize={12} type={'secondary'}>
- {t('workingPanel.search.error')} <a onClick={retry}>{t('workingPanel.search.retry')}</a>
- </Text>
+ <AsyncError
+ align={'start'}
+ title={t('workingPanel.search.error')}
+ variant={'inline'}
+ action={
+ <Button size={'small'} type={'text'} onClick={retry}>
+ {t('workingPanel.search.retry')}
+ </Button>
+ }
+ />
);
- if (isSearching && matches.length === 0) return <Skeleton.Text rows={4} />;
+ if (isSearching && matches.length === 0) return <SkeletonList compact rows={4} />;
if (matches.length === 0)
return (
- <Text fontSize={12} type={'secondary'}>
- {t('workingPanel.search.empty', { keyword })}
- </Text>
+ <Center paddingBlock={24}>
+ <Empty description={t('workingPanel.search.empty', { keyword })} icon={SearchIcon} />
+ </Center>
);
return (
- <Flexbox gap={2} role={'listbox'}>
+ <Flexbox gap={1} role={'listbox'}>
+ <div {...stylex.props(styles.listNote)}>
+ {t('workingPanel.search.resultCount', { count: matches.length })}
+ </div>
{matches.map((match) => (
<MatchItem
active={match.id === activeId}
@@ -223,9 +254,9 @@ export const TopicSearchPane = memo<TopicSearchPaneProps>(({ active, topicId })
/>
))}
{matches.length >= TOPIC_MESSAGE_SEARCH_LIMIT && (
- <Text fontSize={12} style={{ padding: 8 }} type={'secondary'}>
+ <div {...stylex.props(styles.listNote)}>
{t('workingPanel.search.limitReached', { count: TOPIC_MESSAGE_SEARCH_LIMIT })}
- </Text>
+ </div>
)}
</Flexbox>
);
@@ -236,12 +267,13 @@ export const TopicSearchPane = memo<TopicSearchPaneProps>(({ active, topicId })
<style href={'lobe-topic-search-highlight'} precedence={'default'}>
{HIGHLIGHT_SHEET}
</style>
- <Flexbox gap={6} {...stylex.props(styles.header)}>
+ <div {...stylex.props(styles.header)}>
<Input
placeholder={t('workingPanel.search.placeholder')}
prefix={<Icon icon={SearchIcon} size={13} />}
ref={inputRef}
size={'small'}
+ style={{ flex: 1, minWidth: 0 }}
value={value}
suffix={
<Flexbox horizontal align={'center'} gap={2}>
@@ -269,12 +301,7 @@ export const TopicSearchPane = memo<TopicSearchPaneProps>(({ active, topicId })
onChange={(event) => setValue(event.target.value)}
onKeyDown={handleKeyDown}
/>
- {matches.length > 0 && (
- <Text fontSize={12} type={'secondary'}>
- {t('workingPanel.search.resultCount', { count: matches.length })}
- </Text>
- )}
- </Flexbox>
+ </div>
<div {...stylex.props(styles.list)}>{renderBody()}</div>
</Flexbox>
);
diff --git a/src/features/Conversation/WorkingSidebar/WorksSection/VersionList.tsx b/src/features/Conversation/WorkingSidebar/WorksSection/VersionList.tsx
index 4e5cdfd0119..4e253b15898 100644
--- a/src/features/Conversation/WorkingSidebar/WorksSection/VersionList.tsx
+++ b/src/features/Conversation/WorkingSidebar/WorksSection/VersionList.tsx
@@ -1,33 +1,42 @@
import type { WorkVersionItem } from '@lobechat/types';
-import { Center, Flexbox, Spin, Text } from '@lobehub/ui';
+import { Flexbox, Text } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
+import { SkeletonList } from '@/components/Skeleton/NavPanel/List';
import { formatTaskItemDate } from '@/features/AgentTasks/features/formatTaskItemDate';
import { useWorkStore, workActions, workSelectors } from '@/store/work';
+import { sidebarRow } from '@/styles/density.stylex';
import { computeWorkVersionCostDeltas, formatWorkVersionCost } from '@/utils/workVersionCost';
+// Version rows start where the header's icon does: row padding + 16px chevron column + gap.
const styles = stylex.create({
- context: { flexShrink: 0, color: cssVar.colorTextTertiary },
+ context: { flexShrink: 0, fontSize: sidebarRow.metaFontSize, color: cssVar.colorTextTertiary },
error: {
- paddingBlock: '8px',
- paddingInlineStart: '36px',
- paddingInlineEnd: '8px',
+ display: 'flex',
+ alignItems: 'center',
+ minHeight: sidebarRow.height,
+ paddingInlineStart: `calc(${sidebarRow.paddingInline} + 16px + ${sidebarRow.gap})`,
+ paddingInlineEnd: sidebarRow.paddingInline,
+ fontSize: sidebarRow.metaFontSize,
color: cssVar.colorError,
},
+ skeleton: {
+ paddingInlineStart: `calc(${sidebarRow.paddingInline} + 16px + ${sidebarRow.gap})`,
+ paddingInlineEnd: 0,
+ },
versionCost: { color: cssVar.colorTextTertiary },
- versionList: {
- marginInlineStart: '34px',
- paddingBlockStart: '6px',
- paddingBlockEnd: '10px',
- borderBlockStartWidth: '1px',
- borderBlockStartStyle: 'solid',
- borderBlockStartColor: cssVar.colorBorderSecondary,
+ versionList: { gap: '1px' },
+ versionRow: {
+ justifyContent: 'center',
+ minHeight: sidebarRow.height,
+ paddingInlineStart: `calc(${sidebarRow.paddingInline} + 16px + ${sidebarRow.gap})`,
+ paddingInlineEnd: sidebarRow.paddingInline,
+ fontSize: sidebarRow.metaFontSize,
},
- versionRow: { paddingBlock: '6px', fontSize: '12px' },
- versionTitle: { color: cssVar.colorTextSecondary },
+ versionTitle: { fontSize: sidebarRow.textFontSize, color: cssVar.colorTextSecondary },
});
const EMPTY_VERSIONS: WorkVersionItem[] = [];
@@ -46,11 +55,7 @@ const VersionList = memo<{ workId: string }>(({ workId }) => {
if (stored === undefined && !error && !isHydrated) return null;
if (stored === undefined && !error) {
- return (
- <Center height={56}>
- <Spin size="small" />
- </Center>
- );
+ return <SkeletonList compact className={stylex.props(styles.skeleton).className} rows={2} />;
}
// A failed refresh keeps the settled timeline on screen.
@@ -64,8 +69,10 @@ const VersionList = memo<{ workId: string }>(({ workId }) => {
if (data.length === 0) {
return (
- <Flexbox className={stylex.props(styles.versionList).className}>
- <Text type={'secondary'}>{t('workingPanel.works.emptyVersions')}</Text>
+ <Flexbox className={stylex.props(styles.versionRow).className}>
+ <Text fontSize={12} type={'secondary'}>
+ {t('workingPanel.works.emptyVersions')}
+ </Text>
</Flexbox>
);
}
diff --git a/src/features/Conversation/WorkingSidebar/WorksSection/WorkVersionHistoryCard.tsx b/src/features/Conversation/WorkingSidebar/WorksSection/WorkVersionHistoryCard.tsx
index 51f8b42a4b0..baf2b776cd2 100644
--- a/src/features/Conversation/WorkingSidebar/WorksSection/WorkVersionHistoryCard.tsx
+++ b/src/features/Conversation/WorkingSidebar/WorksSection/WorkVersionHistoryCard.tsx
@@ -10,6 +10,8 @@ import TaskStatusTag from '@/features/AgentTasks/features/TaskStatusTag';
import { getWorkTypeDescriptor, isSafeExternalUrl } from '@/features/Work/descriptors';
import { useResourceDeletedPrompt } from '@/features/Work/useResourceDeletedPrompt';
import { useChatStore } from '@/store/chat';
+import { useDensityTokens } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
import VersionList from './VersionList';
@@ -27,30 +29,47 @@ const toTaskStatus = (status?: string | null): TaskStatus =>
status && TASK_STATUS_SET.has(status as TaskStatus) ? (status as TaskStatus) : 'backlog';
const styles = stylex.create({
- context: { flexShrink: 0, color: cssVar.colorTextTertiary },
+ context: {
+ flexShrink: 0,
+ fontSize: sidebarRow.metaFontSize,
+ fontVariantNumeric: 'tabular-nums',
+ color: cssVar.colorTextTertiary,
+ },
header: {
cursor: 'pointer',
userSelect: 'none',
- paddingBlock: '10px',
- paddingInline: '8px',
- backgroundColor: { 'default': null, ':hover': cssVar.colorFillQuaternary },
+ minHeight: sidebarRow.height,
+ paddingInline: sidebarRow.paddingInline,
+ borderRadius: sidebarRow.radius,
+ fontSize: sidebarRow.textFontSize,
+ lineHeight: sidebarRow.textLineHeight,
+ color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
backgroundImage: { 'default': null, ':hover': 'none' },
},
- title: { minWidth: '0', fontSize: '14px', fontWeight: 500 },
- toggle: { flexShrink: 0 },
- workCard: {
- overflow: 'hidden',
- borderWidth: '1px',
- borderStyle: 'solid',
- borderColor: cssVar.colorBorderSecondary,
- borderRadius: '8px',
- backgroundColor: cssVar.colorFillQuaternary,
- backgroundImage: 'none',
+ icon: {
+ display: 'flex',
+ flexShrink: 0,
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: sidebarRow.iconBox,
+ height: sidebarRow.textLineHeight,
+ color: cssVar.colorTextTertiary,
+ },
+ title: { minWidth: '0', fontSize: 'inherit', color: 'inherit' },
+ toggle: {
+ display: 'flex',
+ flexShrink: 0,
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '16px',
+ color: cssVar.colorTextTertiary,
},
});
const WorkVersionHistoryCard = memo<{ work: WorkListItem }>(({ work }) => {
const [expanded, setExpanded] = useState(false);
+ const density = useDensityTokens();
const [openCanvas, openDocument, openFilePreview, openTaskDetail] = useChatStore((s) => [
s.openCanvas,
s.openDocument,
@@ -102,22 +121,26 @@ const WorkVersionHistoryCard = memo<{ work: WorkListItem }>(({ work }) => {
})();
return (
- <Flexbox className={stylex.props(styles.workCard).className}>
+ <Flexbox>
<Flexbox
horizontal
align={'center'}
className={stylex.props(styles.header).className}
- gap={8}
+ gap={density.gap}
onClick={() => setExpanded((value) => !value)}
>
- <ToggleIcon className={stylex.props(styles.toggle).className} size={16} />
+ <span {...stylex.props(styles.toggle)}>
+ <ToggleIcon size={12} />
+ </span>
{work.type === 'task' ? (
<>
<TaskPriorityTag disableDropdown priority={work.task.priority} size={14} />
<TaskStatusTag disableDropdown size={14} status={toTaskStatus(work.task.status)} />
</>
) : (
- <TypeIcon className={stylex.props(styles.context).className} size={16} />
+ <span {...stylex.props(styles.icon)}>
+ <TypeIcon size={density.iconSize} />
+ </span>
)}
<Text className={stylex.props(styles.context).className} style={{ flexShrink: 0 }}>
{label}
diff --git a/src/features/Conversation/WorkingSidebar/WorksSection/index.tsx b/src/features/Conversation/WorkingSidebar/WorksSection/index.tsx
index a1775d5c509..f80e00d116e 100644
--- a/src/features/Conversation/WorkingSidebar/WorksSection/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/WorksSection/index.tsx
@@ -1,12 +1,13 @@
import type { WorkListItem } from '@lobechat/types';
-import { ActionIcon, Center, Empty, Flexbox, Spin } from '@lobehub/ui';
-import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import { ActionIcon, Center, Empty, Flexbox } from '@lobehub/ui';
import * as stylex from '@stylexjs/stylex';
import isEqual from 'fast-deep-equal';
import { ClipboardListIcon, HistoryIcon, ListIcon } from 'lucide-react';
import { memo, useEffect, useMemo, useRef } from 'react';
import { useTranslation } from 'react-i18next';
+import AsyncError from '@/components/AsyncError';
+import { SkeletonList } from '@/components/Skeleton/NavPanel/List';
import { getAllWorkSummaries } from '@/features/Conversation/store/slices/data/workSummaries';
import WorkSummaryCard from '@/features/Work/WorkSummaryCard';
import { useLocalStorageState } from '@/hooks/useLocalStorageState';
@@ -14,6 +15,7 @@ import { workService } from '@/services/work';
import { useChatStore } from '@/store/chat';
import { dbMessageSelectors, operationSelectors } from '@/store/chat/selectors';
import { useWorkStore, workActions, workSelectors } from '@/store/work';
+import { sidebarRow } from '@/styles/density.stylex';
import WorkVersionHistoryCard from './WorkVersionHistoryCard';
@@ -24,21 +26,19 @@ const WORKS_VIEW_MODE_STORAGE_KEY = 'lobechat-working-panel-works-view-mode';
const EMPTY_HISTORY: WorkListItem[] = [];
const styles = stylex.create({
- container: {
+ container: { minHeight: '0' },
+ list: {
minHeight: '0',
- paddingBlock: '8px',
- paddingInlineStart: '8px',
- paddingInlineEnd: '12px',
+ paddingBlockStart: sidebarRow.paneBlockStart,
+ paddingBlockEnd: sidebarRow.paneBlockEnd,
+ paddingInline: sidebarRow.paneInline,
},
- modeToolbar: { flexShrink: 0, alignSelf: 'flex-end' },
- workCard: {
- overflow: 'hidden',
- borderWidth: '1px',
- borderStyle: 'solid',
- borderColor: cssVar.colorBorderSecondary,
- borderRadius: '8px',
- backgroundColor: cssVar.colorFillQuaternary,
- backgroundImage: 'none',
+ modeToolbar: {
+ flexShrink: 0,
+ justifyContent: 'flex-end',
+ height: sidebarRow.toolbarHeight,
+ paddingInlineStart: sidebarRow.toolbarPaddingInlineStart,
+ paddingInlineEnd: sidebarRow.toolbarPaddingInlineEnd,
},
});
@@ -49,7 +49,12 @@ const WorksModeToolbar = memo<{
const { t } = useTranslation('chat');
return (
- <Flexbox horizontal className={stylex.props(styles.modeToolbar).className} gap={4}>
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={stylex.props(styles.modeToolbar).className}
+ gap={4}
+ >
<ActionIcon
active={mode === 'summary'}
icon={ListIcon}
@@ -161,45 +166,38 @@ const WorksSection = memo<WorksSectionProps>(({ active = true }) => {
const content = (() => {
if (isHydrating) return null;
- if (isLoading) {
- return (
- <Center flex={1}>
- <Spin size="middle" />
- </Center>
- );
- }
+ if (isLoading) return <SkeletonList compact rows={4} />;
if (error) {
return (
- <Center flex={1}>
- <Empty description={t('workingPanel.works.error')} icon={ClipboardListIcon} />
- </Center>
+ <AsyncError
+ align={'start'}
+ error={error}
+ title={t('workingPanel.works.error')}
+ variant={'inline'}
+ />
);
}
if (data.length === 0) {
return (
- <Center flex={1}>
+ <Center flex={1} paddingBlock={24}>
<Empty description={t('workingPanel.works.empty')} icon={ClipboardListIcon} />
</Center>
);
}
return mode === 'summary'
- ? summaryData.map((work) => (
- <WorkSummaryCard
- className={stylex.props(styles.workCard).className}
- item={work}
- key={work.id}
- />
- ))
+ ? summaryData.map((work) => <WorkSummaryCard item={work} key={work.id} variant={'row'} />)
: historyData.map((work) => <WorkVersionHistoryCard key={work.id} work={work} />);
})();
return (
- <Flexbox className={stylex.props(styles.container).className} flex={1} gap={12}>
+ <Flexbox className={stylex.props(styles.container).className} flex={1}>
<WorksModeToolbar mode={mode} setMode={setMode} />
- {content}
+ <Flexbox className={stylex.props(styles.list).className} flex={1} gap={1}>
+ {content}
+ </Flexbox>
</Flexbox>
);
});
diff --git a/src/features/Conversation/WorkingSidebar/WorkspaceTab.tsx b/src/features/Conversation/WorkingSidebar/WorkspaceTab.tsx
index e22c0792bfe..5f2071dc5ed 100644
--- a/src/features/Conversation/WorkingSidebar/WorkspaceTab.tsx
+++ b/src/features/Conversation/WorkingSidebar/WorkspaceTab.tsx
@@ -32,7 +32,7 @@ const styles = stylex.create({
borderStyle: 'none',
borderRadius: '4px',
color: { 'default': cssVar.colorTextTertiary, ':hover': cssVar.colorText },
- backgroundColor: { 'default': 'transparent', ':hover': cssVar.colorFillSecondary },
+ backgroundColor: { 'default': 'transparent', ':hover': cssVar.colorFill },
backgroundImage: { 'default': 'none', ':hover': 'none' },
transition: 'color 0.15s, background 0.15s',
animationName: { 'default': fadeIn, '@media (prefers-reduced-motion: reduce)': 'none' },
@@ -47,15 +47,16 @@ const styles = stylex.create({
display: 'flex',
flexShrink: 0,
alignItems: 'center',
+ height: '24px',
borderRadius: '6px',
transition: 'background 0.15s',
- backgroundColor: { 'default': null, ':hover': cssVar.colorFillSecondary },
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
backgroundImage: { 'default': null, ':hover': 'none' },
},
// Composed after `container`: a conditional value replaces the whole property,
// so the hover colour is restated here.
containerActive: {
- backgroundColor: { 'default': cssVar.colorFillTertiary, ':hover': cssVar.colorFillSecondary },
+ backgroundColor: { 'default': cssVar.colorFillSecondary, ':hover': cssVar.colorFillSecondary },
backgroundImage: { 'default': 'none', ':hover': 'none' },
},
pinned: {
@@ -72,12 +73,16 @@ const styles = stylex.create({
label: { overflow: 'hidden', minWidth: '24px', maxWidth: '160px', textOverflow: 'ellipsis' },
tab: {
cursor: 'pointer',
- paddingBlock: '4px',
+ display: 'flex',
+ alignItems: 'center',
+ height: '24px',
+ paddingBlock: 0,
paddingInline: TAB_PADDING,
borderWidth: 0,
borderStyle: 'none',
borderRadius: '6px',
fontSize: '12px',
+ lineHeight: '16px',
// attribute selector outranks the base class so the active color can't lose
// to stylesheet ordering
color: {
diff --git a/src/features/Conversation/WorkingSidebar/index.tsx b/src/features/Conversation/WorkingSidebar/index.tsx
index 7f1af9c9b5a..b6baf9e2d4b 100644
--- a/src/features/Conversation/WorkingSidebar/index.tsx
+++ b/src/features/Conversation/WorkingSidebar/index.tsx
@@ -33,7 +33,6 @@ import {
import { useTranslation } from 'react-i18next';
import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { isDesktop } from '@/const/version';
import {
getPullRequestState,
@@ -63,6 +62,7 @@ import { deviceSelectors, useDeviceStore } from '@/store/device';
import { useElectronStore } from '@/store/electron';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
+import { useHeaderActionSize } from '@/styles/density';
import { openTrustedExternalUrl } from '@/utils/openTrustedExternalUrl';
import { type ComposerTarget, createComposerTarget, resolveThreadComposerTarget } from '../types';
@@ -120,7 +120,7 @@ const styles = stylex.create({
borderWidth: '1px',
borderStyle: 'solid',
borderColor: cssVar.colorBorderSecondary,
- borderRadius: '16px',
+ borderRadius: '12px',
backgroundColor: cssVar.colorBgContainer,
backgroundImage: 'none',
boxShadow: cssVar.boxShadowTertiary,
@@ -141,7 +141,7 @@ const styles = stylex.create({
'scrollbarWidth': 'none',
'overflowX': 'auto',
'display': 'flex',
- 'gap': '4px',
+ 'gap': '2px',
'alignItems': 'center',
'minWidth': '0',
'::-webkit-scrollbar': { display: 'none' },
@@ -167,6 +167,7 @@ interface AgentWorkingSidebarProps {
}
const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth }) => {
+ const headerActionSize = useHeaderActionSize(true);
const { t } = useTranslation(['chat', 'setting']);
// Keep the panel frame + tabs on the navigation commit; the pane contents
// mount in a deferred follow-up pass behind a skeleton.
@@ -925,7 +926,7 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth })
gap={4}
height={44}
justify={'space-between'}
- paddingInline={4}
+ paddingInline={6}
>
<div {...stylex.props(styles.tabsArea)}>
<div {...stylex.props(styles.tabs)} ref={tabsRef}>
@@ -958,7 +959,7 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth })
<ActionIcon
className={stylex.props(styles.add).className}
icon={PlusIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
title={t('workingPanel.openMenu.title')}
/>
</DropdownMenu>
@@ -966,7 +967,7 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth })
<ActionIcon
className={stylex.props(styles.close).className}
icon={PanelRightCloseIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
onClick={() => toggleRightPanel(false)}
/>
</Flexbox>
diff --git a/src/features/DesktopLayoutContainer/cssVariables.test.ts b/src/features/DesktopLayoutContainer/cssVariables.test.ts
index d5cb23a442b..3f88452d8ef 100644
--- a/src/features/DesktopLayoutContainer/cssVariables.test.ts
+++ b/src/features/DesktopLayoutContainer/cssVariables.test.ts
@@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
import { getDarwinMajorVersion, isMacOSWithLargeWindowBorders } from '@/utils/platform';
-import { getInnerCssVariables, getOuterCssVariables } from './cssVariables';
+import { getContainerTopInset, getInnerCssVariables, getOuterCssVariables } from './cssVariables';
vi.mock('@/utils/platform', () => ({
getDarwinMajorVersion: vi.fn(() => 0),
@@ -24,6 +24,16 @@ describe('getOuterCssVariables', () => {
});
});
+describe('getContainerTopInset', () => {
+ it('adds the 1px card border to the 8px web top padding', () => {
+ expect(getContainerTopInset(false)).toBe(9);
+ });
+
+ it('is only the card border on desktop, where the container has no top padding', () => {
+ expect(getContainerTopInset(true)).toBe(1);
+ });
+});
+
describe('getInnerCssVariables', () => {
it('uses the token radius below darwin 25', () => {
mockDarwin.mockReturnValue(24);
diff --git a/src/features/DesktopLayoutContainer/cssVariables.ts b/src/features/DesktopLayoutContainer/cssVariables.ts
index aa641d53a44..730e8ebde44 100644
--- a/src/features/DesktopLayoutContainer/cssVariables.ts
+++ b/src/features/DesktopLayoutContainer/cssVariables.ts
@@ -3,9 +3,16 @@ import { cssVar } from '@lobehub/ui';
import { isDesktop } from '@/const/version';
import { getDarwinMajorVersion, isMacOSWithLargeWindowBorders } from '@/utils/platform';
+export const CONTAINER_BORDER_WIDTH = 1;
+
+const getContainerPaddingTop = (desktop: boolean) => (desktop ? 0 : 8);
+
+export const getContainerTopInset = (desktop: boolean = isDesktop) =>
+ getContainerPaddingTop(desktop) + CONTAINER_BORDER_WIDTH;
+
export const getOuterCssVariables = ({ expand }: { expand?: boolean }): Record<string, string> => ({
'--container-padding-left': expand ? '0px' : '8px',
- '--container-padding-top': isDesktop ? '0px' : '8px',
+ '--container-padding-top': `${getContainerPaddingTop(isDesktop)}px`,
});
export const getInnerCssVariables = ({ isDark }: { isDark: boolean }): Record<string, string> => {
diff --git a/src/features/DesktopLayoutContainer/style.ts b/src/features/DesktopLayoutContainer/style.ts
index 6187735622e..3932f284bd8 100644
--- a/src/features/DesktopLayoutContainer/style.ts
+++ b/src/features/DesktopLayoutContainer/style.ts
@@ -2,6 +2,8 @@ import { createStaticStyles } from '@lobehub/ui';
import { isDesktop } from '@/const/version';
+import { CONTAINER_BORDER_WIDTH } from './cssVariables';
+
export const styles = createStaticStyles(({ css, cssVar }) => ({
// Inner container
innerContainer: css`
@@ -9,7 +11,7 @@ export const styles = createStaticStyles(({ css, cssVar }) => ({
overflow: hidden;
- border: 1px solid var(--container-border-color, ${cssVar.colorBorder});
+ border: ${CONTAINER_BORDER_WIDTH}px solid var(--container-border-color, ${cssVar.colorBorder});
border-radius: var(--container-border-radius, ${cssVar.borderRadius});
border-end-end-radius: var(
--container-border-bottom-right-radius,
diff --git a/src/features/DocumentModal/Header.tsx b/src/features/DocumentModal/Header.tsx
index a8c6ac48b6e..7b1e0374141 100644
--- a/src/features/DocumentModal/Header.tsx
+++ b/src/features/DocumentModal/Header.tsx
@@ -19,7 +19,6 @@ import { useTranslation } from 'react-i18next';
import ShareButton from '@/business/client/features/PageShare/ShareButton';
import { useActiveWorkspaceSlug } from '@/business/client/hooks/useActiveWorkspaceSlug';
-import { DESKTOP_HEADER_ICON_SIZE, DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { AutoSaveHint } from '@/features/EditorCanvas';
import { useMenu } from '@/features/PageEditor/Header/useMenu';
import { usePageAgentPanelControl } from '@/features/PageEditor/RightPanel/OverrideContext';
@@ -28,6 +27,7 @@ import ToggleRightPanelButton from '@/features/RightPanel/ToggleRightPanelButton
import { useAppOrigin } from '@/hooks/useAppOrigin';
import { useDocumentStore } from '@/store/document';
import { editorSelectors } from '@/store/document/slices/editor';
+import { useHeaderActionSize } from '@/styles/density';
import { buildDocumentModalUrl } from './url';
@@ -42,6 +42,8 @@ const styles = createStaticStyles(({ css }) => ({
}));
const DocumentModalHeader = memo(() => {
+ const headerActionSize = useHeaderActionSize();
+ const headerActionSmallSize = useHeaderActionSize(true);
const { t } = useTranslation(['file', 'common']);
const { close } = useModalContext();
const activeWorkspaceSlug = useActiveWorkspaceSlug();
@@ -90,7 +92,7 @@ const DocumentModalHeader = memo(() => {
placement={'bottomLeft'}
popupProps={{ style: { minWidth: 200 } }}
>
- <ActionIcon icon={MoreHorizontal} size={DESKTOP_HEADER_ICON_SMALL_SIZE} />
+ <ActionIcon icon={MoreHorizontal} size={headerActionSmallSize} />
</DropdownMenu>
</Flexbox>
<Flexbox horizontal align={'center'} gap={4}>
@@ -106,7 +108,7 @@ const DocumentModalHeader = memo(() => {
/>
<ActionIcon
icon={XIcon}
- size={DESKTOP_HEADER_ICON_SIZE}
+ size={headerActionSize}
title={t('close', { ns: 'common' })}
onClick={close}
/>
diff --git a/src/features/ExplorerTree/documentTreeStyle.test.ts b/src/features/ExplorerTree/documentTreeStyle.test.ts
index 4a0664e8c1d..f9ad7520291 100644
--- a/src/features/ExplorerTree/documentTreeStyle.test.ts
+++ b/src/features/ExplorerTree/documentTreeStyle.test.ts
@@ -3,6 +3,9 @@ import { join } from 'node:path';
import { describe, expect, it } from 'vitest';
+import { sidebarRow } from '@/styles/density.stylex';
+
+import { COMPACT_FOLDER_ICON_CSS } from '../Conversation/WorkingSidebar/Files/fileTreeStyle';
import {
DOCUMENT_TREE_ICON_CSS,
DOCUMENT_TREE_LAYOUT,
@@ -71,9 +74,17 @@ describe('code tree call sites', () => {
'features/Conversation/WorkingSidebar/Files/index.tsx': [
'features/Conversation/WorkingSidebar/Files/fileTreeStyle.ts',
],
- 'features/Conversation/WorkingSidebar/Review/FileTreeNav.tsx': [],
+ 'features/Conversation/WorkingSidebar/Review/FileTreeNav.tsx': [
+ 'features/Conversation/WorkingSidebar/Files/fileTreeStyle.ts',
+ ],
};
+ it('sizes the code tree folders to the file glyph and spaces them by the row gap', () => {
+ expect(COMPACT_FOLDER_ICON_CSS).toContain('width: 16px');
+ expect(COMPACT_FOLDER_ICON_CSS).toContain('background-size: 16px 16px');
+ expect(COMPACT_FOLDER_ICON_CSS).toContain(`margin-inline-end: ${sidebarRow.gap}`);
+ });
+
it.each(Object.keys(CODE_TREE_FILES))(
'%s renders with FOLDER_ICON_CSS and no document tokens',
(file) => {
@@ -82,12 +93,11 @@ describe('code tree call sites', () => {
expect(source).not.toContain('DOCUMENT_TREE_ICON_CSS');
expect(source).not.toContain('DOCUMENT_TREE_ROW_CSS');
expect(source).not.toContain('DOCUMENT_TREE_LAYOUT');
- // They keep their own pre-existing 12px label and pierre's default 30px row
- // (no `itemHeight` prop) — that is what "文件的那个 tree 渲染保留原样" means.
- // The document tree's 14px / 36px must never reach them.
- // Written as a `stylex.create` custom property key since the StyleX migration.
- expect(source).toMatch(/['"]?--trees-font-size-override['"]?:\s*['"]?12px/);
- expect(source).not.toContain('itemHeight');
+ // They follow the switchable WorkingSidebar row system, never the
+ // document tree's fixed 14px / 36px.
+ expect(source).toContain('COMPACT_FOLDER_ICON_CSS');
+ expect(source).toContain('itemHeight={density.treeItemHeight}');
+ expect(source).toMatch(/['"]--trees-font-size-override['"]:\s*sidebarRow\.textFontSize/);
},
);
});
diff --git a/src/features/Favorites/FavoriteButton.tsx b/src/features/Favorites/FavoriteButton.tsx
index 575928479f5..54b1e776096 100644
--- a/src/features/Favorites/FavoriteButton.tsx
+++ b/src/features/Favorites/FavoriteButton.tsx
@@ -6,10 +6,10 @@ import { StarIcon } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { useHotkeyById } from '@/hooks/useHotkeys/useHotkeyById';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/selectors';
+import { useHeaderActionSize } from '@/styles/density';
import { useOwnsFavoriteHotkey } from './hotkeyOwner';
import { type FavoriteTarget, useFavoriteToggle } from './useFavoriteToggle';
@@ -22,37 +22,36 @@ interface FavoriteButtonProps extends FavoriteTarget {
* Header star that adds the open page to the sidebar Favorites. The most
* recently mounted star also answers the favorite hotkey.
*/
-const FavoriteButton = memo<FavoriteButtonProps>(
- ({ size = DESKTOP_HEADER_ICON_SMALL_SIZE, ...target }) => {
- const { t } = useTranslation('common');
- const { isFavorite, isReady, toggle } = useFavoriteToggle(target);
- const hotkey = useUserStore(settingsSelectors.getHotkeyById(HotkeyEnum.ToggleFavorite));
- const ownsHotkey = useOwnsFavoriteHotkey();
-
- // Typing in a field must not toggle the favorite, so the hotkey stays out of form tags.
- useHotkeyById(HotkeyEnum.ToggleFavorite, () => void toggle(), {
- enableOnFormTags: false,
- enabled: ownsHotkey,
- });
-
- const label = t(isFavorite ? 'favorite.remove' : 'favorite.add');
-
- return (
- <ActionIcon
- aria-label={label}
- aria-pressed={isFavorite}
- color={isFavorite ? cssVar.colorWarning : undefined}
- disabled={!isReady}
- fill={isFavorite ? cssVar.colorWarning : 'none'}
- icon={StarIcon}
- size={size}
- title={label}
- tooltipProps={{ hotkey, placement: 'bottom' }}
- onClick={() => void toggle()}
- />
- );
- },
-);
+const FavoriteButton = memo<FavoriteButtonProps>(({ size, ...target }) => {
+ const { t } = useTranslation('common');
+ const headerActionSmallSize = useHeaderActionSize(true);
+ const { isFavorite, isReady, toggle } = useFavoriteToggle(target);
+ const hotkey = useUserStore(settingsSelectors.getHotkeyById(HotkeyEnum.ToggleFavorite));
+ const ownsHotkey = useOwnsFavoriteHotkey();
+
+ // Typing in a field must not toggle the favorite, so the hotkey stays out of form tags.
+ useHotkeyById(HotkeyEnum.ToggleFavorite, () => void toggle(), {
+ enableOnFormTags: false,
+ enabled: ownsHotkey,
+ });
+
+ const label = t(isFavorite ? 'favorite.remove' : 'favorite.add');
+
+ return (
+ <ActionIcon
+ aria-label={label}
+ aria-pressed={isFavorite}
+ color={isFavorite ? cssVar.colorWarning : undefined}
+ disabled={!isReady}
+ fill={isFavorite ? cssVar.colorWarning : 'none'}
+ icon={StarIcon}
+ size={size ?? headerActionSmallSize}
+ title={label}
+ tooltipProps={{ hotkey, placement: 'bottom' }}
+ onClick={() => void toggle()}
+ />
+ );
+});
FavoriteButton.displayName = 'FavoriteButton';
diff --git a/src/features/Home/Recents/Item.tsx b/src/features/Home/Recents/Item.tsx
index 6ba59e819ce..20c4243bbb4 100644
--- a/src/features/Home/Recents/Item.tsx
+++ b/src/features/Home/Recents/Item.tsx
@@ -48,7 +48,6 @@ const RecentListItem = memo<RecentItem>((item) => {
<Flexbox style={{ position: 'relative' }}>
<NavItem
contextMenuItems={dropdownMenu}
- height={32}
title={title}
actions={
<DropdownMenu items={dropdownMenu()}>
diff --git a/src/features/Home/Recents/List.tsx b/src/features/Home/Recents/List.tsx
index fb54d22c1aa..aacaad44846 100644
--- a/src/features/Home/Recents/List.tsx
+++ b/src/features/Home/Recents/List.tsx
@@ -56,12 +56,7 @@ const RecentsList = memo<RecentsListProps>(({ error, onRetry }) => {
return <ConnectedItem itemRef={itemRef} key={itemRef} queryKey={queryKey} />;
})}
{hasMore && (
- <NavItem
- height={32}
- icon={MoreHorizontalIcon}
- title={t('input.more')}
- onClick={openDrawer}
- />
+ <NavItem icon={MoreHorizontalIcon} title={t('input.more')} onClick={openDrawer} />
)}
<AllRecentsDrawer open={drawerOpen} onClose={closeDrawer} />
</Flexbox>
diff --git a/src/features/Home/Recents/index.tsx b/src/features/Home/Recents/index.tsx
index d3eb45a59e5..e2c2e1bdc03 100644
--- a/src/features/Home/Recents/index.tsx
+++ b/src/features/Home/Recents/index.tsx
@@ -12,7 +12,6 @@ import {
Flexbox,
Icon,
Spin,
- Text,
} from '@lobehub/ui';
import {
ArrowDownIcon,
@@ -28,6 +27,7 @@ import { useTranslation } from 'react-i18next';
import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';
import { openCustomizeSidebarModal } from '@/features/HomeSidebar/Body/CustomizeSidebarModal';
+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';
@@ -46,6 +46,7 @@ interface RecentsProps {
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);
@@ -137,11 +138,9 @@ const Recents = memo<RecentsProps>(({ itemKey }) => {
<AccordionItem value={itemKey}>
<ContextMenuTrigger items={dropdownMenu}>
<AccordionHeader>
- <AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionTrigger style={sectionTriggerStyle}>
<Flexbox horizontal align="center" gap={4}>
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {t('recents')}
- </Text>
+ <SectionTitle>{t('recents')}</SectionTitle>
{syncStatus.isValidating && items && <Spin size="small" variant="network" />}
</Flexbox>
</AccordionTrigger>
diff --git a/src/features/HomeSidebar/Body/Agent/CreateAgentButton.tsx b/src/features/HomeSidebar/Body/Agent/CreateAgentButton.tsx
index da8a9a43d4b..16e2da4d197 100644
--- a/src/features/HomeSidebar/Body/Agent/CreateAgentButton.tsx
+++ b/src/features/HomeSidebar/Body/Agent/CreateAgentButton.tsx
@@ -17,6 +17,7 @@ import { ChevronDownIcon, PlusIcon } from 'lucide-react';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
+import { useNavItemMetrics } from '@/features/NavPanel/density';
import { usePermission } from '@/hooks/usePermission';
import { SessionDefaultGroup } from '@/types/session';
@@ -54,6 +55,7 @@ interface CreateAgentButtonProps {
}
const CreateAgentButton = memo<CreateAgentButtonProps>(({ groupId, className, visibility }) => {
+ const metrics = useNavItemMetrics();
const { t } = useTranslation('chat');
const { allowed: canCreate, reason } = usePermission('create_content');
const {
@@ -117,14 +119,18 @@ const CreateAgentButton = memo<CreateAgentButtonProps>(({ groupId, className, vi
align={'center'}
className={cx(styles.container, className)}
clickable={canCreate}
- gap={8}
- height={36}
- paddingInline={4}
- style={canCreate ? { height: 36 } : { cursor: 'not-allowed', height: 36, opacity: 0.5 }}
+ gap={metrics.gap}
+ height={metrics.rowHeight}
+ paddingInline={metrics.paddingInline}
variant={'borderless'}
+ style={
+ canCreate
+ ? { height: metrics.rowHeight }
+ : { cursor: 'not-allowed', height: metrics.rowHeight, opacity: 0.5 }
+ }
onClick={handleClick}
>
- <Center flex={'none'} height={28} width={28}>
+ <Center flex={'none'} height={metrics.iconBox} width={metrics.iconBox}>
<Icon icon={PlusIcon} size={'small'} />
</Center>
<Text style={{ flex: 1 }} type={'secondary'}>
diff --git a/src/features/HomeSidebar/Body/Agent/List/AgentListContent.tsx b/src/features/HomeSidebar/Body/Agent/List/AgentListContent.tsx
index 3e6b28f1e2e..5d6e935f2e3 100644
--- a/src/features/HomeSidebar/Body/Agent/List/AgentListContent.tsx
+++ b/src/features/HomeSidebar/Body/Agent/List/AgentListContent.tsx
@@ -74,7 +74,7 @@ const AgentListContent = memo<AgentListContentProps>(({ hideInbox, onMoreClick }
if (contentState !== 'ready')
return (
<>
- {!hideInbox && <InboxItem style={{ minHeight: 36 }} />}
+ {!hideInbox && <InboxItem />}
{contentState === 'loading' && <SkeletonList rows={3} />}
</>
);
@@ -83,7 +83,7 @@ const AgentListContent = memo<AgentListContentProps>(({ hideInbox, onMoreClick }
// even when the user has only the built-in Lobe AI inbox.
return (
<>
- {!hideInbox && <InboxItem style={{ minHeight: 36 }} />}
+ {!hideInbox && <InboxItem />}
{showPinned &&
(isWorkspace ? (
<SessionList dataSource={pinnedList!} />
diff --git a/src/features/HomeSidebar/Body/Agent/List/Group/Item.tsx b/src/features/HomeSidebar/Body/Agent/List/Group/Item.tsx
index b14934a0c84..df67e49fa49 100644
--- a/src/features/HomeSidebar/Body/Agent/List/Group/Item.tsx
+++ b/src/features/HomeSidebar/Body/Agent/List/Group/Item.tsx
@@ -17,6 +17,7 @@ import { HashIcon } from 'lucide-react';
import React, { memo, useCallback, useMemo, useState } from 'react';
import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import { useHomeStore } from '@/store/home';
import { useCreateMenuItems } from '../../../../hooks';
@@ -29,6 +30,7 @@ import { useGroupDropdownMenu } from './useDropdownMenu';
const styles = stylex.create({ item: { paddingInlineStart: '14px' } });
const GroupItem = memo<SidebarGroup>(({ items, id, name, visibility }) => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const [anchor, setAnchor] = useState<HTMLElement | null>(null);
const isUpdating = useHomeStore((s) => s.groupUpdatingId === id);
// Public and private folders share one Agents section in a workspace.
@@ -65,12 +67,10 @@ const GroupItem = memo<SidebarGroup>(({ items, id, name, visibility }) => {
<ContextMenuTrigger items={dropdownMenu}>
<div ref={setAnchor}>
<AccordionHeader>
- <AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionTrigger style={sectionTriggerStyle}>
<Flexbox horizontal align="center" gap={6} style={{ overflow: 'hidden' }}>
{groupIcon}
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {name}
- </Text>
+ <SectionTitle>{name}</SectionTitle>
{/* Outside the ellipsis so a long name can't push it out of view. */}
{isPrivateFolder && <PrivateLockIcon />}
</Flexbox>
diff --git a/src/features/HomeSidebar/Body/Agent/List/WorkspaceAgentListContent.tsx b/src/features/HomeSidebar/Body/Agent/List/WorkspaceAgentListContent.tsx
index 7a77ff58719..8a66e19f6ec 100644
--- a/src/features/HomeSidebar/Body/Agent/List/WorkspaceAgentListContent.tsx
+++ b/src/features/HomeSidebar/Body/Agent/List/WorkspaceAgentListContent.tsx
@@ -118,7 +118,7 @@ const WorkspaceAgentListContent = memo<{ hideInbox?: boolean }>(({ hideInbox })
if (contentState !== 'ready')
return (
<>
- {!hideInbox && <InboxItem style={{ minHeight: 36 }} />}
+ {!hideInbox && <InboxItem />}
{contentState === 'loading' && <SkeletonList rows={3} />}
</>
);
@@ -127,7 +127,7 @@ const WorkspaceAgentListContent = memo<{ hideInbox?: boolean }>(({ hideInbox })
return (
<>
- {!hideInbox && <InboxItem style={{ minHeight: 36 }} />}
+ {!hideInbox && <InboxItem />}
{myPinned.length > 0 && (
<Flexbox data-testid={'sidebar-my-pinned'} gap={1}>
<SubHeader
diff --git a/src/features/HomeSidebar/Body/Agent/index.tsx b/src/features/HomeSidebar/Body/Agent/index.tsx
index 405174240a3..707b195f1b1 100644
--- a/src/features/HomeSidebar/Body/Agent/index.tsx
+++ b/src/features/HomeSidebar/Body/Agent/index.tsx
@@ -11,13 +11,13 @@ import {
cx,
Flexbox,
Spin,
- Text,
} from '@lobehub/ui';
import { ArrowRight } from 'lucide-react';
import React, { memo, type MouseEvent, Suspense, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useFetchAgentLabels } from '@/hooks/useFetchAgentLabels';
@@ -36,6 +36,7 @@ interface AgentProps {
const Agent = memo<AgentProps>(({ itemKey }) => {
const { t } = useTranslation('common');
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { isRevalidating } = useFetchAgentList();
// Keep the label registry warm so the per-item "Labels" submenu opens populated.
useFetchAgentLabels();
@@ -121,11 +122,9 @@ const Agent = memo<AgentProps>(({ itemKey }) => {
<AccordionItem value={itemKey}>
<ContextMenuTrigger items={dropdownMenu}>
<AccordionHeader>
- <AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionTrigger style={sectionTriggerStyle}>
<Flexbox horizontal align="center" gap={4}>
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {t('navPanel.agent')}
- </Text>
+ <SectionTitle>{t('navPanel.agent')}</SectionTitle>
{isRevalidating && <Spin size="small" variant="network" />}
</Flexbox>
</AccordionTrigger>
diff --git a/src/features/HomeSidebar/Body/Favorites/FavoriteItem.tsx b/src/features/HomeSidebar/Body/Favorites/FavoriteItem.tsx
index e69d76c6347..4a23553822b 100644
--- a/src/features/HomeSidebar/Body/Favorites/FavoriteItem.tsx
+++ b/src/features/HomeSidebar/Body/Favorites/FavoriteItem.tsx
@@ -40,7 +40,6 @@ const FavoriteItem = memo<FavoriteItemProps>(({ active, item }) => {
<NavItem
active={active}
contextMenuItems={menuItems}
- height={32}
icon={<FavoriteItemIcon item={item} />}
title={item.title}
actions={() => (
diff --git a/src/features/HomeSidebar/Body/Favorites/SortableFavoriteList.tsx b/src/features/HomeSidebar/Body/Favorites/SortableFavoriteList.tsx
index b7897e299af..8a489f7409a 100644
--- a/src/features/HomeSidebar/Body/Favorites/SortableFavoriteList.tsx
+++ b/src/features/HomeSidebar/Body/Favorites/SortableFavoriteList.tsx
@@ -140,7 +140,6 @@ const SortableFavoriteList = memo<{ items: FavoriteItemType[] }>(({ items }) =>
{activeItem ? (
<div {...stylex.props(styles.overlay)}>
<NavItem
- height={32}
icon={<FavoriteItemIcon item={activeItem} />}
// The card itself is the surface: no hover tint on top of the white.
style={{ backgroundColor: 'transparent' }}
diff --git a/src/features/HomeSidebar/Body/Favorites/index.tsx b/src/features/HomeSidebar/Body/Favorites/index.tsx
index 749ae627e6c..35a8d58b527 100644
--- a/src/features/HomeSidebar/Body/Favorites/index.tsx
+++ b/src/features/HomeSidebar/Body/Favorites/index.tsx
@@ -1,17 +1,12 @@
'use client';
-import {
- AccordionHeader,
- AccordionItem,
- AccordionPanel,
- AccordionTrigger,
- Text,
-} from '@lobehub/ui';
+import { AccordionHeader, AccordionItem, AccordionPanel, AccordionTrigger } from '@lobehub/ui';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import AsyncError from '@/components/AsyncError';
import { useFetchFavorites } from '@/features/Favorites';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import { useHomeStore } from '@/store/home';
import { favoriteSelectors } from '@/store/home/selectors';
@@ -30,6 +25,7 @@ interface FavoritesProps {
*/
const Favorites = memo<FavoritesProps>(({ itemKey }) => {
const { t } = useTranslation('common');
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { error, revalidate } = useFetchFavorites();
const list = useHomeStore(favoriteSelectors.favoriteList);
const loadFailed = list === undefined && !!error;
@@ -38,14 +34,12 @@ const Favorites = memo<FavoritesProps>(({ itemKey }) => {
return (
<AccordionItem value={itemKey}>
- {/* Recents and Agents carry a header action that sets their height at
- 32px; Favorites has none, so pin the same height to keep the
- section headers aligned. */}
- <AccordionHeader style={{ minHeight: 32 }}>
- <AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
- <Text ellipsis fontSize={12} type="secondary" weight={500}>
- {t('favorite.section')}
- </Text>
+ {/* 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>
<AccordionPanel>
diff --git a/src/features/HomeSidebar/Body/index.tsx b/src/features/HomeSidebar/Body/index.tsx
index ec4ce748004..fdcb7fb0061 100644
--- a/src/features/HomeSidebar/Body/index.tsx
+++ b/src/features/HomeSidebar/Body/index.tsx
@@ -11,6 +11,7 @@ import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspace
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';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
import { useActiveTabKey } from '@/hooks/useActiveTabKey';
@@ -43,7 +44,6 @@ const ACCORDION_KEYS = new Set<string>([GroupKey.Favorites, GroupKey.Recents, Gr
/** Keys rendered in the header — must be excluded from the body to avoid duplicates
* when migrating users whose persisted sidebarItems still include them. */
const HEADER_KEYS = new Set<string>(['home', 'search']);
-const SECTION_GAP = 8;
const accordionComponents: Record<string, (key: string) => ReactElement> = {
[GroupKey.Agent]: (key) => <Agent itemKey={key} key={key} />,
@@ -69,6 +69,7 @@ const mergeSidebarExpandedKeys = (
const Body = memo(() => {
const { t } = useTranslation('common');
+ const { panelPaddingInline, sectionGap } = useNavItemMetrics();
const tab = useActiveTabKey();
const navigate = useWorkspaceAwareNavigate();
const { topNavItems, bottomMenuItems } = useNavLayout();
@@ -199,7 +200,7 @@ const Body = memo(() => {
<AccordionRoot
indicatorPlacement="inline"
key={`acc-${sectionGroup.length}`}
- style={{ gap: SECTION_GAP }}
+ style={{ gap: sectionGap }}
value={sidebarExpandedKeys}
onValueChange={(keys) => handleAccordionExpandedChange(accordionKeys, keys as string[])}
>
@@ -214,7 +215,7 @@ const Body = memo(() => {
flushAccordion();
if (sectionGroup.length > 0) {
elements.push(
- <Flexbox gap={SECTION_GAP} key={`sections-${elements.length}`}>
+ <Flexbox gap={sectionGap} key={`sections-${elements.length}`}>
{sectionGroup}
</Flexbox>,
);
@@ -252,10 +253,10 @@ const Body = memo(() => {
flushSections();
return elements;
- }, [visibleKeys, renderNavLink, sidebarExpandedKeys, handleAccordionExpandedChange]);
+ }, [visibleKeys, renderNavLink, sidebarExpandedKeys, handleAccordionExpandedChange, sectionGap]);
return (
- <Flexbox flex={1} gap={1} paddingInline={4} style={{ minHeight: '100%' }}>
+ <Flexbox flex={1} gap={1} paddingInline={panelPaddingInline} style={{ minHeight: '100%' }}>
{content}
</Flexbox>
);
diff --git a/src/features/HomeSidebar/Footer/index.tsx b/src/features/HomeSidebar/Footer/index.tsx
index 9cf297847f2..a527f6df833 100644
--- a/src/features/HomeSidebar/Footer/index.tsx
+++ b/src/features/HomeSidebar/Footer/index.tsx
@@ -37,6 +37,8 @@ import { userGeneralSettingsSelectors } from '@/store/user/slices/settings/selec
type FooterMenuItems = NonNullable<DropdownItem[]>;
+const FOOTER_ICON_SIZE = { blockSize: 24, size: 14 };
+
/**
* Wrap each clickable menu item with a unified click tracker, preserving any
* existing onClick. Skips dividers and items without a key. Used to measure
@@ -275,16 +277,16 @@ const Footer = memo(() => {
aria-label={t('userPanel.help')}
data-billboard-anchor=""
icon={CircleHelp}
- size={16}
+ size={FOOTER_ICON_SIZE}
/>
</DropdownMenu>
{!footer.hideGitHub && (
<a aria-label={'GitHub'} href={GITHUB} rel="noopener noreferrer" target={'_blank'}>
- <ActionIcon icon={GithubIcon} size={16} title={'GitHub'} />
+ <ActionIcon icon={GithubIcon} size={FOOTER_ICON_SIZE} title={'GitHub'} />
</a>
)}
<WorkspaceLink to="/eval">
- <ActionIcon icon={FlaskConical} size={16} title="Evaluation Lab" />
+ <ActionIcon icon={FlaskConical} size={FOOTER_ICON_SIZE} title="Evaluation Lab" />
</WorkspaceLink>
</Flexbox>
<ThemeButton placement={'topCenter'} size={16} />
@@ -296,14 +298,18 @@ const Footer = memo(() => {
placement="topLeft"
onOpenChange={handleMenuOpenChange}
>
- <ActionIcon aria-label={t('userPanel.help')} icon={CircleHelp} size={16} />
+ <ActionIcon
+ aria-label={t('userPanel.help')}
+ icon={CircleHelp}
+ size={FOOTER_ICON_SIZE}
+ />
</DropdownMenu>
{isDevMode && (
<WorkspaceLink to="/settings">
<ActionIcon
aria-label={t(settingLabelKey)}
icon={SettingsIcon}
- size={16}
+ size={FOOTER_ICON_SIZE}
title={t(settingLabelKey)}
/>
</WorkspaceLink>
diff --git a/src/features/HomeSidebar/Header/components/HeaderActions.tsx b/src/features/HomeSidebar/Header/components/HeaderActions.tsx
new file mode 100644
index 00000000000..9b5030e5b38
--- /dev/null
+++ b/src/features/HomeSidebar/Header/components/HeaderActions.tsx
@@ -0,0 +1,42 @@
+'use client';
+
+import { ActionIcon } from '@lobehub/ui';
+import { SquarePenIcon } from 'lucide-react';
+import { useTranslation } from 'react-i18next';
+
+import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
+import { useNavLayout } from '@/hooks/useNavLayout';
+import { useHeaderActionSize } from '@/styles/density';
+
+import { resolveHeaderItems } from '../headerItems';
+
+const HeaderActions = () => {
+ const headerActionSize = useHeaderActionSize(true);
+ const { t } = useTranslation('common');
+ const navigate = useWorkspaceAwareNavigate();
+ const { topNavItems } = useNavLayout();
+ const { search } = resolveHeaderItems(topNavItems);
+
+ return (
+ <>
+ {search && (
+ <ActionIcon
+ aria-label={search.title}
+ icon={search.icon}
+ size={headerActionSize}
+ title={search.title}
+ onClick={search.onClick}
+ />
+ )}
+ <ActionIcon
+ aria-label={t('navPanel.newChat')}
+ icon={SquarePenIcon}
+ size={headerActionSize}
+ title={t('navPanel.newChat')}
+ onClick={() => navigate('/')}
+ />
+ </>
+ );
+};
+
+export default HeaderActions;
diff --git a/src/features/HomeSidebar/Header/components/InboxButton.tsx b/src/features/HomeSidebar/Header/components/InboxButton.tsx
deleted file mode 100644
index d849648011d..00000000000
--- a/src/features/HomeSidebar/Header/components/InboxButton.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-'use client';
-
-import { ActionIcon, Badge } from '@lobehub/ui';
-import { BellIcon } from 'lucide-react';
-import { memo, useCallback } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
-
-import { openInboxModal } from './InboxModal';
-import { useInboxUnreadCount } from './useInboxUnreadCount';
-
-const InboxButton = memo(() => {
- const { t } = useTranslation('notification');
- const { enabled, unreadCount } = useInboxUnreadCount();
-
- const handleOpen = useCallback(() => openInboxModal(), []);
-
- if (!enabled) return null;
-
- return (
- <Badge dot={unreadCount > 0} offset={[-6, 6]} size="small">
- <ActionIcon
- icon={BellIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
- title={t('inbox.title')}
- onClick={handleOpen}
- />
- </Badge>
- );
-});
-
-export default InboxButton;
diff --git a/src/features/HomeSidebar/Header/components/InboxModal/index.tsx b/src/features/HomeSidebar/Header/components/InboxModal/index.tsx
index f1be9084a87..79d84cd8ffd 100644
--- a/src/features/HomeSidebar/Header/components/InboxModal/index.tsx
+++ b/src/features/HomeSidebar/Header/components/InboxModal/index.tsx
@@ -30,21 +30,23 @@ import {
MoreHorizontalIcon,
SparklesIcon,
TagIcon,
+ XIcon,
} from 'lucide-react';
import { memo, useCallback, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';
import AsyncError from '@/components/AsyncError';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import NavItem from '@/features/NavPanel/components/NavItem';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
+import { NavPanelDensityContext } from '@/features/NavPanel/density';
import dynamic from '@/libs/next/dynamic';
import { mutate } from '@/libs/swr';
import { inboxKeys } from '@/libs/swr/keys';
import { useHomeStore } from '@/store/home';
import { homeNotificationSelectors } from '@/store/home/selectors';
import type { InboxNavigationCount } from '@/store/home/slices/notification/projection';
+import { useHeaderActionSize, useInterfaceDensity } from '@/styles/density';
import { useNavigationCounts } from './useNavigationCounts';
@@ -124,6 +126,8 @@ const CATEGORY_ICONS: Record<string, LucideIcon> = {
};
const InboxModalContent = memo(() => {
+ const headerActionSize = useHeaderActionSize(true);
+ const interfaceDensity = useInterfaceDensity();
const { i18n, t } = useTranslation('notification');
const workspaceId = useActiveWorkspaceId();
const [navigationFilter, setNavigationFilter] = useState(ALL_FILTER);
@@ -332,66 +336,71 @@ const InboxModalContent = memo(() => {
<ActionIcon
icon={MoreHorizontalIcon}
loading={bulkAction === 'archive'}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
title={t('more', { ns: 'common' })}
/>
</DropdownMenu>
- <ModalClose style={{ position: 'static' }} />
+ <ModalClose
+ render={<ActionIcon icon={XIcon} size={headerActionSize} />}
+ style={{ position: 'static' }}
+ />
</Flexbox>
</Flexbox>
</ModalHeader>
<Flexbox horizontal className={stylex.props(styles.body).className} flex={1}>
- <Flexbox className={stylex.props(styles.sidebar).className} gap={4}>
- <NavItem
- active={navigationFilter === ALL_FILTER}
- icon={BellIcon}
- title={t('inbox.all')}
- extra={
- allCount > 0 ? (
- <Text style={{ marginInlineEnd: 6 }} type="secondary">
- {allCount}
- </Text>
- ) : undefined
- }
- onClick={() => setNavigationFilter(ALL_FILTER)}
- />
- <Flexbox className={stylex.props(styles.categoryList).className} gap={4}>
- {isNavigationCountsLoading ? (
- <SkeletonList rows={4} />
- ) : (
- <>
- {navigationCountsError && (
- <AsyncError
- error={navigationCountsError}
- retrying={isNavigationCountsValidating}
- variant="inline"
- onRetry={() => void refreshNavigationCounts()}
- />
- )}
- {visibleCategoryCounts.map((item) => {
- const count = countForStatus(item);
-
- return (
- <NavItem
- active={navigationFilter === item.category}
- icon={CATEGORY_ICONS[item.category] ?? TagIcon}
- key={item.category}
- title={categoryLabel(item.category)}
- extra={
- count > 0 ? (
- <Text style={{ marginInlineEnd: 6 }} type="secondary">
- {count}
- </Text>
- ) : undefined
- }
- onClick={() => setNavigationFilter(item.category)}
+ <NavPanelDensityContext value={interfaceDensity}>
+ <Flexbox className={stylex.props(styles.sidebar).className} gap={4}>
+ <NavItem
+ active={navigationFilter === ALL_FILTER}
+ icon={BellIcon}
+ title={t('inbox.all')}
+ extra={
+ allCount > 0 ? (
+ <Text style={{ marginInlineEnd: 6 }} type="secondary">
+ {allCount}
+ </Text>
+ ) : undefined
+ }
+ onClick={() => setNavigationFilter(ALL_FILTER)}
+ />
+ <Flexbox className={stylex.props(styles.categoryList).className} gap={4}>
+ {isNavigationCountsLoading ? (
+ <SkeletonList rows={4} />
+ ) : (
+ <>
+ {navigationCountsError && (
+ <AsyncError
+ error={navigationCountsError}
+ retrying={isNavigationCountsValidating}
+ variant="inline"
+ onRetry={() => void refreshNavigationCounts()}
/>
- );
- })}
- </>
- )}
+ )}
+ {visibleCategoryCounts.map((item) => {
+ const count = countForStatus(item);
+
+ return (
+ <NavItem
+ active={navigationFilter === item.category}
+ icon={CATEGORY_ICONS[item.category] ?? TagIcon}
+ key={item.category}
+ title={categoryLabel(item.category)}
+ extra={
+ count > 0 ? (
+ <Text style={{ marginInlineEnd: 6 }} type="secondary">
+ {count}
+ </Text>
+ ) : undefined
+ }
+ onClick={() => setNavigationFilter(item.category)}
+ />
+ );
+ })}
+ </>
+ )}
+ </Flexbox>
</Flexbox>
- </Flexbox>
+ </NavPanelDensityContext>
<Flexbox className={stylex.props(styles.main).className} flex={1}>
<Flexbox flex={1} style={{ minHeight: 0 }}>
<Content
diff --git a/src/features/HomeSidebar/Header/components/InboxRow.tsx b/src/features/HomeSidebar/Header/components/InboxRow.tsx
new file mode 100644
index 00000000000..55117868ab7
--- /dev/null
+++ b/src/features/HomeSidebar/Header/components/InboxRow.tsx
@@ -0,0 +1,47 @@
+'use client';
+
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
+import { InboxIcon } from 'lucide-react';
+import { useTranslation } from 'react-i18next';
+
+import NavItem from '@/features/NavPanel/components/NavItem';
+
+import { openInboxModal } from './InboxModal';
+import { useInboxUnreadCount } from './useInboxUnreadCount';
+
+const styles = stylex.create({
+ count: {
+ minWidth: '16px',
+ height: '16px',
+ paddingInline: '4px',
+ borderRadius: '8px',
+ fontSize: '11px',
+ fontVariantNumeric: 'tabular-nums',
+ lineHeight: '16px',
+ color: cssVar.colorTextSecondary,
+ textAlign: 'center',
+ backgroundColor: cssVar.colorFillSecondary,
+ backgroundImage: 'none',
+ },
+});
+
+const InboxRow = () => {
+ const { t } = useTranslation('notification');
+ const { enabled, unreadCount } = useInboxUnreadCount();
+
+ if (!enabled) return null;
+
+ return (
+ <NavItem
+ icon={InboxIcon}
+ title={t('inbox.title')}
+ extra={
+ unreadCount > 0 ? <span {...stylex.props(styles.count)}>{unreadCount}</span> : undefined
+ }
+ onClick={() => openInboxModal()}
+ />
+ );
+};
+
+export default InboxRow;
diff --git a/src/features/HomeSidebar/Header/components/Nav.tsx b/src/features/HomeSidebar/Header/components/Nav.tsx
index 12da5815097..2d9465771fe 100644
--- a/src/features/HomeSidebar/Header/components/Nav.tsx
+++ b/src/features/HomeSidebar/Header/components/Nav.tsx
@@ -6,20 +6,22 @@ import { useTranslation } from 'react-i18next';
import NavItem from '@/features/NavPanel/components/NavItem';
import { type NavItemProps } from '@/features/NavPanel/components/NavItem';
+import { useNavItemMetrics } from '@/features/NavPanel/density';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
import { useActiveTabKey } from '@/hooks/useActiveTabKey';
import { useNavLayout } from '@/hooks/useNavLayout';
import { isModifierClick } from '@/utils/navigation';
-/** Keys that are rendered in the header; all others are managed by Body via sidebarSectionOrder */
-const HEADER_KEYS = new Set(['home', 'search']);
+import { resolveHeaderItems } from '../headerItems';
+import InboxRow from './InboxRow';
const Nav = memo(() => {
const tab = useActiveTabKey();
const navigate = useWorkspaceAwareNavigate();
const { t } = useTranslation('common');
const { topNavItems: items } = useNavLayout();
+ const { panelPaddingInline } = useNavItemMetrics();
const newBadge = (
<Tag color="blue" size="small">
@@ -28,42 +30,41 @@ const Nav = memo(() => {
);
return (
- <Flexbox gap={1} paddingInline={4}>
- {items
- .filter((item) => HEADER_KEYS.has(item.key) && !item.hidden)
- .map((item) => {
- const extra = item.isNew ? newBadge : undefined;
+ <Flexbox gap={1} paddingInline={panelPaddingInline}>
+ <InboxRow />
+ {resolveHeaderItems(items).rows.map((item) => {
+ const extra = item.isNew ? newBadge : undefined;
- const navItem = (
- <NavItem
- active={tab === item.key}
- extra={extra}
- hidden={item.hidden}
- icon={item.icon as NavItemProps['icon']}
- title={item.title}
- onClick={item.onClick}
- />
- );
+ const navItem = (
+ <NavItem
+ active={tab === item.key}
+ extra={extra}
+ hidden={item.hidden}
+ icon={item.icon as NavItemProps['icon']}
+ title={item.title}
+ onClick={item.onClick}
+ />
+ );
- if (!item.url) return <div key={item.key}>{navItem}</div>;
+ if (!item.url) return <div key={item.key}>{navItem}</div>;
- return (
- <WorkspaceLink
- key={item.key}
- to={item.url}
- onClick={(e) => {
- if (isModifierClick(e)) return;
- e.preventDefault();
- item?.onClick?.();
- if (item.url) {
- navigate(item.url);
- }
- }}
- >
- {navItem}
- </WorkspaceLink>
- );
- })}
+ return (
+ <WorkspaceLink
+ key={item.key}
+ to={item.url}
+ onClick={(e) => {
+ if (isModifierClick(e)) return;
+ e.preventDefault();
+ item?.onClick?.();
+ if (item.url) {
+ navigate(item.url);
+ }
+ }}
+ >
+ {navItem}
+ </WorkspaceLink>
+ );
+ })}
</Flexbox>
);
});
diff --git a/src/features/HomeSidebar/Header/components/User.tsx b/src/features/HomeSidebar/Header/components/User.tsx
index 9913aeb3aec..d04a997fa30 100644
--- a/src/features/HomeSidebar/Header/components/User.tsx
+++ b/src/features/HomeSidebar/Header/components/User.tsx
@@ -4,11 +4,12 @@ import { Block, Flexbox, Icon, Text } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
import { ChevronDownIcon } from 'lucide-react';
-import { memo } from 'react';
+import { memo, use } from 'react';
import { useActiveIdentity } from '@/business/client/hooks/useActiveIdentity';
import { ProductLogo } from '@/components/Branding';
import { USER_DROPDOWN_ICON_ID } from '@/features/NavPanel/constants';
+import { NavPanelDensityContext, useNavItemMetrics } from '@/features/NavPanel/density';
import UserAvatar from '@/features/User/UserAvatar';
import UserPanel from '@/features/User/UserPanel';
import { useUserStore } from '@/store/user';
@@ -32,6 +33,8 @@ const User = memo<{ lite?: boolean }>(({ lite }) => {
// (avatar + name) instead of the user's identity. Personal workspaces and
// OSS builds fall back to the user-level display.
const activeIdentity = useActiveIdentity();
+ const compact = use(NavPanelDensityContext) === 'compact';
+ const { headerAvatarSize, headerLabelFontSize, headerLabelWeight } = useNavItemMetrics();
const displayAvatar = activeIdentity?.avatar ?? undefined;
const displayName = activeIdentity?.name ?? (nickname || username);
@@ -56,14 +59,19 @@ const User = memo<{ lite?: boolean }>(({ lite }) => {
avatarOverride={displayAvatar}
nameOverride={activeIdentity?.name ?? undefined}
shape={'square'}
- size={28}
+ size={headerAvatarSize}
/>
{!lite && (
<Flexbox horizontal align={'center'} gap={4} style={{ overflow: 'hidden' }}>
{!isSignedIn && !activeIdentity ? (
- <ProductLogo color={cssVar.colorText} size={28} type={'text'} />
+ <ProductLogo color={cssVar.colorText} size={compact ? 22 : 28} type={'text'} />
) : (
- <Text ellipsis style={{ flex: 1 }} weight={500}>
+ <Text
+ ellipsis
+ fontSize={headerLabelFontSize}
+ style={{ flex: 1 }}
+ weight={headerLabelWeight}
+ >
{displayName}
</Text>
)}
diff --git a/src/features/HomeSidebar/Header/headerItems.test.ts b/src/features/HomeSidebar/Header/headerItems.test.ts
new file mode 100644
index 00000000000..7caaf787f8c
--- /dev/null
+++ b/src/features/HomeSidebar/Header/headerItems.test.ts
@@ -0,0 +1,31 @@
+import { describe, expect, it } from 'vitest';
+
+import { type NavItem } from '@/hooks/useNavLayout';
+
+import { resolveHeaderItems } from './headerItems';
+
+const item = (key: string, extra: Partial<NavItem> = {}): NavItem => ({
+ icon: null,
+ key,
+ title: key,
+ ...extra,
+});
+
+describe('resolveHeaderItems', () => {
+ it('moves Search out of the rows into the header', () => {
+ const { rows, search } = resolveHeaderItems([item('search'), item('home'), item('tasks')]);
+
+ expect(search?.key).toBe('search');
+ expect(rows.map((row) => row.key)).toEqual(['home']);
+ });
+
+ it('drops hidden items', () => {
+ const { rows, search } = resolveHeaderItems([
+ item('search', { hidden: true }),
+ item('home', { hidden: true }),
+ ]);
+
+ expect(search).toBeUndefined();
+ expect(rows).toEqual([]);
+ });
+});
diff --git a/src/features/HomeSidebar/Header/headerItems.ts b/src/features/HomeSidebar/Header/headerItems.ts
new file mode 100644
index 00000000000..52ce835bc92
--- /dev/null
+++ b/src/features/HomeSidebar/Header/headerItems.ts
@@ -0,0 +1,12 @@
+import { type NavItem } from '@/hooks/useNavLayout';
+
+const ROW_KEYS = new Set(['home']);
+
+export const resolveHeaderItems = (items: NavItem[]) => {
+ const visible = items.filter((item) => !item.hidden);
+
+ return {
+ rows: visible.filter((item) => ROW_KEYS.has(item.key)),
+ search: visible.find((item) => item.key === 'search'),
+ };
+};
diff --git a/src/features/HomeSidebar/Header/index.tsx b/src/features/HomeSidebar/Header/index.tsx
index 6ad2866a886..efa9f35bafa 100644
--- a/src/features/HomeSidebar/Header/index.tsx
+++ b/src/features/HomeSidebar/Header/index.tsx
@@ -2,14 +2,14 @@
import SideBarHeaderLayout from '@/features/NavPanel/SideBarHeaderLayout';
-import InboxButton from './components/InboxButton';
+import HeaderActions from './components/HeaderActions';
import Nav from './components/Nav';
import User from './components/User';
const Header = () => {
return (
<>
- <SideBarHeaderLayout left={<User />} right={<InboxButton />} showBack={false} />
+ <SideBarHeaderLayout left={<User />} right={<HeaderActions />} showBack={false} />
<Nav />
</>
);
diff --git a/src/features/LobeBench/Layout/Sidebar/Body.tsx b/src/features/LobeBench/Layout/Sidebar/Body.tsx
index b3cfdfc8d4e..7f3e29d74df 100644
--- a/src/features/LobeBench/Layout/Sidebar/Body.tsx
+++ b/src/features/LobeBench/Layout/Sidebar/Body.tsx
@@ -47,6 +47,7 @@ import {
useLobeBenchExperiments,
} from '@/features/LobeBench/useLobeBench';
import NavItem from '@/features/NavPanel/components/NavItem';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
@@ -65,6 +66,7 @@ const useActiveKey = () => {
};
const Body = memo(() => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { t } = useTranslation('eval');
const navigate = useWorkspaceAwareNavigate();
const activeKey = useActiveKey();
@@ -124,12 +126,10 @@ const Body = memo(() => {
style={{ gap: 8 }}
>
<AccordionItem value={'experiments'}>
- <AccordionHeader style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionHeader style={sectionTriggerStyle}>
<AccordionTrigger>
<Flexbox horizontal align="center" gap={4}>
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {t('lobeBench.sidebar.experiments')}
- </Text>
+ <SectionTitle>{t('lobeBench.sidebar.experiments')}</SectionTitle>
{experiments.length > 0 && (
<Text fontSize={12} type="secondary">
{experiments.length}
@@ -224,12 +224,10 @@ const Body = memo(() => {
</AccordionItem>
{/* Same three groups as the Evaluation Lab: experiments, benchmarks, datasets. */}
<AccordionItem value={'benchmarks'}>
- <AccordionHeader style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionHeader style={sectionTriggerStyle}>
<AccordionTrigger>
<Flexbox horizontal align="center" gap={4}>
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {t('lobeBench.sidebar.benchmarks')}
- </Text>
+ <SectionTitle>{t('lobeBench.sidebar.benchmarks')}</SectionTitle>
{benchmarks.length > 0 && (
<Text fontSize={12} type="secondary">
{benchmarks.length}
@@ -283,12 +281,10 @@ const Body = memo(() => {
{/* The datasets the benchmarks are made of, then the account's own (cases
picked from the library, or its own), flat like the Evaluation Lab's list. */}
<AccordionItem value={'datasets'}>
- <AccordionHeader style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionHeader style={sectionTriggerStyle}>
<AccordionTrigger>
<Flexbox horizontal align="center" gap={4}>
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {t('lobeBench.sidebar.datasets')}
- </Text>
+ <SectionTitle>{t('lobeBench.sidebar.datasets')}</SectionTitle>
{sidebarDatasets.length > 0 && (
<Text fontSize={12} type="secondary">
{sidebarDatasets.length}
diff --git a/src/features/NavHeader/index.tsx b/src/features/NavHeader/index.tsx
index 547910f0dbc..b9380ce0a70 100644
--- a/src/features/NavHeader/index.tsx
+++ b/src/features/NavHeader/index.tsx
@@ -6,6 +6,7 @@ import { memo } from 'react';
import ToggleLeftPanelButton, { isMacDesktop } from '@/features/NavPanel/ToggleLeftPanelButton';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
+import { DENSITY_TOKENS, useDensityTokens } from '@/styles/density';
import { isMobileSurface } from '@/utils/mobileSurface';
import { getNavHeaderLeading } from './leading';
@@ -41,11 +42,14 @@ const NavHeader = memo<NavHeaderProps>(
...rest
}) => {
const expand = useGlobalStore(systemStatusSelectors.showLeftPanel);
+ const density = useDensityTokens();
+ const mobile = isMobileSurface();
+ const headerHeight = mobile ? DENSITY_TOKENS.loose.headerHeight : density.headerHeight;
const leading = getNavHeaderLeading({
expand: !!expand,
isMacDesktop,
- mobile: isMobileSurface(),
+ mobile,
noContent: !left && !right && !children,
showTogglePanelButton,
});
@@ -59,9 +63,10 @@ const NavHeader = memo<NavHeaderProps>(
align={'center'}
flex={'none'}
gap={4}
- height={44}
+ height={headerHeight}
justify={'space-between'}
- padding={8}
+ paddingBlock={(headerHeight - 28) / 2}
+ paddingInline={8}
style={style}
{...rest}
>
diff --git a/src/features/NavPanel/SideBarDrawer.tsx b/src/features/NavPanel/SideBarDrawer.tsx
index 065b00a04f8..7b883f38175 100644
--- a/src/features/NavPanel/SideBarDrawer.tsx
+++ b/src/features/NavPanel/SideBarDrawer.tsx
@@ -13,7 +13,7 @@ import { XIcon } from 'lucide-react';
import type { ReactNode } from 'react';
import { memo, Suspense, useEffect, useState } from 'react';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
+import { useHeaderActionSize } from '@/styles/density';
import SkeletonList from './components/SkeletonList';
import { NAV_PANEL_RIGHT_DRAWER_ID } from './constants';
@@ -57,6 +57,7 @@ interface SideBarDrawerProps {
const SideBarDrawer = memo<SideBarDrawerProps>(
({ subHeader, open, onClose, children, title, action, width = DRAWER_WIDTH }) => {
+ const headerActionSize = useHeaderActionSize(true);
const [overlayContainer, setOverlayContainer] = useState<HTMLDivElement | null>(null);
const [portalContainer, setPortalContainer] = useState<HTMLElement | null>(null);
@@ -106,7 +107,7 @@ const SideBarDrawer = memo<SideBarDrawerProps>(
{action}
<ActionIcon
icon={XIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
style={{ marginInlineEnd: -2 }}
onClick={onClose}
/>
diff --git a/src/features/NavPanel/SideBarHeaderLayout.tsx b/src/features/NavPanel/SideBarHeaderLayout.tsx
index 830128f7df4..8ce6e79f517 100644
--- a/src/features/NavPanel/SideBarHeaderLayout.tsx
+++ b/src/features/NavPanel/SideBarHeaderLayout.tsx
@@ -13,11 +13,13 @@ import type { MouseEvent, ReactNode } from 'react';
import { memo } from 'react';
import { flushSync } from 'react-dom';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
+import { getContainerTopInset } from '@/features/DesktopLayoutContainer/cssVariables';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
+import { useDensityTokens, useHeaderActionSize } from '@/styles/density';
import { isModifierClick } from '@/utils/navigation';
import BackButton from './components/BackButton';
+import { useNavItemMetrics } from './density';
import ToggleLeftPanelButton from './ToggleLeftPanelButton';
const styles = createStaticStyles(({ css, cssVar }) => ({
@@ -66,6 +68,10 @@ const SideBarHeaderLayout = memo<SideBarHeaderLayoutProps>(
showTogglePanelButton = true,
}) => {
const navigate = useWorkspaceAwareNavigate();
+ const { headerTitleFontSize, headerTitleWeight } = useNavItemMetrics();
+ const { headerHeight } = useDensityTokens();
+ const topInset = getContainerTopInset();
+ const headerActionSize = useHeaderActionSize(true);
const leftContent = left ? (
<Flexbox
horizontal
@@ -77,15 +83,10 @@ const SideBarHeaderLayout = memo<SideBarHeaderLayoutProps>(
}}
>
{showBack && (
- <BackButton
- escape={backEscape}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
- to={backTo}
- onClick={onBack}
- />
+ <BackButton escape={backEscape} size={headerActionSize} to={backTo} onClick={onBack} />
)}
{left && typeof left === 'string' ? (
- <Text ellipsis fontSize={16} weight={500}>
+ <Text ellipsis fontSize={headerTitleFontSize} weight={headerTitleWeight}>
{left}
</Text>
) : (
@@ -126,8 +127,10 @@ const SideBarHeaderLayout = memo<SideBarHeaderLayoutProps>(
align={'center'}
className={styles.container}
flex={'none'}
+ height={headerHeight + topInset}
justify={'space-between'}
- padding={'8px 6px'}
+ paddingInline={6}
+ style={{ paddingBlockStart: topInset }}
>
{leftContent}
<Flexbox horizontal align={'center'} gap={2} justify={'flex-end'}>
diff --git a/src/features/NavPanel/SidebarHeaderSelect.tsx b/src/features/NavPanel/SidebarHeaderSelect.tsx
index b32b3672bc1..3b124cb3257 100644
--- a/src/features/NavPanel/SidebarHeaderSelect.tsx
+++ b/src/features/NavPanel/SidebarHeaderSelect.tsx
@@ -7,7 +7,8 @@ import type { ReactNode } from 'react';
import { memo } from 'react';
import Avatar from '@/components/Avatar';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
+
+import { useNavItemMetrics } from './density';
const styles = createStaticStyles(({ css, cssVar }) => ({
trigger: css`
@@ -59,31 +60,41 @@ interface SidebarHeaderSelectTriggerProps extends Omit<BlockProps, 'children' |
}
export const SidebarHeaderSelectTrigger = memo<SidebarHeaderSelectTriggerProps>(
- ({ avatar, avatarNode, background, className, name, style, title, ...rest }) => (
- <Block
- clickable
- horizontal
- align={'center'}
- className={className}
- gap={8}
- padding={2}
- style={{ minWidth: 32, overflow: 'hidden', ...style }}
- variant={'borderless'}
- {...rest}
- >
- {avatarNode ?? (
- <Avatar avatar={avatar} background={background} name={name} shape={'square'} size={28} />
- )}
- <Text ellipsis weight={500}>
- {title}
- </Text>
- <ActionIcon
- icon={ChevronsUpDownIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
- style={{ width: 24 }}
- />
- </Block>
- ),
+ ({ avatar, avatarNode, background, className, name, style, title, ...rest }) => {
+ const metrics = useNavItemMetrics();
+
+ return (
+ <Block
+ clickable
+ horizontal
+ align={'center'}
+ className={className}
+ gap={8}
+ padding={2}
+ style={{ minWidth: 32, overflow: 'hidden', ...style }}
+ variant={'borderless'}
+ {...rest}
+ >
+ {avatarNode ?? (
+ <Avatar
+ avatar={avatar}
+ background={background}
+ name={name}
+ shape={'square'}
+ size={metrics.headerAvatarSize}
+ />
+ )}
+ <Text ellipsis fontSize={metrics.headerLabelFontSize} weight={metrics.headerLabelWeight}>
+ {title}
+ </Text>
+ <ActionIcon
+ icon={ChevronsUpDownIcon}
+ size={metrics.headerChevronSize}
+ style={{ width: metrics.headerChevronSize.blockSize }}
+ />
+ </Block>
+ );
+ },
);
SidebarHeaderSelectPopover.displayName = 'SidebarHeaderSelectPopover';
diff --git a/src/features/NavPanel/ToggleLeftPanelButton.tsx b/src/features/NavPanel/ToggleLeftPanelButton.tsx
index 399d3238af6..0d04bf7c716 100644
--- a/src/features/NavPanel/ToggleLeftPanelButton.tsx
+++ b/src/features/NavPanel/ToggleLeftPanelButton.tsx
@@ -7,12 +7,12 @@ import { type ReactNode } from 'react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { isDesktop } from '@/const/version';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/selectors';
+import { useHeaderActionSize } from '@/styles/density';
import { isMacOS } from '@/utils/platform';
import { useCloseMobileNavDrawer } from './MobileDrawerContext';
@@ -44,6 +44,7 @@ interface ToggleLeftPanelButtonProps {
const ToggleLeftPanelButton = memo<ToggleLeftPanelButtonProps>(
({ title, showActive, icon, size, id = TOGGLE_BUTTON_ID, forceVisible }) => {
+ const headerActionSize = useHeaderActionSize(true);
const [expand, togglePanel] = useGlobalStore((s) => [
systemStatusSelectors.showLeftPanel(s),
s.toggleLeftPanel,
@@ -61,7 +62,7 @@ const ToggleLeftPanelButton = memo<ToggleLeftPanelButtonProps>(
return (
<ActionIcon
icon={PanelLeftClose}
- size={size || DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={size || headerActionSize}
title={title || t('toggleLeftPanel.title', { ns: 'hotkey' })}
onClick={closeMobileDrawer}
/>
@@ -72,7 +73,7 @@ const ToggleLeftPanelButton = memo<ToggleLeftPanelButtonProps>(
active={showActive ? expand : undefined}
icon={icon || (expand ? PanelLeftClose : PanelLeftOpen)}
id={id ?? undefined}
- size={size || DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={size || headerActionSize}
title={title || t('toggleLeftPanel.title', { ns: 'hotkey' })}
tooltipProps={{
hotkey,
diff --git a/src/features/NavPanel/components/BackButton.tsx b/src/features/NavPanel/components/BackButton.tsx
index 4698953c051..b946bb38746 100644
--- a/src/features/NavPanel/components/BackButton.tsx
+++ b/src/features/NavPanel/components/BackButton.tsx
@@ -3,9 +3,9 @@ import { ChevronLeftIcon } from 'lucide-react';
import { memo, type MouseEvent } from 'react';
import { useActiveWorkspaceSlug } from '@/business/client/hooks/useActiveWorkspaceSlug';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { appNavigate } from '@/features/Electron/navigation/appNavigate';
import { buildWorkspaceAwarePath } from '@/features/Workspace/workspaceAwarePath';
+import { useHeaderActionSize } from '@/styles/density';
export const BACK_BUTTON_ID = 'lobe-back-button';
@@ -16,6 +16,7 @@ interface BackButtonProps extends ActionIconProps {
}
const BackButton = memo<BackButtonProps>(({ to = '/', escape, onClick, ...rest }) => {
+ const headerActionSize = useHeaderActionSize(true);
const activeSlug = useActiveWorkspaceSlug();
const resolvedTo = buildWorkspaceAwarePath(to, activeSlug, { escape });
@@ -33,12 +34,7 @@ const BackButton = memo<BackButtonProps>(({ to = '/', escape, onClick, ...rest }
return (
<a href={resolvedTo} onClick={handleClick}>
- <ActionIcon
- icon={ChevronLeftIcon}
- id={BACK_BUTTON_ID}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
- {...rest}
- />
+ <ActionIcon icon={ChevronLeftIcon} id={BACK_BUTTON_ID} size={headerActionSize} {...rest} />
</a>
);
});
diff --git a/src/features/NavPanel/components/NavItem.tsx b/src/features/NavPanel/components/NavItem.tsx
index ebc09e0ff09..099591509a1 100644
--- a/src/features/NavPanel/components/NavItem.tsx
+++ b/src/features/NavPanel/components/NavItem.tsx
@@ -18,6 +18,7 @@ import { memo } from 'react';
import { isModifierClick } from '@/utils/navigation';
+import { useNavItemMetrics } from '../density';
import { type LazyActions, useLazyActions } from './useLazyActions';
import {
NAV_ITEM_ACTIONS_INSET_VAR,
@@ -168,7 +169,7 @@ const NavItem = memo<NavItemProps>(
active,
href,
icon,
- iconSize = 18,
+ iconSize: iconSizeProp,
title,
titleColor,
titleMarquee,
@@ -184,6 +185,8 @@ const NavItem = memo<NavItemProps>(
onPointerLeave,
...rest
}) => {
+ const metrics = useNavItemMetrics();
+ const iconSize = iconSizeProp ?? metrics.iconSize;
const { mount: mountLazyActions, node: renderedActions } = useLazyActions(actions);
const marqueeAvailable = useTitleMarqueeAvailable();
const marquee = !!titleMarquee && marqueeAvailable;
@@ -227,8 +230,9 @@ const NavItem = memo<NavItemProps>(
: {};
const mergedStyle =
- href || disabled || style
+ href || disabled || style || metrics.radius !== undefined
? {
+ ...(metrics.radius === undefined ? undefined : { borderRadius: metrics.radius }),
...(href ? { color: 'inherit', textDecoration: 'none' } : undefined),
// `disabled` only blocks the click by itself — dim the row so the
// blocked state is visible instead of a silently dead button.
@@ -240,7 +244,7 @@ const NavItem = memo<NavItemProps>(
// A description stacks the title in a column, where `flex: 1` would grow it vertically.
const titleStyle = description ? undefined : { flex: 1 };
const titleNode = marquee ? (
- <Text color={textColor} style={{ ...titleStyle, minWidth: 0 }}>
+ <Text color={textColor} fontSize={metrics.fontSize} style={{ ...titleStyle, minWidth: 0 }}>
<span className={styles.marqueeViewport} ref={titleViewportRef}>
<span className={styles.marqueeText} ref={titleTextRef}>
{title}
@@ -248,7 +252,12 @@ const NavItem = memo<NavItemProps>(
</span>
</Text>
) : (
- <Text color={textColor} ellipsis={{ tooltipWhenOverflow: true }} style={titleStyle}>
+ <Text
+ color={textColor}
+ ellipsis={{ tooltipWhenOverflow: true }}
+ fontSize={metrics.fontSize}
+ style={titleStyle}
+ >
{title}
</Text>
);
@@ -259,9 +268,9 @@ const NavItem = memo<NavItemProps>(
// With a description the row is two lines tall; align the leading icon
// to the title's first line (match its line-height) instead of letting
// it center across both lines, which drops it into the gap.
- height={description ? 22 : 28}
+ height={description ? 22 : metrics.iconBox}
style={description ? { alignSelf: 'flex-start' } : undefined}
- width={28}
+ width={metrics.iconBox}
>
{loading ? (
<Spin size={iconSize} variant="network" />
@@ -278,10 +287,10 @@ const NavItem = memo<NavItemProps>(
className={cx(styles.container, className)}
clickable={!disabled}
data-nav-item=""
- gap={8}
- height={description ? undefined : 36}
+ gap={metrics.gap}
+ height={description ? undefined : metrics.rowHeight}
paddingBlock={description ? 8 : undefined}
- paddingInline={4}
+ paddingInline={metrics.paddingInline}
style={mergedStyle}
variant={variant}
onClick={(e) => {
@@ -307,7 +316,7 @@ const NavItem = memo<NavItemProps>(
style={description ? { alignSelf: 'flex-start' } : undefined}
// Keep the icon column width so the title does not shift; a wider
// label overflows evenly into the gaps around it.
- width={28}
+ width={metrics.iconBox}
>
{iconNode}
{iconBelow}
diff --git a/src/features/NavPanel/components/NavPanelDraggable.tsx b/src/features/NavPanel/components/NavPanelDraggable.tsx
index 620d4884c45..9e9a4e388e4 100644
--- a/src/features/NavPanel/components/NavPanelDraggable.tsx
+++ b/src/features/NavPanel/components/NavPanelDraggable.tsx
@@ -16,8 +16,10 @@ import {
NAV_PANEL_MIN_WIDTH,
systemStatusSelectors,
} from '@/store/global/selectors';
+import { useInterfaceDensity } from '@/styles/density';
import { isMacOS } from '@/utils/platform';
+import { NavPanelDensityContext } from '../density';
import { useNavPanelSizeChangeHandler } from '../hooks/useNavPanel';
import { BACK_BUTTON_ID } from './BackButton';
@@ -120,6 +122,7 @@ export const NavPanelDraggable = memo<NavPanelDraggableProps>(({ activeContent,
systemStatusSelectors.isStatusInit(s),
]);
const handleSizeChange = useNavPanelSizeChangeHandler();
+ const interfaceDensity = useInterfaceDensity();
// Defer DraggablePanel mount until system status hydrates; otherwise defaultSize
// captures the pre-hydration default and the DOM drifts off NavigationBar's live width.
@@ -159,32 +162,34 @@ export const NavPanelDraggable = memo<NavPanelDraggableProps>(({ activeContent,
onExpandChange={togglePanel}
onSizeDragging={handleSizeChange}
>
- <div className={draggableStyles.inner}>
- {/* Home stays mounted while a route-owned panel is active so its list
+ <NavPanelDensityContext value={interfaceDensity}>
+ <div className={draggableStyles.inner}>
+ {/* Home stays mounted while a route-owned panel is active so its list
state survives the round trip. Activity keeps the fibers but not the
visibility, so the layer is force-hidden like HomeLayout does. */}
- {homeContent && (
- <Activity mode={isHomeActive ? 'visible' : 'hidden'} name="NavPanelHome">
- <div
- className={draggableStyles.layer}
- style={isHomeActive ? undefined : hiddenLayerStyle}
- >
- {homeContent}
+ {homeContent && (
+ <Activity mode={isHomeActive ? 'visible' : 'hidden'} name="NavPanelHome">
+ <div
+ className={draggableStyles.layer}
+ style={isHomeActive ? undefined : hiddenLayerStyle}
+ >
+ {homeContent}
+ </div>
+ </Activity>
+ )}
+ {!isHomeActive && (
+ <div className={draggableStyles.layer} key={activeContent.key}>
+ {activeContent.node}
</div>
- </Activity>
- )}
- {!isHomeActive && (
- <div className={draggableStyles.layer} key={activeContent.key}>
- {activeContent.node}
- </div>
- )}
- </div>
- <Suspense fallback={null}>
- <NavPanelUpgradeEntry />
- </Suspense>
- <Suspense>
- <Footer />
- </Suspense>
+ )}
+ </div>
+ <Suspense fallback={null}>
+ <NavPanelUpgradeEntry />
+ </Suspense>
+ <Suspense>
+ <Footer />
+ </Suspense>
+ </NavPanelDensityContext>
</DraggablePanel>
);
});
diff --git a/src/features/NavPanel/components/SectionTitle.tsx b/src/features/NavPanel/components/SectionTitle.tsx
new file mode 100644
index 00000000000..0f65ca71987
--- /dev/null
+++ b/src/features/NavPanel/components/SectionTitle.tsx
@@ -0,0 +1,24 @@
+import { Text } from '@lobehub/ui';
+import { type ReactNode } from 'react';
+
+import { useNavItemMetrics } from '../density';
+
+const SectionTitle = ({ children }: { children: ReactNode }) => {
+ const metrics = useNavItemMetrics();
+
+ return (
+ <Text ellipsis color={metrics.sectionLabelColor} fontSize={12} weight={500}>
+ {children}
+ </Text>
+ );
+};
+
+export const useSectionTriggerStyle = () => {
+ const metrics = useNavItemMetrics();
+ return {
+ paddingBlock: metrics.sectionTriggerPaddingBlock,
+ paddingInline: metrics.sectionTriggerPaddingInline,
+ };
+};
+
+export default SectionTitle;
diff --git a/src/features/NavPanel/density.test.ts b/src/features/NavPanel/density.test.ts
new file mode 100644
index 00000000000..511c1dc9f13
--- /dev/null
+++ b/src/features/NavPanel/density.test.ts
@@ -0,0 +1,37 @@
+import { describe, expect, it } from 'vitest';
+
+import { resolveNavItemMetrics } from './density';
+
+describe('resolveNavItemMetrics', () => {
+ it('keeps 36px rows and the default radius outside the nav panel', () => {
+ expect(resolveNavItemMetrics(null)).toMatchObject({ radius: undefined, rowHeight: 36 });
+ });
+
+ it('uses 32px rows with 28px section headers in a compact nav panel', () => {
+ expect(resolveNavItemMetrics('compact')).toMatchObject({
+ fontSize: 13,
+ rowHeight: 32,
+ sectionTriggerPaddingBlock: 2,
+ });
+ });
+
+ it('scales the panel header down with compact rows', () => {
+ expect(resolveNavItemMetrics('compact')).toMatchObject({
+ headerAvatarSize: 24,
+ headerLabelFontSize: 13,
+ });
+ expect(resolveNavItemMetrics(null)).toMatchObject({
+ headerAvatarSize: 28,
+ headerLabelFontSize: 14,
+ headerTitleFontSize: 16,
+ });
+ });
+
+ it('uses 36px rows with 32px section headers in a loose nav panel', () => {
+ expect(resolveNavItemMetrics('loose')).toMatchObject({
+ fontSize: 14,
+ rowHeight: 36,
+ sectionTriggerPaddingBlock: 4,
+ });
+ });
+});
diff --git a/src/features/NavPanel/density.ts b/src/features/NavPanel/density.ts
new file mode 100644
index 00000000000..f2d786a6ad1
--- /dev/null
+++ b/src/features/NavPanel/density.ts
@@ -0,0 +1,59 @@
+import { type InterfaceDensity } from '@lobechat/types';
+import { cssVar } from '@lobehub/ui';
+import { useContext } from 'react';
+
+import { DENSITY_TOKENS, PanelDensityContext } from '@/styles/density';
+
+export interface NavItemMetrics {
+ fontSize: number;
+ gap: number;
+ headerAvatarSize: number;
+ headerChevronSize: { blockSize: number; size: number };
+ headerLabelFontSize: number;
+ headerLabelWeight: number;
+ headerTitleFontSize: number;
+ headerTitleWeight: number;
+ iconBox: number;
+ iconSize: number;
+ paddingInline: number;
+ panelPaddingInline: number;
+ radius?: number;
+ rowHeight: number;
+ sectionGap: number;
+ sectionLabelColor: string;
+ sectionTriggerPaddingBlock: number;
+ sectionTriggerPaddingInline: string;
+}
+
+const SECTION_ACTION_SIZE = 24;
+
+export const resolveNavItemMetrics = (density: InterfaceDensity | null): NavItemMetrics => {
+ const tokens = DENSITY_TOKENS[density ?? 'loose'];
+ const compact = density === 'compact';
+
+ return {
+ fontSize: tokens.fontSize,
+ gap: tokens.gap,
+ headerAvatarSize: tokens.headerAvatarSize,
+ headerChevronSize: { blockSize: tokens.headerChevronSize + 6, size: tokens.headerChevronSize },
+ headerLabelFontSize: compact ? 13 : 14,
+ headerLabelWeight: compact ? 600 : 500,
+ headerTitleFontSize: compact ? 14 : 16,
+ headerTitleWeight: compact ? 600 : 500,
+ iconBox: tokens.iconBox,
+ iconSize: tokens.iconSize,
+ paddingInline: tokens.paddingInline,
+ panelPaddingInline: tokens.panelPaddingInline,
+ radius: density ? tokens.radius : undefined,
+ rowHeight: tokens.rowHeight,
+ sectionGap: tokens.sectionGap,
+ sectionLabelColor: compact ? cssVar.colorTextTertiary : cssVar.colorTextSecondary,
+ sectionTriggerPaddingBlock: (tokens.sectionHeaderHeight - SECTION_ACTION_SIZE) / 2,
+ sectionTriggerPaddingInline: compact ? '6px 4px' : '8px 4px',
+ };
+};
+
+export const NavPanelDensityContext = PanelDensityContext;
+
+export const useNavItemMetrics = (): NavItemMetrics =>
+ resolveNavItemMetrics(useContext(NavPanelDensityContext));
diff --git a/src/features/NavPanel/switcher/SwitcherRow.tsx b/src/features/NavPanel/switcher/SwitcherRow.tsx
index dfd3531085d..00458f2b49e 100644
--- a/src/features/NavPanel/switcher/SwitcherRow.tsx
+++ b/src/features/NavPanel/switcher/SwitcherRow.tsx
@@ -4,6 +4,7 @@ import { memo } from 'react';
import AgentAvatar from '@/components/AgentAvatar';
+import { useNavItemMetrics } from '../density';
import type { SwitcherItem } from './switcherItems';
const styles = createStaticStyles(({ css, cssVar }) => ({
@@ -33,55 +34,60 @@ interface SwitcherRowProps {
privateLabel?: string;
}
-const SwitcherRow = memo<SwitcherRowProps>(({ active, item, kind, onSelect, privateLabel }) => (
- <Block
- clickable
- horizontal
- align={'center'}
- className={active ? `${styles.row} ${styles.current}` : styles.row}
- flex={'none'}
- gap={8}
- height={36}
- variant={'borderless'}
- onClick={() => onSelect(item.id)}
- >
- {kind === 'agent' ? (
- <AgentAvatar
- agentId={item.id}
- avatar={item.avatar}
- background={item.background}
- name={item.title}
- size={24}
- title={item.title}
- />
- ) : (
- <Avatar
- avatar={item.avatar}
- background={item.background}
- shape={'square'}
- size={24}
- title={item.title}
- />
- )}
- <Text
- ellipsis
- color={active ? cssVar.colorText : cssVar.colorTextSecondary}
- style={{ flex: 1 }}
- weight={active ? 500 : undefined}
+const SwitcherRow = memo<SwitcherRowProps>(({ active, item, kind, onSelect, privateLabel }) => {
+ const metrics = useNavItemMetrics();
+
+ return (
+ <Block
+ clickable
+ horizontal
+ align={'center'}
+ className={active ? `${styles.row} ${styles.current}` : styles.row}
+ flex={'none'}
+ gap={metrics.gap}
+ height={metrics.rowHeight}
+ variant={'borderless'}
+ onClick={() => onSelect(item.id)}
>
- {item.title}
- {item.subtitle && (
- <span style={{ fontSize: 12, marginInlineStart: 6, opacity: 0.6 }}>{item.subtitle}</span>
+ {kind === 'agent' ? (
+ <AgentAvatar
+ agentId={item.id}
+ avatar={item.avatar}
+ background={item.background}
+ name={item.title}
+ size={24}
+ title={item.title}
+ />
+ ) : (
+ <Avatar
+ avatar={item.avatar}
+ background={item.background}
+ shape={'square'}
+ size={24}
+ title={item.title}
+ />
)}
- </Text>
- {item.private && privateLabel && (
- <Text color={cssVar.colorTextTertiary} fontSize={12}>
- {privateLabel}
+ <Text
+ ellipsis
+ color={active ? cssVar.colorText : cssVar.colorTextSecondary}
+ fontSize={metrics.fontSize}
+ style={{ flex: 1 }}
+ weight={active ? 500 : undefined}
+ >
+ {item.title}
+ {item.subtitle && (
+ <span style={{ fontSize: 12, marginInlineStart: 6, opacity: 0.6 }}>{item.subtitle}</span>
+ )}
</Text>
- )}
- {active && <Icon color={cssVar.colorText} icon={CheckIcon} size={14} />}
- </Block>
-));
+ {item.private && privateLabel && (
+ <Text color={cssVar.colorTextTertiary} fontSize={12}>
+ {privateLabel}
+ </Text>
+ )}
+ {active && <Icon color={cssVar.colorText} icon={CheckIcon} size={14} />}
+ </Block>
+ );
+});
SwitcherRow.displayName = 'SwitcherRow';
diff --git a/src/features/PageEditor/Copilot/Toolbar.tsx b/src/features/PageEditor/Copilot/Toolbar.tsx
index c181f759690..55b6c19ca86 100644
--- a/src/features/PageEditor/Copilot/Toolbar.tsx
+++ b/src/features/PageEditor/Copilot/Toolbar.tsx
@@ -3,12 +3,12 @@ import { Clock3Icon, PanelRightCloseIcon, PlusIcon } from 'lucide-react';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { conversationSelectors, useConversationStore } from '@/features/Conversation';
import NavHeader from '@/features/NavHeader';
import { useFetchAgentChatTopics } from '@/hooks/useFetchChatTopics';
import { useChatStore } from '@/store/chat';
import { topicSelectors } from '@/store/chat/slices/topic/selectors';
+import { useHeaderActionSize } from '@/styles/density';
import { usePageAgentPanelControl, usePageAgentPanelOverride } from '../RightPanel/OverrideContext';
import TopicItem from './TopicSelector/TopicItem';
@@ -21,6 +21,7 @@ interface CopilotToolbarProps {
}
const CopilotToolbar = memo<CopilotToolbarProps>(({ onCollapse, onTopicChange, topicId }) => {
+ const headerActionSize = useHeaderActionSize(true);
const { t } = useTranslation('topic');
const [topicPopoverOpen, setTopicPopoverOpen] = useState(false);
const agentId = useConversationStore(conversationSelectors.agentId);
@@ -62,7 +63,7 @@ const CopilotToolbar = memo<CopilotToolbarProps>(({ onCollapse, onTopicChange, t
<>
<ActionIcon
icon={PlusIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
title={t('actions.addNewTopic')}
onClick={() =>
onTopicChange ? onTopicChange(null) : switchTopic(null, { scope: 'page' })
@@ -110,14 +111,14 @@ const CopilotToolbar = memo<CopilotToolbarProps>(({ onCollapse, onTopicChange, t
disabled={isLoadingTopics}
icon={Clock3Icon}
loading={isLoadingTopics}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
/>
</Popover>
)}
{(onCollapse || !hasOverride) && (
<ActionIcon
icon={PanelRightCloseIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
onClick={() => (onCollapse ? onCollapse() : togglePageAgentPanel())}
/>
)}
diff --git a/src/features/PageEditor/Header/index.tsx b/src/features/PageEditor/Header/index.tsx
index 27018ebda64..7f500467d68 100644
--- a/src/features/PageEditor/Header/index.tsx
+++ b/src/features/PageEditor/Header/index.tsx
@@ -22,12 +22,12 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import ShareButton from '@/business/client/features/PageShare/ShareButton';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { AutoSaveHint } from '@/features/EditorCanvas';
import { FavoriteButton } from '@/features/Favorites';
import NavHeader from '@/features/NavHeader';
import ToggleRightPanelButton from '@/features/RightPanel/ToggleRightPanelButton';
import { usePermission } from '@/hooks/usePermission';
+import { useHeaderActionSize } from '@/styles/density';
import { useDocumentComments } from '../DocumentComments/context';
import EditingIndicator from '../EditingIndicator';
@@ -48,6 +48,7 @@ const styles = createStaticStyles(({ css }) => ({
}));
const Header = memo(() => {
+ const headerActionSize = useHeaderActionSize(true);
const { t } = useTranslation('file');
const [documentId, emoji, title, parentId, onBack] = usePageEditorStore((s) => [
s.documentId,
@@ -78,7 +79,7 @@ const Header = memo(() => {
<NavHeader
left={
<>
- {onBack && <ActionIcon icon={ArrowLeftIcon} onClick={onBack} />}
+ {onBack && <ActionIcon icon={ArrowLeftIcon} size={headerActionSize} onClick={onBack} />}
{/* Breadcrumb - show when page has a parent folder */}
{parentId && <Breadcrumb />}
{/* Show icon and title only when there's no parent folder */}
@@ -130,7 +131,7 @@ const Header = memo(() => {
},
}}
>
- <ActionIcon icon={MoreHorizontal} size={DESKTOP_HEADER_ICON_SMALL_SIZE} />
+ <ActionIcon icon={MoreHorizontal} size={headerActionSize} />
</DropdownMenu>
{(comments?.panelAvailable || canExpandRightPanel) && (
// The framed segment control only earns its frame with two
@@ -147,7 +148,7 @@ const Header = memo(() => {
<ActionIcon
active={isCommentsPanelOpen}
icon={MessageSquareTextIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
title={t('pageEditor.comments.toggle')}
onClick={() => setCommentsPanelOpen(!isCommentsPanelOpen)}
/>
diff --git a/src/features/Pages/PageLayout/Body/index.tsx b/src/features/Pages/PageLayout/Body/index.tsx
index 58852c20cbb..97dc811f4d3 100644
--- a/src/features/Pages/PageLayout/Body/index.tsx
+++ b/src/features/Pages/PageLayout/Body/index.tsx
@@ -17,6 +17,7 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import AsyncBoundary from '@/components/AsyncBoundary';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import PageEmpty from '@/features/PageEmpty';
import { pageActions, pageSelectors, usePageStore } from '@/store/page';
@@ -36,6 +37,7 @@ export enum GroupKey {
* lock on their row instead of living in a separate section.
*/
const Body = memo(() => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { t } = useTranslation('file');
// Drive the list's replica sync; keep `isValidating` so the accordion header
@@ -65,12 +67,12 @@ const Body = memo(() => {
<AccordionItem value={GroupKey.AllPages}>
<ContextMenuTrigger items={dropdownMenu}>
<AccordionHeader>
- <AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionTrigger style={sectionTriggerStyle}>
<Flexbox horizontal align="center" gap={4}>
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
+ <SectionTitle>
{t('pageList.title')}
{filteredDocumentsCount > 0 && ` ${filteredDocumentsCount}`}
- </Text>
+ </SectionTitle>
{isValidating && <Spin size="small" variant="network" />}
</Flexbox>
</AccordionTrigger>
diff --git a/src/features/Portal/Acceptance/Header.tsx b/src/features/Portal/Acceptance/Header.tsx
index 3830185920f..cd9f0577940 100644
--- a/src/features/Portal/Acceptance/Header.tsx
+++ b/src/features/Portal/Acceptance/Header.tsx
@@ -1,9 +1,9 @@
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@lobechat/const';
import { ActionIcon } from '@lobehub/ui';
import { ExternalLink } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
+import { useHeaderActionSize } from '@/styles/density';
import { openTrustedExternalUrl } from '@/utils/openTrustedExternalUrl';
import Header from '../components/Header';
@@ -11,6 +11,7 @@ import Title from './Title';
import { useAcceptancePageUrl } from './usePageUrl';
const AcceptanceHeader = memo<{ onClose?: () => void }>(({ onClose }) => {
+ const headerActionSize = useHeaderActionSize(true);
const { t } = useTranslation('verify');
const { externalUrl } = useAcceptancePageUrl();
@@ -21,7 +22,7 @@ const AcceptanceHeader = memo<{ onClose?: () => void }>(({ onClose }) => {
<ActionIcon
disabled={!externalUrl}
icon={ExternalLink}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
title={t('report.actions.openInBrowser')}
onClick={() => {
if (!externalUrl) return;
diff --git a/src/features/Portal/AgentDetail/Header.tsx b/src/features/Portal/AgentDetail/Header.tsx
index 8086fb7b278..d3df2c15330 100644
--- a/src/features/Portal/AgentDetail/Header.tsx
+++ b/src/features/Portal/AgentDetail/Header.tsx
@@ -1,6 +1,5 @@
'use client';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@lobechat/const';
import { ActionIcon } from '@lobehub/ui';
import { Maximize2Icon } from 'lucide-react';
import { memo } from 'react';
@@ -10,10 +9,12 @@ import PortalChromeHeader from '@/features/Portal/components/Header';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';
+import { useHeaderActionSize } from '@/styles/density';
import Title from './Title';
const Header = memo<{ onClose?: () => void }>(({ onClose }) => {
+ const headerActionSize = useHeaderActionSize(true);
const { t } = useTranslation('chat');
const agentId = useChatStore(chatPortalSelectors.agentDetailId);
const navigate = useWorkspaceAwareNavigate();
@@ -26,7 +27,7 @@ const Header = memo<{ onClose?: () => void }>(({ onClose }) => {
agentId ? (
<ActionIcon
icon={Maximize2Icon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
title={t('internalLink.agent.open')}
onClick={() => {
navigate(`/agent/${agentId}`);
diff --git a/src/features/Portal/Document/PortalHeader.tsx b/src/features/Portal/Document/PortalHeader.tsx
index 74b68c3ce81..b5504b3ac80 100644
--- a/src/features/Portal/Document/PortalHeader.tsx
+++ b/src/features/Portal/Document/PortalHeader.tsx
@@ -1,6 +1,5 @@
'use client';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@lobechat/const';
import { ActionIcon, Flexbox } from '@lobehub/ui';
import { Maximize2Icon } from 'lucide-react';
import { memo } from 'react';
@@ -11,6 +10,7 @@ import PortalChromeHeader from '@/features/Portal/components/Header';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useAgentStore } from '@/store/agent';
import { useChatStore } from '@/store/chat';
+import { useHeaderActionSize } from '@/styles/density';
import AutoSaveHint from './AutoSaveHint';
import { useResolvedAgentDocumentId } from './documentViewContext';
@@ -23,6 +23,7 @@ import { usePortalDocumentHeaderActions } from './usePortalDocumentHeader';
* collapses the portal so returning to chat lands on a clean conversation.
*/
const OpenAsPageAction = memo(() => {
+ const headerActionSize = useHeaderActionSize(true);
const { t } = useTranslation('chat');
const { path } = usePortalDocumentHeaderActions();
const navigate = useWorkspaceAwareNavigate();
@@ -33,7 +34,7 @@ const OpenAsPageAction = memo(() => {
return (
<ActionIcon
icon={Maximize2Icon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
title={t('agentDocument.openAsPage')}
onClick={() => {
navigate(path);
diff --git a/src/features/Portal/Goal/Header.tsx b/src/features/Portal/Goal/Header.tsx
index 677c1390e13..a5eee58061c 100644
--- a/src/features/Portal/Goal/Header.tsx
+++ b/src/features/Portal/Goal/Header.tsx
@@ -1,4 +1,3 @@
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@lobechat/const';
import { ActionIcon } from '@lobehub/ui';
import { Maximize2Icon } from 'lucide-react';
import { memo } from 'react';
@@ -6,12 +5,14 @@ import { useTranslation } from 'react-i18next';
import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';
+import { useHeaderActionSize } from '@/styles/density';
import PortalHeader from '../components/Header';
import Title from './Title';
import { useOpenGoalPage } from './useOpenGoalPage';
const Header = memo<{ onClose?: () => void }>(({ onClose }) => {
+ const headerActionSize = useHeaderActionSize(true);
const { t } = useTranslation('chat');
const goalId = useChatStore(chatPortalSelectors.goalPortalId);
const openGoalPage = useOpenGoalPage(goalId);
@@ -24,7 +25,7 @@ const Header = memo<{ onClose?: () => void }>(({ onClose }) => {
<ActionIcon
aria-label={t('goalProcess.portal.openPage')}
icon={Maximize2Icon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
title={t('goalProcess.portal.openPage')}
onClick={openGoalPage}
/>
diff --git a/src/features/Portal/LocalFile/Header.tsx b/src/features/Portal/LocalFile/Header.tsx
index 5b87ab7fc3a..b9e962cc5a9 100644
--- a/src/features/Portal/LocalFile/Header.tsx
+++ b/src/features/Portal/LocalFile/Header.tsx
@@ -1,6 +1,6 @@
'use client';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE, isDesktop } from '@lobechat/const';
+import { isDesktop } from '@lobechat/const';
import { ActionIcon } from '@lobehub/ui';
import { FolderOpen } from 'lucide-react';
import { memo, useCallback } from 'react';
@@ -10,10 +10,12 @@ import PortalHeader from '@/features/Portal/components/Header';
import { localFileService } from '@/services/electron/localFileService';
import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';
+import { useHeaderActionSize } from '@/styles/density';
import TabStrip from './TabStrip';
const Header = memo<{ onClose?: () => void }>(({ onClose }) => {
+ const headerActionSize = useHeaderActionSize(true);
const { t } = useTranslation('chat');
const activeLocalFilePath = useChatStore(chatPortalSelectors.activeLocalFilePath);
// Remote device and sandbox paths cannot be revealed in the local filesystem.
@@ -37,7 +39,7 @@ const Header = memo<{ onClose?: () => void }>(({ onClose }) => {
<ActionIcon
aria-label={t('workingPanel.files.showInSystem')}
icon={FolderOpen}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
title={t('workingPanel.files.showInSystem')}
onClick={handleOpenFileFolder}
/>
diff --git a/src/features/Portal/MemoryDetail/Header.tsx b/src/features/Portal/MemoryDetail/Header.tsx
index 0ed964726d5..393939b5c47 100644
--- a/src/features/Portal/MemoryDetail/Header.tsx
+++ b/src/features/Portal/MemoryDetail/Header.tsx
@@ -1,6 +1,5 @@
'use client';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@lobechat/const';
import { ActionIcon } from '@lobehub/ui';
import { Maximize2Icon } from 'lucide-react';
import { memo } from 'react';
@@ -10,11 +9,13 @@ import PortalChromeHeader from '@/features/Portal/components/Header';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';
+import { useHeaderActionSize } from '@/styles/density';
import { getMemoryDetailPath } from './memoryDetailRoutes';
import Title from './Title';
const Header = memo<{ onClose?: () => void }>(({ onClose }) => {
+ const headerActionSize = useHeaderActionSize(true);
const { t } = useTranslation('chat');
const view = useChatStore(chatPortalSelectors.memoryDetailView);
const navigate = useWorkspaceAwareNavigate();
@@ -27,7 +28,7 @@ const Header = memo<{ onClose?: () => void }>(({ onClose }) => {
view ? (
<ActionIcon
icon={Maximize2Icon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
title={t('agentSignal.receipts.memory.openInMemory')}
onClick={() => {
navigate(getMemoryDetailPath(view.layer, view.id));
diff --git a/src/features/Portal/TaskDetail/Header.tsx b/src/features/Portal/TaskDetail/Header.tsx
index 6213e5cb7e9..53434b8a05d 100644
--- a/src/features/Portal/TaskDetail/Header.tsx
+++ b/src/features/Portal/TaskDetail/Header.tsx
@@ -1,4 +1,3 @@
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@lobechat/const';
import { ActionIcon } from '@lobehub/ui';
import { ExternalLink } from 'lucide-react';
import { memo } from 'react';
@@ -9,6 +8,7 @@ import { useAppOrigin } from '@/hooks/useAppOrigin';
import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';
import { useTaskStore } from '@/store/task';
+import { useHeaderActionSize } from '@/styles/density';
import { openTrustedExternalUrl } from '@/utils/openTrustedExternalUrl';
import PortalHeader from '../components/Header';
@@ -17,6 +17,7 @@ import { getTaskDetailPageUrl } from './url';
import { useForeignTaskDetail } from './useForeignTaskDetail';
const TaskDetailHeader = memo<{ onClose?: () => void }>(({ onClose }) => {
+ const headerActionSize = useHeaderActionSize(true);
const { t } = useTranslation('verify');
const appOrigin = useAppOrigin();
const activeWorkspaceSlug = useActiveWorkspaceSlug();
@@ -45,7 +46,7 @@ const TaskDetailHeader = memo<{ onClose?: () => void }>(({ onClose }) => {
<ActionIcon
disabled={!pageUrl}
icon={ExternalLink}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
title={t('report.actions.openInBrowser')}
onClick={() => {
if (!pageUrl) return;
diff --git a/src/features/Portal/Thread/Header/index.tsx b/src/features/Portal/Thread/Header/index.tsx
index 1f8c3ae85f3..db4be6c2e8f 100644
--- a/src/features/Portal/Thread/Header/index.tsx
+++ b/src/features/Portal/Thread/Header/index.tsx
@@ -1,4 +1,3 @@
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@lobechat/const';
import { ActionIcon } from '@lobehub/ui';
import { ArrowLeftRight } from 'lucide-react';
import { memo } from 'react';
@@ -6,10 +5,12 @@ import { useTranslation } from 'react-i18next';
import PortalHeader from '@/features/Portal/components/Header';
import { useChatStore } from '@/store/chat';
+import { useHeaderActionSize } from '@/styles/density';
import Title from './Title';
const Header = memo<{ onClose?: () => void }>(({ onClose }) => {
+ const headerActionSize = useHeaderActionSize(true);
const { t } = useTranslation('thread');
const [portalThreadId, closeThreadPortal, switchThread] = useChatStore((s) => [
s.portalThreadId,
@@ -25,7 +26,7 @@ const Header = memo<{ onClose?: () => void }>(({ onClose }) => {
<ActionIcon
aria-label={t('portal.openInMain')}
icon={ArrowLeftRight}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
title={t('portal.openInMain')}
onClick={() => {
switchThread(portalThreadId);
diff --git a/src/features/Portal/TopicComments/Sidebar.tsx b/src/features/Portal/TopicComments/Sidebar.tsx
index 64c03f528d2..031d81c1bd5 100644
--- a/src/features/Portal/TopicComments/Sidebar.tsx
+++ b/src/features/Portal/TopicComments/Sidebar.tsx
@@ -3,10 +3,10 @@ import { ArrowLeft } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';
import { PortalViewType } from '@/store/chat/slices/portal/initialState';
+import { useHeaderActionSize } from '@/styles/density';
import Body from './Body';
import ThreadBody from './ThreadBody';
@@ -26,6 +26,7 @@ const styles = createStaticStyles(({ css }) => ({
}));
const TopicCommentsSidebar = memo(() => {
+ const headerActionSize = useHeaderActionSize(true);
const { t } = useTranslation(['chat', 'common']);
const view = useChatStore(chatPortalSelectors.currentView);
const [goBack, openTopicComments] = useChatStore((s) => [s.goBack, s.openTopicComments]);
@@ -47,7 +48,7 @@ const TopicCommentsSidebar = memo(() => {
<Flexbox horizontal align={'center'} className={styles.subheader} gap={4}>
<ActionIcon
icon={ArrowLeft}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
title={t('back', { ns: 'common' })}
onClick={isThread ? goBack : () => openTopicComments(view.topicId)}
/>
diff --git a/src/features/Portal/VerifyReport/Header.tsx b/src/features/Portal/VerifyReport/Header.tsx
index d9af1bc23c5..ab4c7662fda 100644
--- a/src/features/Portal/VerifyReport/Header.tsx
+++ b/src/features/Portal/VerifyReport/Header.tsx
@@ -1,9 +1,9 @@
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@lobechat/const';
import { ActionIcon } from '@lobehub/ui';
import { ExternalLink } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
+import { useHeaderActionSize } from '@/styles/density';
import { openTrustedExternalUrl } from '@/utils/openTrustedExternalUrl';
import Header from '../components/Header';
@@ -11,6 +11,7 @@ import Title from './Title';
import { useVerifyReportUrl } from './useReportUrl';
const VerifyReportHeader = memo<{ onClose?: () => void }>(({ onClose }) => {
+ const headerActionSize = useHeaderActionSize(true);
const { t } = useTranslation('verify');
const { externalUrl, standalone } = useVerifyReportUrl();
@@ -23,7 +24,7 @@ const VerifyReportHeader = memo<{ onClose?: () => void }>(({ onClose }) => {
<ActionIcon
disabled={!externalUrl}
icon={ExternalLink}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
title={t('report.actions.openInBrowser')}
onClick={() => {
if (!externalUrl) return;
diff --git a/src/features/Portal/components/Header.tsx b/src/features/Portal/components/Header.tsx
index a69cfa9982b..dd513c48a1b 100644
--- a/src/features/Portal/components/Header.tsx
+++ b/src/features/Portal/components/Header.tsx
@@ -1,10 +1,6 @@
'use client';
-import {
- AGENT_CHAT_TOPIC_PAGE_URL,
- AGENT_CHAT_TOPIC_URL,
- DESKTOP_HEADER_ICON_SMALL_SIZE,
-} from '@lobechat/const';
+import { AGENT_CHAT_TOPIC_PAGE_URL, AGENT_CHAT_TOPIC_URL } from '@lobechat/const';
import { ActionIcon, Flexbox } from '@lobehub/ui';
import { ArrowLeft, X } from 'lucide-react';
import { type CSSProperties, Fragment, memo, type ReactNode } from 'react';
@@ -15,6 +11,7 @@ import NavHeader from '@/features/NavHeader';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';
+import { useHeaderActionSize } from '@/styles/density';
import { PortalMoreMenuSlot } from './PortalMoreMenu/context';
@@ -26,6 +23,7 @@ const Header = memo<{
style?: CSSProperties;
title: ReactNode;
}>(({ onClose, paddingInline = 8, rightExtra, style, title }) => {
+ const headerActionSize = useHeaderActionSize(true);
const { t } = useTranslation('common');
const location = useLocation();
const navigate = useWorkspaceAwareNavigate();
@@ -50,7 +48,7 @@ const Header = memo<{
<ActionIcon
aria-label={t('back')}
icon={ArrowLeft}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
title={t('back')}
onClick={goBack}
/>
@@ -67,7 +65,7 @@ const Header = memo<{
<ActionIcon
aria-label={t('close')}
icon={X}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
title={t('close')}
onClick={() => {
if (onClose) {
diff --git a/src/features/Projects/KnowledgeBases/index.tsx b/src/features/Projects/KnowledgeBases/index.tsx
index 9d94f9cd251..c60a9d0f0b9 100644
--- a/src/features/Projects/KnowledgeBases/index.tsx
+++ b/src/features/Projects/KnowledgeBases/index.tsx
@@ -16,6 +16,7 @@ import KnowledgeIcon from '@/components/KnowledgeIcon';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import type { ProjectDetail } from '@/store/project';
import { useProjectStore } from '@/store/project';
+import { useDensityTokens } from '@/styles/density';
import { KnowledgeType } from '@/types/knowledgeBase';
import { openAddKnowledgeBaseModal } from './AddKnowledgeBaseModal';
@@ -24,6 +25,7 @@ type ProjectKnowledgeBase = NonNullable<ProjectDetail['knowledgeBases']>[number]
export function ProjectKnowledgeBaseSettings({ detail }: { detail: ProjectDetail }) {
const { t } = useTranslation('project');
+ const { pageTitleFontSize } = useDensityTokens();
const navigate = useWorkspaceAwareNavigate();
const updateProjectKnowledgeBase = useProjectStore((s) => s.updateProjectKnowledgeBase);
const removeProjectKnowledgeBase = useProjectStore((s) => s.removeProjectKnowledgeBase);
@@ -68,7 +70,7 @@ export function ProjectKnowledgeBaseSettings({ detail }: { detail: ProjectDetail
<Flexbox gap={20}>
<Flexbox horizontal align="flex-start" gap={16} justify="space-between">
<Flexbox gap={6}>
- <Text fontSize={16} weight={600}>
+ <Text fontSize={pageTitleFontSize} weight={600}>
{t('settings.knowledgeBases')}
</Text>
<Text type="secondary">{t('knowledgeBases.description')}</Text>
diff --git a/src/features/Projects/LinearSync/ImportTrigger.tsx b/src/features/Projects/LinearSync/ImportTrigger.tsx
index 97eba4b732b..6534cd8b2b1 100644
--- a/src/features/Projects/LinearSync/ImportTrigger.tsx
+++ b/src/features/Projects/LinearSync/ImportTrigger.tsx
@@ -6,8 +6,8 @@ import { DownloadIcon } from 'lucide-react';
import { memo, type ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import LinearIcon from '@/features/Integrations/Linear/LinearIcon';
+import { useHeaderActionSize } from '@/styles/density';
import { openLinearIssueImportModal } from './openImportModal';
@@ -27,6 +27,7 @@ interface ImportTriggerProps {
const ImportTrigger = memo<ImportTriggerProps>(
({ connections, disabled, onSynced, projectId, variant }) => {
const { t } = useTranslation('integration');
+ const headerActionSmallSize = useHeaderActionSize(true);
const open = (connection: LinearConnectionView) =>
openLinearIssueImportModal({ connection, onSynced, projectId });
@@ -38,7 +39,7 @@ const ImportTrigger = memo<ImportTriggerProps>(
aria-label={t('linear.sync.project.entry')}
disabled={disabled}
icon={LinearIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={t('linear.sync.project.entry')}
onClick={onClick}
/>
diff --git a/src/features/Projects/Members/index.tsx b/src/features/Projects/Members/index.tsx
index fc217268f45..68990bd1f14 100644
--- a/src/features/Projects/Members/index.tsx
+++ b/src/features/Projects/Members/index.tsx
@@ -35,6 +35,7 @@ import { useHomeStore } from '@/store/home';
import { homeAgentListSelectors } from '@/store/home/selectors';
import type { ProjectDetail } from '@/store/project';
import { useProjectStore } from '@/store/project';
+import { useDensityTokens } from '@/styles/density';
import { directoryAgentName } from '../WorkingDirectories/useDirectoryAgent';
import { openEditMemberModal } from './EditMemberModal';
@@ -61,6 +62,7 @@ const rowStyle = (index: number) =>
export function ProjectMemberSettings({ detail }: { detail: ProjectDetail }) {
const { t } = useTranslation('project');
+ const { pageTitleFontSize } = useDensityTokens();
const [inviteOpen, setInviteOpen] = useState(false);
const addProjectAgents = useProjectStore((s) => s.addProjectAgents);
const updateProjectAgent = useProjectStore((s) => s.updateProjectAgent);
@@ -177,7 +179,7 @@ export function ProjectMemberSettings({ detail }: { detail: ProjectDetail }) {
<Flexbox gap={20}>
<Flexbox horizontal align="flex-start" gap={16} justify="space-between">
<Flexbox gap={6}>
- <Text fontSize={16} weight={600}>
+ <Text fontSize={pageTitleFontSize} weight={600}>
{t('settings.members')}
</Text>
<Text type="secondary">{t('members.description')}</Text>
diff --git a/src/features/Projects/Review/MembersSettings.tsx b/src/features/Projects/Review/MembersSettings.tsx
index 348820664a3..155c79703fe 100644
--- a/src/features/Projects/Review/MembersSettings.tsx
+++ b/src/features/Projects/Review/MembersSettings.tsx
@@ -10,6 +10,7 @@ import { projectReviewService } from '@/services/projectReview';
import type { ProjectDetail } from '@/store/project';
import { useUserStore } from '@/store/user';
import { userProfileSelectors } from '@/store/user/selectors';
+import { useDensityTokens } from '@/styles/density';
import ProjectCreator from '../ProjectCreator';
import { openAddMemberModal } from './AddMemberModal';
@@ -23,6 +24,7 @@ interface MembersSettingsProps {
export function MembersSettings({ project }: MembersSettingsProps) {
const { t } = useTranslation('project');
+ const { pageTitleFontSize } = useDensityTokens();
const projectId = project.id;
const { data, error, mutate } = useProjectMembers(projectId);
const actorId = useUserStore(userProfileSelectors.userId);
@@ -37,7 +39,7 @@ export function MembersSettings({ project }: MembersSettingsProps) {
if (!data.workspaceId)
return (
<Flexbox gap={20}>
- <Text fontSize={16} weight={600}>
+ <Text fontSize={pageTitleFontSize} weight={600}>
{t('review.members.title')}
</Text>
<Block variant="outlined">{creatorRow}</Block>
@@ -81,7 +83,7 @@ export function MembersSettings({ project }: MembersSettingsProps) {
<Flexbox gap={20}>
<Flexbox horizontal align="flex-start" gap={16} justify="space-between">
<Flexbox gap={6}>
- <Text fontSize={16} weight={600}>
+ <Text fontSize={pageTitleFontSize} weight={600}>
{t('review.members.title')}
</Text>
<Text type="secondary">{t('review.members.roleInheritance')}</Text>
diff --git a/src/features/Projects/Review/SitesSettings.tsx b/src/features/Projects/Review/SitesSettings.tsx
index 3e3d70b7db2..6a9bc8c78f4 100644
--- a/src/features/Projects/Review/SitesSettings.tsx
+++ b/src/features/Projects/Review/SitesSettings.tsx
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
import AsyncError from '@/components/AsyncError';
import SkeletonBar from '@/components/Skeleton/Bar';
+import { useDensityTokens } from '@/styles/density';
import { SiteCard } from './SiteCard';
import { openSiteModal } from './SiteFormModal';
@@ -11,6 +12,7 @@ import { isForbidden, useProjectSites } from './useProjectReview';
export function SitesSettings({ projectId }: { projectId: string }) {
const { t } = useTranslation('project');
+ const { pageTitleFontSize } = useDensityTokens();
const { data: sites, error, mutate } = useProjectSites(projectId);
if (isForbidden(error)) return <Empty description={t('review.accessForbidden')} />;
@@ -19,7 +21,7 @@ export function SitesSettings({ projectId }: { projectId: string }) {
<Flexbox gap={20}>
<Flexbox horizontal align="flex-start" gap={12} justify="space-between">
<Flexbox gap={6}>
- <Text fontSize={16} weight={600}>
+ <Text fontSize={pageTitleFontSize} weight={600}>
{t('review.sites.title')}
</Text>
<Text type="secondary">{t('review.sites.description')}</Text>
diff --git a/src/features/Projects/WorkingDirectories/SidebarTopics.tsx b/src/features/Projects/WorkingDirectories/SidebarTopics.tsx
index 1e6165626a9..adc0754669f 100644
--- a/src/features/Projects/WorkingDirectories/SidebarTopics.tsx
+++ b/src/features/Projects/WorkingDirectories/SidebarTopics.tsx
@@ -31,6 +31,7 @@ import {
useTopicListFilter,
} from '@/features/AgentSidebar/Topic/TopicListScope';
import { useOnlyMineTopics, useScopedTopics } from '@/features/AgentSidebar/Topic/useScopedTopics';
+import { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import {
useProjectDirectories,
@@ -77,6 +78,7 @@ export function ProjectDirectoryTopics(props: ProjectDirectoryTopicsProps) {
}
function ProjectTopicList({ projectId, coordinatorAgentId, itemKey }: ProjectDirectoryTopicsProps) {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { t } = useTranslation('project');
const { t: tTopic } = useTranslation('topic');
const { topicGroupMode } = useAgentTopicGroupMode();
@@ -100,7 +102,7 @@ function ProjectTopicList({ projectId, coordinatorAgentId, itemKey }: ProjectDir
return (
<AccordionItem value={itemKey}>
<AccordionHeader>
- <AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionTrigger style={sectionTriggerStyle}>
<Text ellipsis fontSize={12} type="secondary" weight={500}>
{t('topics.title')}
</Text>
diff --git a/src/features/Projects/WorkingDirectories/WorkingDirectorySettings.tsx b/src/features/Projects/WorkingDirectories/WorkingDirectorySettings.tsx
index df71748d78f..97335385982 100644
--- a/src/features/Projects/WorkingDirectories/WorkingDirectorySettings.tsx
+++ b/src/features/Projects/WorkingDirectories/WorkingDirectorySettings.tsx
@@ -25,6 +25,7 @@ import {
useProjectDirectoryStore,
useProjectEnvironments,
} from '@/store/projectWorkingDirectory';
+import { useDensityTokens } from '@/styles/density';
import { openAddDirectoryModal } from './AddDirectoryModal';
import { openBindDirectoryModal } from './BindDirectoryModal';
@@ -46,6 +47,7 @@ const DevicePresence = ({ device }: { device?: DeviceListItem }) => {
export function WorkingDirectorySettings({ projectId }: { projectId: string }) {
const { t } = useTranslation('project');
+ const { pageTitleFontSize } = useDensityTokens();
const navigate = useWorkspaceAwareNavigate();
const [params, setParams] = useSearchParams();
const environmentId = params.get('environment') ?? '';
@@ -84,7 +86,7 @@ export function WorkingDirectorySettings({ projectId }: { projectId: string }) {
return (
<Flexbox gap={20}>
<Flexbox gap={6}>
- <Text fontSize={16} weight={600}>
+ <Text fontSize={pageTitleFontSize} weight={600}>
{t('settings.workLocations')}
</Text>
<Text type="secondary">{t('settings.directoryListDescription')}</Text>
diff --git a/src/features/Projects/WorkingDirectories/index.tsx b/src/features/Projects/WorkingDirectories/index.tsx
index f73cf774088..3b03b9fdd28 100644
--- a/src/features/Projects/WorkingDirectories/index.tsx
+++ b/src/features/Projects/WorkingDirectories/index.tsx
@@ -37,6 +37,7 @@ import {
useProjectEnvironments,
} from '@/store/projectWorkingDirectory';
import type { SandboxEnvironment } from '@/store/sandbox';
+import { useDensityTokens } from '@/styles/density';
import { openAddEnvironmentModal } from '../AddEnvironmentModal';
import { environmentRepositoryUrl } from '../environmentSource';
@@ -102,6 +103,7 @@ export function ProjectWorkingDirectories({
shared,
}: ProjectWorkingDirectoriesProps) {
const { t } = useTranslation(['project', 'common']);
+ const { pageTitleFontSize } = useDensityTokens();
const navigate = useWorkspaceAwareNavigate();
const linkedRequest = useProjectDirectoryStore((s) => s.useFetchEnvironments)(projectId);
const directoriesRequest = useProjectDirectoryStore((s) => s.useFetchDirectories)(projectId);
@@ -331,7 +333,7 @@ export function ProjectWorkingDirectories({
<Flexbox gap={16}>
<Flexbox gap={8}>
<Flexbox horizontal align="center" gap={12} justify="space-between" wrap="wrap">
- <Text fontSize={16} weight={600}>
+ <Text fontSize={pageTitleFontSize} weight={600}>
{t('settings.environments')}
</Text>
{actions}
diff --git a/src/features/Projects/Workspace/ProjectDashboard.tsx b/src/features/Projects/Workspace/ProjectDashboard.tsx
index bd0561366b9..de133e37090 100644
--- a/src/features/Projects/Workspace/ProjectDashboard.tsx
+++ b/src/features/Projects/Workspace/ProjectDashboard.tsx
@@ -43,6 +43,7 @@ import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwar
import { goalSelectors, useGoalStore } from '@/store/goal';
import type { ProjectDetail } from '@/store/project';
import { useWorkStore, workActions, workSelectors } from '@/store/work';
+import { useDensityTokens } from '@/styles/density';
const styles = createStaticStyles(({ css }) => ({
attention: css`
@@ -149,21 +150,24 @@ const SectionTitle = memo<{
count?: number;
onAction?: () => void;
title: string;
-}>(({ action, count, onAction, title }) => (
- <Flexbox horizontal align={'center'} justify={'space-between'}>
- <Flexbox horizontal align={'center'} gap={7}>
- <Text fontSize={16} weight={600}>
- {title}
- </Text>
- {count !== undefined && <Tag>{count}</Tag>}
+}>(({ action, count, onAction, title }) => {
+ const { pageTitleFontSize } = useDensityTokens();
+ return (
+ <Flexbox horizontal align={'center'} justify={'space-between'}>
+ <Flexbox horizontal align={'center'} gap={7}>
+ <Text fontSize={pageTitleFontSize} weight={600}>
+ {title}
+ </Text>
+ {count !== undefined && <Tag>{count}</Tag>}
+ </Flexbox>
+ {action && (
+ <Button size={'small'} type={'text'} onClick={onAction}>
+ {action}
+ </Button>
+ )}
</Flexbox>
- {action && (
- <Button size={'small'} type={'text'} onClick={onAction}>
- {action}
- </Button>
- )}
- </Flexbox>
-));
+ );
+});
const ProjectDashboard = memo<ProjectDashboardProps>(({ detail, projectId }) => {
const { t } = useTranslation('project');
diff --git a/src/features/ResourceHome/Home/HomeList.tsx b/src/features/ResourceHome/Home/HomeList.tsx
index 2b2eb4973fc..34f456ed96e 100644
--- a/src/features/ResourceHome/Home/HomeList.tsx
+++ b/src/features/ResourceHome/Home/HomeList.tsx
@@ -27,6 +27,7 @@ import { homeRecentSelectors } from '@/store/home/slices/recent/selectors';
import { knowledgeBaseSelectors, useKnowledgeBaseStore } from '@/store/library';
import { useUserStore } from '@/store/user';
import { userProfileSelectors } from '@/store/user/slices/auth/selectors';
+import { sidebarRow } from '@/styles/density.stylex';
import { isArtifactPage } from '../Layout/Body/PageSection/group';
import { docsFilePath, docsPagePath, DRIVE_PATH, LIBRARY_INDEX_PATH } from '../paths';
@@ -103,7 +104,7 @@ const styles = stylex.create({
gap: '16px',
alignItems: 'center',
width: '100%',
- paddingBlock: '10px',
+ paddingBlock: `calc((${sidebarRow.listRowHeight} - 28px) / 2)`,
paddingInline: '12px',
borderWidth: 0,
borderBlockEndWidth: '1px',
@@ -114,13 +115,13 @@ const styles = stylex.create({
},
tab: {
cursor: 'pointer',
- paddingBlock: '6px',
+ paddingBlock: `calc((${sidebarRow.controlHeight} - 20px) / 2)`,
paddingInline: 0,
borderWidth: 0,
borderBlockEndWidth: '2px',
borderBlockEndStyle: 'solid',
borderBlockEndColor: 'transparent',
- fontSize: '14px',
+ fontSize: sidebarRow.textFontSize,
color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
backgroundColor: 'transparent',
},
diff --git a/src/features/ResourceHome/Layout/Body/PageSection/index.tsx b/src/features/ResourceHome/Layout/Body/PageSection/index.tsx
index 0b92a7db072..6dc6c31cafa 100644
--- a/src/features/ResourceHome/Layout/Body/PageSection/index.tsx
+++ b/src/features/ResourceHome/Layout/Body/PageSection/index.tsx
@@ -22,6 +22,7 @@ import { useTranslation } from 'react-i18next';
import AsyncBoundary from '@/components/AsyncBoundary';
import EmptyNavItem from '@/features/NavPanel/components/EmptyNavItem';
import NavItem from '@/features/NavPanel/components/NavItem';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import { usePermission } from '@/hooks/usePermission';
import { pageActions, pageSelectors, usePageStore } from '@/store/page';
@@ -45,6 +46,7 @@ interface PageSectionProps {
* `shared` is what other workspace members published.
*/
const PageSection = memo<PageSectionProps>(({ itemKey, scope }) => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { t } = useTranslation('file');
const [creating, setCreating] = useState(false);
const { allowed: canCreate, reason } = usePermission('create_content');
@@ -109,11 +111,9 @@ const PageSection = memo<PageSectionProps>(({ itemKey, scope }) => {
return (
<AccordionItem value={itemKey}>
<AccordionHeader>
- <AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionTrigger style={sectionTriggerStyle}>
<Flexbox horizontal align={'center'} gap={4}>
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {title}
- </Text>
+ <SectionTitle>{title}</SectionTitle>
{isValidating && !!groups?.length && <Spin size={'small'} variant={'network'} />}
</Flexbox>
</AccordionTrigger>
diff --git a/src/features/ResourceHome/Layout/Body/index.tsx b/src/features/ResourceHome/Layout/Body/index.tsx
index cc769c44038..4422833250a 100644
--- a/src/features/ResourceHome/Layout/Body/index.tsx
+++ b/src/features/ResourceHome/Layout/Body/index.tsx
@@ -14,12 +14,14 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { useCreateNewModal } from '@/features/LibraryModal';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { usePermission } from '@/hooks/usePermission';
import LibraryList from './LibraryList';
const SidebarBody = memo<{ itemKey: string }>(({ itemKey }) => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { t } = useTranslation('file');
const navigate = useWorkspaceAwareNavigate();
@@ -48,10 +50,8 @@ const SidebarBody = memo<{ itemKey: string }>(({ itemKey }) => {
return (
<AccordionItem value={itemKey}>
<AccordionHeader>
- <AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {t('docs.recentLibraries')}
- </Text>
+ <AccordionTrigger style={sectionTriggerStyle}>
+ <SectionTitle>{t('docs.recentLibraries')}</SectionTitle>
</AccordionTrigger>
<div
className={cx(
diff --git a/src/features/ResourceHome/Skeleton.tsx b/src/features/ResourceHome/Skeleton.tsx
index 8ef1abf508c..2b5cc835a8a 100644
--- a/src/features/ResourceHome/Skeleton.tsx
+++ b/src/features/ResourceHome/Skeleton.tsx
@@ -13,6 +13,7 @@ import MasonryViewSkeleton from '@/features/ResourceManager/components/Explorer/
import { useMasonryColumnCount } from '@/features/ResourceManager/components/Explorer/useMasonryColumnCount';
import WorkGallerySkeleton from '@/features/WorkGallery/Skeleton';
import type { RouteSkeletonProps } from '@/spa/router/routeMeta';
+import { useDensityTokens } from '@/styles/density';
import { resolveResourceSkeletonView } from './skeletonView';
@@ -20,6 +21,7 @@ const ResourceCategorySkeleton = ({ chrome = 'page' }: RouteSkeletonProps) => {
const { pathname } = useLocation();
const [searchParams] = useSearchParams();
const columnCount = useMasonryColumnCount();
+ const { headerHeight } = useDensityTokens();
const view = resolveResourceSkeletonView(pathname, searchParams.get('view'));
if (view === 'works') return <WorkGallerySkeleton />;
@@ -37,7 +39,7 @@ const ResourceCategorySkeleton = ({ chrome = 'page' }: RouteSkeletonProps) => {
horizontal
align={'center'}
flex={'none'}
- height={44}
+ height={headerHeight}
justify={'space-between'}
paddingInline={16}
>
diff --git a/src/features/ResourceManager/components/Explorer/ListView/ListItem/index.tsx b/src/features/ResourceManager/components/Explorer/ListView/ListItem/index.tsx
index 64aaecfcba6..9896a2b3406 100644
--- a/src/features/ResourceManager/components/Explorer/ListView/ListItem/index.tsx
+++ b/src/features/ResourceManager/components/Explorer/ListView/ListItem/index.tsx
@@ -18,6 +18,7 @@ import UserAvatar from '@/components/UserAvatar';
import { useResourceManagerStore } from '@/features/ResourceManager/store';
import { isExplorerItemSelected } from '@/features/ResourceManager/store/selectors';
import { fileManagerSelectors, getChunkTargetId, useFileStore } from '@/store/file';
+import { useDensityTokens } from '@/styles/density';
import type { FileListItem as FileListItemType } from '@/types/files';
import { formatSize } from '@/utils/format';
@@ -197,6 +198,7 @@ const FileListItem = ({
userId,
visibility,
}: FileListItemProps) => {
+ const { listRowHeight } = useDensityTokens();
const { t } = useTranslation(['components', 'file', 'chat', 'common']);
const uploaderName =
uploader?.fullName || uploader?.username || (uploader?.id ? uploader.id.slice(0, 8) : '');
@@ -362,7 +364,7 @@ const FileListItem = ({
data-parent-key={parentKey}
data-row-index={index}
draggable={!!resourceManagerState.libraryId}
- height={48}
+ height={listRowHeight}
paddingInline={8}
className={cx(
styles.container,
diff --git a/src/features/ResourceManager/components/Explorer/ListView/Skeleton.tsx b/src/features/ResourceManager/components/Explorer/ListView/Skeleton.tsx
index d81b88d0ff9..13ed1c2065b 100644
--- a/src/features/ResourceManager/components/Explorer/ListView/Skeleton.tsx
+++ b/src/features/ResourceManager/components/Explorer/ListView/Skeleton.tsx
@@ -1,5 +1,7 @@
import { Center, Checkbox, cssVar, Flexbox, Skeleton } from '@lobehub/ui';
+import { useDensityTokens } from '@/styles/density';
+
import { FILE_DATE_WIDTH, FILE_SIZE_WIDTH, getListViewMinWidth } from './ListItem/constants';
interface ListViewSkeletonProps {
@@ -18,6 +20,7 @@ const ListViewSkeleton = ({
count = 6,
showUploader = true,
}: ListViewSkeletonProps) => {
+ const { listRowHeight } = useDensityTokens();
// Calculate opacity gradient from 100% to 20%
const getOpacity = (index: number) => 1 - (index / (count - 1)) * 0.8;
@@ -27,7 +30,7 @@ const ListViewSkeleton = ({
<Flexbox
horizontal
align={'center'}
- height={48}
+ height={listRowHeight}
key={index}
paddingInline={8}
style={{
diff --git a/src/features/ResourceManager/components/Explorer/ListView/VirtualizedFileList.tsx b/src/features/ResourceManager/components/Explorer/ListView/VirtualizedFileList.tsx
index 778b6f05678..f1d57e96ffc 100644
--- a/src/features/ResourceManager/components/Explorer/ListView/VirtualizedFileList.tsx
+++ b/src/features/ResourceManager/components/Explorer/ListView/VirtualizedFileList.tsx
@@ -1,10 +1,11 @@
import type { RefObject } from 'react';
-import { useCallback, useEffect, useLayoutEffect, useRef } from 'react';
+import { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from 'react';
import type { ListRange, VirtuosoHandle } from 'react-virtuoso';
import { Virtuoso } from 'react-virtuoso';
import { useResourceManagerStore } from '@/features/ResourceManager/store';
import { isExplorerItemSelected } from '@/features/ResourceManager/store/selectors';
+import { useDensityTokens } from '@/styles/density';
import type { FileListItem } from '@/types/files';
import { useExplorerSelectionActions } from '../hooks/useExplorerSelection';
@@ -17,8 +18,6 @@ import {
const LIST_COMPONENTS = { Footer: ExplorerListFooter };
-const ROW_HEIGHT = 48;
-
/**
* Rows rendered beyond the viewport. The previous 2000px budget kept ~40
* off-screen interactive rows mounted, and every scroll step had to mount a
@@ -27,7 +26,10 @@ const ROW_HEIGHT = 48;
* margin keeps each step short; a deeper one (20 rows) made the blank frames
* worse, not better.
*/
-const INCREASE_VIEWPORT_BY = { bottom: ROW_HEIGHT * 8, top: ROW_HEIGHT * 4 };
+const getIncreaseViewportBy = (rowHeight: number) => ({
+ bottom: rowHeight * 8,
+ top: rowHeight * 4,
+});
/**
* Rows before the end at which the next page starts loading. Rendering margin
@@ -73,6 +75,8 @@ const VirtualizedFileList = ({
showUploader = true,
virtuosoRef,
}: VirtualizedFileListProps) => {
+ const { listRowHeight } = useDensityTokens();
+ const increaseViewportBy = useMemo(() => getIncreaseViewportBy(listRowHeight), [listRowHeight]);
const {
clearSelectAllState,
isItemSelectable,
@@ -169,10 +173,10 @@ const VirtualizedFileList = ({
computeItemKey={computeItemKey}
context={footerContext}
data={data}
- defaultItemHeight={ROW_HEIGHT}
+ defaultItemHeight={listRowHeight}
endReached={handleEndReached}
- fixedItemHeight={ROW_HEIGHT}
- increaseViewportBy={INCREASE_VIEWPORT_BY}
+ fixedItemHeight={listRowHeight}
+ increaseViewportBy={increaseViewportBy}
initialItemCount={Math.min(30, data.length)}
rangeChanged={handleRangeChanged}
ref={virtuosoRef}
diff --git a/src/features/ResourceManager/components/ResourceModeToggle/index.tsx b/src/features/ResourceManager/components/ResourceModeToggle/index.tsx
index ee4faee5816..a582ea9d860 100644
--- a/src/features/ResourceManager/components/ResourceModeToggle/index.tsx
+++ b/src/features/ResourceManager/components/ResourceModeToggle/index.tsx
@@ -13,9 +13,9 @@ import { memo, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { useResourceManagerStore } from '@/features/ResourceManager/store';
import type { ResourceListVisibilityFilter } from '@/features/ResourceManager/store/initialState';
+import { useHeaderActionSize } from '@/styles/density';
const OPTIONS: Array<{
icon: typeof LockIcon;
@@ -47,6 +47,7 @@ const OPTIONS: Array<{
*/
const ResourceModeToggle = memo(() => {
const { t } = useTranslation('chat');
+ const headerActionSmallSize = useHeaderActionSize(true);
const activeWorkspaceId = useActiveWorkspaceId();
const [listVisibility, setListVisibility, hydrateListVisibility] = useResourceManagerStore(
(s) => [s.listVisibility, s.setListVisibility, s.hydrateListVisibility],
@@ -94,7 +95,7 @@ const ResourceModeToggle = memo(() => {
<DropdownMenu items={menuItems} open={open} onOpenChange={setOpen}>
<ActionIcon
icon={current.icon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={`${t('resources.visibility.label')}: ${currentLabel}`}
/>
</DropdownMenu>
diff --git a/src/features/RightPanel/ToggleRightPanelButton.tsx b/src/features/RightPanel/ToggleRightPanelButton.tsx
index d6fe36e84ad..5f56e3515c3 100644
--- a/src/features/RightPanel/ToggleRightPanelButton.tsx
+++ b/src/features/RightPanel/ToggleRightPanelButton.tsx
@@ -7,11 +7,11 @@ import { type ReactNode } from 'react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/selectors';
+import { useHeaderActionSize } from '@/styles/density';
export const TOGGLE_BUTTON_ID = 'toggle_right_panel_button';
@@ -31,6 +31,7 @@ interface ToggleRightPanelButtonProps {
const ToggleRightPanelButton = memo<ToggleRightPanelButtonProps>(
({ title, showActive, icon, hideWhenExpanded, size, expand: expandProp, onToggle }) => {
+ const headerActionSize = useHeaderActionSize(true);
const [globalExpand, globalToggle, isStatusInit] = useGlobalStore((s) => [
systemStatusSelectors.showRightPanel(s),
s.toggleRightPanel,
@@ -54,7 +55,7 @@ const ToggleRightPanelButton = memo<ToggleRightPanelButtonProps>(
active={showActive ? expand : undefined}
icon={icon || (expand ? PanelRightClose : PanelRightOpen)}
id={TOGGLE_BUTTON_ID}
- size={size || DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={size || headerActionSize}
title={title || t('toggleRightPanel.title', { ns: 'hotkey' })}
tooltipProps={{
hotkey,
diff --git a/src/features/SandboxDrive/Cleanup/index.tsx b/src/features/SandboxDrive/Cleanup/index.tsx
index 8f0cf617464..474ec380039 100644
--- a/src/features/SandboxDrive/Cleanup/index.tsx
+++ b/src/features/SandboxDrive/Cleanup/index.tsx
@@ -10,6 +10,7 @@ import { useTranslation } from 'react-i18next';
import { getActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';
import { describeError } from '@/features/EnvironmentManager/errorMessage';
+import { useDensityTokens } from '@/styles/density';
import { formatSize } from '@/utils/format';
import { STORAGE_CATEGORIES } from './analysis';
@@ -57,6 +58,7 @@ interface StorageCleanupProps {
*/
const StorageCleanup = memo<StorageCleanupProps>(({ drive, onBack }) => {
const { t } = useTranslation(['setting', 'common']);
+ const { pageTitleFontSize } = useDensityTokens();
const { analysis, error, remove, rescan, scanning } = useStorageAnalysis(drive);
const result = analysis?.result;
const selection = useCleanupSelection(result);
@@ -118,7 +120,7 @@ const StorageCleanup = memo<StorageCleanupProps>(({ drive, onBack }) => {
<Flexbox horizontal align={'center'} gap={8}>
<ActionIcon icon={ArrowLeftIcon} title={t('drive.cleanup.back')} onClick={onBack} />
<Flexbox flex={1} gap={2}>
- <Text as={'h2'} fontSize={16} style={{ margin: 0 }} weight={600}>
+ <Text as={'h2'} fontSize={pageTitleFontSize} style={{ margin: 0 }} weight={600}>
{t('drive.cleanup.title')}
</Text>
<Text fontSize={12} type={'secondary'}>
diff --git a/src/features/Settings/Layout/Body/index.tsx b/src/features/Settings/Layout/Body/index.tsx
index 15300cda473..f71f7c67d81 100644
--- a/src/features/Settings/Layout/Body/index.tsx
+++ b/src/features/Settings/Layout/Body/index.tsx
@@ -5,6 +5,7 @@ import { memo, useMemo } from 'react';
import { Link } from 'react-router';
import NavItem from '@/features/NavPanel/components/NavItem';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import { getTabUrl, SearchSection } from '@/features/SettingsSearch';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useActiveLocation } from '@/hooks/useActiveLocation';
@@ -16,6 +17,7 @@ import { useExpandedSettingsGroups } from '../../hooks/useExpandedSettingsGroups
import { usePersonalSettingsSearchScope } from '../../hooks/useSettingsSearchScope';
const Body = memo(() => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const categoryGroups = useCategory();
const searchScope = usePersonalSettingsSearchScope(categoryGroups);
const navigate = useWorkspaceAwareNavigate();
@@ -43,15 +45,11 @@ const Body = memo(() => {
<Accordion
gap={8}
indicatorPlacement="inline"
- styles={{ trigger: { paddingBlock: 4, paddingInline: '8px 4px' } }}
+ styles={{ trigger: sectionTriggerStyle }}
value={expandedGroups}
items={categoryGroups.map((group) => ({
key: group.key,
- title: (
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {group.title}
- </Text>
- ),
+ title: <SectionTitle>{group.title}</SectionTitle>,
children: (
<Flexbox gap={1} paddingBlock={1}>
{group.items.map((item) => {
diff --git a/src/features/Settings/common/features/Common/Common.tsx b/src/features/Settings/common/features/Common/Common.tsx
index 7740ccce5f6..b5ce639dd84 100644
--- a/src/features/Settings/common/features/Common/Common.tsx
+++ b/src/features/Settings/common/features/Common/Common.tsx
@@ -3,7 +3,7 @@
import { Flexbox, Icon, ImageSelect, Select, Tabs } from '@lobehub/ui';
import { Form, type FormGroupItem, useForm } from '@lobehub/ui/form';
import isEqual from 'fast-deep-equal';
-import { Ban, Gauge, Monitor, Moon, Mouse, Sun, Waves } from 'lucide-react';
+import { Ban, Gauge, Monitor, Moon, Mouse, Rows3, Rows4, Sun, Waves } from 'lucide-react';
import { useTheme as useNextThemesTheme } from 'next-themes';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -153,6 +153,33 @@ const Common = memo(() => {
name: 'animationMode',
valueProp: 'activeKey',
},
+ {
+ children: (
+ <Tabs
+ items={[
+ {
+ icon: <Icon icon={Rows4} size={16} />,
+ key: 'compact',
+ label: t('settingAppearance.density.compact'),
+ },
+ {
+ icon: <Icon icon={Rows3} size={16} />,
+ key: 'loose',
+ label: t('settingAppearance.density.loose'),
+ },
+ ]}
+ />
+ ),
+ desc: t('settingAppearance.density.desc'),
+ label: (
+ <SettingsSearchAnchor id={'appearance-density'}>
+ {t('settingAppearance.density.title')}
+ </SettingsSearchAnchor>
+ ),
+ minWidth: undefined,
+ name: 'interfaceDensity',
+ valueProp: 'activeKey',
+ },
{
children: (
<Tabs
diff --git a/src/features/Settings/provider/ProviderMenu/AddNew.tsx b/src/features/Settings/provider/ProviderMenu/AddNew.tsx
index 389d661cc19..ff241352693 100644
--- a/src/features/Settings/provider/ProviderMenu/AddNew.tsx
+++ b/src/features/Settings/provider/ProviderMenu/AddNew.tsx
@@ -4,12 +4,13 @@ import { ActionIcon, Tooltip } from '@lobehub/ui';
import { PlusIcon } from 'lucide-react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { usePermission } from '@/hooks/usePermission';
+import { useHeaderActionSize } from '@/styles/density';
import { createCreateNewProviderModal } from '../features/CreateNewProvider';
const AddNewProvider = () => {
+ const headerActionSize = useHeaderActionSize(true);
const { t } = useTranslation('modelProvider');
const { allowed: canManageProvider, reason } = usePermission('manage_provider_key');
@@ -17,7 +18,7 @@ const AddNewProvider = () => {
<ActionIcon
disabled={!canManageProvider}
icon={PlusIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
title={canManageProvider ? t('menu.addCustomProvider') : undefined}
onClick={() => {
if (!canManageProvider) return;
diff --git a/src/features/Settings/provider/ProviderMenu/List.tsx b/src/features/Settings/provider/ProviderMenu/List.tsx
index 555e9c6daad..86f27988349 100644
--- a/src/features/Settings/provider/ProviderMenu/List.tsx
+++ b/src/features/Settings/provider/ProviderMenu/List.tsx
@@ -19,6 +19,7 @@ import { ArrowDownUpIcon } from 'lucide-react';
import { type ReactNode, useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import { aiProviderSelectors } from '@/store/aiInfra';
import { useAiInfraStore } from '@/store/aiInfra/store';
import { useGlobalStore } from '@/store/global';
@@ -44,35 +45,37 @@ const ProviderSection = ({
contextMenuItems,
title,
value,
-}: ProviderSectionProps) => (
- <AccordionItem value={value}>
- <ContextMenuTrigger items={contextMenuItems}>
- <AccordionHeader>
- <AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {title}
- </Text>
- </AccordionTrigger>
- {action && (
- <div
- className={cx(
- 'accordion-action',
- accordionStyles.action,
- accordionStyles.actionBorderless,
- )}
- >
- {action}
- </div>
- )}
- </AccordionHeader>
- </ContextMenuTrigger>
- <AccordionPanel>
- <Flexbox gap={4} paddingBlock={1}>
- {children}
- </Flexbox>
- </AccordionPanel>
- </AccordionItem>
-);
+}: ProviderSectionProps) => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
+
+ return (
+ <AccordionItem value={value}>
+ <ContextMenuTrigger items={contextMenuItems}>
+ <AccordionHeader>
+ <AccordionTrigger style={sectionTriggerStyle}>
+ <SectionTitle>{title}</SectionTitle>
+ </AccordionTrigger>
+ {action && (
+ <div
+ className={cx(
+ 'accordion-action',
+ accordionStyles.action,
+ accordionStyles.actionBorderless,
+ )}
+ >
+ {action}
+ </div>
+ )}
+ </AccordionHeader>
+ </ContextMenuTrigger>
+ <AccordionPanel>
+ <Flexbox gap={4} paddingBlock={1}>
+ {children}
+ </Flexbox>
+ </AccordionPanel>
+ </AccordionItem>
+ );
+};
const ProviderList = (props: {
mobile?: boolean;
diff --git a/src/features/Settings/provider/ProviderMenu/index.tsx b/src/features/Settings/provider/ProviderMenu/index.tsx
index 5364a1c24cc..60d6a4bbd26 100644
--- a/src/features/Settings/provider/ProviderMenu/index.tsx
+++ b/src/features/Settings/provider/ProviderMenu/index.tsx
@@ -8,7 +8,9 @@ import { useTranslation } from 'react-i18next';
import AsyncBoundary from '@/components/AsyncBoundary';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
+import { NavPanelDensityContext } from '@/features/NavPanel/density';
import { useAiInfraStore } from '@/store/aiInfra/store';
+import { useInterfaceDensity } from '@/styles/density';
import { PROVIDER_MENU_WIDTH } from '../const';
import AddNew from './AddNew';
@@ -23,63 +25,66 @@ const Layout = memo(({ children, mobile }: ProviderMenuProps) => {
const { t } = useTranslation('modelProvider');
const providerSearchKeyword = useAiInfraStore((s) => s.providerSearchKeyword);
+ const interfaceDensity = useInterfaceDensity();
const width = mobile ? undefined : PROVIDER_MENU_WIDTH;
return (
- <Flexbox
- width={width}
- style={{
- background: cssVar.colorBgContainer,
- borderRight: `1px solid ${cssVar.colorBorderSecondary}`,
- minWidth: width,
- overflow: mobile ? undefined : 'scroll',
- }}
- >
+ <NavPanelDensityContext value={mobile ? null : interfaceDensity}>
<Flexbox
- horizontal
- align={'center'}
- gap={8}
- justify={'space-between'}
- padding={8}
- width={'100%'}
+ width={width}
style={{
background: cssVar.colorBgContainer,
- borderBottom: `1px solid ${cssVar.colorBorderSecondary}`,
- marginBottom: 8,
- position: 'sticky',
- top: 0,
- zIndex: 50,
+ borderRight: `1px solid ${cssVar.colorBorderSecondary}`,
+ minWidth: width,
+ overflow: mobile ? undefined : 'scroll',
}}
>
- <SearchBar
- allowClear
- placeholder={t('menu.searchProviders')}
- style={{ width: '100%' }}
- value={providerSearchKeyword}
- variant={'borderless'}
- prefix={
- <Icon
- color={cssVar.colorTextDescription}
- icon={SearchIcon}
- style={{
- marginRight: 12,
- }}
- />
- }
- styles={{
- input: {
- paddingBlock: 3,
- paddingLeft: 6,
- },
- }}
- onInputChange={(v) => {
- useAiInfraStore.setState({ providerSearchKeyword: v });
+ <Flexbox
+ horizontal
+ align={'center'}
+ gap={8}
+ justify={'space-between'}
+ padding={8}
+ width={'100%'}
+ style={{
+ background: cssVar.colorBgContainer,
+ borderBottom: `1px solid ${cssVar.colorBorderSecondary}`,
+ marginBottom: 8,
+ position: 'sticky',
+ top: 0,
+ zIndex: 50,
}}
- />
- <AddNew />
+ >
+ <SearchBar
+ allowClear
+ placeholder={t('menu.searchProviders')}
+ style={{ width: '100%' }}
+ value={providerSearchKeyword}
+ variant={'borderless'}
+ prefix={
+ <Icon
+ color={cssVar.colorTextDescription}
+ icon={SearchIcon}
+ style={{
+ marginRight: 12,
+ }}
+ />
+ }
+ styles={{
+ input: {
+ paddingBlock: 3,
+ paddingLeft: 6,
+ },
+ }}
+ onInputChange={(v) => {
+ useAiInfraStore.setState({ providerSearchKeyword: v });
+ }}
+ />
+ <AddNew />
+ </Flexbox>
+ {children}
</Flexbox>
- {children}
- </Flexbox>
+ </NavPanelDensityContext>
);
});
diff --git a/src/features/Settings/stats/features/overview/ShareButton/index.tsx b/src/features/Settings/stats/features/overview/ShareButton/index.tsx
index 84436a580ee..12a7c2dc416 100644
--- a/src/features/Settings/stats/features/overview/ShareButton/index.tsx
+++ b/src/features/Settings/stats/features/overview/ShareButton/index.tsx
@@ -4,18 +4,20 @@ import { ActionIcon } from '@lobehub/ui';
import { Share2Icon } from 'lucide-react';
import { memo, useState } from 'react';
-import { DESKTOP_HEADER_ICON_SIZE, MOBILE_HEADER_ICON_SIZE } from '@/const/layoutTokens';
+import { MOBILE_HEADER_ICON_SIZE } from '@/const/layoutTokens';
+import { useHeaderActionSize } from '@/styles/density';
import ShareModal from './ShareModal';
const ShareButton = memo<{ mobile?: boolean }>(({ mobile }) => {
+ const headerActionSize = useHeaderActionSize();
const [open, setOpen] = useState(false);
return (
<>
<ActionIcon
icon={Share2Icon}
- size={mobile ? MOBILE_HEADER_ICON_SIZE : DESKTOP_HEADER_ICON_SIZE}
+ size={mobile ? MOBILE_HEADER_ICON_SIZE : headerActionSize}
onClick={() => setOpen(true)}
/>
<ShareModal mobile={mobile} open={open} onCancel={() => setOpen(false)} />
diff --git a/src/features/SettingsSearch/items.ts b/src/features/SettingsSearch/items.ts
index 20c89136d83..38ef177d375 100644
--- a/src/features/SettingsSearch/items.ts
+++ b/src/features/SettingsSearch/items.ts
@@ -343,6 +343,13 @@ export const SETTINGS_SEARCH_ITEMS: SettingsSearchItem[] = [
labelKey: 'settingAppearance.animationMode.title',
tab: SettingsTabs.Appearance,
},
+ {
+ anchor: 'appearance-density',
+ descKey: 'settingAppearance.density.desc',
+ keywords: ['density', 'compact', 'loose', 'spacing', 'row height', 'sidebar'],
+ labelKey: 'settingAppearance.density.title',
+ tab: SettingsTabs.Appearance,
+ },
{
anchor: 'appearance-context-menu',
descKey: 'settingAppearance.contextMenuMode.desc',
diff --git a/src/features/SkillsList/SkillSection.tsx b/src/features/SkillsList/SkillSection.tsx
index 163c04315fe..2576070009c 100644
--- a/src/features/SkillsList/SkillSection.tsx
+++ b/src/features/SkillsList/SkillSection.tsx
@@ -1,7 +1,20 @@
-import { Accordion, Center, createStaticStyles, Flexbox, Spin, Text } from '@lobehub/ui';
+import {
+ Accordion,
+ Center,
+ createStaticStyles,
+ Empty,
+ Flexbox,
+ Icon,
+ Spin,
+ Text,
+} from '@lobehub/ui';
+import { SkillsIcon } from '@lobehub/ui/icons';
+import { ChevronDownIcon } from 'lucide-react';
import { memo, type ReactNode, useState } from 'react';
import AsyncError from '@/components/AsyncError';
+import { SkeletonList } from '@/components/Skeleton/NavPanel/List';
+import { sidebarRow } from '@/styles/density.stylex';
export interface SkillSectionHeader {
/** Independent header action, outside the accordion's collapse trigger. */
@@ -16,6 +29,8 @@ export interface SkillSectionHeader {
export interface SkillSectionProps {
children?: ReactNode;
+ /** The WorkingSidebar row system: section header, tertiary label, hover-revealed action and chevron. */
+ compact?: boolean;
emptyText?: string;
/**
* A failed fetch. When set (and there's no data), the body renders a failure +
@@ -51,6 +66,84 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
font-size: 12px;
font-weight: 500;
`,
+ compactHeader: css`
+ display: flex;
+ gap: 4px;
+ align-items: center;
+
+ height: ${sidebarRow.sectionHeaderHeight};
+ padding-inline: ${sidebarRow.paddingInline};
+
+ [data-section-action] {
+ pointer-events: none;
+ opacity: 0;
+ transition: opacity 0.15s;
+ }
+
+ &:hover [data-section-action],
+ &:focus-within [data-section-action] {
+ pointer-events: auto;
+ opacity: 1;
+ }
+
+ [data-section-chevron] {
+ display: flex;
+ opacity: 0;
+ transition:
+ opacity 0.15s,
+ transform 0.15s;
+ }
+
+ &:hover [data-section-chevron],
+ &:focus-within [data-section-chevron],
+ [aria-expanded='false'] [data-section-chevron] {
+ opacity: 1;
+ }
+
+ [aria-expanded='false'] [data-section-chevron] {
+ transform: rotate(-90deg);
+ }
+ `,
+ compactLabel: css`
+ display: flex;
+ flex: 1;
+ gap: 4px;
+ align-items: center;
+
+ min-width: 0;
+ height: 100%;
+ padding: 0;
+ border: 0;
+ border-radius: 4px;
+
+ font: inherit;
+ font-size: ${sidebarRow.labelFontSize};
+ font-weight: ${sidebarRow.labelFontWeight};
+ line-height: ${sidebarRow.textLineHeight};
+ color: ${cssVar.colorTextTertiary};
+ text-align: start;
+
+ background: none;
+
+ &:focus-visible {
+ outline: 2px solid ${cssVar.colorPrimary};
+ outline-offset: -2px;
+ }
+ `,
+ compactLabelButton: css`
+ cursor: pointer;
+ `,
+ compactTitle: css`
+ overflow: hidden;
+ min-width: 0;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ `,
+ compactCount: css`
+ flex-shrink: 0;
+ font-weight: 400;
+ font-variant-numeric: tabular-nums;
+ `,
}));
const ITEM_KEY = 'skill-section';
@@ -73,6 +166,7 @@ HeaderRow.displayName = 'SkillSectionHeaderRow';
interface BodyProps {
children?: ReactNode;
+ compact?: boolean;
emptyText?: string;
error?: unknown;
isEmpty?: boolean;
@@ -80,41 +174,79 @@ interface BodyProps {
onRetry?: () => void;
}
-const Body = memo<BodyProps>(({ children, emptyText, error, isEmpty, isLoading, onRetry }) => {
- // Error before empty: a failed scan gets its own state, never a "no skills".
- if (error && isEmpty) {
- return (
- <Flexbox paddingBlock={4} paddingInline={4}>
- <AsyncError error={error} variant={'inline'} onRetry={onRetry} />
- </Flexbox>
- );
- }
- if (isLoading) {
- return (
- <Center paddingBlock={12}>
- <Spin size="middle" />
- </Center>
- );
- }
- if (isEmpty) {
- return (
- <Center paddingBlock={8}>
- <Text className={styles.empty}>{emptyText}</Text>
- </Center>
- );
- }
- return <>{children}</>;
-});
+const CompactBody = memo<Omit<BodyProps, 'compact'>>(
+ ({ children, emptyText, error, isEmpty, isLoading, onRetry }) => {
+ if (error && isEmpty) {
+ return (
+ <Flexbox paddingBlock={4} paddingInline={4}>
+ <AsyncError align={'start'} error={error} variant={'inline'} onRetry={onRetry} />
+ </Flexbox>
+ );
+ }
+ if (isLoading) return <SkeletonList compact rows={3} />;
+ if (isEmpty) {
+ return (
+ <Center paddingBlock={24}>
+ <Empty description={emptyText} icon={SkillsIcon} />
+ </Center>
+ );
+ }
+ return <>{children}</>;
+ },
+);
+
+CompactBody.displayName = 'SkillSectionCompactBody';
+
+const Body = memo<BodyProps>(
+ ({ children, compact, emptyText, error, isEmpty, isLoading, onRetry }) => {
+ if (compact)
+ return (
+ <CompactBody
+ emptyText={emptyText}
+ error={error}
+ isEmpty={isEmpty}
+ isLoading={isLoading}
+ onRetry={onRetry}
+ >
+ {children}
+ </CompactBody>
+ );
+ // Error before empty: a failed scan gets its own state, never a "no skills".
+ if (error && isEmpty) {
+ return (
+ <Flexbox paddingBlock={4} paddingInline={4}>
+ <AsyncError error={error} variant={'inline'} onRetry={onRetry} />
+ </Flexbox>
+ );
+ }
+ if (isLoading) {
+ return (
+ <Center paddingBlock={12}>
+ <Spin size="middle" />
+ </Center>
+ );
+ }
+ if (isEmpty) {
+ return (
+ <Center paddingBlock={8}>
+ <Text className={styles.empty}>{emptyText}</Text>
+ </Center>
+ );
+ }
+ return <>{children}</>;
+ },
+);
Body.displayName = 'SkillSectionBody';
const SkillSection = memo<SkillSectionProps>(
- ({ children, emptyText, error, isEmpty, isLoading, onRetry, sectionHeader }) => {
+ ({ children, compact, emptyText, error, isEmpty, isLoading, onRetry, sectionHeader }) => {
// Hook always runs regardless of whether sectionHeader is provided.
const [expanded, setExpanded] = useState(sectionHeader?.defaultExpanded ?? true);
const body = (
<Body
+ compact={compact}
emptyText={emptyText}
error={error}
isEmpty={isEmpty}
@@ -129,6 +261,40 @@ const SkillSection = memo<SkillSectionProps>(
const { action, collapsible = true, count, title } = sectionHeader;
+ if (compact) {
+ const label = (
+ <>
+ <span className={styles.compactTitle}>{title}</span>
+ {typeof count === 'number' && count > 0 && (
+ <span className={styles.compactCount}>{count}</span>
+ )}
+ </>
+ );
+ return (
+ <Flexbox gap={1}>
+ <div className={styles.compactHeader}>
+ {collapsible ? (
+ <button
+ aria-expanded={expanded}
+ className={`${styles.compactLabel} ${styles.compactLabelButton}`}
+ type={'button'}
+ onClick={() => setExpanded((value) => !value)}
+ >
+ {label}
+ <span data-section-chevron>
+ <Icon icon={ChevronDownIcon} size={12} />
+ </span>
+ </button>
+ ) : (
+ <div className={styles.compactLabel}>{label}</div>
+ )}
+ {action && <div data-section-action>{action}</div>}
+ </div>
+ {(!collapsible || expanded) && body}
+ </Flexbox>
+ );
+ }
+
if (!collapsible) {
return (
<Flexbox gap={4}>
diff --git a/src/features/SkillsList/SkillsList.tsx b/src/features/SkillsList/SkillsList.tsx
index 5c9cea59e0c..4a97ecd7397 100644
--- a/src/features/SkillsList/SkillsList.tsx
+++ b/src/features/SkillsList/SkillsList.tsx
@@ -1,10 +1,13 @@
import { EMPTY_ARRAY } from '@lobechat/const';
-import { createStaticStyles, Flexbox, Icon, Text, Tooltip } from '@lobehub/ui';
+import { createStaticStyles, cx, Flexbox, Icon, Text, Tooltip } from '@lobehub/ui';
import { SkillsIcon } from '@lobehub/ui/icons';
import { ChevronRightIcon, FileIcon, FolderIcon } from 'lucide-react';
import type React from 'react';
import { memo, useCallback, useMemo, useState } from 'react';
+import { useDensityTokens } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
+
export interface SkillListItem {
description?: string;
/**
@@ -19,6 +22,8 @@ export interface SkillListItem {
}
interface SkillsListProps {
+ /** The WorkingSidebar row system. */
+ compact?: boolean;
items: SkillListItem[];
onOpenFile?: (item: SkillListItem, relativePath: string) => void;
onOpenSkill?: (item: SkillListItem) => void;
@@ -32,6 +37,8 @@ interface SkillsListProps {
onSkillDragStart?: (item: SkillListItem, event: React.DragEvent) => void;
}
+const COMPACT_CHEVRON_SLOT = 16;
+
const styles = createStaticStyles(({ css, cssVar }) => ({
chevron: css`
flex-shrink: 0;
@@ -85,6 +92,37 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
flex-shrink: 0;
color: ${cssVar.colorTextTertiary};
`,
+ compactItem: css`
+ height: auto;
+ min-height: ${sidebarRow.controlHeight};
+ padding-inline: ${sidebarRow.paddingInline};
+ `,
+ compactChildItem: css`
+ height: auto;
+ min-height: ${sidebarRow.controlHeight};
+ padding-inline-end: ${sidebarRow.paddingInline};
+ font-size: ${sidebarRow.textFontSize};
+ `,
+ compactIconBox: css`
+ display: flex;
+ flex-shrink: 0;
+ align-items: center;
+ justify-content: center;
+
+ width: ${sidebarRow.iconBox};
+ height: ${sidebarRow.iconBox};
+
+ color: ${cssVar.colorTextTertiary};
+ `,
+ compactChevronSlot: css`
+ display: flex;
+ flex-shrink: 0;
+ align-items: center;
+ justify-content: center;
+
+ width: ${COMPACT_CHEVRON_SLOT}px;
+ height: ${sidebarRow.textLineHeight};
+ `,
treeChevronSlot: css`
display: flex;
flex-shrink: 0;
@@ -139,8 +177,10 @@ const buildSkillTree = (paths: string[]): TreeNode[] => {
const TREE_BASE_INSET = 24;
const TREE_DEPTH_INDENT = 14;
+const COMPACT_TREE_DEPTH_INDENT = 12;
interface TreeRowProps {
+ compact?: boolean;
depth: number;
expanded: Set<string>;
node: TreeNode;
@@ -148,70 +188,97 @@ interface TreeRowProps {
onToggleFolder: (folderPath: string) => void;
}
-const TreeRow = memo<TreeRowProps>(({ depth, expanded, node, onOpenFile, onToggleFolder }) => {
- const isOpen = expanded.has(node.path);
- const paddingInlineStart = TREE_BASE_INSET + depth * TREE_DEPTH_INDENT;
+const TreeRow = memo<TreeRowProps>(
+ ({ compact, depth, expanded, node, onOpenFile, onToggleFolder }) => {
+ const density = useDensityTokens();
+ const isOpen = expanded.has(node.path);
+ const paddingInlineStart = compact
+ ? density.paddingInline +
+ COMPACT_CHEVRON_SLOT +
+ density.gap +
+ depth * COMPACT_TREE_DEPTH_INDENT
+ : TREE_BASE_INSET + depth * TREE_DEPTH_INDENT;
+ const rowClassName = cx(styles.childItem, compact && styles.compactChildItem);
+ const iconSize = compact ? density.iconSize : 12;
+ const rowGap = compact ? density.gap : 6;
+ const labelStyle = {
+ color: 'inherit',
+ flex: 1,
+ fontSize: compact ? density.fontSize : 12,
+ minWidth: 0,
+ };
+ const renderIcon = (icon: typeof FileIcon) =>
+ compact ? (
+ <span className={styles.compactIconBox}>
+ <Icon icon={icon} size={iconSize} />
+ </span>
+ ) : (
+ <Icon className={styles.childItemIcon} icon={icon} size={iconSize} />
+ );
+
+ if (node.isDirectory) {
+ return (
+ <>
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={rowClassName}
+ gap={rowGap}
+ style={{ paddingInlineStart }}
+ onClick={() => onToggleFolder(node.path)}
+ >
+ <span className={compact ? styles.compactChevronSlot : styles.treeChevronSlot}>
+ <Icon
+ className={`${styles.chevron} ${isOpen ? styles.chevronExpanded : ''}`}
+ icon={ChevronRightIcon}
+ size={12}
+ />
+ </span>
+ {renderIcon(FolderIcon)}
+ <Text ellipsis style={labelStyle}>
+ {node.name}
+ </Text>
+ </Flexbox>
+ {isOpen &&
+ node.children.map((child) => (
+ <TreeRow
+ compact={compact}
+ depth={depth + 1}
+ expanded={expanded}
+ key={child.path}
+ node={child}
+ onOpenFile={onOpenFile}
+ onToggleFolder={onToggleFolder}
+ />
+ ))}
+ </>
+ );
+ }
- if (node.isDirectory) {
return (
- <>
- <Flexbox
- horizontal
- align={'center'}
- className={styles.childItem}
- gap={6}
- style={{ paddingInlineStart }}
- onClick={() => onToggleFolder(node.path)}
- >
- <span className={styles.treeChevronSlot}>
- <Icon
- className={`${styles.chevron} ${isOpen ? styles.chevronExpanded : ''}`}
- icon={ChevronRightIcon}
- size={12}
- />
- </span>
- <Icon className={styles.childItemIcon} icon={FolderIcon} size={12} />
- <Text ellipsis style={{ color: 'inherit', flex: 1, fontSize: 12, minWidth: 0 }}>
- {node.name}
- </Text>
- </Flexbox>
- {isOpen &&
- node.children.map((child) => (
- <TreeRow
- depth={depth + 1}
- expanded={expanded}
- key={child.path}
- node={child}
- onOpenFile={onOpenFile}
- onToggleFolder={onToggleFolder}
- />
- ))}
- </>
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={rowClassName}
+ gap={rowGap}
+ style={{ paddingInlineStart }}
+ title={node.path}
+ onClick={() => onOpenFile(node.path)}
+ >
+ <span className={compact ? styles.compactChevronSlot : styles.treeChevronSlot} />
+ {renderIcon(FileIcon)}
+ <Text ellipsis style={labelStyle}>
+ {node.name}
+ </Text>
+ </Flexbox>
);
- }
-
- return (
- <Flexbox
- horizontal
- align={'center'}
- className={styles.childItem}
- gap={6}
- style={{ paddingInlineStart }}
- title={node.path}
- onClick={() => onOpenFile(node.path)}
- >
- <span className={styles.treeChevronSlot} />
- <Icon className={styles.childItemIcon} icon={FileIcon} size={12} />
- <Text ellipsis style={{ color: 'inherit', flex: 1, fontSize: 12, minWidth: 0 }}>
- {node.name}
- </Text>
- </Flexbox>
- );
-});
+ },
+);
TreeRow.displayName = 'SkillsListTreeRow';
interface SkillRowProps {
+ compact?: boolean;
expanded: boolean;
item: SkillListItem;
onOpenFile?: (item: SkillListItem, relativePath: string) => void;
@@ -227,6 +294,7 @@ interface SkillRowProps {
// referentially equal and the memo actually bails out.
const SkillRow = memo<SkillRowProps>(
({
+ compact,
expanded,
item,
onOpenFile,
@@ -236,6 +304,12 @@ const SkillRow = memo<SkillRowProps>(
onToggle,
reserveChevronSlot,
}) => {
+ const density = useDensityTokens();
+ const slotStyle = {
+ flexShrink: 0,
+ height: compact ? density.lineHeight : 20,
+ width: compact ? COMPACT_CHEVRON_SLOT : 20,
+ };
const activateSkill = onSelectSkill ?? onOpenSkill;
const files = onSelectSkill ? EMPTY_ARRAY : (item.files ?? EMPTY_ARRAY);
const hasFiles = files.length > 0;
@@ -266,9 +340,9 @@ const SkillRow = memo<SkillRowProps>(
<Flexbox
horizontal
align={'center'}
- className={styles.item}
+ className={cx(styles.item, compact && styles.compactItem)}
draggable={!!onSkillDragStart}
- gap={6}
+ gap={compact ? density.gap : 6}
role={activateSkill ? 'button' : undefined}
tabIndex={activateSkill ? 0 : undefined}
onClick={activateSkill ? () => activateSkill(item) : undefined}
@@ -285,7 +359,7 @@ const SkillRow = memo<SkillRowProps>(
<Flexbox
align={'center'}
justify={'center'}
- style={{ cursor: 'pointer', flexShrink: 0, height: 20, width: 20 }}
+ style={{ ...slotStyle, cursor: 'pointer' }}
onClick={(e) => {
e.stopPropagation();
onToggle(item.id);
@@ -294,13 +368,19 @@ const SkillRow = memo<SkillRowProps>(
<Icon
className={`${styles.chevron} ${expanded ? styles.chevronExpanded : ''}`}
icon={ChevronRightIcon}
- size={14}
+ size={compact ? 12 : 14}
/>
</Flexbox>
) : !onSelectSkill && reserveChevronSlot ? (
- <span style={{ flexShrink: 0, height: 20, width: 20 }} />
+ <span style={slotStyle} />
) : null}
- <Icon className={styles.itemIcon} icon={SkillsIcon} size={14} />
+ {compact ? (
+ <span className={styles.compactIconBox}>
+ <Icon icon={SkillsIcon} size={density.iconSize} />
+ </span>
+ ) : (
+ <Icon className={styles.itemIcon} icon={SkillsIcon} size={14} />
+ )}
{item.description ? (
<Tooltip
placement={'left'}
@@ -322,6 +402,7 @@ const SkillRow = memo<SkillRowProps>(
onOpenFile &&
tree.map((node) => (
<TreeRow
+ compact={compact}
depth={0}
expanded={expandedFolders}
key={node.path}
@@ -338,7 +419,7 @@ const SkillRow = memo<SkillRowProps>(
SkillRow.displayName = 'SkillsListSkillRow';
const SkillsList = memo<SkillsListProps>(
- ({ items, onOpenFile, onOpenSkill, onSelectSkill, onSkillDragStart }) => {
+ ({ compact, items, onOpenFile, onOpenSkill, onSelectSkill, onSkillDragStart }) => {
const [expanded, setExpanded] = useState<Set<string>>(() => new Set());
const toggle = useCallback((id: string) => {
@@ -356,9 +437,10 @@ const SkillsList = memo<SkillsListProps>(
);
return (
- <Flexbox gap={2}>
+ <Flexbox gap={compact ? 1 : 2}>
{items.map((item) => (
<SkillRow
+ compact={compact}
expanded={expanded.has(item.id)}
item={item}
key={item.id}
diff --git a/src/features/TopicComment/TopicCommentButton.tsx b/src/features/TopicComment/TopicCommentButton.tsx
index c11253006c9..09a32881252 100644
--- a/src/features/TopicComment/TopicCommentButton.tsx
+++ b/src/features/TopicComment/TopicCommentButton.tsx
@@ -4,13 +4,15 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE, MOBILE_HEADER_ICON_SIZE } from '@/const/layoutTokens';
+import { MOBILE_HEADER_ICON_SIZE } from '@/const/layoutTokens';
import { useAgentContext } from '@/features/Conversation/useAgentContext';
import { useChatStore } from '@/store/chat';
+import { useHeaderActionSize } from '@/styles/density';
import { usePrefetchTopicCommentsOnTopicLoad, useTopicCommentSummary } from './hooks';
const TopicCommentButton = memo<{ mobile?: boolean }>(({ mobile }) => {
+ const headerActionSize = useHeaderActionSize(true);
const { t } = useTranslation('chat');
const workspaceId = useActiveWorkspaceId();
const { topicId } = useAgentContext();
@@ -24,7 +26,7 @@ const TopicCommentButton = memo<{ mobile?: boolean }>(({ mobile }) => {
<Badge count={data?.total} offset={[-3, 3]} overflowCount={99} size={'small'}>
<ActionIcon
icon={MessageCircle}
- size={mobile ? MOBILE_HEADER_ICON_SIZE : DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={mobile ? MOBILE_HEADER_ICON_SIZE : headerActionSize}
title={t('topicComment.title')}
tooltipProps={{ placement: 'bottom' }}
onClick={() => openTopicComments(topicId)}
diff --git a/src/features/WideScreenContainer/WideScreenButton.tsx b/src/features/WideScreenContainer/WideScreenButton.tsx
index f4064a8724c..a729f30ab9d 100644
--- a/src/features/WideScreenContainer/WideScreenButton.tsx
+++ b/src/features/WideScreenContainer/WideScreenButton.tsx
@@ -5,11 +5,12 @@ import { PanelLeftRightDashedIcon, SquareChartGanttIcon } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
+import { useHeaderActionSize } from '@/styles/density';
const WideScreenButton = memo(() => {
+ const headerActionSize = useHeaderActionSize(true);
const { t } = useTranslation('chat');
const [wideScreen, toggleWideScreen] = useGlobalStore((s) => [
@@ -20,7 +21,7 @@ const WideScreenButton = memo(() => {
return (
<ActionIcon
icon={wideScreen ? SquareChartGanttIcon : PanelLeftRightDashedIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSize}
title={t(wideScreen ? 'toggleWideScreen.off' : 'toggleWideScreen.on')}
tooltipProps={{
placement: 'bottom',
diff --git a/src/features/Work/WorkSummaryCard.tsx b/src/features/Work/WorkSummaryCard.tsx
index 5fc871f66f5..ae51d2a1e11 100644
--- a/src/features/Work/WorkSummaryCard.tsx
+++ b/src/features/Work/WorkSummaryCard.tsx
@@ -8,6 +8,8 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { useChatStore } from '@/store/chat';
+import { useDensityTokens } from '@/styles/density';
+import { sidebarRow } from '@/styles/density.stylex';
import { getWorkVersionTotalTokens } from '@/utils/workCumulativeUsage';
import { formatWorkVersionCost } from '@/utils/workVersionCost';
@@ -156,6 +158,39 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
font-size: 15px;
font-weight: 500;
`,
+ row: css`
+ overflow: hidden;
+
+ width: 100%;
+ padding-block: 5px;
+ padding-inline: ${sidebarRow.paddingInline};
+ border-radius: ${sidebarRow.radius};
+ `,
+ rowClickable: css`
+ cursor: pointer;
+
+ &:hover {
+ background: ${cssVar.colorFillTertiary};
+ }
+ `,
+ rowIcon: css`
+ flex-shrink: 0;
+ width: ${sidebarRow.iconBox};
+ height: ${sidebarRow.textLineHeight};
+ color: ${cssVar.colorTextTertiary};
+ `,
+ rowTitle: css`
+ min-width: 0;
+ font-size: ${sidebarRow.textFontSize};
+ line-height: ${sidebarRow.textLineHeight};
+ color: ${cssVar.colorText};
+ `,
+ rowMeta: css`
+ min-width: 0;
+ font-size: ${sidebarRow.metaFontSize};
+ line-height: 18px;
+ color: ${cssVar.colorTextTertiary};
+ `,
}));
interface WorkMetaLineProps {
@@ -247,15 +282,17 @@ interface WorkSummaryCardProps {
* `card` (default) renders the elevated 36×36 icon-box layout used across the
* chat portal and the works gallery. `inline` renders a flat row (17px icon,
* 6px hover fill) for the WorkingSidebar Overview, so a shared card doesn't
- * dictate the flat sidebar's visual vocabulary.
+ * dictate the flat sidebar's visual vocabulary. `row` is the WorkingSidebar
+ * two-line row: the row-text title, then the meta line and usage.
*/
- variant?: 'card' | 'inline';
+ variant?: 'card' | 'inline' | 'row';
}
const WorkSummaryCard = memo<WorkSummaryCardProps>(
({ className, item, onOpen, variant = 'card' }) => {
const { t } = useTranslation('chat');
const { t: tTopic } = useTranslation('topic');
+ const density = useDensityTokens();
const openCanvas = useChatStore((s) => s.openCanvas);
const openDocument = useChatStore((s) => s.openDocument);
const openFilePreview = useChatStore((s) => s.openFilePreview);
@@ -343,6 +380,42 @@ const WorkSummaryCard = memo<WorkSummaryCardProps>(
);
}
+ if (variant === 'row') {
+ return (
+ <Flexbox
+ horizontal
+ align={'flex-start'}
+ className={cx(styles.row, clickable && styles.rowClickable, className)}
+ gap={density.gap}
+ onClick={clickable ? handleOpen : undefined}
+ >
+ <Center className={styles.rowIcon} title={stateLabel}>
+ <Icon size={density.iconSize} />
+ </Center>
+ <Flexbox flex={1} style={{ minWidth: 0 }}>
+ <Text ellipsis className={styles.rowTitle} title={title}>
+ {title}
+ </Text>
+ <Flexbox horizontal align={'center'} className={styles.rowMeta} gap={4}>
+ <WorkMetaLine
+ branch={branch}
+ description={description}
+ identifier={metaIdentifier}
+ identifierIcon={identifierIcon}
+ variant={'card'}
+ />
+ {usage && (
+ <Center horizontal className={styles.cost} gap={2} title={usageTitle}>
+ <LobeIcon icon={usage.icon} />
+ {usage.value}
+ </Center>
+ )}
+ </Flexbox>
+ </Flexbox>
+ </Flexbox>
+ );
+ }
+
if (variant === 'inline') {
return (
<Flexbox
diff --git a/src/features/WorkspaceSetting/SideBar/Body.tsx b/src/features/WorkspaceSetting/SideBar/Body.tsx
index 6c329d20e50..8164ff28164 100644
--- a/src/features/WorkspaceSetting/SideBar/Body.tsx
+++ b/src/features/WorkspaceSetting/SideBar/Body.tsx
@@ -6,6 +6,7 @@ import { Link } from 'react-router';
import { useActiveWorkspaceSlug } from '@/business/client/hooks/useActiveWorkspaceSlug';
import NavItem from '@/features/NavPanel/components/NavItem';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import { useExpandedSettingsGroups } from '@/features/Settings/hooks/useExpandedSettingsGroups';
import { SearchSection } from '@/features/SettingsSearch';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
@@ -20,6 +21,7 @@ import {
} from '../hooks/useSettingsSearchScope';
const Body = memo(() => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const navigate = useWorkspaceAwareNavigate();
const location = useActiveLocation();
const slug = useActiveWorkspaceSlug();
@@ -49,15 +51,11 @@ const Body = memo(() => {
<Accordion
gap={8}
indicatorPlacement="inline"
- styles={{ trigger: { paddingBlock: 4, paddingInline: '8px 4px' } }}
+ styles={{ trigger: sectionTriggerStyle }}
value={expandedGroups}
items={groups.map((group) => ({
key: group.key,
- title: (
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {group.title}
- </Text>
- ),
+ title: <SectionTitle>{group.title}</SectionTitle>,
children: (
<Flexbox gap={1} paddingBlock={1}>
{group.items.map((item) => {
diff --git a/src/layout/GlobalProvider/AppTheme.tsx b/src/layout/GlobalProvider/AppTheme.tsx
index 540b9de3ae1..ea36360cc34 100644
--- a/src/layout/GlobalProvider/AppTheme.tsx
+++ b/src/layout/GlobalProvider/AppTheme.tsx
@@ -22,6 +22,7 @@ import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
import { useUserStore } from '@/store/user';
import { preferenceSelectors, userGeneralSettingsSelectors } from '@/store/user/selectors';
+import { compactDensityTheme } from '@/styles/densityTheme';
import { sx } from '@/styles/sx';
import { setCookie } from '@/utils/client/cookie';
import { resolveLang } from '@/utils/client/switchLang';
@@ -60,10 +61,11 @@ const AppTheme = memo<AppThemeProps>(
customFontFamily,
}) => {
const language = useGlobalStore(systemStatusSelectors.language);
- const [primaryColor, neutralColor, fontAntialiasing] = useUserStore((s) => [
+ const [primaryColor, neutralColor, fontAntialiasing, interfaceDensity] = useUserStore((s) => [
userGeneralSettingsSelectors.primaryColor(s),
userGeneralSettingsSelectors.neutralColor(s),
userGeneralSettingsSelectors.fontAntialiasing(s),
+ userGeneralSettingsSelectors.interfaceDensity(s),
]);
const [userFontFamily, userFontFamilyCode] = useUserStore((s) => [
preferenceSelectors.fontFamily(s),
@@ -128,6 +130,14 @@ const AppTheme = memo<AppThemeProps>(
else document.documentElement.dataset.fontAntialiasing = 'off';
}, [fontAntialiasing]);
+ useEffect(() => {
+ document.documentElement.dataset.density = interfaceDensity;
+ if (interfaceDensity !== 'compact') return;
+ const classes = stylex.props(compactDensityTheme).className?.split(' ') ?? [];
+ document.documentElement.classList.add(...classes);
+ return () => document.documentElement.classList.remove(...classes);
+ }, [interfaceDensity]);
+
return (
<ConfigProvider
locale={uiLocale}
diff --git a/src/routes/(main)/(create)/features/GenerationLayout/Body/index.tsx b/src/routes/(main)/(create)/features/GenerationLayout/Body/index.tsx
index e7db869493c..b80783b0c36 100644
--- a/src/routes/(main)/(create)/features/GenerationLayout/Body/index.tsx
+++ b/src/routes/(main)/(create)/features/GenerationLayout/Body/index.tsx
@@ -6,6 +6,7 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
import { useUserStore } from '@/store/user';
@@ -21,6 +22,7 @@ enum GroupKey {
}
const Body = memo<GenerationLayoutCommonProps>((props) => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { namespace, useStore, viewModeStatusKey, generationTopicsSelector } = props;
const { t } = useTranslation(namespace);
const isLogin = useUserStore(authSelectors.isLogin);
@@ -67,16 +69,16 @@ const Body = memo<GenerationLayoutCommonProps>((props) => {
defaultValue={[GroupKey.PrivateTopics, GroupKey.WorkspaceTopics]}
gap={2}
indicatorPlacement="inline"
- styles={{ trigger: { paddingBlock: 4, paddingInline: '8px 4px' } }}
+ styles={{ trigger: sectionTriggerStyle }}
items={[
{
action: viewModeTabs,
key: GroupKey.PrivateTopics,
title: (
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
+ <SectionTitle>
{t('topic.privateTitle')}
{privateCount > 0 && ` ${privateCount}`}
- </Text>
+ </SectionTitle>
),
children: (
<List
@@ -90,10 +92,10 @@ const Body = memo<GenerationLayoutCommonProps>((props) => {
{
key: GroupKey.WorkspaceTopics,
title: (
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
+ <SectionTitle>
{t('topic.workspaceTitle')}
{workspaceCount > 0 && ` ${workspaceCount}`}
- </Text>
+ </SectionTitle>
),
children: (
<List
@@ -116,16 +118,16 @@ const Body = memo<GenerationLayoutCommonProps>((props) => {
defaultValue={[GroupKey.Topics]}
gap={2}
indicatorPlacement="inline"
- styles={{ trigger: { paddingBlock: 4, paddingInline: '8px 4px' } }}
+ styles={{ trigger: sectionTriggerStyle }}
items={[
{
action: viewModeTabs,
key: GroupKey.Topics,
title: (
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
+ <SectionTitle>
{t('topic.title')}
{count > 0 && ` ${count}`}
- </Text>
+ </SectionTitle>
),
children: (
<List
diff --git a/src/routes/(main)/agent/features/Conversation/Header/ShareButton/index.tsx b/src/routes/(main)/agent/features/Conversation/Header/ShareButton/index.tsx
index edf5421253e..b10a56ecce6 100644
--- a/src/routes/(main)/agent/features/Conversation/Header/ShareButton/index.tsx
+++ b/src/routes/(main)/agent/features/Conversation/Header/ShareButton/index.tsx
@@ -7,13 +7,14 @@ import { useTranslation } from 'react-i18next';
import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';
import { withSuspense } from '@/components/withSuspense';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE, MOBILE_HEADER_ICON_SIZE } from '@/const/layoutTokens';
+import { MOBILE_HEADER_ICON_SIZE } from '@/const/layoutTokens';
import { useAgentContext } from '@/features/Conversation/useAgentContext';
import { useShareModal } from '@/features/ShareModal';
import { LazySharePopover as SharePopover } from '@/features/SharePopover/lazy';
import { usePermission } from '@/hooks/usePermission';
import { useServerConfigStore } from '@/store/serverConfig';
import { serverConfigSelectors } from '@/store/serverConfig/selectors';
+import { useHeaderActionSize } from '@/styles/density';
interface ShareButtonProps {
mobile?: boolean;
@@ -28,6 +29,7 @@ const ShareButton = memo<ShareButtonProps>(({ mobile, setOpen, open }) => {
const enableTopicLinkShare = useServerConfigStore(serverConfigSelectors.enableBusinessFeatures);
const { allowed: canShare, reason } = usePermission('edit_own_content');
const workspaceId = useActiveWorkspaceId();
+ const headerActionSmallSize = useHeaderActionSize(true);
// Hide share button when no topic exists (no messages sent yet)
if (!topicId) return null;
@@ -41,7 +43,7 @@ const ShareButton = memo<ShareButtonProps>(({ mobile, setOpen, open }) => {
<ActionIcon
disabled={!canShare}
icon={Share2}
- size={mobile ? MOBILE_HEADER_ICON_SIZE : DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={mobile ? MOBILE_HEADER_ICON_SIZE : headerActionSmallSize}
title={canShare ? t('share') : reason}
tooltipProps={{
placement: 'bottom',
diff --git a/src/routes/(main)/agent/features/Conversation/Header/TerminalPanelToggle/index.test.tsx b/src/routes/(main)/agent/features/Conversation/Header/TerminalPanelToggle/index.test.tsx
index 16b6a444121..0da32d386d6 100644
--- a/src/routes/(main)/agent/features/Conversation/Header/TerminalPanelToggle/index.test.tsx
+++ b/src/routes/(main)/agent/features/Conversation/Header/TerminalPanelToggle/index.test.tsx
@@ -58,6 +58,9 @@ vi.mock('@/store/user/selectors', () => ({
settingsSelectors: {
getHotkeyById: () => () => 'ctrl+backquote',
},
+ userGeneralSettingsSelectors: {
+ interfaceDensity: () => 'loose',
+ },
}));
describe('TerminalPanelToggle', () => {
diff --git a/src/routes/(main)/agent/features/Conversation/Header/TerminalPanelToggle/index.tsx b/src/routes/(main)/agent/features/Conversation/Header/TerminalPanelToggle/index.tsx
index c350ed1f745..4b814eadcc1 100644
--- a/src/routes/(main)/agent/features/Conversation/Header/TerminalPanelToggle/index.tsx
+++ b/src/routes/(main)/agent/features/Conversation/Header/TerminalPanelToggle/index.tsx
@@ -6,12 +6,12 @@ import { SquareTerminalIcon } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { useTerminalEntry } from '@/features/ChatTerminal/useTerminalEntry';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/selectors';
+import { useHeaderActionSize } from '@/styles/density';
const TerminalPanelToggle = memo(() => {
const { t } = useTranslation('chat');
@@ -20,6 +20,7 @@ const TerminalPanelToggle = memo(() => {
s.toggleTerminalPanel,
]);
const hotkey = useUserStore(settingsSelectors.getHotkeyById(HotkeyEnum.ToggleTerminalPanel));
+ const headerActionSmallSize = useHeaderActionSize(true);
// Shown for coding agents only, and only where a shell can run; other agents
// reach the terminal from the Overview resources (see `useTerminalEntry`).
@@ -31,7 +32,7 @@ const TerminalPanelToggle = memo(() => {
<ActionIcon
active={showTerminalPanel}
icon={SquareTerminalIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={t('terminalPanel.title')}
tooltipProps={{ hotkey, placement: 'bottom' }}
onClick={() => toggleTerminalPanel()}
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 dca7a29f748..8f6e2396be2 100644
--- a/src/routes/(main)/agent/features/Conversation/Header/WorkingPanelToggle/index.tsx
+++ b/src/routes/(main)/agent/features/Conversation/Header/WorkingPanelToggle/index.tsx
@@ -1,6 +1,5 @@
'use client';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@lobechat/const';
import { ActionIcon } from '@lobehub/ui';
import { LayoutDashboardIcon, PanelRightOpenIcon } from 'lucide-react';
import { memo } from 'react';
@@ -9,10 +8,12 @@ import { useLocation } from 'react-router';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
+import { useHeaderActionSize } from '@/styles/density';
const WorkingPanelToggle = memo(() => {
const { t } = useTranslation('chat');
const { pathname } = useLocation();
+ const headerActionSmallSize = useHeaderActionSize(true);
const [
showRightPanel,
showWorkingOverview,
@@ -43,7 +44,7 @@ const WorkingPanelToggle = memo(() => {
active={showWorkingOverview}
aria-label={t('workingPanel.overview.title')}
icon={LayoutDashboardIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={t('workingPanel.overview.title')}
onClick={() => {
if (showWorkingOverview) {
@@ -58,7 +59,7 @@ const WorkingPanelToggle = memo(() => {
<ActionIcon
aria-label={t('workingPanel.title')}
icon={PanelRightOpenIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={t('workingPanel.title')}
onClick={() => openWorkingSidebar()}
/>
diff --git a/src/routes/(main)/agent/features/Conversation/Header/index.tsx b/src/routes/(main)/agent/features/Conversation/Header/index.tsx
index 0f44e9b0eff..644e577bcff 100644
--- a/src/routes/(main)/agent/features/Conversation/Header/index.tsx
+++ b/src/routes/(main)/agent/features/Conversation/Header/index.tsx
@@ -13,6 +13,7 @@ import { useEffectiveWorkingDirectory } from '@/hooks/useEffectiveWorkingDirecto
import { useAgentStore } from '@/store/agent';
import { agentSelectors, chatConfigByIdSelectors } from '@/store/agent/selectors';
import { useElectronStore } from '@/store/electron';
+import { sidebarRow } from '@/styles/density.stylex';
import HeaderActions from './HeaderActions';
import ShareButton from './ShareButton';
@@ -110,7 +111,7 @@ const headerStyles = createStaticStyles(({ css }) => ({
align-items: center;
justify-content: center;
- height: 44px;
+ height: ${sidebarRow.headerHeight};
${FLOATING_HEADER_QUERY} {
display: flex;
diff --git a/src/routes/(main)/agent/profile/features/Header/index.tsx b/src/routes/(main)/agent/profile/features/Header/index.tsx
index 23bea64d8c6..bbcabab069b 100644
--- a/src/routes/(main)/agent/profile/features/Header/index.tsx
+++ b/src/routes/(main)/agent/profile/features/Header/index.tsx
@@ -32,7 +32,6 @@ import { useAuthorInfo } from '@/business/client/hooks/useAuthorInfo';
import { useBusinessAgentImportMenuItem } from '@/business/client/hooks/useBusinessAgentImportMenuItem';
import { useHasActiveWorkspace } from '@/business/client/hooks/useHasActiveWorkspace';
import { useAgentShareSupported } from '@/business/client/useAgentShareSupported';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import AgentBreadcrumb from '@/features/AgentBreadcrumb';
import { useAgentMarketSubmission } from '@/features/AgentMarketSubmission/useAgentMarketSubmission';
import AgentProfileTabs, { AGENT_PROFILE_TABS_CENTER_STYLE } from '@/features/AgentProfileTabs';
@@ -50,6 +49,7 @@ import { agentSelectors, builtinAgentSelectors } from '@/store/agent/selectors';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
import { useHomeStore } from '@/store/home';
+import { useHeaderActionSize } from '@/styles/density';
import { getDeleteErrorMessageKey } from '@/utils/forbiddenError';
import { sanitizeFileName } from '@/utils/sanitizeFileName';
@@ -118,6 +118,7 @@ interface HeaderProps {
}
const Header = memo<HeaderProps>(({ active = 'profile' }) => {
+ const headerActionSmallSize = useHeaderActionSize(true);
const { i18n, t } = useTranslation(['setting', 'chat', 'file', 'common', 'agent']);
const dateLocale = i18n?.resolvedLanguage || i18n?.language;
const navigate = useWorkspaceAwareNavigate();
@@ -441,14 +442,14 @@ const Header = memo<HeaderProps>(({ active = 'profile' }) => {
{canShareAgent && (
<ActionIcon
icon={Share2Icon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={t('share.entry', { ns: 'agent' })}
tooltipProps={{ placement: 'bottom' }}
onClick={handleOpenShare}
/>
)}
<DropdownMenu items={menuItems}>
- <ActionIcon icon={MoreHorizontal} size={DESKTOP_HEADER_ICON_SMALL_SIZE} />
+ <ActionIcon icon={MoreHorizontal} size={headerActionSmallSize} />
</DropdownMenu>
{!isHeterogeneous && isStatusInit && !lockedByOther && !lockPending && (
<ToggleRightPanelButton
diff --git a/src/routes/(main)/eval/_layout/Sidebar/Body/BenchmarkList.tsx b/src/routes/(main)/eval/_layout/Sidebar/Body/BenchmarkList.tsx
index 220d91ae267..123542df22b 100644
--- a/src/routes/(main)/eval/_layout/Sidebar/Body/BenchmarkList.tsx
+++ b/src/routes/(main)/eval/_layout/Sidebar/Body/BenchmarkList.tsx
@@ -25,6 +25,7 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import NavItem from '@/features/NavPanel/components/NavItem';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
@@ -56,6 +57,7 @@ interface BenchmarkListProps {
}
const BenchmarkList = memo<BenchmarkListProps>(({ activeKey, itemKey }) => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { t } = useTranslation('eval');
const navigate = useWorkspaceAwareNavigate();
const benchmarkList = useEvalStore(benchmarkSelectors.agentBenchmarkList);
@@ -63,12 +65,10 @@ const BenchmarkList = memo<BenchmarkListProps>(({ activeKey, itemKey }) => {
return (
<AccordionItem value={itemKey}>
- <AccordionHeader style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionHeader style={sectionTriggerStyle}>
<AccordionTrigger>
<Flexbox horizontal align="center" gap={4}>
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {t('sidebar.benchmarks')}
- </Text>
+ <SectionTitle>{t('sidebar.benchmarks')}</SectionTitle>
{benchmarkList.length > 0 && (
<Text fontSize={12} type="secondary">
{benchmarkList.length}
diff --git a/src/routes/(main)/eval/_layout/Sidebar/Body/DatasetList.tsx b/src/routes/(main)/eval/_layout/Sidebar/Body/DatasetList.tsx
index b0bfd48b7a8..96d6666be09 100644
--- a/src/routes/(main)/eval/_layout/Sidebar/Body/DatasetList.tsx
+++ b/src/routes/(main)/eval/_layout/Sidebar/Body/DatasetList.tsx
@@ -13,6 +13,7 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import NavItem from '@/features/NavPanel/components/NavItem';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
@@ -30,6 +31,7 @@ interface DatasetListProps {
* this a captured dataset could be created but never found.
*/
const DatasetList = memo<DatasetListProps>(({ activeKey, itemKey }) => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { t } = useTranslation('eval');
const navigate = useWorkspaceAwareNavigate();
const useFetchAllDatasets = useEvalStore((s) => s.useFetchAllDatasets);
@@ -40,12 +42,10 @@ const DatasetList = memo<DatasetListProps>(({ activeKey, itemKey }) => {
return (
<AccordionItem value={itemKey}>
- <AccordionHeader style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionHeader style={sectionTriggerStyle}>
<AccordionTrigger>
<Flexbox horizontal align="center" gap={4}>
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {t('sidebar.datasets')}
- </Text>
+ <SectionTitle>{t('sidebar.datasets')}</SectionTitle>
{datasets.length > 0 && (
<Text fontSize={12} type="secondary">
{datasets.length}
diff --git a/src/routes/(main)/eval/_layout/Sidebar/Body/ExperimentList.tsx b/src/routes/(main)/eval/_layout/Sidebar/Body/ExperimentList.tsx
index fc424954092..3b8d1dd92d1 100644
--- a/src/routes/(main)/eval/_layout/Sidebar/Body/ExperimentList.tsx
+++ b/src/routes/(main)/eval/_layout/Sidebar/Body/ExperimentList.tsx
@@ -14,6 +14,7 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import NavItem from '@/features/NavPanel/components/NavItem';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
@@ -26,6 +27,7 @@ interface ExperimentListProps {
}
const ExperimentList = memo<ExperimentListProps>(({ activeKey, itemKey }) => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { t } = useTranslation('eval');
const { t: tCommon } = useTranslation('common');
const navigate = useWorkspaceAwareNavigate();
@@ -82,12 +84,10 @@ const ExperimentList = memo<ExperimentListProps>(({ activeKey, itemKey }) => {
return (
<AccordionItem value={itemKey}>
- <AccordionHeader style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionHeader style={sectionTriggerStyle}>
<AccordionTrigger>
<Flexbox horizontal align="center" gap={4}>
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {t('sidebar.experiments')}
- </Text>
+ <SectionTitle>{t('sidebar.experiments')}</SectionTitle>
{experimentList.length > 0 && (
<Text fontSize={12} type="secondary">
{experimentList.length}
diff --git a/src/routes/(main)/eval/bench/[benchmarkId]/_layout/Sidebar/Body/DatasetList.tsx b/src/routes/(main)/eval/bench/[benchmarkId]/_layout/Sidebar/Body/DatasetList.tsx
index 83180c57eae..c78473fc157 100644
--- a/src/routes/(main)/eval/bench/[benchmarkId]/_layout/Sidebar/Body/DatasetList.tsx
+++ b/src/routes/(main)/eval/bench/[benchmarkId]/_layout/Sidebar/Body/DatasetList.tsx
@@ -15,6 +15,7 @@ import { useTranslation } from 'react-i18next';
import { benchmarkDatasetPath } from '@/features/LobeBench/experimentNavigation';
import { useIsLobeBenchBenchmark } from '@/features/LobeBench/useIsLobeBenchBenchmark';
import NavItem from '@/features/NavPanel/components/NavItem';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
@@ -27,6 +28,7 @@ interface DatasetListProps {
}
const DatasetList = memo<DatasetListProps>(({ activeKey, benchmarkId, itemKey }) => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { t } = useTranslation('eval');
const navigate = useWorkspaceAwareNavigate();
const datasetList = useEvalStore(datasetSelectors.datasetList(benchmarkId));
@@ -35,12 +37,10 @@ const DatasetList = memo<DatasetListProps>(({ activeKey, benchmarkId, itemKey })
return (
<AccordionItem value={itemKey}>
- <AccordionHeader style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionHeader style={sectionTriggerStyle}>
<AccordionTrigger>
<Flexbox horizontal align="center" gap={4}>
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {t('sidebar.datasets')}
- </Text>
+ <SectionTitle>{t('sidebar.datasets')}</SectionTitle>
{datasetList.length > 0 && (
<Text fontSize={12} type="secondary">
{datasetList.length}
diff --git a/src/routes/(main)/eval/bench/[benchmarkId]/_layout/Sidebar/Body/RunList.tsx b/src/routes/(main)/eval/bench/[benchmarkId]/_layout/Sidebar/Body/RunList.tsx
index 56dd4b3fb64..931d17847a6 100644
--- a/src/routes/(main)/eval/bench/[benchmarkId]/_layout/Sidebar/Body/RunList.tsx
+++ b/src/routes/(main)/eval/bench/[benchmarkId]/_layout/Sidebar/Body/RunList.tsx
@@ -13,6 +13,7 @@ import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import NavItem from '@/features/NavPanel/components/NavItem';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
@@ -48,6 +49,7 @@ interface RunListProps {
}
const RunList = memo<RunListProps>(({ activeKey, benchmarkId, itemKey }) => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { t } = useTranslation('eval');
const navigate = useWorkspaceAwareNavigate();
const runList = useEvalStore(runSelectors.runList(benchmarkId));
@@ -63,12 +65,10 @@ const RunList = memo<RunListProps>(({ activeKey, benchmarkId, itemKey }) => {
return (
<AccordionItem value={itemKey}>
- <AccordionHeader style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionHeader style={sectionTriggerStyle}>
<AccordionTrigger>
<Flexbox horizontal align="center" gap={4}>
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {t('sidebar.runs')}
- </Text>
+ <SectionTitle>{t('sidebar.runs')}</SectionTitle>
{runList.length > 0 && (
<Text fontSize={12} type="secondary">
{runList.length}
diff --git a/src/routes/(main)/group/_layout/Sidebar/Header/Agent/index.tsx b/src/routes/(main)/group/_layout/Sidebar/Header/Agent/index.tsx
index 3c67b91ff41..c98c76d2cab 100644
--- a/src/routes/(main)/group/_layout/Sidebar/Header/Agent/index.tsx
+++ b/src/routes/(main)/group/_layout/Sidebar/Header/Agent/index.tsx
@@ -7,6 +7,7 @@ import { type PropsWithChildren } from 'react';
import { useTranslation } from 'react-i18next';
import { SkeletonItem } from '@/features/NavPanel/components/SkeletonList';
+import { useNavItemMetrics } from '@/features/NavPanel/density';
import { useActiveRouteParams } from '@/hooks/useActiveRouteParams';
import SupervisorAvatar from '@/routes/(main)/group/features/GroupAvatar';
import { useAgentGroupStore } from '@/store/agentGroup';
@@ -16,6 +17,8 @@ import SwitchPanel from './SwitchPanel';
const Agent = memo<PropsWithChildren>(() => {
const { t } = useTranslation(['chat', 'common']);
+ const { headerAvatarSize, headerChevronSize, headerLabelFontSize, headerLabelWeight } =
+ useNavItemMetrics();
const { gid } = useActiveRouteParams<{ gid: string }>();
const [isGroupsInit, groupMeta] = useAgentGroupStore((s) => [
@@ -25,7 +28,7 @@ const Agent = memo<PropsWithChildren>(() => {
const displayTitle = groupMeta?.title || t('untitledGroup', { ns: 'chat' });
- if (isGroupsInit) return <SkeletonItem height={32} padding={0} />;
+ if (isGroupsInit) return <SkeletonItem height={headerAvatarSize + 4} padding={0} />;
return (
<SwitchPanel>
@@ -41,18 +44,15 @@ const Agent = memo<PropsWithChildren>(() => {
overflow: 'hidden',
}}
>
- <SupervisorAvatar size={28} />
- <Text ellipsis weight={500}>
+ <SupervisorAvatar size={headerAvatarSize} />
+ <Text ellipsis fontSize={headerLabelFontSize} weight={headerLabelWeight}>
{displayTitle}
</Text>
<ActionIcon
icon={ChevronsUpDownIcon}
- size={{
- blockSize: 28,
- size: 16,
- }}
+ size={headerChevronSize}
style={{
- width: 24,
+ width: headerChevronSize.blockSize,
}}
/>
</Block>
diff --git a/src/routes/(main)/group/_layout/Sidebar/Members/index.tsx b/src/routes/(main)/group/_layout/Sidebar/Members/index.tsx
index 3d1d6a23f83..c5611f9a78c 100644
--- a/src/routes/(main)/group/_layout/Sidebar/Members/index.tsx
+++ b/src/routes/(main)/group/_layout/Sidebar/Members/index.tsx
@@ -16,6 +16,7 @@ import { type MouseEvent } from 'react';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import { useResourceAccess } from '@/features/ResourcePermission/useResourceAccess';
import { useInitGroupConfig } from '@/hooks/useInitGroupConfig';
import { usePermission } from '@/hooks/usePermission';
@@ -30,6 +31,7 @@ interface MembersProps {
}
const Members = memo<MembersProps>(({ itemKey }) => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { t } = useTranslation('chat');
const { allowed: hasEditPermission, reason } = usePermission('edit_own_content');
const [addModalOpen, setAddModalOpen] = useState(false);
@@ -63,10 +65,8 @@ const Members = memo<MembersProps>(({ itemKey }) => {
return (
<AccordionItem value={itemKey}>
<AccordionHeader>
- <AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {`${t('groupSidebar.tabs.members')} ${membersCount}`}
- </Text>
+ <AccordionTrigger style={sectionTriggerStyle}>
+ <SectionTitle>{`${t('groupSidebar.tabs.members')} ${membersCount}`}</SectionTitle>
</AccordionTrigger>
<div
className={cx(
diff --git a/src/routes/(main)/group/_layout/Sidebar/Topic/TopicListContent/ByTimeMode/GroupItem.tsx b/src/routes/(main)/group/_layout/Sidebar/Topic/TopicListContent/ByTimeMode/GroupItem.tsx
index d850a099f32..01619e1b660 100644
--- a/src/routes/(main)/group/_layout/Sidebar/Topic/TopicListContent/ByTimeMode/GroupItem.tsx
+++ b/src/routes/(main)/group/_layout/Sidebar/Topic/TopicListContent/ByTimeMode/GroupItem.tsx
@@ -10,6 +10,7 @@ import dayjs from 'dayjs';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
+import { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import { type GroupedTopic } from '@/types/topic';
import TopicItem from '../../List/Item';
@@ -24,6 +25,7 @@ interface GroupItemProps {
}
const GroupItem = memo<GroupItemProps>(({ group, activeTopicId, activeThreadId }) => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { t } = useTranslation('topic');
const { id, title, children } = group;
@@ -32,7 +34,7 @@ const GroupItem = memo<GroupItemProps>(({ group, activeTopicId, activeThreadId }
return (
<AccordionItem value={id}>
<AccordionHeader>
- <AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionTrigger style={sectionTriggerStyle}>
<Flexbox horizontal align="center" gap={6} height={24} style={{ overflow: 'hidden' }}>
<Text ellipsis fontSize={12} style={{ flex: 1 }} type={'secondary'} weight={500}>
{title || timeTitle}
diff --git a/src/routes/(main)/group/_layout/Sidebar/Topic/index.tsx b/src/routes/(main)/group/_layout/Sidebar/Topic/index.tsx
index b354416e6e3..8cfdaf26ec2 100644
--- a/src/routes/(main)/group/_layout/Sidebar/Topic/index.tsx
+++ b/src/routes/(main)/group/_layout/Sidebar/Topic/index.tsx
@@ -15,6 +15,7 @@ import {
import React, { memo, Suspense } from 'react';
import { useTranslation } from 'react-i18next';
+import SectionTitle, { useSectionTriggerStyle } from '@/features/NavPanel/components/SectionTitle';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import { useFetchChatTopics } from '@/hooks/useFetchChatTopics';
import { useChatStore } from '@/store/chat';
@@ -30,6 +31,7 @@ interface TopicProps {
}
const Topic = memo<TopicProps>(({ itemKey }) => {
+ const sectionTriggerStyle = useSectionTriggerStyle();
const { t } = useTranslation(['topic', 'common']);
const [topicCount] = useChatStore((s) => [topicSelectors.currentTopicCount(s)]);
const dropdownMenu = useTopicActionsDropdownMenu();
@@ -39,11 +41,9 @@ const Topic = memo<TopicProps>(({ itemKey }) => {
<AccordionItem value={itemKey}>
<ContextMenuTrigger items={dropdownMenu}>
<AccordionHeader>
- <AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
+ <AccordionTrigger style={sectionTriggerStyle}>
<Flexbox horizontal align="center" gap={4}>
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {`${t('title')} ${topicCount > 0 ? topicCount : ''}`}
- </Text>
+ <SectionTitle>{`${t('title')} ${topicCount > 0 ? topicCount : ''}`}</SectionTitle>
{isRevalidating && <Spin size="small" variant="network" />}
</Flexbox>
</AccordionTrigger>
diff --git a/src/routes/(main)/group/features/Conversation/Header/ShareButton/index.tsx b/src/routes/(main)/group/features/Conversation/Header/ShareButton/index.tsx
index 7cca8a1b820..1205d32fc8b 100644
--- a/src/routes/(main)/group/features/Conversation/Header/ShareButton/index.tsx
+++ b/src/routes/(main)/group/features/Conversation/Header/ShareButton/index.tsx
@@ -5,12 +5,13 @@ import { Share2 } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SIZE, MOBILE_HEADER_ICON_SIZE } from '@/const/layoutTokens';
+import { MOBILE_HEADER_ICON_SIZE } from '@/const/layoutTokens';
import { useShareModal } from '@/features/ShareModal';
import { LazySharePopover as SharePopover } from '@/features/SharePopover/lazy';
import { usePermission } from '@/hooks/usePermission';
import { useServerConfigStore } from '@/store/serverConfig';
import { serverConfigSelectors } from '@/store/serverConfig/selectors';
+import { useHeaderActionSize } from '@/styles/density';
import { useGroupContext } from '../../useGroupContext';
@@ -29,6 +30,7 @@ const ShareButton = memo<ShareButtonProps>(({ mobile, setOpen, open }) => {
const { agentId, topicId: activeTopicId } = useGroupContext();
const enableTopicLinkShare = useServerConfigStore(serverConfigSelectors.enableBusinessFeatures);
const { allowed: canShare, reason } = usePermission('edit_own_content');
+ const headerActionSize = useHeaderActionSize();
// Hide share button when no topic exists (no messages sent yet)
if (!activeTopicId) return null;
@@ -37,7 +39,7 @@ const ShareButton = memo<ShareButtonProps>(({ mobile, setOpen, open }) => {
<ActionIcon
disabled={!canShare}
icon={Share2}
- size={mobile ? MOBILE_HEADER_ICON_SIZE : DESKTOP_HEADER_ICON_SIZE}
+ size={mobile ? MOBILE_HEADER_ICON_SIZE : headerActionSize}
title={canShare ? t('share') : reason}
tooltipProps={{
placement: 'bottom',
diff --git a/src/routes/(main)/group/profile/features/AgentBuilder/TopicSelector.tsx b/src/routes/(main)/group/profile/features/AgentBuilder/TopicSelector.tsx
index 7ea2232e995..aae5850b317 100644
--- a/src/routes/(main)/group/profile/features/AgentBuilder/TopicSelector.tsx
+++ b/src/routes/(main)/group/profile/features/AgentBuilder/TopicSelector.tsx
@@ -4,12 +4,12 @@ import { Clock3Icon, PlusIcon } from 'lucide-react';
import { memo, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import NavHeader from '@/features/NavHeader';
import { useFetchAgentChatTopics } from '@/hooks/useFetchChatTopics';
import { useQueryState } from '@/hooks/useQueryParam';
import { useChatStore } from '@/store/chat';
import { topicSelectors } from '@/store/chat/slices/topic/selectors';
+import { useHeaderActionSize } from '@/styles/density';
const styles = createStaticStyles(({ css }) => ({
// The tag is a flex item of the header's left slot: without these it keeps its
@@ -32,6 +32,7 @@ interface TopicSelectorProps {
const TopicSelector = memo<TopicSelectorProps>(({ agentId, disabled }) => {
const { t } = useTranslation('topic');
+ const headerActionSmallSize = useHeaderActionSize(true);
// Fetch topics for the group agent builder
useFetchAgentChatTopics(agentId);
@@ -93,7 +94,7 @@ const TopicSelector = memo<TopicSelectorProps>(({ agentId, disabled }) => {
<ActionIcon
disabled={disabled}
icon={PlusIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={t('actions.addNewTopic')}
onClick={() => {
if (disabled) return;
@@ -110,7 +111,7 @@ const TopicSelector = memo<TopicSelectorProps>(({ agentId, disabled }) => {
<ActionIcon
disabled={disabled || isEmpty}
icon={Clock3Icon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
/>
</DropdownMenu>
</>
diff --git a/src/routes/(main)/group/profile/features/Header/AgentBuilderToggle.tsx b/src/routes/(main)/group/profile/features/Header/AgentBuilderToggle.tsx
index 23b7471cff0..3e6f214df93 100644
--- a/src/routes/(main)/group/profile/features/Header/AgentBuilderToggle.tsx
+++ b/src/routes/(main)/group/profile/features/Header/AgentBuilderToggle.tsx
@@ -3,20 +3,21 @@ import { BotMessageSquareIcon } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SIZE } from '@/const/layoutTokens';
import { useGroupProfileStore } from '@/store/groupProfile';
+import { useHeaderActionSize } from '@/styles/density';
const AgentBuilderToggle = memo(() => {
const { t } = useTranslation('chat');
const chatPanelExpanded = useGroupProfileStore((s) => s.chatPanelExpanded);
const setChatPanelExpanded = useGroupProfileStore((s) => s.setChatPanelExpanded);
+ const headerActionSize = useHeaderActionSize();
return (
<ActionIcon
active={chatPanelExpanded}
aria-label={t('agentBuilder.title')}
icon={BotMessageSquareIcon}
- size={DESKTOP_HEADER_ICON_SIZE}
+ size={headerActionSize}
title={t('agentBuilder.title')}
onClick={() => setChatPanelExpanded((prev) => !prev)}
/>
diff --git a/src/routes/(main)/memory/(home)/features/RoleTagCloud/index.tsx b/src/routes/(main)/memory/(home)/features/RoleTagCloud/index.tsx
index 9457ce7cd01..ef39d6925ff 100644
--- a/src/routes/(main)/memory/(home)/features/RoleTagCloud/index.tsx
+++ b/src/routes/(main)/memory/(home)/features/RoleTagCloud/index.tsx
@@ -3,9 +3,9 @@ import { MaximizeIcon, MinimizeIcon } from 'lucide-react';
import { memo, useEffect, useState } from 'react';
import SkeletonBar from '@/components/Skeleton/Bar';
-import { DESKTOP_HEADER_ICON_SIZE } from '@/const/layoutTokens';
import { type QueryTagsResult } from '@/database/models/userMemory';
import dynamic from '@/libs/next/dynamic';
+import { useHeaderActionSize } from '@/styles/density';
const TagCloudCanvas = dynamic(() => import('./TagCloudCanvas'), {
loading: () => <SkeletonBar height={400} radius={12} />,
@@ -56,6 +56,7 @@ interface RoleTagCloudProps {
const RoleTagCloud = memo<RoleTagCloudProps>(({ tags }) => {
const [fullscreen, setFullscreen] = useState(false);
const [fullscreenAnimation, setFullscreenAnimation] = useState(false);
+ const headerActionSize = useHeaderActionSize();
useEffect(() => {
setFullscreenAnimation(true);
@@ -77,7 +78,7 @@ const RoleTagCloud = memo<RoleTagCloudProps>(({ tags }) => {
<ActionIcon
className={cx('fullscreen-icon', styles.icon)}
icon={fullscreen ? MinimizeIcon : MaximizeIcon}
- size={DESKTOP_HEADER_ICON_SIZE}
+ size={headerActionSize}
onClick={() => {
setFullscreen(!fullscreen);
}}
diff --git a/src/routes/(main)/memory/activities/features/ActivityRightPanel.tsx b/src/routes/(main)/memory/activities/features/ActivityRightPanel.tsx
index c3eb9fd57d9..f4ab6605e89 100644
--- a/src/routes/(main)/memory/activities/features/ActivityRightPanel.tsx
+++ b/src/routes/(main)/memory/activities/features/ActivityRightPanel.tsx
@@ -2,22 +2,23 @@
import { memo } from 'react';
-import { DESKTOP_HEADER_ICON_SIZE } from '@/const/layoutTokens';
import { useQueryState } from '@/hooks/useQueryParam';
import DetailPanel from '@/routes/(main)/memory/features/DetailPanel';
+import { useHeaderActionSize } from '@/styles/density';
import ActivityDetail from './ActivityDetail';
import ActivityDropdown from './ActivityDropdown';
const ActivityRightPanel = memo(() => {
const [activityId] = useQueryState('activityId', { clearOnDefault: true });
+ const headerActionSize = useHeaderActionSize();
if (!activityId) return null;
return (
<DetailPanel
header={{
- right: <ActivityDropdown id={activityId} size={DESKTOP_HEADER_ICON_SIZE} />,
+ right: <ActivityDropdown id={activityId} size={headerActionSize} />,
}}
>
<ActivityDetail id={activityId} />
diff --git a/src/routes/(main)/memory/features/ActionBar/PurgeButton.tsx b/src/routes/(main)/memory/features/ActionBar/PurgeButton.tsx
index 1b4a00e6d0c..c9267528166 100644
--- a/src/routes/(main)/memory/features/ActionBar/PurgeButton.tsx
+++ b/src/routes/(main)/memory/features/ActionBar/PurgeButton.tsx
@@ -6,8 +6,8 @@ import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useSearchParams } from 'react-router';
-import { DESKTOP_HEADER_ICON_SIZE, DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { useUserMemoryStore } from '@/store/userMemory';
+import { useHeaderActionSize } from '@/styles/density';
export const MEMORY_DETAIL_QUERY_KEYS = [
'activityId',
@@ -27,6 +27,8 @@ const PurgeButton = memo<Props>(({ iconOnly }) => {
const purgeAllMemories = useUserMemoryStore((s) => s.purgeAllMemories);
const [loading, setLoading] = useState(false);
const [searchParams, setSearchParams] = useSearchParams();
+ const headerActionSize = useHeaderActionSize();
+ const headerActionSmallSize = useHeaderActionSize(true);
const handleClick = () => {
confirmModal({
@@ -64,7 +66,7 @@ const PurgeButton = memo<Props>(({ iconOnly }) => {
danger
icon={Trash2Icon}
loading={loading}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
tooltipProps={{ placement: 'bottom' }}
onClick={handleClick}
/>
@@ -75,7 +77,7 @@ const PurgeButton = memo<Props>(({ iconOnly }) => {
return (
<Button
danger
- icon={<Icon icon={Trash2Icon} size={DESKTOP_HEADER_ICON_SIZE} />}
+ icon={<Icon icon={Trash2Icon} size={headerActionSize} />}
loading={loading}
size={'small'}
style={{ maxWidth: 300 }}
diff --git a/src/routes/(main)/memory/features/MemoryAnalysis/AnalysisTrigger.tsx b/src/routes/(main)/memory/features/MemoryAnalysis/AnalysisTrigger.tsx
index c4019e75f64..63b4fa5ebdf 100644
--- a/src/routes/(main)/memory/features/MemoryAnalysis/AnalysisTrigger.tsx
+++ b/src/routes/(main)/memory/features/MemoryAnalysis/AnalysisTrigger.tsx
@@ -5,8 +5,8 @@ import { CalendarClockIcon } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { useMemoryAnalysisAsyncTask } from '@/routes/(main)/memory/features/MemoryAnalysis/useTask';
+import { useHeaderActionSize } from '@/styles/density';
import { createDateRangeModal } from './DateRangeModal';
@@ -17,6 +17,7 @@ interface Props {
const AnalysisTrigger = memo<Props>(({ iconOnly }) => {
const { t } = useTranslation('memory');
const { isValidating } = useMemoryAnalysisAsyncTask();
+ const headerActionSmallSize = useHeaderActionSize(true);
const handleClick = () => {
createDateRangeModal();
@@ -26,7 +27,7 @@ const AnalysisTrigger = memo<Props>(({ iconOnly }) => {
<Tooltip title={t('analysis.action.button')}>
<ActionIcon
icon={CalendarClockIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
tooltipProps={{ placement: 'bottom' }}
onClick={handleClick}
/>
diff --git a/src/routes/(main)/memory/features/ViewModeSwitcher.tsx b/src/routes/(main)/memory/features/ViewModeSwitcher.tsx
index 78700080caa..53cf0028c41 100644
--- a/src/routes/(main)/memory/features/ViewModeSwitcher.tsx
+++ b/src/routes/(main)/memory/features/ViewModeSwitcher.tsx
@@ -5,8 +5,8 @@ import { CalendarDaysIcon, LayoutDashboardIcon } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { type ViewMode } from '@/features/Memory';
+import { useHeaderActionSize } from '@/styles/density';
export type { ViewMode } from '@/features/Memory';
@@ -17,20 +17,21 @@ interface ViewModeSwitcherProps {
const ViewModeSwitcher = memo<ViewModeSwitcherProps>(({ value, onChange }) => {
const { t } = useTranslation('memory');
+ const headerActionSmallSize = useHeaderActionSize(true);
return (
<>
<ActionIcon
active={value === 'timeline'}
icon={CalendarDaysIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={t('viewMode.timeline')}
onClick={() => onChange('timeline')}
/>
<ActionIcon
active={value === 'grid'}
icon={LayoutDashboardIcon}
- size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ size={headerActionSmallSize}
title={t('viewMode.masonry')}
onClick={() => onChange('grid')}
/>
diff --git a/src/routes/(main)/memory/identities/features/IdentityRightPanel.tsx b/src/routes/(main)/memory/identities/features/IdentityRightPanel.tsx
index 09d905346b2..5dc0820e4ac 100644
--- a/src/routes/(main)/memory/identities/features/IdentityRightPanel.tsx
+++ b/src/routes/(main)/memory/identities/features/IdentityRightPanel.tsx
@@ -2,22 +2,23 @@
import { memo } from 'react';
-import { DESKTOP_HEADER_ICON_SIZE } from '@/const/layoutTokens';
import { useQueryState } from '@/hooks/useQueryParam';
import DetailPanel from '@/routes/(main)/memory/features/DetailPanel';
+import { useHeaderActionSize } from '@/styles/density';
import IdentityDetail from './IdentityDetail';
import IdentityDropdown from './IdentityDropdown';
const IdentityRightPanel = memo(() => {
const [identityId] = useQueryState('identityId', { clearOnDefault: true });
+ const headerActionSize = useHeaderActionSize();
if (!identityId) return null;
return (
<DetailPanel
header={{
- right: <IdentityDropdown id={identityId} size={DESKTOP_HEADER_ICON_SIZE} />,
+ right: <IdentityDropdown id={identityId} size={headerActionSize} />,
}}
>
<IdentityDetail id={identityId} />
diff --git a/src/routes/(main)/memory/preferences/features/PreferenceRightPanel.tsx b/src/routes/(main)/memory/preferences/features/PreferenceRightPanel.tsx
index 05aceb6ef5d..9cea9007568 100644
--- a/src/routes/(main)/memory/preferences/features/PreferenceRightPanel.tsx
+++ b/src/routes/(main)/memory/preferences/features/PreferenceRightPanel.tsx
@@ -2,22 +2,23 @@
import { memo } from 'react';
-import { DESKTOP_HEADER_ICON_SIZE } from '@/const/layoutTokens';
import { useQueryState } from '@/hooks/useQueryParam';
import DetailPanel from '@/routes/(main)/memory/features/DetailPanel';
+import { useHeaderActionSize } from '@/styles/density';
import PreferenceDetail from './PreferenceDetail';
import PreferenceDropdown from './PreferenceDropdown';
const PreferenceRightPanel = memo(() => {
const [preferenceId] = useQueryState('preferenceId', { clearOnDefault: true });
+ const headerActionSize = useHeaderActionSize();
if (!preferenceId) return null;
return (
<DetailPanel
header={{
- right: <PreferenceDropdown id={preferenceId} size={DESKTOP_HEADER_ICON_SIZE} />,
+ right: <PreferenceDropdown id={preferenceId} size={headerActionSize} />,
}}
>
<PreferenceDetail id={preferenceId} />
diff --git a/src/store/user/slices/settings/selectors/general.test.ts b/src/store/user/slices/settings/selectors/general.test.ts
index d35dff1f90c..728ee29e383 100644
--- a/src/store/user/slices/settings/selectors/general.test.ts
+++ b/src/store/user/slices/settings/selectors/general.test.ts
@@ -21,6 +21,7 @@ describe('settingsSelectors', () => {
costEstimateWarningThreshold: 0.5,
fontSize: 12,
highlighterTheme: 'lobe-theme',
+ interfaceDensity: 'loose',
isDevMode: false,
isLiteMode: false,
mermaidTheme: 'lobe-theme',
@@ -44,6 +45,22 @@ describe('settingsSelectors', () => {
});
});
+ describe('interfaceDensity', () => {
+ it('defaults to loose when unset', () => {
+ expect(userGeneralSettingsSelectors.interfaceDensity(initialState as UserStore)).toBe(
+ 'loose',
+ );
+ });
+
+ it('returns compact when chosen', () => {
+ const s: UserState = merge(initialState, {
+ settings: { general: { interfaceDensity: 'compact' } },
+ });
+
+ expect(userGeneralSettingsSelectors.interfaceDensity(s as UserStore)).toBe('compact');
+ });
+ });
+
describe('fontAntialiasing', () => {
it('should default to true when unset', () => {
expect(userGeneralSettingsSelectors.fontAntialiasing(initialState as UserStore)).toBe(true);
diff --git a/src/store/user/slices/settings/selectors/general.ts b/src/store/user/slices/settings/selectors/general.ts
index 73dfa008191..65c05ea6388 100644
--- a/src/store/user/slices/settings/selectors/general.ts
+++ b/src/store/user/slices/settings/selectors/general.ts
@@ -1,5 +1,5 @@
import { isDesktop } from '@lobechat/const';
-import { type FollowUpMode, resolveFollowUpMode } from '@lobechat/types';
+import { type FollowUpMode, type InterfaceDensity, resolveFollowUpMode } from '@lobechat/types';
import { DEFAULT_LANG } from '@/const/locale';
import { type Locales, normalizeLocale } from '@/locales/resources';
@@ -46,6 +46,8 @@ const enablePasteAutoConvert = (s: UserStore) =>
generalConfig(s).enablePasteAutoConvert ?? s.preference.lab?.enableInputMarkdown !== false;
const showImageReadPreview = (s: UserStore) => generalConfig(s).showImageReadPreview ?? true;
const fontAntialiasing = (s: UserStore) => generalConfig(s).fontAntialiasing ?? true;
+const interfaceDensity = (s: UserStore): InterfaceDensity =>
+ generalConfig(s).interfaceDensity ?? 'loose';
/** The setting is a boolean: either the live tool list is open or it is a
* summary row. "Open" means the full list — the height-capped middle level
* just hid part of what the user asked to see. */
@@ -73,6 +75,7 @@ export const userGeneralSettingsSelectors = {
fontAntialiasing,
fontSize,
highlighterTheme,
+ interfaceDensity,
mermaidTheme,
neutralColor,
primaryColor,
diff --git a/src/styles/density.stylex.ts b/src/styles/density.stylex.ts
new file mode 100644
index 00000000000..007b969c4a7
--- /dev/null
+++ b/src/styles/density.stylex.ts
@@ -0,0 +1,42 @@
+import * as stylex from '@stylexjs/stylex';
+
+export const densityTokens = stylex.defineVars({
+ '--lobe-density-control-height': '32px',
+ '--lobe-density-font-size': '14px',
+ '--lobe-density-header-height': '44px',
+ '--lobe-density-icon-box': '28px',
+ '--lobe-density-icon-size': '18px',
+ '--lobe-density-line-height': '22px',
+ '--lobe-density-list-row-height': '48px',
+ '--lobe-density-page-title-font-size': '16px',
+ '--lobe-density-radius': '8px',
+ '--lobe-density-row-height': '36px',
+ '--lobe-density-section-gap': '16px',
+ '--lobe-density-toolbar-height': '40px',
+});
+
+export const sidebarRow = stylex.defineVars({
+ controlHeight: 'var(--lobe-density-control-height)',
+ gap: '8px',
+ headerHeight: 'var(--lobe-density-header-height)',
+ height: 'var(--lobe-density-row-height)',
+ iconBox: 'var(--lobe-density-icon-box)',
+ iconSize: 'var(--lobe-density-icon-size)',
+ labelFontSize: '12px',
+ labelFontWeight: '500',
+ listRowHeight: 'var(--lobe-density-list-row-height)',
+ metaFontSize: '12px',
+ pageTitleFontSize: 'var(--lobe-density-page-title-font-size)',
+ paddingInline: '4px',
+ paneBlockEnd: '12px',
+ paneBlockStart: '4px',
+ paneInline: '6px',
+ radius: 'var(--lobe-density-radius)',
+ sectionGap: 'var(--lobe-density-section-gap)',
+ sectionHeaderHeight: 'var(--lobe-density-control-height)',
+ textFontSize: 'var(--lobe-density-font-size)',
+ textLineHeight: 'var(--lobe-density-line-height)',
+ toolbarHeight: 'var(--lobe-density-toolbar-height)',
+ toolbarPaddingInlineEnd: '8px',
+ toolbarPaddingInlineStart: '12px',
+});
diff --git a/src/styles/density.test.ts b/src/styles/density.test.ts
new file mode 100644
index 00000000000..8c151d7e49e
--- /dev/null
+++ b/src/styles/density.test.ts
@@ -0,0 +1,29 @@
+import { describe, expect, it } from 'vitest';
+
+import { DENSITY_TOKENS } from './density';
+
+describe('DENSITY_TOKENS', () => {
+ it('uses 32px rows in compact', () => {
+ expect(DENSITY_TOKENS.compact).toMatchObject({
+ fontSize: 13,
+ headerAvatarSize: 24,
+ headerHeight: 40,
+ iconSize: 16,
+ rowHeight: 32,
+ });
+ });
+
+ it('keeps the current header action sizes in loose', () => {
+ expect(DENSITY_TOKENS.loose.headerActionSize).toEqual({ blockSize: 32, size: 20 });
+ expect(DENSITY_TOKENS.loose.headerActionSmallSize).toEqual({ blockSize: 28, size: 16 });
+ });
+
+ it('sizes tree rows from the control height', () => {
+ expect(DENSITY_TOKENS.compact.treeItemHeight).toBe(28);
+ expect(DENSITY_TOKENS.loose.treeItemHeight).toBe(32);
+ });
+
+ it('uses 36px rows in loose', () => {
+ expect(DENSITY_TOKENS.loose).toMatchObject({ fontSize: 14, iconSize: 18, rowHeight: 36 });
+ });
+});
diff --git a/src/styles/density.ts b/src/styles/density.ts
new file mode 100644
index 00000000000..82c5ba95153
--- /dev/null
+++ b/src/styles/density.ts
@@ -0,0 +1,121 @@
+import { type InterfaceDensity } from '@lobechat/types';
+import { createContext, useContext } from 'react';
+
+import { useUserStore } from '@/store/user';
+import { userGeneralSettingsSelectors } from '@/store/user/selectors';
+
+export interface ActionSize {
+ blockSize: number;
+ size: number;
+}
+
+export interface DensityTokens {
+ controlHeight: number;
+ fontSize: number;
+ gap: number;
+ headerActionSize: ActionSize;
+ headerActionSmallSize: ActionSize;
+ headerAvatarSize: number;
+ headerChevronSize: number;
+ headerHeight: number;
+ iconBox: number;
+ iconSize: number;
+ lineHeight: number;
+ listRowHeight: number;
+ paddingInline: number;
+ pageTitleFontSize: number;
+ panelPaddingInline: number;
+ radius: number;
+ rowHeight: number;
+ sectionGap: number;
+ sectionHeaderHeight: number;
+ toolbarHeight: number;
+ treeItemHeight: number;
+}
+
+type DensityScale = Omit<
+ DensityTokens,
+ | 'headerActionSize'
+ | 'headerActionSmallSize'
+ | 'headerChevronSize'
+ | 'sectionHeaderHeight'
+ | 'treeItemHeight'
+> & {
+ headerIconSize: number;
+ headerSmallIconSize: number;
+};
+
+const withDerivedTokens = ({
+ headerIconSize,
+ headerSmallIconSize,
+ ...scale
+}: DensityScale): DensityTokens => ({
+ ...scale,
+ headerActionSize: { blockSize: scale.controlHeight, size: headerIconSize },
+ headerActionSmallSize: { blockSize: scale.iconBox, size: headerSmallIconSize },
+ headerChevronSize: headerSmallIconSize,
+ sectionHeaderHeight: scale.controlHeight,
+ treeItemHeight: scale.controlHeight,
+});
+
+// The px values also live in density.stylex.ts and densityTheme.ts as --lobe-density-* CSS
+// variables, because StyleX only compiles literals; densityParity.test.ts keeps them in step.
+export const DENSITY_TOKENS: Record<InterfaceDensity, DensityTokens> = {
+ compact: withDerivedTokens({
+ controlHeight: 28,
+ fontSize: 13,
+ gap: 8,
+ headerAvatarSize: 24,
+ headerHeight: 40,
+ headerIconSize: 16,
+ headerSmallIconSize: 14,
+ iconBox: 24,
+ iconSize: 16,
+ lineHeight: 20,
+ listRowHeight: 40,
+ pageTitleFontSize: 14,
+ paddingInline: 4,
+ panelPaddingInline: 6,
+ radius: 6,
+ rowHeight: 32,
+ sectionGap: 12,
+ toolbarHeight: 36,
+ }),
+ loose: withDerivedTokens({
+ controlHeight: 32,
+ fontSize: 14,
+ gap: 8,
+ headerAvatarSize: 28,
+ headerHeight: 44,
+ headerIconSize: 20,
+ headerSmallIconSize: 16,
+ iconBox: 28,
+ iconSize: 18,
+ lineHeight: 22,
+ listRowHeight: 48,
+ pageTitleFontSize: 16,
+ paddingInline: 4,
+ panelPaddingInline: 4,
+ radius: 8,
+ rowHeight: 36,
+ sectionGap: 16,
+ toolbarHeight: 40,
+ }),
+};
+
+export const useInterfaceDensity = () =>
+ useUserStore(userGeneralSettingsSelectors.interfaceDensity);
+
+export const useDensityTokens = () => DENSITY_TOKENS[useInterfaceDensity()];
+
+export const PanelDensityContext = createContext<InterfaceDensity | null>(null);
+
+export const usePanelDensityTokens = (): DensityTokens | null => {
+ const density = useContext(PanelDensityContext);
+ return density ? DENSITY_TOKENS[density] : null;
+};
+
+export const useHeaderActionSize = (small?: boolean): ActionSize => {
+ const tokens = useDensityTokens();
+ return small ? tokens.headerActionSmallSize : tokens.headerActionSize;
+};
diff --git a/src/styles/densityParity.test.ts b/src/styles/densityParity.test.ts
new file mode 100644
index 00000000000..45dea410cde
--- /dev/null
+++ b/src/styles/densityParity.test.ts
@@ -0,0 +1,32 @@
+import { readFileSync } from 'node:fs';
+import { join } from 'node:path';
+
+import { describe, expect, it } from 'vitest';
+
+import { DENSITY_TOKENS } from './density';
+
+const readTokens = (file: string) => {
+ const source = readFileSync(join(__dirname, file), 'utf8');
+ const tokens: Record<string, number> = {};
+ for (const [, name, value] of source.matchAll(/'--lobe-density-([a-z-]+)': '(\d+)px'/g)) {
+ tokens[name.replaceAll(/-([a-z])/g, (_, char: string) => char.toUpperCase())] = Number(value);
+ }
+ return tokens;
+};
+
+describe('density CSS variables', () => {
+ it('declares loose defaults that match DENSITY_TOKENS.loose', () => {
+ const tokens = readTokens('density.stylex.ts');
+
+ expect(Object.keys(tokens).length).toBeGreaterThan(0);
+ expect(DENSITY_TOKENS.loose).toMatchObject(tokens);
+ });
+
+ it('overrides every variable in the compact theme with DENSITY_TOKENS.compact', () => {
+ const loose = readTokens('density.stylex.ts');
+ const compact = readTokens('densityTheme.ts');
+
+ expect(Object.keys(compact).sort()).toEqual(Object.keys(loose).sort());
+ expect(DENSITY_TOKENS.compact).toMatchObject(compact);
+ });
+});
diff --git a/src/styles/densityTheme.ts b/src/styles/densityTheme.ts
new file mode 100644
index 00000000000..b8d7f1417a4
--- /dev/null
+++ b/src/styles/densityTheme.ts
@@ -0,0 +1,18 @@
+import * as stylex from '@stylexjs/stylex';
+
+import { densityTokens } from './density.stylex';
+
+export const compactDensityTheme = stylex.createTheme(densityTokens, {
+ '--lobe-density-control-height': '28px',
+ '--lobe-density-font-size': '13px',
+ '--lobe-density-header-height': '40px',
+ '--lobe-density-icon-box': '24px',
+ '--lobe-density-icon-size': '16px',
+ '--lobe-density-line-height': '20px',
+ '--lobe-density-list-row-height': '40px',
+ '--lobe-density-page-title-font-size': '14px',
+ '--lobe-density-radius': '6px',
+ '--lobe-density-row-height': '32px',
+ '--lobe-density-section-gap': '12px',
+ '--lobe-density-toolbar-height': '36px',
+});
diff --git a/src/styles/global.css b/src/styles/global.css
index d6f028242a9..0fc0e0e8ad0 100644
--- a/src/styles/global.css
+++ b/src/styles/global.css
@@ -130,3 +130,32 @@ html.desktop[data-window-fullscreen] body {
display: none !important;
}
}
+
+/* lobe-ui ships its rules inside @layer lobe-ui, so these unlayered overrides win without !important */
+html[data-density='compact'] .lobe-menu-popup,
+html[data-density='compact'] .lobe-select__popup {
+ font-size: var(--lobe-density-font-size);
+}
+
+html[data-density='compact'] .lobe-dropdown-menu__item,
+html[data-density='compact'] .lobe-context-menu__item,
+html[data-density='compact'] .lobe-select__option {
+ min-height: var(--lobe-density-control-height);
+ padding-block: calc((var(--lobe-density-control-height) - 20px) / 2);
+ padding-inline: 8px;
+
+ font-size: var(--lobe-density-font-size);
+ line-height: 20px;
+}
+
+html[data-density='compact'] .lobe-select[data-size='middle'],
+html[data-density='compact'] .lobe-tabs__tab {
+ height: var(--lobe-density-control-height);
+ min-height: var(--lobe-density-control-height);
+ font-size: var(--lobe-density-font-size);
+}
+
+html[data-density='compact'] .lobe-segmented[data-size='small'] .lobe-segmented__item {
+ height: calc(var(--lobe-density-control-height) - 8px);
+ min-height: 0;
+}