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.

🐛 fix(nav): restore agent switcher subtitles (#18409)

Arvin Xu97385c1eb308
diff --git a/src/features/AgentSidebar/Header/Agent/SwitchPanel.tsx b/src/features/AgentSidebar/Header/Agent/SwitchPanel.tsx
index 49dda7ce071..d5702a4e01c 100644
--- a/src/features/AgentSidebar/Header/Agent/SwitchPanel.tsx
+++ b/src/features/AgentSidebar/Header/Agent/SwitchPanel.tsx
@@ -30,12 +30,14 @@ const SwitchPanel = memo<PropsWithChildren>(({ children }) => {
background: row.backgroundColor,
id: row.id,
private: true,
+ subtitle: row.subtitle,
title: row.title,
})),
...workspaceRows.map((row) => ({
avatar: row.avatar,
background: row.backgroundColor,
id: row.id,
+ subtitle: row.subtitle,
title: row.title,
})),
],
diff --git a/src/features/Conversation/Messages/EditedFilesCard/index.tsx b/src/features/Conversation/Messages/EditedFilesCard/index.tsx
index 80a321edeb3..6bfac8ba20a 100644
--- a/src/features/Conversation/Messages/EditedFilesCard/index.tsx
+++ b/src/features/Conversation/Messages/EditedFilesCard/index.tsx
@@ -38,7 +38,7 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
width: 100%;
border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 8px;
+ border-radius: ${cssVar.borderRadiusLG};
background: ${cssVar.colorBgElevated};
`,
diff --git a/src/features/Home/AgentSelect/useHomeAgentRows.test.ts b/src/features/Home/AgentSelect/useHomeAgentRows.test.ts
index 05a74cb9aba..5743f267d1c 100644
--- a/src/features/Home/AgentSelect/useHomeAgentRows.test.ts
+++ b/src/features/Home/AgentSelect/useHomeAgentRows.test.ts
@@ -218,6 +218,23 @@ describe('useHomeAgentRows', () => {
expect(result.current.workspaceRows.find((row) => row.id === 'agt_pinned')?.pinned).toBe(true);
});
+ it('keeps the agent role as the secondary row title', () => {
+ mocks.homeState.ungroupedAgents = [
+ agent('agt_codex', 'Codex', { name: 'Coco' }),
+ agent('agt_legacy', 'Legacy role'),
+ ];
+
+ const { result } = renderHook(() => useHomeAgentRows());
+
+ expect(result.current.workspaceRows.find((row) => row.id === 'agt_codex')).toMatchObject({
+ subtitle: 'Codex',
+ title: 'Coco',
+ });
+ expect(result.current.workspaceRows.find((row) => row.id === 'agt_legacy')?.subtitle).toBe(
+ undefined,
+ );
+ });
+
it('excludes chat groups so only agent ids reach the home input', () => {
mocks.homeState.ungroupedAgents = [
agent('agt_a', 'Agent'),
diff --git a/src/features/Home/AgentSelect/useHomeAgentRows.ts b/src/features/Home/AgentSelect/useHomeAgentRows.ts
index 34155082551..2660355518b 100644
--- a/src/features/Home/AgentSelect/useHomeAgentRows.ts
+++ b/src/features/Home/AgentSelect/useHomeAgentRows.ts
@@ -1,6 +1,10 @@
'use client';
-import { agentDisplayName, type SidebarAgentItem } from '@lobechat/types';
+import {
+ agentDisplayName,
+ agentSecondaryDisplayName,
+ type SidebarAgentItem,
+} from '@lobechat/types';
import isEqual from 'fast-deep-equal';
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -21,6 +25,7 @@ export interface AgentRow {
backgroundColor?: string;
id: string;
pinned?: boolean;
+ subtitle?: string;
title: string;
}
@@ -82,6 +87,7 @@ export const useHomeAgentRows = (): HomeAgentRows => {
backgroundColor: item.backgroundColor || undefined,
id: item.id,
pinned: item.pinned ?? false,
+ subtitle: agentSecondaryDisplayName(item),
title: agentDisplayName(item, t('untitledAgent')),
});
}
diff --git a/src/features/NavPanel/switcher/SwitcherRow.tsx b/src/features/NavPanel/switcher/SwitcherRow.tsx
index bc4fed4b497..af9d6ce740f 100644
--- a/src/features/NavPanel/switcher/SwitcherRow.tsx
+++ b/src/features/NavPanel/switcher/SwitcherRow.tsx
@@ -51,6 +51,9 @@ const SwitcherRow = memo<SwitcherRowProps>(({ active, item, onSelect, privateLab
weight={active ? 500 : undefined}
>
{item.title}
+ {item.subtitle && (
+ <span style={{ fontSize: 12, marginInlineStart: 6, opacity: 0.6 }}>{item.subtitle}</span>
+ )}
</Text>
{item.private && privateLabel && (
<Text color={cssVar.colorTextTertiary} fontSize={12}>
diff --git a/src/features/NavPanel/switcher/switcherItems.test.ts b/src/features/NavPanel/switcher/switcherItems.test.ts
index 8f28323327f..bf06b0ad1c8 100644
--- a/src/features/NavPanel/switcher/switcherItems.test.ts
+++ b/src/features/NavPanel/switcher/switcherItems.test.ts
@@ -50,4 +50,10 @@ describe('filterSwitcherItems', () => {
it('matches titles case-insensitively', () => {
expect(filterSwitcherItems(items, 'wr')).toEqual([item('2', 'Writing')]);
});
+
+ it('matches secondary titles case-insensitively', () => {
+ const roleItem = { id: '4', subtitle: 'Claude Code', title: 'Little C' };
+
+ expect(filterSwitcherItems([...items, roleItem], 'claude')).toEqual([roleItem]);
+ });
});
diff --git a/src/features/NavPanel/switcher/switcherItems.ts b/src/features/NavPanel/switcher/switcherItems.ts
index 36d36bae06b..3997cdbb2ad 100644
--- a/src/features/NavPanel/switcher/switcherItems.ts
+++ b/src/features/NavPanel/switcher/switcherItems.ts
@@ -3,6 +3,7 @@ export interface SwitcherItem {
background?: string;
id: string;
private?: boolean;
+ subtitle?: string;
title: string;
}
@@ -35,11 +36,15 @@ export const pickRecentItems = <T extends { id: string }>(
return out;
};
-export const filterSwitcherItems = <T extends { title: string }>(
+export const filterSwitcherItems = <T extends { subtitle?: string; title: string }>(
items: readonly T[],
query: string,
): T[] => {
const normalized = query.trim().toLowerCase();
if (!normalized) return [...items];
- return items.filter((item) => item.title.toLowerCase().includes(normalized));
+ return items.filter(
+ (item) =>
+ item.title.toLowerCase().includes(normalized) ||
+ item.subtitle?.toLowerCase().includes(normalized),
+ );
};