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(topic): stack draft hint under the avatar on two-line rows (#22323)

AmAzing-750de8786f16
diff --git a/src/features/AgentSidebar/Topic/List/Item/index.test.tsx b/src/features/AgentSidebar/Topic/List/Item/index.test.tsx
index 857ec88c0f6..e82a8d17faf 100644
--- a/src/features/AgentSidebar/Topic/List/Item/index.test.tsx
+++ b/src/features/AgentSidebar/Topic/List/Item/index.test.tsx
@@ -21,6 +21,7 @@ const topicUnreadCompletedMock = vi.hoisted(() => ({ value: false }));
const onlyMineMock = vi.hoisted(() => ({ value: false }));
const currentUserIdMock = vi.hoisted(() => ({ value: 'user-1' as string | undefined }));
const goalsEnabledMock = vi.hoisted(() => ({ value: true }));
+const hasDraftMock = vi.hoisted(() => ({ value: false }));
const topicMetaCardMock = vi.hoisted(() => ({
value: undefined as
| {
@@ -66,6 +67,7 @@ vi.mock('@/features/NavPanel/components/NavItem', () => ({
extra,
href,
icon,
+ slots,
title,
}: {
actions?: ReactNode | (() => ReactNode);
@@ -74,11 +76,18 @@ vi.mock('@/features/NavPanel/components/NavItem', () => ({
extra?: ReactNode;
href?: string;
icon?: ReactNode;
+ slots?: { iconBelow?: ReactNode; titlePrefix?: ReactNode };
title?: ReactNode;
}) => (
<div data-active={String(active)} data-href={href} data-testid="nav-item">
- {icon}
- {title}
+ <div data-testid="nav-item-leading">
+ {icon}
+ {slots?.iconBelow}
+ </div>
+ <div data-testid="nav-item-title">
+ {slots?.titlePrefix}
+ {title}
+ </div>
{description}
{extra}
{typeof actions === 'function' ? actions() : actions}
@@ -94,6 +103,9 @@ vi.mock('@/features/ChatInput/ControlBar/DirIcon', () => ({
vi.mock('@/business/client/hooks/useActiveWorkspaceSlug', () => ({
useActiveWorkspaceSlug: () => 'team',
}));
+vi.mock('@/features/ChatInput/draftStorage', () => ({
+ useHasDraft: () => hasDraftMock.value,
+}));
vi.mock('@/features/AgentChannel/const', () => ({
getPlatformIcon: () => null,
}));
@@ -207,6 +219,7 @@ describe('TopicItem active state', () => {
onlyMineMock.value = false;
currentUserIdMock.value = 'user-1';
goalsEnabledMock.value = true;
+ hasDraftMock.value = false;
vi.useRealTimers();
});
@@ -555,6 +568,39 @@ describe('TopicItem active state', () => {
expect(screen.getByText('repo/repo-fix · fix')).toBeInTheDocument();
});
+ describe('draft hint', () => {
+ beforeEach(() => {
+ hasDraftMock.value = true;
+ useTopicNavigationMock.mockReturnValue({
+ isInAgentSubRoute: false,
+ isInTopicContextRoute: false,
+ navigateToTopic: vi.fn(),
+ routeTopicId: undefined,
+ });
+ });
+
+ it('stacks the draft hint under the leading icon on a two-line row', () => {
+ render(
+ <TopicItem
+ showWorkingDirectory
+ id="tpc_test"
+ metadata={{ workingDirectory: '/repo' }}
+ title="Topic"
+ />,
+ );
+
+ expect(within(screen.getByTestId('nav-item-leading')).getByText('draft')).toBeInTheDocument();
+ expect(within(screen.getByTestId('nav-item-title')).queryByText('draft')).toBeNull();
+ });
+
+ it('keeps the draft hint before the title on a single-line row', () => {
+ render(<TopicItem id="tpc_test" title="Topic" />);
+
+ expect(within(screen.getByTestId('nav-item-title')).getByText('draft')).toBeInTheDocument();
+ expect(within(screen.getByTestId('nav-item-leading')).queryByText('draft')).toBeNull();
+ });
+ });
+
// The unread dot and the linked-PR marker compete for the same icon slot, and
// unread is one of the three `pending` attention states, so it has to win.
it('keeps the unread dot visible when the topic has a linked pull request', () => {
diff --git a/src/features/AgentSidebar/Topic/List/Item/index.tsx b/src/features/AgentSidebar/Topic/List/Item/index.tsx
index acb30955e2e..25f962e15fa 100644
--- a/src/features/AgentSidebar/Topic/List/Item/index.tsx
+++ b/src/features/AgentSidebar/Topic/List/Item/index.tsx
@@ -429,6 +429,16 @@ const TopicItemRow = memo<TopicItemRowProps>(
{t('draft')}
</Text>
) : undefined;
+ // On a two-line row (title + working directory) the hint sits under the
+ // leading avatar instead, so it no longer eats into the title width.
+ const draftBelowIcon = hasDraft ? (
+ <Text
+ fontSize={10}
+ style={{ color: cssVar.colorError, flex: 'none', lineHeight: 1, whiteSpace: 'nowrap' }}
+ >
+ {t('draft')}
+ </Text>
+ ) : undefined;
// Codex-style hover detail card: when the topic carries git context, hovering
// the row reveals a card on the right with repo / branch / worktree / PR / CI —
@@ -625,7 +635,6 @@ const TopicItemRow = memo<TopicItemRowProps>(
description={workingDirectoryNode}
href={href}
icon={leadingIconNode}
- slots={{ titlePrefix: draftPrefix }}
title={title === '...' ? <DotsLoading gap={3} size={4} /> : title}
titleColor={cssVar.colorText}
actions={() => (
@@ -658,6 +667,9 @@ const TopicItemRow = memo<TopicItemRowProps>(
)}
</>
}
+ slots={
+ workingDirectoryNode ? { iconBelow: draftBelowIcon } : { titlePrefix: draftPrefix }
+ }
onClick={handleClick}
onDoubleClick={() => void handleDoubleClick()}
onDragStart={handleDragStart}
diff --git a/src/features/NavPanel/components/NavItem.tsx b/src/features/NavPanel/components/NavItem.tsx
index 0b4b74893d5..8b58a1a24ef 100644
--- a/src/features/NavPanel/components/NavItem.tsx
+++ b/src/features/NavPanel/components/NavItem.tsx
@@ -76,6 +76,8 @@ const styles = createStaticStyles(({ css }) => ({
}));
export interface NavItemSlots {
+ /** Stacked under the leading icon, e.g. a short status label on a two-line row. */
+ iconBelow?: ReactNode;
iconPostfix?: ReactNode;
titlePrefix?: ReactNode;
}
@@ -158,7 +160,7 @@ const NavItem = memo<NavItemProps>(
const textColor = titleColor ?? (active ? cssVar.colorText : cssVar.colorTextSecondary);
const variant = active ? 'filled' : 'borderless';
- const { titlePrefix, iconPostfix } = slots || {};
+ const { titlePrefix, iconBelow, iconPostfix } = slots || {};
// Link props for cmd+click support
const linkProps = href
? {
@@ -178,6 +180,24 @@ const NavItem = memo<NavItemProps>(
}
: undefined;
+ const iconNode = icon && (
+ <Center
+ flex={'none'}
+ // 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}
+ style={description ? { alignSelf: 'flex-start' } : undefined}
+ width={28}
+ >
+ {loading ? (
+ <Spin size={iconSize} variant="network" />
+ ) : (
+ <Icon color={iconColor} icon={icon} size={iconSize} />
+ )}
+ </Center>
+ );
+
const Content = (
<Block
horizontal
@@ -204,22 +224,21 @@ const NavItem = memo<NavItemProps>(
onFocus={handleFocus}
onPointerEnter={handlePointerEnter}
>
- {icon && (
- <Center
+ {iconNode && iconBelow ? (
+ <Flexbox
+ align={'center'}
flex={'none'}
- // 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}
+ gap={2}
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}
>
- {loading ? (
- <Spin size={iconSize} variant="network" />
- ) : (
- <Icon color={iconColor} icon={icon} size={iconSize} />
- )}
- </Center>
+ {iconNode}
+ {iconBelow}
+ </Flexbox>
+ ) : (
+ iconNode
)}
{iconPostfix}