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(agent): move agent mail into a Profile page under an Identity group (#22634)

Arvin Xu707893c4b5da
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index 4b443776b92..5479c4f3570 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -2361,9 +2361,11 @@
"supervisor.label": "Orchestrator",
"supervisor.todoList.allComplete": "All tasks completed",
"supervisor.todoList.title": "Tasks Completed",
- "tab.groupProfile": "Group Profile",
"tab.backToChat": "Back to chat",
+ "tab.group.identity": "Identity",
+ "tab.groupProfile": "Group Profile",
"tab.integration": "IM Bots",
+ "tab.mail": "Mail",
"tab.profile": "Agent Profile",
"tab.profileBasic": "Profile",
"tab.search": "Search",
diff --git a/locales/en-US/electron.json b/locales/en-US/electron.json
index bd18849e80d..d0a87d57969 100644
--- a/locales/en-US/electron.json
+++ b/locales/en-US/electron.json
@@ -37,6 +37,7 @@
"navigation.image": "Image",
"navigation.knowledgeBase": "Knowledge Base",
"navigation.lobehub": "LobeHub",
+ "navigation.mail": "Mail",
"navigation.memory": "Memory",
"navigation.memoryContexts": "Memory - Contexts",
"navigation.memoryIdentities": "Memory - Identities",
diff --git a/locales/en-US/setting.json b/locales/en-US/setting.json
index 1321d7f4d01..d2440e539a7 100644
--- a/locales/en-US/setting.json
+++ b/locales/en-US/setting.json
@@ -216,7 +216,6 @@
"agentSkillModal.url.urlPlaceholder": "https://example.com/path/to/SKILL.md",
"agentSkillTag": "Agent Skill",
"agentTab.graph": "Graph Runtime",
- "agentTab.identity": "Identity",
"agentTab.opening": "Opening Settings",
"agentTab.plugin": "Skill Settings",
"agentTab.prompt": "Agent Profile",
@@ -1072,7 +1071,7 @@
"identity.status.provisioning": "Opening",
"identity.status.revoked": "Released",
"identity.status.suspended": "Suspended",
- "identity.title": "Identity",
+ "identity.title": "Addresses",
"llm.aesGcm": "Your keys and proxy address will be encrypted using the <1>AES-GCM</1> encryption algorithm",
"llm.apiKey.desc": "Please enter your {{name}} API Key",
"llm.apiKey.placeholder": "{{name}} API Key",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index e1582da6272..6e6fd5f4e70 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -2361,9 +2361,11 @@
"supervisor.label": "主管",
"supervisor.todoList.allComplete": "所有任务已完成",
"supervisor.todoList.title": "任务完成",
- "tab.groupProfile": "群组档案",
"tab.backToChat": "返回对话",
+ "tab.group.identity": "身份",
+ "tab.groupProfile": "群组档案",
"tab.integration": "IM 机器人",
+ "tab.mail": "邮箱",
"tab.profile": "助理档案",
"tab.profileBasic": "基础档案",
"tab.search": "搜索",
diff --git a/locales/zh-CN/electron.json b/locales/zh-CN/electron.json
index 7301e2b6e72..8ce525b860e 100644
--- a/locales/zh-CN/electron.json
+++ b/locales/zh-CN/electron.json
@@ -37,6 +37,7 @@
"navigation.image": "图像",
"navigation.knowledgeBase": "知识库",
"navigation.lobehub": "LobeHub",
+ "navigation.mail": "邮箱",
"navigation.memory": "记忆",
"navigation.memoryContexts": "记忆 - 上下文",
"navigation.memoryIdentities": "记忆 - 身份",
diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.json
index 8246a0891a9..f560415a447 100644
--- a/locales/zh-CN/setting.json
+++ b/locales/zh-CN/setting.json
@@ -216,7 +216,6 @@
"agentSkillModal.url.urlPlaceholder": "https://example.com/path/to/SKILL.md",
"agentSkillTag": "Agent 技能",
"agentTab.graph": "Graph 运行时",
- "agentTab.identity": "身份",
"agentTab.opening": "开场设置",
"agentTab.plugin": "技能设置",
"agentTab.prompt": "助理档案",
@@ -1072,7 +1071,7 @@
"identity.status.provisioning": "开通中",
"identity.status.revoked": "已释放",
"identity.status.suspended": "已暂停",
- "identity.title": "身份",
+ "identity.title": "邮箱地址",
"llm.aesGcm": "你的密钥与代理地址等将使用 <1>AES-GCM</1> 加密算法进行加密",
"llm.apiKey.desc": "请填写你的 {{name}} API Key",
"llm.apiKey.placeholder": "{{name}} API Key",
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index 400382ec756..85581a8aeda 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -1968,7 +1968,9 @@ export default {
'supervisor.todoList.title': 'Tasks Completed',
'tab.groupProfile': 'Group Profile',
'tab.backToChat': 'Back to chat',
+ 'tab.group.identity': 'Identity',
'tab.integration': 'IM Bots',
+ 'tab.mail': 'Mail',
'tab.profile': 'Agent Profile',
'tab.profileBasic': 'Profile',
'tab.search': 'Search',
diff --git a/packages/locales/src/default/electron.ts b/packages/locales/src/default/electron.ts
index 49ac1e9dfe6..3cafa559850 100644
--- a/packages/locales/src/default/electron.ts
+++ b/packages/locales/src/default/electron.ts
@@ -29,6 +29,7 @@ export default {
'navigation.image': 'Image',
'navigation.knowledgeBase': 'Knowledge Base',
'navigation.lobehub': 'LobeHub',
+ 'navigation.mail': 'Mail',
'navigation.memory': 'Memory',
'navigation.memoryContexts': 'Memory - Contexts',
'navigation.memoryIdentities': 'Memory - Identities',
diff --git a/packages/locales/src/default/setting.ts b/packages/locales/src/default/setting.ts
index dc70b0a1cb4..4591aa54304 100644
--- a/packages/locales/src/default/setting.ts
+++ b/packages/locales/src/default/setting.ts
@@ -328,7 +328,6 @@ export default {
'agentSkillModal.url.urlPlaceholder': 'https://example.com/path/to/SKILL.md',
'agentSkillTag': 'Agent Skill',
'agentTab.graph': 'Graph Runtime',
- 'agentTab.identity': 'Identity',
'agentTab.opening': 'Opening Settings',
'agentTab.plugin': 'Skill Settings',
'agentTab.prompt': 'Agent Profile',
@@ -373,7 +372,7 @@ export default {
'identity.status.provisioning': 'Opening',
'identity.status.revoked': 'Released',
'identity.status.suspended': 'Suspended',
- 'identity.title': 'Identity',
+ 'identity.title': 'Addresses',
'permission.accessTag.useOnlyTip':
'Your member permission here is "Can use" — you can view and use it, but not edit. Ask the creator or a workspace owner for edit access.',
'permission.accessTag.viewOnlyTip':
diff --git a/src/features/AgentSetting/AgentIdentity/AccountCard.tsx b/src/features/AgentMail/AccountCard.tsx
similarity index 100%
rename from src/features/AgentSetting/AgentIdentity/AccountCard.tsx
rename to src/features/AgentMail/AccountCard.tsx
diff --git a/src/features/AgentSetting/AgentIdentity/IdentityAccounts.tsx b/src/features/AgentMail/IdentityAccounts.tsx
similarity index 100%
rename from src/features/AgentSetting/AgentIdentity/IdentityAccounts.tsx
rename to src/features/AgentMail/IdentityAccounts.tsx
diff --git a/src/features/AgentSetting/AgentIdentity/InboxMessageModal.tsx b/src/features/AgentMail/InboxMessageModal.tsx
similarity index 100%
rename from src/features/AgentSetting/AgentIdentity/InboxMessageModal.tsx
rename to src/features/AgentMail/InboxMessageModal.tsx
diff --git a/src/features/AgentSetting/AgentIdentity/InboxSection.tsx b/src/features/AgentMail/InboxSection.tsx
similarity index 100%
rename from src/features/AgentSetting/AgentIdentity/InboxSection.tsx
rename to src/features/AgentMail/InboxSection.tsx
diff --git a/src/features/AgentSetting/AgentIdentity/InlineError.tsx b/src/features/AgentMail/InlineError.tsx
similarity index 100%
rename from src/features/AgentSetting/AgentIdentity/InlineError.tsx
rename to src/features/AgentMail/InlineError.tsx
diff --git a/src/features/AgentSetting/AgentIdentity/ProvisionCard.tsx b/src/features/AgentMail/ProvisionCard.tsx
similarity index 100%
rename from src/features/AgentSetting/AgentIdentity/ProvisionCard.tsx
rename to src/features/AgentMail/ProvisionCard.tsx
diff --git a/src/features/AgentSetting/AgentIdentity/SectionHeader.tsx b/src/features/AgentMail/SectionHeader.tsx
similarity index 100%
rename from src/features/AgentSetting/AgentIdentity/SectionHeader.tsx
rename to src/features/AgentMail/SectionHeader.tsx
diff --git a/src/features/AgentSetting/AgentIdentity/const.test.ts b/src/features/AgentMail/const.test.ts
similarity index 97%
rename from src/features/AgentSetting/AgentIdentity/const.test.ts
rename to src/features/AgentMail/const.test.ts
index 88242d2d7b2..bc87e316501 100644
--- a/src/features/AgentSetting/AgentIdentity/const.test.ts
+++ b/src/features/AgentMail/const.test.ts
@@ -1,7 +1,7 @@
import { AGENT_ACCOUNT_PERSISTED_KINDS } from '@lobechat/types';
import { describe, expect, it } from 'vitest';
-import { IDENTITY_CHANNELS, isChannelAccount, isUnchanneledAccount,KIND_ICONS } from './const';
+import { IDENTITY_CHANNELS, isChannelAccount, isUnchanneledAccount, KIND_ICONS } from './const';
const mailChannel = IDENTITY_CHANNELS.find((channel) => channel.provider === 'agent-mail')!;
diff --git a/src/features/AgentSetting/AgentIdentity/const.tsx b/src/features/AgentMail/const.tsx
similarity index 97%
rename from src/features/AgentSetting/AgentIdentity/const.tsx
rename to src/features/AgentMail/const.tsx
index 2211c6959e4..88025318a84 100644
--- a/src/features/AgentSetting/AgentIdentity/const.tsx
+++ b/src/features/AgentMail/const.tsx
@@ -3,7 +3,7 @@ import type { LucideIcon } from 'lucide-react';
import { KeyRound, Mail, Phone, Wallet } from 'lucide-react';
/**
- * One address channel the identity tab can open.
+ * One address channel the mail page can open.
*
* The pair (kind, provider) is what the control plane is asked for; the icon
* and copy are presentation. `prefixable` marks the channels where the caller
diff --git a/src/features/AgentSetting/AgentIdentity/identityUi.test.tsx b/src/features/AgentMail/identityUi.test.tsx
similarity index 100%
rename from src/features/AgentSetting/AgentIdentity/identityUi.test.tsx
rename to src/features/AgentMail/identityUi.test.tsx
diff --git a/src/features/AgentMail/index.tsx b/src/features/AgentMail/index.tsx
new file mode 100644
index 00000000000..bc3aa24eae0
--- /dev/null
+++ b/src/features/AgentMail/index.tsx
@@ -0,0 +1,60 @@
+'use client';
+
+import { Flexbox } from '@lobehub/ui';
+
+import AgentBreadcrumb from '@/features/AgentBreadcrumb';
+import AgentProfileTabs, { AGENT_PROFILE_TABS_CENTER_STYLE } from '@/features/AgentProfileTabs';
+import NavHeader from '@/features/NavHeader';
+import WideScreenContainer from '@/features/WideScreenContainer';
+import { StyleSheet } from '@/utils/styles';
+
+import IdentityAccounts from './IdentityAccounts';
+import InboxSection from './InboxSection';
+
+const styles = StyleSheet.create({
+ body: {
+ display: 'flex',
+ overflowY: 'auto',
+ position: 'relative',
+ },
+});
+
+interface AgentMailProps {
+ agentId: string;
+ /** Read-only viewer: addresses and mail stay readable, nothing can be opened or released. */
+ disabled?: boolean;
+}
+
+/**
+ * The agent's mail page: which addresses it owns, and what has arrived.
+ *
+ * Two sections rather than two tabs, because they answer one question — "is
+ * anyone reaching this agent, and through what?" — and the inbox is only
+ * meaningful next to the addresses that received it.
+ */
+const AgentMail = ({ agentId, disabled }: AgentMailProps) => (
+ <Flexbox height={'100%'} width={'100%'}>
+ <NavHeader
+ left={<AgentBreadcrumb agentId={agentId} />}
+ // `relative` anchors the absolutely-centered switcher below.
+ style={{ position: 'relative' }}
+ styles={{
+ // Center on the header midpoint (equal gaps), not the leftover track.
+ center: AGENT_PROFILE_TABS_CENTER_STYLE,
+ left: { minWidth: 0, paddingInlineStart: 8 },
+ }}
+ >
+ <AgentProfileTabs active={'mail'} agentId={agentId} />
+ </NavHeader>
+ <Flexbox flex={1} style={styles.body} width={'100%'}>
+ <WideScreenContainer>
+ <Flexbox gap={24} paddingBlock={16}>
+ <IdentityAccounts agentId={agentId} disabled={disabled} />
+ <InboxSection agentId={agentId} />
+ </Flexbox>
+ </WideScreenContainer>
+ </Flexbox>
+ </Flexbox>
+);
+
+export default AgentMail;
diff --git a/src/features/AgentSetting/AgentIdentity/styles.ts b/src/features/AgentMail/styles.ts
similarity index 97%
rename from src/features/AgentSetting/AgentIdentity/styles.ts
rename to src/features/AgentMail/styles.ts
index 7f238e594a4..05b0639a012 100644
--- a/src/features/AgentSetting/AgentIdentity/styles.ts
+++ b/src/features/AgentMail/styles.ts
@@ -2,7 +2,7 @@ import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
/**
- * Shared surfaces for the identity tab.
+ * Shared surfaces for the mail page.
*
* Filled-and-rounded rather than outlined: a border here would read as a
* card-inside-a-card boundary (the settings panel is already the container),
diff --git a/src/features/AgentSetting/AgentIdentity/useAgentIdentity.test.ts b/src/features/AgentMail/useAgentIdentity.test.ts
similarity index 100%
rename from src/features/AgentSetting/AgentIdentity/useAgentIdentity.test.ts
rename to src/features/AgentMail/useAgentIdentity.test.ts
diff --git a/src/features/AgentSetting/AgentIdentity/useAgentIdentity.ts b/src/features/AgentMail/useAgentIdentity.ts
similarity index 100%
rename from src/features/AgentSetting/AgentIdentity/useAgentIdentity.ts
rename to src/features/AgentMail/useAgentIdentity.ts
diff --git a/src/features/AgentSetting/AgentIdentity/useIdentityActions.test.ts b/src/features/AgentMail/useIdentityActions.test.ts
similarity index 100%
rename from src/features/AgentSetting/AgentIdentity/useIdentityActions.test.ts
rename to src/features/AgentMail/useIdentityActions.test.ts
diff --git a/src/features/AgentSetting/AgentIdentity/useIdentityActions.tsx b/src/features/AgentMail/useIdentityActions.tsx
similarity index 100%
rename from src/features/AgentSetting/AgentIdentity/useIdentityActions.tsx
rename to src/features/AgentMail/useIdentityActions.tsx
diff --git a/src/features/AgentMail/useShowAgentIdentity.test.tsx b/src/features/AgentMail/useShowAgentIdentity.test.tsx
new file mode 100644
index 00000000000..45f314706f9
--- /dev/null
+++ b/src/features/AgentMail/useShowAgentIdentity.test.tsx
@@ -0,0 +1,86 @@
+import { renderHook, waitFor } from '@testing-library/react';
+import type { ReactNode } from 'react';
+import { SWRConfig } from 'swr';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { useShowAgentIdentity } from './useShowAgentIdentity';
+
+const mocks = vi.hoisted(() => ({
+ serverState: { serverConfig: { agentIdentityProviders: [] as string[] } },
+ userState: { preference: { lab: { enableAgentIdentity: false } } },
+}));
+
+const accountService = vi.hoisted(() => ({ list: vi.fn(async () => [] as unknown[]) }));
+vi.mock('@/services/agentAccount', () => ({ agentAccountService: accountService }));
+
+vi.mock('@/store/serverConfig', () => ({
+ useServerConfigStore: (selector: (state: typeof mocks.serverState) => unknown) =>
+ selector(mocks.serverState),
+}));
+
+vi.mock('@/store/serverConfig/selectors', () => ({
+ serverConfigSelectors: {
+ agentIdentityProviders: (state: typeof mocks.serverState) =>
+ state.serverConfig.agentIdentityProviders,
+ },
+}));
+
+vi.mock('@/store/user', () => ({
+ useUserStore: (selector: (state: typeof mocks.userState) => unknown) => selector(mocks.userState),
+}));
+
+vi.mock('@/store/user/selectors', () => ({
+ labPreferSelectors: {
+ enableAgentIdentity: (state: typeof mocks.userState) =>
+ state.preference.lab.enableAgentIdentity,
+ },
+}));
+
+const wrapper = ({ children }: { children: ReactNode }) => (
+ <SWRConfig value={{ dedupingInterval: 0, provider: () => new Map() }}>{children}</SWRConfig>
+);
+
+describe('useShowAgentIdentity', () => {
+ beforeEach(() => {
+ accountService.list.mockClear();
+ mocks.userState.preference.lab.enableAgentIdentity = false;
+ mocks.serverState.serverConfig.agentIdentityProviders = [];
+ });
+
+ it('needs the Labs toggle even with a provider configured', () => {
+ mocks.serverState.serverConfig.agentIdentityProviders = ['agent-mail'];
+
+ const { result } = renderHook(() => useShowAgentIdentity('agt_1'), { wrapper });
+
+ expect(result.current).toBe(false);
+ });
+
+ it('shows with the Labs toggle on and a provider configured', () => {
+ mocks.userState.preference.lab.enableAgentIdentity = true;
+ mocks.serverState.serverConfig.agentIdentityProviders = ['agent-mail'];
+
+ const { result } = renderHook(() => useShowAgentIdentity('agt_1'), { wrapper });
+
+ expect(result.current).toBe(true);
+ });
+
+ it('hides when the deployment has no provider and the agent owns no address', () => {
+ mocks.userState.preference.lab.enableAgentIdentity = true;
+
+ const { result } = renderHook(() => useShowAgentIdentity('agt_1'), { wrapper });
+
+ expect(result.current).toBe(false);
+ });
+
+ it('stays reachable for an agent that already owns an address, even with no provider', async () => {
+ mocks.userState.preference.lab.enableAgentIdentity = true;
+ accountService.list.mockResolvedValueOnce([
+ { id: 'acc_1', identifier: '[email protected]', status: 'active' },
+ ]);
+
+ const { result } = renderHook(() => useShowAgentIdentity('agt_1'), { wrapper });
+
+ await waitFor(() => expect(result.current).toBe(true));
+ expect(accountService.list).toHaveBeenCalledWith({ agentId: 'agt_1' });
+ });
+});
diff --git a/src/features/AgentSetting/AgentIdentity/useShowAgentIdentity.ts b/src/features/AgentMail/useShowAgentIdentity.ts
similarity index 79%
rename from src/features/AgentSetting/AgentIdentity/useShowAgentIdentity.ts
rename to src/features/AgentMail/useShowAgentIdentity.ts
index 9502603a95a..a7dfe6ad74c 100644
--- a/src/features/AgentSetting/AgentIdentity/useShowAgentIdentity.ts
+++ b/src/features/AgentMail/useShowAgentIdentity.ts
@@ -1,4 +1,3 @@
-import { useAgentStore } from '@/store/agent';
import { useServerConfigStore } from '@/store/serverConfig';
import { serverConfigSelectors } from '@/store/serverConfig/selectors';
import { useUserStore } from '@/store/user';
@@ -7,7 +6,7 @@ import { labPreferSelectors } from '@/store/user/selectors';
import { useAgentAccounts } from './useAgentIdentity';
/**
- * Whether the identity tab has anything to offer: the user opted into the Labs
+ * Whether the mail page has anything to offer: the user opted into the Labs
* experiment, and either this deployment can open an address (a provider is
* configured) or the agent already owns one.
*
@@ -15,19 +14,18 @@ import { useAgentAccounts } from './useAgentIdentity';
* address that already exists must stay reachable after its provider's
* credentials are removed, so it can still be read, copied and released.
*/
-export const useShowAgentIdentity = (): boolean => {
+export const useShowAgentIdentity = (agentId: string): boolean => {
const enabled = useUserStore(labPreferSelectors.enableAgentIdentity);
const providers = useServerConfigStore(serverConfigSelectors.agentIdentityProviders);
- const agentId = useAgentStore((s) => s.activeAgentId);
// Only ask for the agent's accounts when they are what decides it.
const needsAccounts = enabled && providers.length === 0 && !!agentId;
- const { data: accounts, error } = useAgentAccounts(needsAccounts ? agentId! : '');
+ const { data: accounts, error } = useAgentAccounts(needsAccounts ? agentId : '');
if (!enabled) return false;
if (providers.length > 0) return true;
// The read that decides it failed: the agent may own an address, so keep the
- // tab — it shows the failure and a retry — rather than hide it on a guess.
+ // entry — the page shows the failure and a retry — rather than hide it on a guess.
if (error && !accounts) return true;
return (accounts ?? []).some((account) => account.status !== 'revoked');
diff --git a/src/features/AgentProfileTabs/tabOptions.test.ts b/src/features/AgentProfileTabs/tabOptions.test.ts
index 8879330abb9..f045140e983 100644
--- a/src/features/AgentProfileTabs/tabOptions.test.ts
+++ b/src/features/AgentProfileTabs/tabOptions.test.ts
@@ -4,10 +4,12 @@ import {
buildAgentProfileTabOptions,
buildAgentProfileTabPath,
getAgentProfileTab,
+ groupAgentProfileTabOptions,
} from './tabOptions';
const labels = {
channel: 'tab.integration',
+ mail: 'tab.mail',
profile: 'tab.profile',
share: 'share',
statistics: 'usageStats.title',
@@ -22,6 +24,7 @@ describe('buildAgentProfileTabPath', () => {
describe('getAgentProfileTab', () => {
it.each([
['/agent/agt_1/profile', 'profile'],
+ ['/agent/agt_1/mail', 'mail'],
['/agent/agt_1/channel/slack', 'channel'],
['/acme/agent/agt_1/statistics/', 'statistics'],
['/_dangerous_local_dev_proxy/acme/agent/agt_1/share', 'share'],
@@ -43,6 +46,7 @@ describe('buildAgentProfileTabOptions', () => {
active: 'profile',
canConfigure: true,
labels,
+ mailSupported: false,
shareSupported: true,
});
@@ -59,6 +63,7 @@ describe('buildAgentProfileTabOptions', () => {
active: 'profile',
canConfigure: true,
labels,
+ mailSupported: false,
shareSupported: false,
});
@@ -70,6 +75,7 @@ describe('buildAgentProfileTabOptions', () => {
active: 'statistics',
canConfigure: false,
labels,
+ mailSupported: false,
shareSupported: true,
});
@@ -81,6 +87,7 @@ describe('buildAgentProfileTabOptions', () => {
active: 'channel',
canConfigure: false,
labels,
+ mailSupported: false,
shareSupported: false,
});
@@ -92,9 +99,65 @@ describe('buildAgentProfileTabOptions', () => {
active: 'share',
canConfigure: false,
labels,
+ mailSupported: false,
shareSupported: false,
});
expect(options.map((option) => option.value)).toEqual(['statistics', 'share']);
});
+
+ it('lists mail after the profile only where it is supported', () => {
+ const options = buildAgentProfileTabOptions({
+ active: 'profile',
+ canConfigure: true,
+ labels,
+ mailSupported: true,
+ shareSupported: false,
+ });
+
+ expect(options.map((option) => option.value)).toEqual([
+ 'profile',
+ 'mail',
+ 'channel',
+ 'statistics',
+ ]);
+ });
+
+ it('drops mail for a member without edit access', () => {
+ const options = buildAgentProfileTabOptions({
+ active: 'statistics',
+ canConfigure: false,
+ labels,
+ mailSupported: true,
+ shareSupported: false,
+ });
+
+ expect(options.map((option) => option.value)).toEqual(['statistics']);
+ });
+});
+
+describe('groupAgentProfileTabOptions', () => {
+ const option = (value: 'channel' | 'mail' | 'profile' | 'share' | 'statistics') => ({
+ label: value,
+ value,
+ });
+
+ it('puts the profile, mail and IM bots under identity', () => {
+ const groups = groupAgentProfileTabOptions(
+ ['profile', 'mail', 'channel', 'statistics', 'share'].map((value) =>
+ option(value as Parameters<typeof option>[0]),
+ ),
+ );
+
+ expect(groups.map((group) => [group.key, group.options.map((item) => item.value)])).toEqual([
+ ['identity', ['profile', 'mail', 'channel']],
+ ['general', ['statistics', 'share']],
+ ]);
+ });
+
+ it('leaves out a group with nothing to open', () => {
+ const groups = groupAgentProfileTabOptions([option('statistics')]);
+
+ expect(groups.map((group) => group.key)).toEqual(['general']);
+ });
});
diff --git a/src/features/AgentProfileTabs/tabOptions.ts b/src/features/AgentProfileTabs/tabOptions.ts
index 149cc81e55d..022f9171bf5 100644
--- a/src/features/AgentProfileTabs/tabOptions.ts
+++ b/src/features/AgentProfileTabs/tabOptions.ts
@@ -1,17 +1,24 @@
import urlJoin from 'url-join';
-export type AgentProfileTab = 'channel' | 'profile' | 'share' | 'statistics';
+export type AgentProfileTab = 'channel' | 'mail' | 'profile' | 'share' | 'statistics';
export interface AgentProfileTabOption {
label: string;
value: AgentProfileTab;
}
+export type AgentProfileTabGroupKey = 'general' | 'identity';
+
+export interface AgentProfileTabGroup {
+ key: AgentProfileTabGroupKey;
+ options: AgentProfileTabOption[];
+}
+
export const buildAgentProfileTabPath = (agentId: string, tab: AgentProfileTab) =>
urlJoin('/agent', agentId, tab);
const AGENT_PROFILE_ROUTE =
- /^(?:\/[^/]+)?\/agent\/[^/]+\/(profile|channel(?:\/[^/]+)?|statistics|share)\/?$/;
+ /^(?:\/[^/]+)?\/agent\/[^/]+\/(profile|mail|channel(?:\/[^/]+)?|statistics|share)\/?$/;
/**
* The profile-group tab a URL belongs to, if any. Anchored on Agent subroutes,
@@ -42,14 +49,17 @@ export const buildAgentProfileTabOptions = ({
active,
canConfigure,
labels,
+ mailSupported,
shareSupported,
}: {
active: AgentProfileTab;
canConfigure: boolean;
labels: Record<AgentProfileTab, string>;
+ mailSupported: boolean;
shareSupported: boolean;
}): AgentProfileTabOption[] => {
const showProfile = canConfigure || active === 'profile';
+ const showMail = (canConfigure && mailSupported) || active === 'mail';
// Channels can dispatch to a bound device; cloud sandbox support is not required.
const showChannel = canConfigure || active === 'channel';
// Sharing hands visitors real execution on the owner's account, so the
@@ -59,8 +69,23 @@ export const buildAgentProfileTabOptions = ({
return [
showProfile ? { label: labels.profile, value: 'profile' as const } : null,
+ showMail ? { label: labels.mail, value: 'mail' as const } : null,
showChannel ? { label: labels.channel, value: 'channel' as const } : null,
{ label: labels.statistics, value: 'statistics' as const },
showShare ? { label: labels.share, value: 'share' as const } : null,
].filter((option) => !!option);
};
+
+const AGENT_PROFILE_TAB_GROUPS: { key: AgentProfileTabGroupKey; tabs: AgentProfileTab[] }[] = [
+ { key: 'identity', tabs: ['profile', 'mail', 'channel'] },
+ { key: 'general', tabs: ['statistics', 'share'] },
+];
+
+/** Sidebar sections for the visible tabs; a section with nothing to open is left out. */
+export const groupAgentProfileTabOptions = (
+ options: AgentProfileTabOption[],
+): AgentProfileTabGroup[] =>
+ AGENT_PROFILE_TAB_GROUPS.map(({ key, tabs }) => ({
+ key,
+ options: tabs.flatMap((tab) => options.filter((option) => option.value === tab)),
+ })).filter((group) => group.options.length > 0);
diff --git a/src/features/AgentProfileTabs/useAgentProfileTabOptions.ts b/src/features/AgentProfileTabs/useAgentProfileTabOptions.ts
index f0736062c9e..44c22bc488e 100644
--- a/src/features/AgentProfileTabs/useAgentProfileTabOptions.ts
+++ b/src/features/AgentProfileTabs/useAgentProfileTabOptions.ts
@@ -2,6 +2,7 @@ import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useAgentShareSupported } from '@/business/client/useAgentShareSupported';
+import { useShowAgentIdentity } from '@/features/AgentMail/useShowAgentIdentity';
import { useResourceAccess } from '@/features/ResourcePermission/useResourceAccess';
import { usePermission } from '@/hooks/usePermission';
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
@@ -23,6 +24,7 @@ export const useAgentProfileTabOptions = (active: AgentProfileTab, agentId: stri
const canManageShare =
!!isAgentEditable && isAccessResolved && canEditContent && canManageResource;
const { visible: shareVisible } = useAgentShareSupported(agentId);
+ const mailSupported = useShowAgentIdentity(agentId);
return useMemo(
() =>
@@ -31,6 +33,7 @@ export const useAgentProfileTabOptions = (active: AgentProfileTab, agentId: stri
canConfigure,
labels: {
channel: t('tab.integration'),
+ mail: t('tab.mail'),
// Inside the profile group the whole surface *is* the agent profile,
// so the first entry is the "basic" tab, not "Agent Profile" again —
// that broader name stays on the sidebar entry that opens the group.
@@ -38,8 +41,9 @@ export const useAgentProfileTabOptions = (active: AgentProfileTab, agentId: stri
share: t('share', { ns: 'common' }),
statistics: t('usageStats.title', { ns: 'spend' }),
},
+ mailSupported,
shareSupported: shareVisible === true && canManageShare,
}),
- [active, canConfigure, canManageShare, shareVisible, t],
+ [active, canConfigure, canManageShare, mailSupported, shareVisible, t],
);
};
diff --git a/src/features/AgentSetting/AgentIdentity/index.tsx b/src/features/AgentSetting/AgentIdentity/index.tsx
deleted file mode 100644
index 86d3bb2b257..00000000000
--- a/src/features/AgentSetting/AgentIdentity/index.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-'use client';
-
-import { Flexbox } from '@lobehub/ui';
-import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { useStore } from '../store';
-import IdentityAccounts from './IdentityAccounts';
-import InboxSection from './InboxSection';
-
-/**
- * The identity tab: which addresses this agent owns, and what has arrived.
- *
- * Two sections rather than two tabs, because they answer one question — "is
- * anyone reaching this agent, and through what?" — and the inbox is only
- * meaningful next to the addresses that received it.
- */
-const AgentIdentity = memo(() => {
- const { t } = useTranslation('setting');
- const [id, disabled] = useStore((s) => [s.id, s.disabled]);
-
- if (!id) {
- return (
- <Flexbox flex={1} style={{ color: 'var(--lobe-colors-text-tertiary)', fontSize: 13 }}>
- {t('identity.noAgent')}
- </Flexbox>
- );
- }
-
- return (
- <Flexbox gap={24} paddingBlock={16}>
- <IdentityAccounts agentId={id} disabled={disabled} />
- <InboxSection agentId={id} />
- </Flexbox>
- );
-});
-
-AgentIdentity.displayName = 'AgentIdentity';
-
-export default AgentIdentity;
diff --git a/src/features/AgentSetting/AgentSettingsContent.tsx b/src/features/AgentSetting/AgentSettingsContent.tsx
index 410024e0f89..01bcb34765e 100644
--- a/src/features/AgentSetting/AgentSettingsContent.tsx
+++ b/src/features/AgentSetting/AgentSettingsContent.tsx
@@ -9,8 +9,6 @@ import { labPreferSelectors } from '@/store/user/selectors';
import AgentConnectors from './AgentConnectors';
import AgentGraphRuntime from './AgentGraphRuntime';
-import AgentIdentity from './AgentIdentity';
-import { useShowAgentIdentity } from './AgentIdentity/useShowAgentIdentity';
import AgentOpening from './AgentOpening';
export interface AgentSettingsContentProps {
@@ -21,14 +19,12 @@ export interface AgentSettingsContentProps {
const AgentSettingsContent = memo<AgentSettingsContentProps>(({ tab, loadingSkeleton }) => {
const loading = useAgentStore(agentSelectors.isAgentConfigLoading);
const enableAgentGraphConfigLab = useUserStore(labPreferSelectors.enableAgentGraphConfig);
- const showIdentity = useShowAgentIdentity();
if (loading) return loadingSkeleton;
return (
<>
{tab === ChatSettingsTabs.Opening && <AgentOpening />}
- {showIdentity && tab === ChatSettingsTabs.Identity && <AgentIdentity />}
{enableAgentGraphConfigLab && tab === ChatSettingsTabs.Graph && <AgentGraphRuntime />}
{tab === ChatSettingsTabs.Connector && <AgentConnectors />}
</>
diff --git a/src/features/AgentSidebar/ProfileNav.tsx b/src/features/AgentSidebar/ProfileNav.tsx
index 13efe673b1f..d30767308e5 100644
--- a/src/features/AgentSidebar/ProfileNav.tsx
+++ b/src/features/AgentSidebar/ProfileNav.tsx
@@ -1,11 +1,12 @@
'use client';
-import { Flexbox } from '@lobehub/ui';
+import { Flexbox, Text } from '@lobehub/ui';
import type { LucideIcon } from 'lucide-react';
import {
ChartColumnBigIcon,
ChevronLeftIcon,
FileUserIcon,
+ MailIcon,
RadioTowerIcon,
Share2Icon,
} from 'lucide-react';
@@ -15,6 +16,7 @@ import urlJoin from 'url-join';
import {
type AgentProfileTab,
buildAgentProfileTabPath,
+ groupAgentProfileTabOptions,
} from '@/features/AgentProfileTabs/tabOptions';
import { useAgentProfileTabOptions } from '@/features/AgentProfileTabs/useAgentProfileTabOptions';
import NavItem from '@/features/NavPanel/components/NavItem';
@@ -27,6 +29,7 @@ import Agent from './Header/Agent';
const TAB_ICONS: Record<AgentProfileTab, LucideIcon> = {
channel: RadioTowerIcon,
+ mail: MailIcon,
profile: FileUserIcon,
share: Share2Icon,
statistics: ChartColumnBigIcon,
@@ -46,15 +49,30 @@ const ProfileNav = ({ active }: ProfileNavProps) => {
return (
<SideBarLayout
body={
- <Flexbox gap={1} paddingInline={4}>
- {options.map(({ label, value }) => (
- <NavItem
- active={value === active}
- icon={TAB_ICONS[value]}
- key={value}
- title={label}
- onClick={() => navigate(buildAgentProfileTabPath(agentId, value))}
- />
+ <Flexbox gap={12} paddingInline={4}>
+ {groupAgentProfileTabOptions(options).map((group) => (
+ <Flexbox gap={1} key={group.key}>
+ {group.key === 'identity' && (
+ <Text
+ ellipsis
+ fontSize={12}
+ style={{ paddingBlock: 4, paddingInline: 8 }}
+ type={'secondary'}
+ weight={500}
+ >
+ {t('tab.group.identity')}
+ </Text>
+ )}
+ {group.options.map(({ label, value }) => (
+ <NavItem
+ active={value === active}
+ icon={TAB_ICONS[value]}
+ key={value}
+ title={label}
+ onClick={() => navigate(buildAgentProfileTabPath(agentId, value))}
+ />
+ ))}
+ </Flexbox>
))}
</Flexbox>
}
diff --git a/src/routes/(main)/agent/features/routeMeta.ts b/src/routes/(main)/agent/features/routeMeta.ts
index 8ee0936bd3b..8d39dad5f0d 100644
--- a/src/routes/(main)/agent/features/routeMeta.ts
+++ b/src/routes/(main)/agent/features/routeMeta.ts
@@ -2,6 +2,7 @@ import {
ChartColumnBigIcon,
FileUserIcon,
GraduationCapIcon,
+ MailIcon,
MessageSquare,
MessagesSquareIcon,
RadioTowerIcon,
@@ -87,6 +88,12 @@ export const agentProfileRouteMeta = routeMeta({
titleKey: 'navigation.profile',
});
+export const agentMailRouteMeta = routeMeta({
+ icon: MailIcon,
+ Skeleton: createSurfaceSkeleton('list'),
+ titleKey: 'navigation.mail',
+});
+
export const agentChannelRouteMeta = routeMeta({
DynamicMeta: ChannelDynamicMeta,
icon: RadioTowerIcon,
diff --git a/src/routes/(main)/agent/mail/index.tsx b/src/routes/(main)/agent/mail/index.tsx
new file mode 100644
index 00000000000..e38f4d6a516
--- /dev/null
+++ b/src/routes/(main)/agent/mail/index.tsx
@@ -0,0 +1,24 @@
+'use client';
+
+import { useParams } from 'react-router';
+
+import AgentMail from '@/features/AgentMail';
+import ResourceConfigAccessGate from '@/features/ResourcePermission/ResourceConfigAccessGate';
+import { usePermission } from '@/hooks/usePermission';
+
+const AgentMailPage = () => {
+ const { aid } = useParams<{ aid?: string }>();
+ const { allowed: canEdit } = usePermission('edit_own_content');
+
+ return (
+ <ResourceConfigAccessGate
+ redirectPath={`/agent/${aid ?? ''}`}
+ resourceId={aid}
+ resourceType="agent"
+ >
+ {aid && <AgentMail agentId={aid} disabled={!canEdit} />}
+ </ResourceConfigAccessGate>
+ );
+};
+
+export default AgentMailPage;
diff --git a/src/routes/(main)/agent/profile/features/AgentSettings/Content.test.tsx b/src/routes/(main)/agent/profile/features/AgentSettings/Content.test.tsx
index 54b11ee4beb..62ba73a7c13 100644
--- a/src/routes/(main)/agent/profile/features/AgentSettings/Content.test.tsx
+++ b/src/routes/(main)/agent/profile/features/AgentSettings/Content.test.tsx
@@ -1,6 +1,5 @@
-import { render, screen, waitFor } from '@testing-library/react';
+import { render, screen } from '@testing-library/react';
import type { ReactNode } from 'react';
-import { SWRConfig } from 'swr';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { ChatSettingsTabs } from '@/store/global/initialState';
@@ -17,8 +16,7 @@ const mocks = vi.hoisted(() => ({
optimisticUpdateAgentConfig: vi.fn(),
optimisticUpdateAgentMeta: vi.fn(),
},
- serverState: { serverConfig: { agentIdentityProviders: [] as string[] } },
- userState: { preference: { lab: { enableAgentGraphConfig: false, enableAgentIdentity: false } } },
+ userState: { preference: { lab: { enableAgentGraphConfig: false } } },
}));
vi.mock('@/features/AgentSetting', () => ({
@@ -44,9 +42,6 @@ vi.mock('@/features/AgentSetting', () => ({
),
}));
-const accountService = vi.hoisted(() => ({ list: vi.fn(async () => [] as unknown[]) }));
-vi.mock('@/services/agentAccount', () => ({ agentAccountService: accountService }));
-
vi.mock('@/store/agent', () => {
const useAgentStore = (selector: (state: typeof mocks.agentState) => unknown) =>
selector(mocks.agentState);
@@ -67,18 +62,6 @@ vi.mock('@/store/agent/selectors', () => ({
},
}));
-vi.mock('@/store/serverConfig', () => ({
- useServerConfigStore: (selector: (state: typeof mocks.serverState) => unknown) =>
- selector(mocks.serverState),
-}));
-
-vi.mock('@/store/serverConfig/selectors', () => ({
- serverConfigSelectors: {
- agentIdentityProviders: (state: typeof mocks.serverState) =>
- state.serverConfig.agentIdentityProviders,
- },
-}));
-
vi.mock('@/store/user', () => ({
useUserStore: (selector: (state: typeof mocks.userState) => unknown) => selector(mocks.userState),
}));
@@ -87,8 +70,6 @@ vi.mock('@/store/user/selectors', () => ({
labPreferSelectors: {
enableAgentGraphConfig: (state: typeof mocks.userState) =>
state.preference.lab.enableAgentGraphConfig,
- enableAgentIdentity: (state: typeof mocks.userState) =>
- state.preference.lab.enableAgentIdentity,
},
}));
@@ -97,8 +78,6 @@ describe('AgentSettings Content', () => {
mocks.agentState.isInbox = true;
mocks.agentState.isCurrentAgentHeterogeneous = false;
mocks.userState.preference.lab.enableAgentGraphConfig = false;
- mocks.userState.preference.lab.enableAgentIdentity = false;
- mocks.serverState.serverConfig.agentIdentityProviders = [];
});
it('opens on the opening tab', () => {
@@ -132,49 +111,4 @@ describe('AgentSettings Content', () => {
expect(screen.getByTestId('layout')).toHaveAttribute('data-tabs', ChatSettingsTabs.Opening);
});
-
- it('shows identity only with the Labs toggle on and a provider configured', () => {
- mocks.serverState.serverConfig.agentIdentityProviders = ['agent-mail'];
-
- const { unmount } = render(<Content />);
- // A configured provider alone does not surface the experiment.
- expect(screen.getByTestId('layout')).toHaveAttribute('data-tabs', ChatSettingsTabs.Opening);
- unmount();
-
- mocks.userState.preference.lab.enableAgentIdentity = true;
- render(<Content />);
- expect(screen.getByTestId('layout')).toHaveAttribute(
- 'data-tabs',
- `${ChatSettingsTabs.Opening},${ChatSettingsTabs.Identity}`,
- );
- });
-
- it('hides identity when the deployment has no identity provider, even in Labs', () => {
- mocks.userState.preference.lab.enableAgentIdentity = true;
-
- render(<Content />);
-
- expect(screen.getByTestId('layout')).toHaveAttribute('data-tabs', ChatSettingsTabs.Opening);
- });
-
- it('keeps identity reachable for an agent that already owns an address, even with no provider', async () => {
- mocks.userState.preference.lab.enableAgentIdentity = true;
- accountService.list.mockResolvedValueOnce([
- { id: 'acc_1', identifier: '[email protected]', status: 'active' },
- ]);
-
- render(
- <SWRConfig value={{ dedupingInterval: 0, provider: () => new Map() }}>
- <Content />
- </SWRConfig>,
- );
-
- await waitFor(() =>
- expect(screen.getByTestId('layout')).toHaveAttribute(
- 'data-tabs',
- `${ChatSettingsTabs.Opening},${ChatSettingsTabs.Identity}`,
- ),
- );
- expect(accountService.list).toHaveBeenCalledWith({ agentId: 'inbox-agent' });
- });
});
diff --git a/src/routes/(main)/agent/profile/features/AgentSettings/Content.tsx b/src/routes/(main)/agent/profile/features/AgentSettings/Content.tsx
index 46d6d2cc300..23c9fffc891 100644
--- a/src/routes/(main)/agent/profile/features/AgentSettings/Content.tsx
+++ b/src/routes/(main)/agent/profile/features/AgentSettings/Content.tsx
@@ -2,7 +2,7 @@
import { DEFAULT_INBOX_TITLE } from '@lobechat/const';
import isEqual from 'fast-deep-equal';
-import { GitBranchIcon, IdCardIcon, MessageSquareHeartIcon } from 'lucide-react';
+import { GitBranchIcon, MessageSquareHeartIcon } from 'lucide-react';
import { memo, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { shallow } from 'zustand/shallow';
@@ -13,7 +13,6 @@ import {
SettingsModalLayout,
type SettingsModalTabItem,
} from '@/features/AgentSetting';
-import { useShowAgentIdentity } from '@/features/AgentSetting/AgentIdentity/useShowAgentIdentity';
import { usePermission } from '@/hooks/usePermission';
import { useAgentStore } from '@/store/agent';
import { agentSelectors, builtinAgentSelectors } from '@/store/agent/selectors';
@@ -23,7 +22,6 @@ import { labPreferSelectors } from '@/store/user/selectors';
const TAB_META = {
[ChatSettingsTabs.Graph]: { icon: GitBranchIcon, labelKey: 'agentTab.graph' },
- [ChatSettingsTabs.Identity]: { icon: IdCardIcon, labelKey: 'agentTab.identity' },
[ChatSettingsTabs.Opening]: { icon: MessageSquareHeartIcon, labelKey: 'agentTab.opening' },
} as const;
@@ -40,16 +38,13 @@ const Content = memo(() => {
const enableAgentGraphConfigLab = useUserStore(labPreferSelectors.enableAgentGraphConfig);
const [tab, setTab] = useState(ChatSettingsTabs.Opening);
const showGraphTab = enableAgentGraphConfigLab && !isInbox && !isHeterogeneous;
- const showIdentityTab = useShowAgentIdentity();
const availableTabs = useMemo(
() =>
- [
- ChatSettingsTabs.Opening,
- showIdentityTab ? ChatSettingsTabs.Identity : null,
- showGraphTab ? ChatSettingsTabs.Graph : null,
- ].filter(Boolean) as ChatSettingsTabs[],
- [showGraphTab, showIdentityTab],
+ [ChatSettingsTabs.Opening, showGraphTab ? ChatSettingsTabs.Graph : null].filter(
+ Boolean,
+ ) as ChatSettingsTabs[],
+ [showGraphTab],
);
const activeTab = availableTabs.includes(tab) ? tab : availableTabs[0];
diff --git a/src/spa/router/agentPageRoutes.tsx b/src/spa/router/agentPageRoutes.tsx
index 2ceda349dc3..67a23c1cc90 100644
--- a/src/spa/router/agentPageRoutes.tsx
+++ b/src/spa/router/agentPageRoutes.tsx
@@ -7,6 +7,7 @@ import { taskRouteMeta, tasksRouteMeta } from '@/features/AgentTasks/routeMeta';
import {
agentChannelDetailRouteMeta,
agentChannelRouteMeta,
+ agentMailRouteMeta,
agentPermissionRouteMeta,
agentProfileRouteMeta,
agentSelfLearningRouteMeta,
@@ -81,6 +82,11 @@ export const agentPageChildren: RouteObject[] = [
handle: { meta: agentProfileRouteMeta },
path: 'profile',
},
+ {
+ element: dynamicElement(() => import('@/routes/(main)/agent/mail'), 'Desktop > Chat > Mail'),
+ handle: { meta: agentMailRouteMeta },
+ path: 'mail',
+ },
{
element: dynamicElement(
() => import('@/routes/(main)/agent/channel'),
diff --git a/src/store/global/initialState.ts b/src/store/global/initialState.ts
index 6952e46b49a..1a473769a24 100644
--- a/src/store/global/initialState.ts
+++ b/src/store/global/initialState.ts
@@ -26,7 +26,6 @@ export enum SidebarTabKey {
export enum ChatSettingsTabs {
Connector = 'connector',
Graph = 'graph',
- Identity = 'identity',
Opening = 'opening',
Plugin = 'plugin',
Prompt = 'prompt',