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.

✨feat: add agent-specific topic grouping mode and improve empty state… (#14225)

AmAzing-fa508f425926
diff --git a/e2e/src/steps/community/interactions.steps.ts b/e2e/src/steps/community/interactions.steps.ts
index 5376da12c31..02db9f083a3 100644
--- a/e2e/src/steps/community/interactions.steps.ts
+++ b/e2e/src/steps/community/interactions.steps.ts
@@ -1,7 +1,7 @@
import { Then, When } from '@cucumber/cucumber';
import { expect } from '@playwright/test';
-import { CustomWorld } from '../../support/world';
+import type { CustomWorld } from '../../support/world';
// ============================================
// When Steps (Actions)
@@ -143,7 +143,9 @@ When('I wait for the next page to load', async function (this: CustomWorld) {
When('I click on the first assistant card', async function (this: CustomWorld) {
await this.page.waitForLoadState('networkidle', { timeout: 30_000 });
- const firstCard = this.page.locator('[data-testid="assistant-item"]').first();
+ const firstCard = this.page
+ .locator('[data-testid="assistant-item"][data-agent-type="agent"]')
+ .first();
await firstCard.waitFor({ state: 'visible', timeout: 30_000 });
// Store the current URL before clicking
diff --git a/locales/en-US/discover.json b/locales/en-US/discover.json
index dc2193c463c..3172f4b501d 100644
--- a/locales/en-US/discover.json
+++ b/locales/en-US/discover.json
@@ -624,6 +624,8 @@
"user.logout": "Logout",
"user.myProfile": "My Profile",
"user.noAgents": "This user hasn’t published any Agents yet",
+ "user.noAgents.ownerDescription": "Create your first Agent and share it with the Community.",
+ "user.noAgents.title": "No Agents yet",
"user.noFavoriteAgents": "No saved Agents yet",
"user.noFavoritePlugins": "No saved Skills yet",
"user.noForkedAgentGroups": "No forked Agent Groups yet",
diff --git a/locales/zh-CN/discover.json b/locales/zh-CN/discover.json
index f777f063ab9..67ade395aaa 100644
--- a/locales/zh-CN/discover.json
+++ b/locales/zh-CN/discover.json
@@ -624,6 +624,8 @@
"user.logout": "退出登录",
"user.myProfile": "我的主页",
"user.noAgents": "该用户暂未发布助理",
+ "user.noAgents.ownerDescription": "创建你的第一个助理,分享到社区。",
+ "user.noAgents.title": "还没有助理",
"user.noFavoriteAgents": "暂无收藏的助理",
"user.noFavoritePlugins": "暂无收藏的插件",
"user.noForkedAgentGroups": "尚无已派生的代理组",
diff --git a/packages/types/src/agent/chatConfig.ts b/packages/types/src/agent/chatConfig.ts
index 4d62efeb1ed..35704dd16bc 100644
--- a/packages/types/src/agent/chatConfig.ts
+++ b/packages/types/src/agent/chatConfig.ts
@@ -1,8 +1,9 @@
import { z } from 'zod';
-import { type SearchMode } from '../search';
-import { type UserMemoryEffort } from '../user/settings/memory';
-import { type RuntimeEnvConfig } from './agentConfig';
+import type { SearchMode } from '../search';
+import type { TopicGroupMode } from '../topic';
+import type { UserMemoryEffort } from '../user/settings/memory';
+import type { RuntimeEnvConfig } from './agentConfig';
export interface WorkingModel {
model: string;
@@ -145,6 +146,11 @@ export interface LobeAgentChatConfig extends AgentMemoryChatConfig {
*/
toolResultMaxLength?: number;
+ /**
+ * Agent-specific topic list organization preference.
+ */
+ topicGroupMode?: TopicGroupMode;
+
urlContext?: boolean;
useModelBuiltinSearch?: boolean;
@@ -221,6 +227,7 @@ export const AgentChatConfigSchema = z
thinkingLevel4: z.enum(['minimal', 'high']).optional(),
thinkingLevel5: z.enum(['minimal', 'low', 'medium', 'high']).optional(),
toolResultMaxLength: z.number().default(25000),
+ topicGroupMode: z.enum(['byTime', 'byProject', 'flat']).optional(),
urlContext: z.boolean().optional(),
useModelBuiltinSearch: z.boolean().optional(),
})
diff --git a/src/locales/default/discover.ts b/src/locales/default/discover.ts
index 75505a892b1..93b71d8ea85 100644
--- a/src/locales/default/discover.ts
+++ b/src/locales/default/discover.ts
@@ -1147,6 +1147,10 @@ export default {
'user.noAgents': 'This user hasn’t published any Agents yet',
+ 'user.noAgents.ownerDescription': 'Create your first Agent and share it with the Community.',
+
+ 'user.noAgents.title': 'No Agents yet',
+
'user.noFavoriteAgents': 'No saved Agents yet',
'user.noFavoritePlugins': 'No saved Skills yet',
diff --git a/src/routes/(main)/agent/_layout/Sidebar/Topic/List/index.tsx b/src/routes/(main)/agent/_layout/Sidebar/Topic/List/index.tsx
index 4d8d91400af..3bef621a781 100644
--- a/src/routes/(main)/agent/_layout/Sidebar/Topic/List/index.tsx
+++ b/src/routes/(main)/agent/_layout/Sidebar/Topic/List/index.tsx
@@ -10,10 +10,9 @@ import { useFetchChatTopics } from '@/hooks/useFetchChatTopics';
import { useQueryRoute } from '@/hooks/useQueryRoute';
import { useChatStore } from '@/store/chat';
import { topicSelectors } from '@/store/chat/selectors';
-import { useUserStore } from '@/store/user';
-import { preferenceSelectors } from '@/store/user/selectors';
import AllTopicsDrawer from '../AllTopicsDrawer';
+import { useAgentTopicGroupMode } from '../hooks/useAgentTopicGroupMode';
import ByProjectMode from '../TopicListContent/ByProjectMode';
import ByTimeMode from '../TopicListContent/ByTimeMode';
import FlatMode from '../TopicListContent/FlatMode';
@@ -30,7 +29,7 @@ const TopicList = memo(() => {
s.closeAllTopicsDrawer,
]);
- const topicGroupMode = useUserStore(preferenceSelectors.topicGroupMode);
+ const { topicGroupMode } = useAgentTopicGroupMode();
useFetchChatTopics();
diff --git a/src/routes/(main)/agent/_layout/Sidebar/Topic/TopicListContent/GroupedAccordion.tsx b/src/routes/(main)/agent/_layout/Sidebar/Topic/TopicListContent/GroupedAccordion.tsx
index 0166b797e66..71431c18d82 100644
--- a/src/routes/(main)/agent/_layout/Sidebar/Topic/TopicListContent/GroupedAccordion.tsx
+++ b/src/routes/(main)/agent/_layout/Sidebar/Topic/TopicListContent/GroupedAccordion.tsx
@@ -16,6 +16,8 @@ import { useUserStore } from '@/store/user';
import { preferenceSelectors } from '@/store/user/selectors';
import { type GroupedTopic } from '@/types/topic';
+import { useAgentTopicGroupMode } from '../hooks/useAgentTopicGroupMode';
+
export interface GroupItemComponentProps {
activeThreadId?: string;
activeTopicId?: string;
@@ -30,7 +32,7 @@ const GroupedAccordion = memo<GroupedAccordionProps>(({ GroupItem }) => {
const { t } = useTranslation('topic');
const topicPageSize = useGlobalStore(systemStatusSelectors.topicPageSize);
const topicSortBy = useUserStore(preferenceSelectors.topicSortBy);
- const topicGroupMode = useUserStore(preferenceSelectors.topicGroupMode);
+ const { topicGroupMode } = useAgentTopicGroupMode();
const [hasMore, isExpandingPageSize, openAllTopicsDrawer] = useChatStore((s) => [
topicSelectors.hasMoreTopics(s),
diff --git a/src/routes/(main)/agent/_layout/Sidebar/Topic/TopicListContent/index.tsx b/src/routes/(main)/agent/_layout/Sidebar/Topic/TopicListContent/index.tsx
index fb484a5da86..cd3ae59ea5b 100644
--- a/src/routes/(main)/agent/_layout/Sidebar/Topic/TopicListContent/index.tsx
+++ b/src/routes/(main)/agent/_layout/Sidebar/Topic/TopicListContent/index.tsx
@@ -10,9 +10,8 @@ import { useFetchChatTopics } from '@/hooks/useFetchChatTopics';
import { useQueryRoute } from '@/hooks/useQueryRoute';
import { useChatStore } from '@/store/chat';
import { topicSelectors } from '@/store/chat/selectors';
-import { useUserStore } from '@/store/user';
-import { preferenceSelectors } from '@/store/user/selectors';
+import { useAgentTopicGroupMode } from '../hooks/useAgentTopicGroupMode';
import ByProjectMode from './ByProjectMode';
import ByTimeMode from './ByTimeMode';
import FlatMode from './FlatMode';
@@ -28,7 +27,7 @@ const TopicListContent = memo(() => {
topicSelectors.isInSearchMode(s),
]);
- const topicGroupMode = useUserStore(preferenceSelectors.topicGroupMode);
+ const { topicGroupMode } = useAgentTopicGroupMode();
useFetchChatTopics();
diff --git a/src/routes/(main)/agent/_layout/Sidebar/Topic/hooks/useAgentTopicGroupMode.ts b/src/routes/(main)/agent/_layout/Sidebar/Topic/hooks/useAgentTopicGroupMode.ts
new file mode 100644
index 00000000000..95a1028f9d8
--- /dev/null
+++ b/src/routes/(main)/agent/_layout/Sidebar/Topic/hooks/useAgentTopicGroupMode.ts
@@ -0,0 +1,39 @@
+import { useCallback, useMemo } from 'react';
+
+import { useAgentStore } from '@/store/agent';
+import { agentSelectors } from '@/store/agent/selectors';
+import { useUserStore } from '@/store/user';
+import { preferenceSelectors } from '@/store/user/selectors';
+import type { TopicGroupMode } from '@/types/topic';
+
+import { resolveAgentTopicGroupMode } from '../utils/topicGroupMode';
+
+export const useAgentTopicGroupMode = () => {
+ const agentType = useAgentStore(agentSelectors.currentAgentHeterogeneousProviderType);
+ const agentTopicGroupMode = useAgentStore(
+ (s) => agentSelectors.currentAgentConfig(s)?.chatConfig?.topicGroupMode,
+ );
+ const updateAgentChatConfig = useAgentStore((s) => s.updateAgentChatConfig);
+ const globalMode = useUserStore(preferenceSelectors.topicGroupMode);
+
+ const topicGroupMode = resolveAgentTopicGroupMode({
+ agentTopicGroupMode,
+ agentType,
+ globalMode,
+ });
+
+ const updateTopicGroupMode = useCallback(
+ async (mode: TopicGroupMode) => {
+ await updateAgentChatConfig({ topicGroupMode: mode });
+ },
+ [updateAgentChatConfig],
+ );
+
+ return useMemo(
+ () => ({
+ topicGroupMode,
+ updateTopicGroupMode,
+ }),
+ [topicGroupMode, updateTopicGroupMode],
+ );
+};
diff --git a/src/routes/(main)/agent/_layout/Sidebar/Topic/useFilterMenu.tsx b/src/routes/(main)/agent/_layout/Sidebar/Topic/useFilterMenu.tsx
index 7d9a6ab547d..bd1356d2f7b 100644
--- a/src/routes/(main)/agent/_layout/Sidebar/Topic/useFilterMenu.tsx
+++ b/src/routes/(main)/agent/_layout/Sidebar/Topic/useFilterMenu.tsx
@@ -8,17 +8,17 @@ import { useUserStore } from '@/store/user';
import { preferenceSelectors } from '@/store/user/selectors';
import type { TopicGroupMode, TopicSortBy } from '@/types/topic';
+import { useAgentTopicGroupMode } from './hooks/useAgentTopicGroupMode';
+
export const useTopicFilterDropdownMenu = (): DropdownItem[] => {
const { t } = useTranslation('topic');
+ const { topicGroupMode, updateTopicGroupMode } = useAgentTopicGroupMode();
- const [topicGroupMode, topicSortBy, topicIncludeCompleted, updatePreference] = useUserStore(
- (s) => [
- preferenceSelectors.topicGroupMode(s),
- preferenceSelectors.topicSortBy(s),
- preferenceSelectors.topicIncludeCompleted(s),
- s.updatePreference,
- ],
- );
+ const [topicSortBy, topicIncludeCompleted, updatePreference] = useUserStore((s) => [
+ preferenceSelectors.topicSortBy(s),
+ preferenceSelectors.topicIncludeCompleted(s),
+ s.updatePreference,
+ ]);
return useMemo(() => {
const groupModes: TopicGroupMode[] = ['byTime', 'byProject', 'flat'];
@@ -31,7 +31,7 @@ export const useTopicFilterDropdownMenu = (): DropdownItem[] => {
key: `group-${mode}`,
label: t(`filter.groupMode.${mode}`),
onClick: () => {
- updatePreference({ topicGroupMode: mode });
+ void updateTopicGroupMode(mode);
},
})),
key: 'organize',
@@ -69,5 +69,12 @@ export const useTopicFilterDropdownMenu = (): DropdownItem[] => {
type: 'group' as const,
},
];
- }, [topicGroupMode, topicSortBy, topicIncludeCompleted, updatePreference, t]);
+ }, [
+ topicGroupMode,
+ topicSortBy,
+ topicIncludeCompleted,
+ updatePreference,
+ updateTopicGroupMode,
+ t,
+ ]);
};
diff --git a/src/routes/(main)/agent/_layout/Sidebar/Topic/utils/topicGroupMode.test.ts b/src/routes/(main)/agent/_layout/Sidebar/Topic/utils/topicGroupMode.test.ts
new file mode 100644
index 00000000000..8a13d6df0b2
--- /dev/null
+++ b/src/routes/(main)/agent/_layout/Sidebar/Topic/utils/topicGroupMode.test.ts
@@ -0,0 +1,50 @@
+import { describe, expect, it } from 'vitest';
+
+import { resolveAgentTopicGroupMode } from './topicGroupMode';
+
+describe('resolveAgentTopicGroupMode', () => {
+ it('defaults Claude Code agents to project grouping', () => {
+ expect(
+ resolveAgentTopicGroupMode({
+ agentType: 'claude-code',
+ globalMode: 'byTime',
+ }),
+ ).toBe('byProject');
+ });
+
+ it('defaults Codex agents to project grouping', () => {
+ expect(
+ resolveAgentTopicGroupMode({
+ agentType: 'codex',
+ globalMode: 'byTime',
+ }),
+ ).toBe('byProject');
+ });
+
+ it('keeps normal agents on the global default grouping', () => {
+ expect(resolveAgentTopicGroupMode({ globalMode: 'byTime' })).toBe('byTime');
+ });
+
+ it('keeps Claude Code agents on project grouping when the global selection changes', () => {
+ expect(
+ resolveAgentTopicGroupMode({
+ agentType: 'claude-code',
+ globalMode: 'flat',
+ }),
+ ).toBe('byProject');
+ });
+
+ it('uses the global selection for normal agents', () => {
+ expect(resolveAgentTopicGroupMode({ globalMode: 'flat' })).toBe('flat');
+ });
+
+ it('uses the agent chat config selection when present', () => {
+ expect(
+ resolveAgentTopicGroupMode({
+ agentTopicGroupMode: 'byTime',
+ agentType: 'codex',
+ globalMode: 'byTime',
+ }),
+ ).toBe('byTime');
+ });
+});
diff --git a/src/routes/(main)/agent/_layout/Sidebar/Topic/utils/topicGroupMode.ts b/src/routes/(main)/agent/_layout/Sidebar/Topic/utils/topicGroupMode.ts
new file mode 100644
index 00000000000..728e12e97c2
--- /dev/null
+++ b/src/routes/(main)/agent/_layout/Sidebar/Topic/utils/topicGroupMode.ts
@@ -0,0 +1,32 @@
+import type { HeterogeneousProviderConfig } from '@lobechat/types';
+
+import type { TopicGroupMode } from '@/types/topic';
+
+type HeterogeneousAgentType = HeterogeneousProviderConfig['type'];
+
+const PROJECT_DEFAULT_HETEROGENEOUS_AGENT_TYPES = new Set<HeterogeneousAgentType>([
+ 'claude-code',
+ 'codex',
+]);
+
+export const getDefaultTopicGroupModeByAgentType = (
+ fallbackMode: TopicGroupMode,
+ agentType?: HeterogeneousAgentType,
+): TopicGroupMode =>
+ agentType && PROJECT_DEFAULT_HETEROGENEOUS_AGENT_TYPES.has(agentType)
+ ? 'byProject'
+ : fallbackMode;
+
+export const resolveAgentTopicGroupMode = ({
+ agentTopicGroupMode,
+ agentType,
+ globalMode,
+}: {
+ agentTopicGroupMode?: TopicGroupMode;
+ agentType?: HeterogeneousAgentType;
+ globalMode: TopicGroupMode;
+}): TopicGroupMode => {
+ if (agentTopicGroupMode) return agentTopicGroupMode;
+
+ return getDefaultTopicGroupModeByAgentType(globalMode, agentType);
+};
diff --git a/src/routes/(main)/community/(detail)/user/features/UserAgentList.tsx b/src/routes/(main)/community/(detail)/user/features/UserAgentList.tsx
index f48820d517c..9f96974e5ad 100644
--- a/src/routes/(main)/community/(detail)/user/features/UserAgentList.tsx
+++ b/src/routes/(main)/community/(detail)/user/features/UserAgentList.tsx
@@ -68,7 +68,13 @@ const UserAgentList = memo<UserAgentListProps>(({ rows = 4, pageSize = 8 }) => {
setCurrentPage(1);
}, [statusFilter, searchQuery]);
- if (agents.length === 0 && forkedAgents.length === 0) return <AssistantEmpty />;
+ if (agents.length === 0 && forkedAgents.length === 0)
+ return (
+ <AssistantEmpty
+ description={isOwner ? t('user.noAgents.ownerDescription') : t('user.noAgents')}
+ title={t('user.noAgents.title')}
+ />
+ );
const showPagination = filteredAgents.length > pageSize;
diff --git a/src/routes/(main)/community/(list)/agent/features/List/Item.tsx b/src/routes/(main)/community/(list)/agent/features/List/Item.tsx
index 6aee238a506..a75656c87a2 100644
--- a/src/routes/(main)/community/(list)/agent/features/List/Item.tsx
+++ b/src/routes/(main)/community/(list)/agent/features/List/Item.tsx
@@ -111,6 +111,7 @@ const AssistantItem = memo<DiscoverAssistantItem>(
return (
<Block
clickable
+ data-agent-type={type ?? 'agent'}
data-testid="assistant-item"
height={'100%'}
variant={'outlined'}
diff --git a/src/server/workflows/agentSignal/__tests__/run.test.ts b/src/server/workflows/agentSignal/__tests__/run.test.ts
index 7dec8cc094d..7fbb3b8f808 100644
--- a/src/server/workflows/agentSignal/__tests__/run.test.ts
+++ b/src/server/workflows/agentSignal/__tests__/run.test.ts
@@ -226,7 +226,7 @@ describe('runAgentSignalWorkflow', () => {
expect(capturedSourceEvent?.payload.serializedContext).not.toContain(
'Future assistant reply that should be excluded from the anchored root context.',
);
- });
+ }, 10_000);
it('assembles serializedContext from the matching thread before executing a threaded source event', async () => {
const db = await getTestDB();
diff --git a/src/store/agent/selectors/selectors.ts b/src/store/agent/selectors/selectors.ts
index 0e5decc0dd5..00a71352000 100644
--- a/src/store/agent/selectors/selectors.ts
+++ b/src/store/agent/selectors/selectors.ts
@@ -291,10 +291,14 @@ const isCurrentAgentExternal = (s: AgentStoreState): boolean => !currentAgentDat
const isCurrentAgentHeterogeneous = (s: AgentStoreState): boolean =>
!!currentAgentConfig(s)?.agencyConfig?.heterogeneousProvider;
+const currentAgentHeterogeneousProviderType = (s: AgentStoreState) =>
+ currentAgentConfig(s)?.agencyConfig?.heterogeneousProvider?.type;
+
const getAgentDocumentsById = (agentId: string) => (s: AgentStoreState) =>
s.agentDocumentsMap[agentId];
export const agentSelectors = {
+ currentAgentHeterogeneousProviderType,
currentAgentAvatar,
currentAgentBackgroundColor,
currentAgentConfig,