🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(agent): move self-evolving into the agent profile group (#22674)
Arvin Xu9a648461ae9d
diff --git a/src/features/AgentProfileTabs/tabOptions.test.ts b/src/features/AgentProfileTabs/tabOptions.test.tsindex f045140e983..ec7d3d0892c 100644--- a/src/features/AgentProfileTabs/tabOptions.test.ts+++ b/src/features/AgentProfileTabs/tabOptions.test.ts@@ -1,6 +1,7 @@import { describe, expect, it } from 'vitest';import {+ type AgentProfileTab,buildAgentProfileTabOptions,buildAgentProfileTabPath,getAgentProfileTab,@@ -8,11 +9,12 @@ import {} from './tabOptions';const labels = {- channel: 'tab.integration',- mail: 'tab.mail',- profile: 'tab.profile',- share: 'share',- statistics: 'usageStats.title',+ 'channel': 'tab.integration',+ 'mail': 'tab.mail',+ 'profile': 'tab.profile',+ 'self-evolving': 'title',+ 'share': 'share',+ 'statistics': 'usageStats.title',};describe('buildAgentProfileTabPath', () => {@@ -28,16 +30,22 @@ describe('getAgentProfileTab', () => {['/agent/agt_1/channel/slack', 'channel'],['/acme/agent/agt_1/statistics/', 'statistics'],['/_dangerous_local_dev_proxy/acme/agent/agt_1/share', 'share'],+ ['/agent/agt_1/self-evolving', 'self-evolving'],+ ['/agent/agt_1/self-evolving/new', 'self-evolving'],+ ['/acme/agent/agt_1/self-evolving/dom_1/experience/les_1', 'self-evolving'],])('maps %s to its tab', (pathname, tab) => {expect(getAgentProfileTab(pathname)).toBe(tab);});- it.each(['/agent/agt_1', '/agent/agt_1/tpc_1', '/agent/agt_1/share/extra', '/settings/profile'])(- 'leaves %s outside the group',- (pathname) => {- expect(getAgentProfileTab(pathname)).toBeUndefined();- },- );+ it.each([+ '/agent/agt_1',+ '/agent/agt_1/tpc_1',+ '/agent/agt_1/share/extra',+ '/agent/agt_1/self-evolving-x',+ '/settings/profile',+ ])('leaves %s outside the group', (pathname) => {+ expect(getAgentProfileTab(pathname)).toBeUndefined();+ });});describe('buildAgentProfileTabOptions', () => {@@ -47,6 +55,7 @@ describe('buildAgentProfileTabOptions', () => {canConfigure: true,labels,mailSupported: false,+ selfLearningSupported: false,shareSupported: true,});@@ -64,6 +73,7 @@ describe('buildAgentProfileTabOptions', () => {canConfigure: true,labels,mailSupported: false,+ selfLearningSupported: false,shareSupported: false,});@@ -76,6 +86,7 @@ describe('buildAgentProfileTabOptions', () => {canConfigure: false,labels,mailSupported: false,+ selfLearningSupported: false,shareSupported: true,});@@ -88,6 +99,7 @@ describe('buildAgentProfileTabOptions', () => {canConfigure: false,labels,mailSupported: false,+ selfLearningSupported: false,shareSupported: false,});@@ -100,6 +112,7 @@ describe('buildAgentProfileTabOptions', () => {canConfigure: false,labels,mailSupported: false,+ selfLearningSupported: false,shareSupported: false,});@@ -112,6 +125,7 @@ describe('buildAgentProfileTabOptions', () => {canConfigure: true,labels,mailSupported: true,+ selfLearningSupported: false,shareSupported: false,});@@ -123,12 +137,39 @@ describe('buildAgentProfileTabOptions', () => {]);});+ it('lists self-evolving only where it is supported, regardless of edit access', () => {+ const options = buildAgentProfileTabOptions({+ active: 'statistics',+ canConfigure: false,+ labels,+ mailSupported: false,+ selfLearningSupported: true,+ shareSupported: false,+ });++ expect(options.map((option) => option.value)).toEqual(['self-evolving', 'statistics']);+ });++ it('keeps self-evolving when it owns the current page even though it is gated off', () => {+ const options = buildAgentProfileTabOptions({+ active: 'self-evolving',+ canConfigure: false,+ labels,+ mailSupported: false,+ selfLearningSupported: false,+ shareSupported: false,+ });++ expect(options.map((option) => option.value)).toEqual(['self-evolving', 'statistics']);+ });+it('drops mail for a member without edit access', () => {const options = buildAgentProfileTabOptions({active: 'statistics',canConfigure: false,labels,mailSupported: true,+ selfLearningSupported: false,shareSupported: false,});@@ -137,21 +178,19 @@ describe('buildAgentProfileTabOptions', () => {});describe('groupAgentProfileTabOptions', () => {- const option = (value: 'channel' | 'mail' | 'profile' | 'share' | 'statistics') => ({+ const option = (value: AgentProfileTab) => ({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]),- ),+ (['profile', 'mail', 'channel', 'self-evolving', 'statistics', 'share'] as const).map(option),);expect(groups.map((group) => [group.key, group.options.map((item) => item.value)])).toEqual([['identity', ['profile', 'mail', 'channel']],- ['general', ['statistics', 'share']],+ ['general', ['self-evolving', 'statistics', 'share']],]);});diff --git a/src/features/AgentProfileTabs/tabOptions.ts b/src/features/AgentProfileTabs/tabOptions.tsindex 022f9171bf5..27d19ca1dc5 100644--- a/src/features/AgentProfileTabs/tabOptions.ts+++ b/src/features/AgentProfileTabs/tabOptions.ts@@ -1,6 +1,7 @@import urlJoin from 'url-join';-export type AgentProfileTab = 'channel' | 'mail' | 'profile' | 'share' | 'statistics';+export type AgentProfileTab =+ 'channel' | 'mail' | 'profile' | 'self-evolving' | 'share' | 'statistics';export interface AgentProfileTabOption {label: string;@@ -18,7 +19,7 @@ export const buildAgentProfileTabPath = (agentId: string, tab: AgentProfileTab)urlJoin('/agent', agentId, tab);const AGENT_PROFILE_ROUTE =- /^(?:\/[^/]+)?\/agent\/[^/]+\/(profile|mail|channel(?:\/[^/]+)?|statistics|share)\/?$/;+ /^(?:\/[^/]+)?\/agent\/[^/]+\/(profile|mail|channel(?:\/[^/]+)?|self-evolving(?:\/[^/]+)*|statistics|share)\/?$/;/*** The profile-group tab a URL belongs to, if any. Anchored on Agent subroutes,@@ -50,12 +51,14 @@ export const buildAgentProfileTabOptions = ({canConfigure,labels,mailSupported,+ selfLearningSupported,shareSupported,}: {active: AgentProfileTab;canConfigure: boolean;labels: Record<AgentProfileTab, string>;mailSupported: boolean;+ selfLearningSupported: boolean;shareSupported: boolean;}): AgentProfileTabOption[] => {const showProfile = canConfigure || active === 'profile';@@ -66,11 +69,13 @@ export const buildAgentProfileTabOptions = ({// segment follows the same configure gate as Profile / Channels on top of the// capability gate (personal, non-builtin agents on deployments that allow it).const showShare = (canConfigure && shareSupported) || active === 'share';+ const showSelfLearning = selfLearningSupported || active === 'self-evolving';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,+ showSelfLearning ? { label: labels['self-evolving'], value: 'self-evolving' as const } : null,{ label: labels.statistics, value: 'statistics' as const },showShare ? { label: labels.share, value: 'share' as const } : null,].filter((option) => !!option);@@ -78,7 +83,7 @@ export const buildAgentProfileTabOptions = ({const AGENT_PROFILE_TAB_GROUPS: { key: AgentProfileTabGroupKey; tabs: AgentProfileTab[] }[] = [{ key: 'identity', tabs: ['profile', 'mail', 'channel'] },- { key: 'general', tabs: ['statistics', 'share'] },+ { key: 'general', tabs: ['self-evolving', 'statistics', 'share'] },];/** Sidebar sections for the visible tabs; a section with nothing to open is left out. */diff --git a/src/features/AgentProfileTabs/useAgentProfileTabOptions.ts b/src/features/AgentProfileTabs/useAgentProfileTabOptions.tsindex 44c22bc488e..b09434381fa 100644--- a/src/features/AgentProfileTabs/useAgentProfileTabOptions.ts+++ b/src/features/AgentProfileTabs/useAgentProfileTabOptions.ts@@ -4,14 +4,16 @@ import { useTranslation } from 'react-i18next';import { useAgentShareSupported } from '@/business/client/useAgentShareSupported';import { useShowAgentIdentity } from '@/features/AgentMail/useShowAgentIdentity';import { useResourceAccess } from '@/features/ResourcePermission/useResourceAccess';+import { useSelfLearningSurface } from '@/features/SelfLearning/SurfaceGate/useSelfLearningSurface';import { usePermission } from '@/hooks/usePermission';import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';+import { isMobileSurface } from '@/utils/mobileSurface';import { type AgentProfileTab, buildAgentProfileTabOptions } from './tabOptions';/** The profile-group entries this member may open, for any switcher of the group. */export const useAgentProfileTabOptions = (active: AgentProfileTab, agentId: string) => {- const { t } = useTranslation(['chat', 'common', 'spend']);+ const { t } = useTranslation(['chat', 'common', 'selfLearning', 'spend']);const { allowed: canEditContent } = usePermission('edit_own_content');const { canEditResource, canManageResource, isAccessResolved } = useResourceAccess(@@ -25,6 +27,10 @@ export const useAgentProfileTabOptions = (active: AgentProfileTab, agentId: stri!!isAgentEditable && isAccessResolved && canEditContent && canManageResource;const { visible: shareVisible } = useAgentShareSupported(agentId);const mailSupported = useShowAgentIdentity(agentId);+ const { enabled: enableSelfLearning } = useSelfLearningSurface();+ // The mobile Segmented has no room for another segment, so mobile keeps the+ // drawer entry in `AgentSidebar/Header/Nav`.+ const selfLearningSupported = enableSelfLearning && !isMobileSurface();return useMemo(() =>@@ -32,18 +38,20 @@ export const useAgentProfileTabOptions = (active: AgentProfileTab, agentId: striactive,canConfigure,labels: {- channel: t('tab.integration'),- mail: t('tab.mail'),+ '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.- profile: t('tab.profileBasic'),- share: t('share', { ns: 'common' }),- statistics: t('usageStats.title', { ns: 'spend' }),+ 'profile': t('tab.profileBasic'),+ 'self-evolving': t('title', { ns: 'selfLearning' }),+ 'share': t('share', { ns: 'common' }),+ 'statistics': t('usageStats.title', { ns: 'spend' }),},mailSupported,+ selfLearningSupported,shareSupported: shareVisible === true && canManageShare,}),- [active, canConfigure, canManageShare, mailSupported, shareVisible, t],+ [active, canConfigure, canManageShare, mailSupported, selfLearningSupported, shareVisible, t],);};diff --git a/src/features/AgentSidebar/Content.test.tsx b/src/features/AgentSidebar/Content.test.tsxindex e0fad60911c..e3b384e18ae 100644--- a/src/features/AgentSidebar/Content.test.tsx+++ b/src/features/AgentSidebar/Content.test.tsx@@ -27,6 +27,8 @@ describe('AgentSidebarContent', () => {['/agent/agt_1/channel/slack', 'channel'],['/agent/agt_1/statistics', 'statistics'],['/agent/agt_1/share', 'share'],+ ['/agent/agt_1/self-evolving', 'self-evolving'],+ ['/agent/agt_1/self-evolving/dom_1/experience', 'self-evolving'],])('replaces the topic sidebar on %s', (pathname, tab) => {mocks.pathname = pathname;render(<AgentSidebarContent />);diff --git a/src/features/AgentSidebar/Header/Nav.test.tsx b/src/features/AgentSidebar/Header/Nav.test.tsxindex 1490b8490d3..3dfb992f98f 100644--- a/src/features/AgentSidebar/Header/Nav.test.tsx+++ b/src/features/AgentSidebar/Header/Nav.test.tsx@@ -3,7 +3,7 @@*/import { fireEvent, render, screen } from '@testing-library/react';import type { ReactNode } from 'react';-import { beforeEach, describe, expect, it, vi } from 'vitest';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import Nav from './Nav';@@ -244,33 +244,57 @@ describe('Agent sidebar header nav', () => {},);- it('navigates to the agent self-learning page', () => {+ it('moves self-evolving into the profile group for members who can open it', () => {usePathnameMock.mockReturnValue('/agent/agt_eH4zL98zBx5u');render(<Nav />);- fireEvent.click(screen.getByRole('button', { name: 'title' }));- expect(switchTopicMock).toHaveBeenCalledWith(null, { skipRefreshMessage: true });- expect(pushMock).toHaveBeenCalledWith('/agent/agt_eH4zL98zBx5u/self-evolving');+ expect(screen.queryByRole('button', { name: 'title' })).toBeNull();+ expect(screen.getByRole('button', { name: 'tab.profile' })).toBeInTheDocument();});- // The surface is opt-in WIP, so the entry must disappear with the Labs toggle- // rather than lead everyone to a page whose data pipeline isn't running yet.- it('hides the self-learning entry when the labs toggle is off', () => {- labMock.enableSelfLearning = false;+ it('keeps self-evolving reachable when the profile entry is hidden', () => {+ permissionMock.edit_own_content = false;usePathnameMock.mockReturnValue('/agent/agt_eH4zL98zBx5u');render(<Nav />);+ expect(screen.queryByRole('button', { name: 'tab.profile' })).toBeNull();+ fireEvent.click(screen.getByRole('button', { name: 'title' }));- expect(screen.queryByRole('button', { name: 'title' })).toBeNull();+ expect(switchTopicMock).toHaveBeenCalledWith(null, { skipRefreshMessage: true });+ expect(pushMock).toHaveBeenCalledWith('/agent/agt_eH4zL98zBx5u/self-evolving');});- it('keeps the self-learning entry active on its own route', () => {- usePathnameMock.mockReturnValue('/agent/agt_eH4zL98zBx5u/self-evolving');+ describe('on mobile, where the profile Segmented has no room for it', () => {+ beforeEach(() => {+ vi.stubGlobal('__MOBILE__', true);+ });+ afterEach(() => {+ vi.unstubAllGlobals();+ });- render(<Nav />);+ it('lights only the self-evolving entry on its own route', () => {+ usePathnameMock.mockReturnValue('/agent/agt_eH4zL98zBx5u/self-evolving/dom_1');++ render(<Nav />);++ expect(screen.getByRole('button', { name: 'title' })).toHaveAttribute('data-active', 'true');+ expect(screen.getByRole('button', { name: 'tab.profile' })).toHaveAttribute(+ 'data-active',+ 'false',+ );+ });++ // The surface is opt-in WIP, so the entry must disappear with the Labs toggle+ // rather than lead everyone to a page whose data pipeline isn't running yet.+ it('hides the entry when the labs toggle is off', () => {+ labMock.enableSelfLearning = false;+ usePathnameMock.mockReturnValue('/agent/agt_eH4zL98zBx5u');++ render(<Nav />);- expect(screen.getByRole('button', { name: 'title' })).toHaveAttribute('data-active', 'true');+ expect(screen.queryByRole('button', { name: 'title' })).toBeNull();+ });});it('places topics above profile, goals, self-learning, and tasks in the agent navigation', () => {diff --git a/src/features/AgentSidebar/Header/Nav.tsx b/src/features/AgentSidebar/Header/Nav.tsxindex fa1ae73bf73..51b2a741548 100644--- a/src/features/AgentSidebar/Header/Nav.tsx+++ b/src/features/AgentSidebar/Header/Nav.tsx@@ -29,6 +29,7 @@ import { useGlobalStore } from '@/store/global';import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';import { useUserStore } from '@/store/user';import { labPreferSelectors } from '@/store/user/selectors';+import { isMobileSurface } from '@/utils/mobileSurface';import { isAgentProfileRoute } from './isAgentProfileRoute';@@ -42,10 +43,10 @@ const Nav = memo(() => {// The profile entry owns a group of sub-views — profile / channels /// statistics / share. On mobile they stay switched by a Segmented while this// list remains in the drawer, so every one of them keeps this entry lit.- const isProfileActive = isAgentProfileRoute(pathname);- const isGoalsActive = pathname.endsWith('/goals');// 下钻页 /self-evolving/:domainId 也算在这个入口下,否则点进去侧边栏就失焦了const isSelfLearningActive = pathname.includes('/self-evolving');+ const isProfileActive = isAgentProfileRoute(pathname) && !isSelfLearningActive;+ const isGoalsActive = pathname.endsWith('/goals');const isTasksActive = pathname.endsWith('/tasks') || pathname.includes('/task/');// Topic IDs are prefixed `topics_`, so /agent/:aid/topics_abc would also match// pathname.includes('/topics') — anchor to end to avoid that false positive.@@ -66,6 +67,9 @@ const Nav = memo(() => {const isNewTopicSendInFlight = useChatStore(topicSelectors.isNewTopicSendInFlight);const enableGoals = useUserStore(labPreferSelectors.enableGoals);const { enabled: enableSelfLearning } = useSelfLearningSurface();+ // Self-evolving lives in the profile group; it stays here only where that group+ // cannot reach it: members with no profile entry, and the mobile Segmented.+ const showSelfLearningEntry = enableSelfLearning && (hideProfile || isMobileSurface());const { mutate } = useActionSWR(topicActionKeys.openNewOrSave(), openNewTopicOrSaveTopic);const handleNewTopic = () => {@@ -114,7 +118,7 @@ const Nav = memo(() => {}}/>)}- {enableSelfLearning && (+ {showSelfLearningEntry && (<NavItemactive={isSelfLearningActive}icon={DnaIcon}diff --git a/src/features/AgentSidebar/Header/isAgentProfileRoute.test.ts b/src/features/AgentSidebar/Header/isAgentProfileRoute.test.tsindex a0405f9168a..e31f724f5cf 100644--- a/src/features/AgentSidebar/Header/isAgentProfileRoute.test.ts+++ b/src/features/AgentSidebar/Header/isAgentProfileRoute.test.ts@@ -9,6 +9,7 @@ describe('isAgentProfileRoute', () => {'/agent/agt_1/channel/slack','/agent/agt_1/statistics','/agent/agt_1/share',+ '/agent/agt_1/self-evolving/dom_1','/acme/agent/agt_1/profile','/acme/agent/agt_1/channel/slack','/acme/agent/agt_1/statistics/',diff --git a/src/features/AgentSidebar/ProfileNav.tsx b/src/features/AgentSidebar/ProfileNav.tsxindex d30767308e5..d5b2ab5ee27 100644--- a/src/features/AgentSidebar/ProfileNav.tsx+++ b/src/features/AgentSidebar/ProfileNav.tsx@@ -5,6 +5,7 @@ import type { LucideIcon } from 'lucide-react';import {ChartColumnBigIcon,ChevronLeftIcon,+ DnaIcon,FileUserIcon,MailIcon,RadioTowerIcon,@@ -28,11 +29,12 @@ import { useActiveRouteParams } from '@/hooks/useActiveRouteParams';import Agent from './Header/Agent';const TAB_ICONS: Record<AgentProfileTab, LucideIcon> = {- channel: RadioTowerIcon,- mail: MailIcon,- profile: FileUserIcon,- share: Share2Icon,- statistics: ChartColumnBigIcon,+ 'channel': RadioTowerIcon,+ 'mail': MailIcon,+ 'profile': FileUserIcon,+ 'self-evolving': DnaIcon,+ 'share': Share2Icon,+ 'statistics': ChartColumnBigIcon,};interface ProfileNavProps {