🤯 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
💄 style(agent-profile): move advanced settings and permissions into the sidebar (#23669)
Lobehub Codera30f5b8a58bc
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex 74b7e70cfa3..35c3cbd1134 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -2568,6 +2568,7 @@"tab.engine": "Engine","tab.environment": "Environment","tab.goalsAndTasks": "Tasks and goals",+ "tab.group.advanced": "Advanced","tab.group.identity": "Identity","tab.group.setup": "Configure","tab.group.shape": "Shape",diff --git a/locales/en-US/electron.json b/locales/en-US/electron.jsonindex 134f7dcac17..315e4b270b6 100644--- a/locales/en-US/electron.json+++ b/locales/en-US/electron.json@@ -29,6 +29,7 @@"navigation.engine": "Agent Engine","navigation.environment": "Agent Environment","navigation.goals": "Goals",+ "navigation.graph": "Graph Runtime","navigation.group": "Group","navigation.groupChat": "Group Chat","navigation.groupProfile": "Group Profile",@@ -57,6 +58,7 @@"navigation.newChat": "New Chat","navigation.noPages": "No pages yet","navigation.onboarding": "Onboarding",+ "navigation.opening": "Opening Settings","navigation.page": "Page","navigation.pages": "Pages","navigation.permission": "Permissions",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex b3a7819d84d..2b3a398a3df 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -2568,6 +2568,7 @@"tab.engine": "引擎","tab.environment": "执行环境","tab.goalsAndTasks": "任务与目标",+ "tab.group.advanced": "进阶配置","tab.group.identity": "身份","tab.group.setup": "配置","tab.group.shape": "塑造",diff --git a/locales/zh-CN/electron.json b/locales/zh-CN/electron.jsonindex 707993950b1..d76c7595133 100644--- a/locales/zh-CN/electron.json+++ b/locales/zh-CN/electron.json@@ -29,6 +29,7 @@"navigation.engine": "助理引擎","navigation.environment": "助理执行环境","navigation.goals": "目标",+ "navigation.graph": "Graph 运行时","navigation.group": "群组","navigation.groupChat": "群组对话","navigation.groupProfile": "群组档案",@@ -57,6 +58,7 @@"navigation.newChat": "新建对话","navigation.noPages": "暂无页面","navigation.onboarding": "引导",+ "navigation.opening": "开场设置","navigation.page": "文稿","navigation.pages": "文稿","navigation.permission": "成员权限",diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex 4a07456e8b5..196e64cceee 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -2168,6 +2168,7 @@ export default {'supervisor.todoList.title': 'Tasks Completed','tab.groupProfile': 'Group Profile','tab.backToChat': 'Back to chat',+ 'tab.group.advanced': 'Advanced','tab.group.identity': 'Identity','tab.group.shape': 'Shape','tab.group.setup': 'Configure',diff --git a/packages/locales/src/default/electron.ts b/packages/locales/src/default/electron.tsindex 1bc492a591b..9606b07e18d 100644--- a/packages/locales/src/default/electron.ts+++ b/packages/locales/src/default/electron.ts@@ -29,6 +29,7 @@ export default {'navigation.group': 'Group','navigation.groupChat': 'Group Chat','navigation.groupProfile': 'Group Profile',+ 'navigation.graph': 'Graph Runtime','navigation.home': 'Home','navigation.image': 'Image','navigation.knowledgeBase': 'Knowledge Base',@@ -52,6 +53,7 @@ export default {'navigation.newChat': 'New Chat','navigation.noPages': 'No pages yet','navigation.onboarding': 'Onboarding',+ 'navigation.opening': 'Opening Settings','navigation.page': 'Page','navigation.pages': 'Pages','navigation.permission': 'Permissions',diff --git a/src/features/AgentProfileTabs/tabOptions.test.ts b/src/features/AgentProfileTabs/tabOptions.test.tsindex abf76c5d7f2..411df1348c6 100644--- a/src/features/AgentProfileTabs/tabOptions.test.ts+++ b/src/features/AgentProfileTabs/tabOptions.test.ts@@ -13,9 +13,12 @@ const labels = {'channel': 'tab.integration','engine': 'tab.engine','environment': 'tab.environment',+ 'graph': 'agentTab.graph','instruction': 'tab.instruction','knowledge': 'tab.knowledge','mail': 'tab.mail',+ 'opening': 'agentTab.opening',+ 'permission': 'permission.page.entry','profile': 'tab.profile','self-evolving': 'title','share': 'share',@@ -44,6 +47,9 @@ describe('getAgentProfileTab', () => {['/_dangerous_local_dev_proxy/acme/agent/agt_1/share', 'share'],['/agent/agt_1/self-evolving', 'self-evolving'],['/agent/agt_1/webhook', 'webhook'],+ ['/acme/agent/agt_1/opening', 'opening'],+ ['/agent/agt_1/graph', 'graph'],+ ['/acme/agent/agt_1/permission', 'permission'],['/acme/agent/agt_1/automations', 'automations'],['/agent/agt_1/self-evolving/new', 'self-evolving'],['/acme/agent/agt_1/self-evolving/dom_1/experience/les_1', 'self-evolving'],@@ -404,3 +410,126 @@ describe('automations tab', () => {).toContain('automations');});});++describe('permission tab', () => {+ const base = {+ labels,+ mailSupported: false,+ selfLearningSupported: false,+ shareSupported: true,+ heterogeneous: false,+ };++ it('sits with the general entries, before share, for a workspace agent', () => {+ const options = buildAgentProfileTabOptions({+ ...base,+ active: 'profile',+ canConfigure: true,+ permissionSupported: true,+ });++ expect(+ groupAgentProfileTabOptions(options)+ .find((group) => group.key === 'general')+ ?.options.map((option) => option.value),+ ).toEqual(['statistics', 'permission', 'share']);+ });++ it('leaves the tab out without a workspace or edit access', () => {+ for (const gate of [+ { canConfigure: true, permissionSupported: false },+ { canConfigure: false, permissionSupported: true },+ ])+ expect(+ buildAgentProfileTabOptions({ ...base, active: 'profile', ...gate }).map((o) => o.value),+ ).not.toContain('permission');+ });++ it('keeps the tab of the current page even when gated off', () => {+ const options = buildAgentProfileTabOptions({+ ...base,+ active: 'permission',+ canConfigure: false,+ });++ expect(options.map((option) => option.value)).toContain('permission');+ });+});++describe('opening and graph tabs', () => {+ const base = {+ labels,+ mailSupported: false,+ selfLearningSupported: false,+ shareSupported: false,+ heterogeneous: false,+ };++ it('lists opening under Shape and graph under its own Advanced section', () => {+ const groups = groupAgentProfileTabOptions(+ buildAgentProfileTabOptions({+ ...base,+ active: 'profile',+ canConfigure: true,+ graphSupported: true,+ openingSupported: true,+ }),+ );+ const tabsOf = (key: string) =>+ groups.find((group) => group.key === key)?.options.map((option) => option.value);++ expect(tabsOf('shape')).toEqual(['instruction', 'knowledge', 'opening']);+ expect(tabsOf('setup')).toEqual(['engine', 'tools', 'skills']);+ expect(tabsOf('advanced')).toEqual(['graph']);+ expect(groups.map((group) => group.key)).toEqual([+ 'profile',+ 'shape',+ 'setup',+ 'identity',+ 'advanced',+ 'general',+ ]);+ });++ it('drops the Advanced section when the graph option does not apply', () => {+ const groups = groupAgentProfileTabOptions(+ buildAgentProfileTabOptions({+ ...base,+ active: 'profile',+ canConfigure: true,+ openingSupported: true,+ }),+ );++ expect(groups.map((group) => group.key)).not.toContain('advanced');+ });++ it('keeps opening for a heterogeneous agent', () => {+ const options = buildAgentProfileTabOptions({+ ...base,+ active: 'profile',+ canConfigure: true,+ heterogeneous: true,+ openingSupported: true,+ });++ expect(options.map((option) => option.value)).toContain('opening');+ });++ it.each([+ ['opening', { canConfigure: false, openingSupported: true }],+ ['opening', { canConfigure: true, openingSupported: false }],+ ['graph', { canConfigure: false, graphSupported: true }],+ ['graph', { canConfigure: true, graphSupported: false }],+ ] as const)('leaves %s out when its gate is closed', (tab, gate) => {+ const options = buildAgentProfileTabOptions({ ...base, active: 'profile', ...gate });++ expect(options.map((option) => option.value)).not.toContain(tab);+ });++ it.each(['opening', 'graph'] as const)('keeps %s on its own page when gated off', (active) => {+ const options = buildAgentProfileTabOptions({ ...base, active, canConfigure: false });++ expect(options.map((option) => option.value)).toContain(active);+ });+});diff --git a/src/features/AgentProfileTabs/tabOptions.ts b/src/features/AgentProfileTabs/tabOptions.tsindex fa717ade4cb..d95bb959f29 100644--- a/src/features/AgentProfileTabs/tabOptions.ts+++ b/src/features/AgentProfileTabs/tabOptions.ts@@ -5,9 +5,12 @@ export type AgentProfileTab =| 'channel'| 'engine'| 'environment'+ | 'graph'| 'instruction'| 'knowledge'| 'mail'+ | 'opening'+ | 'permission'| 'profile'| 'self-evolving'| 'share'@@ -21,7 +24,8 @@ export interface AgentProfileTabOption {value: AgentProfileTab;}-export type AgentProfileTabGroupKey = 'general' | 'identity' | 'profile' | 'setup' | 'shape';+export type AgentProfileTabGroupKey =+ 'advanced' | 'general' | 'identity' | 'profile' | 'setup' | 'shape';export interface AgentProfileTabGroup {key: AgentProfileTabGroupKey;@@ -32,7 +36,7 @@ export const buildAgentProfileTabPath = (agentId: string, tab: AgentProfileTab)urlJoin('/agent', agentId, tab);const AGENT_PROFILE_ROUTE =- /^(?:\/[^/]+)?\/agent\/[^/]+\/(profile|instruction|knowledge|engine|environment|tools|skills|mail(?:\/[^/]+)?|channel(?:\/[^/]+)?|automations|webhook|self-evolving(?:\/[^/]+)*|statistics|share)\/?$/;+ /^(?:\/[^/]+)?\/agent\/[^/]+\/(profile|instruction|knowledge|engine|environment|tools|skills|opening|graph|mail(?:\/[^/]+)?|channel(?:\/[^/]+)?|automations|webhook|self-evolving(?:\/[^/]+)*|statistics|permission|share)\/?$/;/*** The profile-group tab a URL belongs to, if any. Anchored on Agent subroutes,@@ -63,8 +67,11 @@ export const buildAgentProfileTabOptions = ({active,automationsSupported = false,canConfigure,+ graphSupported = false,labels,mailSupported,+ openingSupported = false,+ permissionSupported = false,selfLearningSupported,shareSupported,heterogeneous,@@ -74,8 +81,14 @@ export const buildAgentProfileTabOptions = ({/** Inbound webhooks are switched on for this member (`webhook`). */automationsSupported?: boolean;canConfigure: boolean;+ /** The Graph runtime option applies to this agent on this surface (`graph`). */+ graphSupported?: boolean;labels: Record<AgentProfileTab, string>;mailSupported: boolean;+ /** This surface lists the opening page; mobile has its own settings screen. */+ openingSupported?: boolean;+ /** The agent lives in a workspace and this surface lists the page (`permission`). */+ permissionSupported?: boolean;selfLearningSupported: boolean;shareSupported: boolean;/**@@ -96,6 +109,8 @@ export const buildAgentProfileTabOptions = ({const showEnvironment = (canConfigure && heterogeneous) || active === 'environment';const showTools = (canConfigure && !heterogeneous) || active === 'tools';const showSkills = (canConfigure && !heterogeneous) || active === 'skills';+ const showOpening = (canConfigure && openingSupported) || active === 'opening';+ const showGraph = (canConfigure && graphSupported) || active === 'graph';const showMail = (canConfigure && mailSupported) || active === 'mail';// Channels can dispatch to a bound device; cloud sandbox support is not required.const showChannel = canConfigure || active === 'channel';@@ -109,11 +124,14 @@ export const buildAgentProfileTabOptions = ({// capability gate (personal, non-builtin agents on deployments that allow it).const showShare = (canConfigure && shareSupported) || active === 'share';const showSelfLearning = selfLearningSupported || active === 'self-evolving';+ // The page applies the same edit gate and bounces anyone else back with a toast.+ const showPermission = (canConfigure && permissionSupported) || active === 'permission';return [showProfile ? { label: labels.profile, value: 'profile' as const } : null,showInstruction ? { label: labels.instruction, value: 'instruction' as const } : null,showKnowledge ? { label: labels.knowledge, value: 'knowledge' as const } : null,+ showOpening ? { label: labels.opening, value: 'opening' as const } : null,showEngine ? { label: labels.engine, value: 'engine' as const } : null,showEnvironment ? { label: labels.environment, value: 'environment' as const } : null,showTools ? { label: labels.tools, value: 'tools' as const } : null,@@ -122,18 +140,21 @@ export const buildAgentProfileTabOptions = ({showChannel ? { label: labels.channel, value: 'channel' as const } : null,showAutomations ? { label: labels.automations, value: 'automations' as const } : null,showWebhook ? { label: labels.webhook, value: 'webhook' as const } : null,+ showGraph ? { label: labels.graph, value: 'graph' as const } : null,showSelfLearning ? { label: labels['self-evolving'], value: 'self-evolving' as const } : null,{ label: labels.statistics, value: 'statistics' as const },+ showPermission ? { label: labels.permission, value: 'permission' as const } : null,showShare ? { label: labels.share, value: 'share' as const } : null,].filter((option) => !!option);};const AGENT_PROFILE_TAB_GROUPS: { key: AgentProfileTabGroupKey; tabs: AgentProfileTab[] }[] = [{ key: 'profile', tabs: ['profile'] },- { key: 'shape', tabs: ['instruction', 'knowledge'] },+ { key: 'shape', tabs: ['instruction', 'knowledge', 'opening'] },{ key: 'setup', tabs: ['engine', 'environment', 'tools', 'skills'] },{ key: 'identity', tabs: ['mail', 'channel', 'automations', 'webhook'] },- { key: 'general', tabs: ['self-evolving', 'statistics', 'share'] },+ { key: 'advanced', tabs: ['graph'] },+ { key: 'general', tabs: ['self-evolving', 'statistics', 'permission', '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 f3b5ec9d0b0..6b1b4ec73ce 100644--- a/src/features/AgentProfileTabs/useAgentProfileTabOptions.ts+++ b/src/features/AgentProfileTabs/useAgentProfileTabOptions.ts@@ -1,8 +1,10 @@import { useMemo } from 'react';import { useTranslation } from 'react-i18next';+import { useHasActiveWorkspace } from '@/business/client/hooks/useHasActiveWorkspace';import { useAgentShareSupported } from '@/business/client/useAgentShareSupported';import { useShowAgentIdentity } from '@/features/AgentMail/useShowAgentIdentity';+import { useAgentGraphSupported } from '@/features/AgentSettingsPage/useAgentGraphSupported';import { useResourceAccess } from '@/features/ResourcePermission/useResourceAccess';import { useSelfLearningSurface } from '@/features/SelfLearning/SurfaceGate/useSelfLearningSurface';import { usePermission } from '@/hooks/usePermission';@@ -19,7 +21,7 @@ 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', 'selfLearning', 'spend']);+ const { t } = useTranslation(['chat', 'common', 'selfLearning', 'setting', 'spend']);const { allowed: canEditContent } = usePermission('edit_own_content');const { canEditResource, canManageResource, isAccessResolved } = useResourceAccess(@@ -31,6 +33,7 @@ export const useAgentProfileTabOptions = (active: AgentProfileTab, agentId: striconst canConfigure = !!isAgentEditable && isAccessResolved && canEditContent && canEditResource;const canManageShare =!!isAgentEditable && isAccessResolved && canEditContent && canManageResource;+ const hasActiveWorkspace = useHasActiveWorkspace();const { visible: shareVisible } = useAgentShareSupported(agentId);const mailSupported = useShowAgentIdentity(agentId);// One flag switches on everything that wakes an agent from outside: its list and its webhooks.@@ -40,6 +43,11 @@ export const useAgentProfileTabOptions = (active: AgentProfileTab, agentId: stri// The mobile Segmented has no room for another segment, so mobile keeps the// drawer entry in `AgentSidebar/Header/Nav`.const selfLearningSupported = enableSelfLearning && !isMobileSurface();+ // Mobile reaches these from the profile header menu instead.+ const agentGraphSupported = useAgentGraphSupported();+ const graphSupported = agentGraphSupported && !isMobileSurface();+ const openingSupported = !isMobileSurface();+ const permissionSupported = hasActiveWorkspace && !isMobileSurface();return useMemo(() =>@@ -47,14 +55,18 @@ export const useAgentProfileTabOptions = (active: AgentProfileTab, agentId: striactive,automationsSupported: webhookSupported,canConfigure,+ graphSupported,labels: {'automations': t('tab.automations'),'channel': t('tab.integration'),'engine': t('tab.engine'),'environment': t('tab.environment'),+ 'graph': t('agentTab.graph', { ns: 'setting' }),'instruction': t('tab.instruction'),'knowledge': t('tab.knowledge'),'mail': t('tab.mail'),+ 'opening': t('agentTab.opening', { ns: 'setting' }),+ 'permission': t('permission.page.entry', { ns: 'setting' }),// 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.@@ -67,6 +79,8 @@ export const useAgentProfileTabOptions = (active: AgentProfileTab, agentId: stri'webhook': t('tab.webhook'),},mailSupported,+ openingSupported,+ permissionSupported,selfLearningSupported,shareSupported: shareVisible === true && canManageShare,heterogeneous: isHeterogeneous,@@ -76,8 +90,11 @@ export const useAgentProfileTabOptions = (active: AgentProfileTab, agentId: striactive,canConfigure,canManageShare,+ graphSupported,isHeterogeneous,mailSupported,+ openingSupported,+ permissionSupported,selfLearningSupported,shareVisible,t,diff --git a/src/features/AgentSettingsPage/GraphSettings.tsx b/src/features/AgentSettingsPage/GraphSettings.tsxnew file mode 100644index 00000000000..c5fb5474bb5--- /dev/null+++ b/src/features/AgentSettingsPage/GraphSettings.tsx@@ -0,0 +1,23 @@+'use client';++import { Navigate } from 'react-router';++import SurfaceSkeleton from '@/components/Skeleton/Surface';+import AgentGraphRuntime from '@/features/AgentSetting/AgentGraphRuntime';+import { useUserStore } from '@/store/user';++import { useAgentGraphSupported } from './useAgentGraphSupported';++/** A deep link is the only way here without the option, so send it to a page that exists. */+const GraphSettings = () => {+ const isUserStateInit = useUserStore((s) => s.isUserStateInit);+ const supported = useAgentGraphSupported();++ // The Labs switch reads as off until the user state lands.+ if (!isUserStateInit) return <SurfaceSkeleton header={false} variant={'form'} />;+ if (!supported) return <Navigate replace relative={'path'} to={'../opening'} />;++ return <AgentGraphRuntime />;+};++export default GraphSettings;diff --git a/src/features/AgentSettingsPage/index.tsx b/src/features/AgentSettingsPage/index.tsxnew file mode 100644index 00000000000..0fcaf95715f--- /dev/null+++ b/src/features/AgentSettingsPage/index.tsx@@ -0,0 +1,75 @@+'use client';++import { Flexbox } from '@lobehub/ui';+import type { ReactNode } from 'react';++import AsyncBoundary from '@/components/AsyncBoundary';+import SurfaceSkeleton from '@/components/Skeleton/Surface';+import AgentBreadcrumb from '@/features/AgentBreadcrumb';+import { AgentSettingsProvider } from '@/features/AgentSetting/AgentSettingsProvider';+import NavHeader from '@/features/NavHeader';+import WideScreenContainer from '@/features/WideScreenContainer';+import { useAgentStore } from '@/store/agent';+import { agentSelectors } from '@/store/agent/selectors';++import { useAgentSettingsPage } from './useAgentSettingsPage';++const SettingsProvider = ({ children }: { children: ReactNode }) => {+ const { agentId, canEdit, config, meta, updateConfig, updateMeta } = useAgentSettingsPage();++ return (+ <AgentSettingsProvider+ config={config}+ disabled={!canEdit}+ id={agentId}+ loading={false}+ meta={meta}+ onConfigChange={updateConfig}+ onMetaChange={updateMeta}+ >+ {children}+ </AgentSettingsProvider>+ );+};++interface AgentSettingsPageProps {+ children: ReactNode;+ title: string;+}++/** Shell for a profile-group page whose body edits the agent through the settings store. */+const AgentSettingsPage = ({ children, title }: AgentSettingsPageProps) => {+ const activeAgentId = useAgentStore((s) => s.activeAgentId);+ // Data-presence loading stays true on failure, so read the recorded fetch+ // error too; otherwise a failed config load would show an empty form.+ const isAgentConfigLoading = useAgentStore(agentSelectors.isAgentConfigLoading);+ const configError = useAgentStore(agentSelectors.currentAgentConfigError);+ const retryAgentConfigFetch = useAgentStore((s) => s.retryAgentConfigFetch);++ return (+ <Flexbox height={'100%'} width={'100%'}>+ <NavHeader+ left={activeAgentId ? <AgentBreadcrumb agentId={activeAgentId} title={title} /> : null}+ styles={{ left: { paddingInlineStart: 24 } }}+ />+ <Flexbox flex={1} style={{ overflowY: 'auto', position: 'relative' }} width={'100%'}>+ <WideScreenContainer>+ <Flexbox paddingBlock={16}>+ <AsyncBoundary+ data={isAgentConfigLoading ? undefined : true}+ error={configError}+ errorVariant={'page'}+ isLoading={isAgentConfigLoading && !configError}+ loading={<SurfaceSkeleton header={false} variant={'form'} />}+ onRetry={() => retryAgentConfigFetch()}+ >+ <SettingsProvider>{children}</SettingsProvider>+ </AsyncBoundary>+ </Flexbox>+ </WideScreenContainer>+ </Flexbox>+ </Flexbox>+ );+};++export default AgentSettingsPage;diff --git a/src/features/AgentSettingsPage/useAgentGraphSupported.test.ts b/src/features/AgentSettingsPage/useAgentGraphSupported.test.tsnew file mode 100644index 00000000000..bbdbebf7199--- /dev/null+++ b/src/features/AgentSettingsPage/useAgentGraphSupported.test.ts@@ -0,0 +1,63 @@+import { renderHook } from '@testing-library/react';+import { beforeEach, describe, expect, it, vi } from 'vitest';++import { useAgentGraphSupported } from './useAgentGraphSupported';++const mocks = vi.hoisted(() => ({+ agentState: { isCurrentAgentHeterogeneous: false, isInbox: false },+ userState: { preference: { lab: { enableAgentGraphConfig: false } } },+}));++vi.mock('@/store/agent', () => ({+ useAgentStore: (selector: (state: typeof mocks.agentState) => unknown) =>+ selector(mocks.agentState),+}));++vi.mock('@/store/agent/selectors', () => ({+ agentSelectors: {+ isCurrentAgentHeterogeneous: (state: typeof mocks.agentState) =>+ state.isCurrentAgentHeterogeneous,+ },+ builtinAgentSelectors: {+ isInboxAgent: (state: typeof mocks.agentState) => state.isInbox,+ },+}));++vi.mock('@/store/user', () => ({+ useUserStore: (selector: (state: typeof mocks.userState) => unknown) => selector(mocks.userState),+}));++vi.mock('@/store/user/selectors', () => ({+ labPreferSelectors: {+ enableAgentGraphConfig: (state: typeof mocks.userState) =>+ state.preference.lab.enableAgentGraphConfig,+ },+}));++describe('useAgentGraphSupported', () => {+ beforeEach(() => {+ mocks.agentState.isInbox = false;+ mocks.agentState.isCurrentAgentHeterogeneous = false;+ mocks.userState.preference.lab.enableAgentGraphConfig = false;+ });++ it('is off while the Labs switch is off', () => {+ expect(renderHook(() => useAgentGraphSupported()).result.current).toBe(false);+ });++ it('is on for a custom agent when the Labs switch is on', () => {+ mocks.userState.preference.lab.enableAgentGraphConfig = true;++ expect(renderHook(() => useAgentGraphSupported()).result.current).toBe(true);+ });++ it.each(['isInbox', 'isCurrentAgentHeterogeneous'] as const)(+ 'stays off when %s, even with the Labs switch on',+ (flag) => {+ mocks.userState.preference.lab.enableAgentGraphConfig = true;+ mocks.agentState[flag] = true;++ expect(renderHook(() => useAgentGraphSupported()).result.current).toBe(false);+ },+ );+});diff --git a/src/features/AgentSettingsPage/useAgentGraphSupported.ts b/src/features/AgentSettingsPage/useAgentGraphSupported.tsnew file mode 100644index 00000000000..9b6d55b17d0--- /dev/null+++ b/src/features/AgentSettingsPage/useAgentGraphSupported.ts@@ -0,0 +1,13 @@+import { useAgentStore } from '@/store/agent';+import { agentSelectors, builtinAgentSelectors } from '@/store/agent/selectors';+import { useUserStore } from '@/store/user';+import { labPreferSelectors } from '@/store/user/selectors';++/** Graph runtime is a Labs option for custom agents that run on the built-in runtime. */+export const useAgentGraphSupported = () => {+ const enabled = useUserStore(labPreferSelectors.enableAgentGraphConfig);+ const isInbox = useAgentStore(builtinAgentSelectors.isInboxAgent);+ const isHeterogeneous = useAgentStore(agentSelectors.isCurrentAgentHeterogeneous);++ return !!enabled && !isInbox && !isHeterogeneous;+};diff --git a/src/features/AgentSettingsPage/useAgentSettingsPage.test.ts b/src/features/AgentSettingsPage/useAgentSettingsPage.test.tsnew file mode 100644index 00000000000..1407761f6e2--- /dev/null+++ b/src/features/AgentSettingsPage/useAgentSettingsPage.test.ts@@ -0,0 +1,72 @@+import { act, renderHook } from '@testing-library/react';+import { beforeEach, describe, expect, it, vi } from 'vitest';++import { useAgentSettingsPage } from './useAgentSettingsPage';++const mocks = vi.hoisted(() => ({+ agentState: {+ activeAgentId: 'agent-1' as string | undefined,+ config: {},+ meta: {},+ optimisticUpdateAgentConfig: vi.fn(),+ optimisticUpdateAgentMeta: vi.fn(),+ },+ canEdit: true,+}));++vi.mock('@/hooks/usePermission', () => ({+ usePermission: () => ({ allowed: mocks.canEdit }),+}));++vi.mock('@/store/agent', () => {+ const useAgentStore = (selector: (state: typeof mocks.agentState) => unknown) =>+ selector(mocks.agentState);+ useAgentStore.getState = () => mocks.agentState;++ return { useAgentStore };+});++vi.mock('@/store/agent/selectors', () => ({+ agentSelectors: {+ currentAgentConfig: (state: typeof mocks.agentState) => state.config,+ currentAgentMeta: (state: typeof mocks.agentState) => state.meta,+ },+}));++describe('useAgentSettingsPage', () => {+ beforeEach(() => {+ mocks.agentState.activeAgentId = 'agent-1';+ mocks.agentState.optimisticUpdateAgentConfig.mockClear();+ mocks.agentState.optimisticUpdateAgentMeta.mockClear();+ mocks.canEdit = true;+ });++ it('saves config and meta to the active agent', async () => {+ const { result } = renderHook(() => useAgentSettingsPage());++ await act(async () => {+ await result.current.updateConfig({ openingMessage: 'hi' });+ await result.current.updateMeta({ title: 'Agent' });+ });++ expect(mocks.agentState.optimisticUpdateAgentConfig).toHaveBeenCalledWith('agent-1', {+ openingMessage: 'hi',+ });+ expect(mocks.agentState.optimisticUpdateAgentMeta).toHaveBeenCalledWith('agent-1', {+ title: 'Agent',+ });+ });++ it('does not save for a member who cannot edit', async () => {+ mocks.canEdit = false;+ const { result } = renderHook(() => useAgentSettingsPage());++ await act(async () => {+ await result.current.updateConfig({ openingMessage: 'hi' });+ await result.current.updateMeta({ title: 'Agent' });+ });++ expect(mocks.agentState.optimisticUpdateAgentConfig).not.toHaveBeenCalled();+ expect(mocks.agentState.optimisticUpdateAgentMeta).not.toHaveBeenCalled();+ });+});diff --git a/src/features/AgentSettingsPage/useAgentSettingsPage.ts b/src/features/AgentSettingsPage/useAgentSettingsPage.tsnew file mode 100644index 00000000000..822eacb28fe--- /dev/null+++ b/src/features/AgentSettingsPage/useAgentSettingsPage.ts@@ -0,0 +1,26 @@+import type { LobeAgentConfig, MetaData } from '@lobechat/types';+import isEqual from 'fast-deep-equal';++import { usePermission } from '@/hooks/usePermission';+import { useAgentStore } from '@/store/agent';+import { agentSelectors } from '@/store/agent/selectors';++/** The active agent's config and meta, with writes gated on edit permission. */+export const useAgentSettingsPage = () => {+ const { allowed: canEdit } = usePermission('edit_own_content');+ const agentId = useAgentStore((s) => s.activeAgentId);+ const config = useAgentStore(agentSelectors.currentAgentConfig, isEqual);+ const meta = useAgentStore(agentSelectors.currentAgentMeta, isEqual);++ const updateConfig = async (next: Partial<LobeAgentConfig>) => {+ if (!canEdit || !agentId) return;+ await useAgentStore.getState().optimisticUpdateAgentConfig(agentId, next);+ };++ const updateMeta = async (next: Partial<MetaData>) => {+ if (!canEdit || !agentId) return;+ await useAgentStore.getState().optimisticUpdateAgentMeta(agentId, next);+ };++ return { agentId, canEdit, config, meta, updateConfig, updateMeta };+};diff --git a/src/features/AgentSidebar/ProfileNav.tsx b/src/features/AgentSidebar/ProfileNav.tsxindex 959b620864f..3fe77231d85 100644--- a/src/features/AgentSidebar/ProfileNav.tsx+++ b/src/features/AgentSidebar/ProfileNav.tsx@@ -7,14 +7,17 @@ import {ChevronLeftIcon,CpuIcon,DnaIcon,+ GitBranchIcon,LibraryBigIcon,MailIcon,+ MessageSquareHeartIcon,MonitorSmartphoneIcon,RadioTowerIcon,ScrollTextIcon,Share2Icon,SparklesIcon,UserRoundIcon,+ UsersIcon,WebhookIcon,WrenchIcon,ZapIcon,@@ -41,9 +44,12 @@ const TAB_ICONS: Record<AgentProfileTab, LucideIcon> = {'channel': RadioTowerIcon,'engine': CpuIcon,'environment': MonitorSmartphoneIcon,+ 'graph': GitBranchIcon,'instruction': ScrollTextIcon,'knowledge': LibraryBigIcon,'mail': MailIcon,+ 'opening': MessageSquareHeartIcon,+ 'permission': UsersIcon,'profile': UserRoundIcon,'self-evolving': DnaIcon,'share': Share2Icon,diff --git a/src/features/RouteMeta/AgentDynamicMeta.tsx b/src/features/RouteMeta/AgentDynamicMeta.tsxindex 38a1e0dd28f..9abb1d2529d 100644--- a/src/features/RouteMeta/AgentDynamicMeta.tsx+++ b/src/features/RouteMeta/AgentDynamicMeta.tsx@@ -109,6 +109,8 @@ export const ChannelDynamicMeta = createAgentSectionDynamicMeta('navigation.chanexport const StatisticsDynamicMeta = createAgentSectionDynamicMeta('navigation.stats');export const ShareDynamicMeta = createAgentSectionDynamicMeta('navigation.agentShare');export const SelfLearningDynamicMeta = createAgentSectionDynamicMeta('navigation.selfLearning');+export const OpeningDynamicMeta = createAgentSectionDynamicMeta('navigation.opening');+export const GraphDynamicMeta = createAgentSectionDynamicMeta('navigation.graph');export const PermissionDynamicMeta = createAgentSectionDynamicMeta('navigation.permission');export const DocumentsDynamicMeta = createAgentSectionDynamicMeta('navigation.document');export const GoalsDynamicMeta = createAgentSectionDynamicMeta('navigation.goals');diff --git a/src/hooks/useInterceptingRoutes.test.ts b/src/hooks/useInterceptingRoutes.test.tsindex 6c326ee83f4..da4376500a8 100644--- a/src/hooks/useInterceptingRoutes.test.ts+++ b/src/hooks/useInterceptingRoutes.test.ts@@ -1,60 +1,62 @@import { act, renderHook } from '@testing-library/react';-import { beforeEach, describe, expect, it, vi } from 'vitest';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';-import { useIsMobile } from '@/hooks/useIsMobile';-import { openAgentSettingsModal } from '@/routes/(main)/agent/profile/features/AgentSettings';import { useAgentStore } from '@/store/agent';-import { ChatSettingsTabs } from '@/store/global/initialState';import { useOpenChatSettings } from './useInterceptingRoutes';const mockNavigate = vi.fn();-const mockUseNavigate = vi.fn(() => mockNavigate);-const mockUseLocation = vi.fn(() => ({ pathname: '/' }));vi.mock('react-router', () => ({- useNavigate: () => mockUseNavigate(),- useLocation: () => mockUseLocation(),-}));-vi.mock('@/hooks/useIsMobile', () => ({- useIsMobile: vi.fn(),+ useLocation: () => ({ pathname: '/' }),+ useNavigate: () => mockNavigate,}));vi.mock('@/store/global', () => ({useGlobalStore: {setState: vi.fn(),},}));-vi.mock('@/routes/(main)/agent/profile/features/AgentSettings', () => ({- openAgentSettingsModal: vi.fn(),-}));+describe('useOpenChatSettings', () => {beforeEach(() => {vi.clearAllMocks();useAgentStore.setState({ activeAgentId: undefined });});- it('navigates to mobile agent settings route for the active agent', () => {+ afterEach(() => {+ vi.unstubAllGlobals();+ });++ it('navigates to the mobile settings screen in the mobile bundle', () => {+ vi.stubGlobal('__MOBILE__', true);useAgentStore.setState({ activeAgentId: '123' });- vi.mocked(useIsMobile).mockReturnValue(true);- const { result } = renderHook(() => useOpenChatSettings(ChatSettingsTabs.Opening));+ const { result } = renderHook(() => useOpenChatSettings());act(() => {result.current();});- expect(mockNavigate).toHaveBeenCalledWith(`/agent/123/settings?showMobileWorkspace=true`);+ expect(mockNavigate).toHaveBeenCalledWith('/agent/123/settings?showMobileWorkspace=true');});- it('opens desktop agent settings overlay when not on mobile', async () => {+ it('navigates to the opening settings page on desktop and web', () => {+ vi.stubGlobal('__MOBILE__', false);useAgentStore.setState({ activeAgentId: '456' });- vi.mocked(useIsMobile).mockReturnValue(false);+ const { result } = renderHook(() => useOpenChatSettings());++ act(() => {+ result.current();+ });++ expect(mockNavigate).toHaveBeenCalledWith('/agent/456/opening');+ });- const { result } = renderHook(() => useOpenChatSettings(ChatSettingsTabs.Opening));+ it('does nothing without an active agent', () => {+ const { result } = renderHook(() => useOpenChatSettings());act(() => {result.current();});- await vi.waitFor(() => expect(openAgentSettingsModal).toHaveBeenCalled());expect(mockNavigate).not.toHaveBeenCalled();});});diff --git a/src/hooks/useInterceptingRoutes.ts b/src/hooks/useInterceptingRoutes.tsindex 2890377d971..b26d5c2a22b 100644--- a/src/hooks/useInterceptingRoutes.ts+++ b/src/hooks/useInterceptingRoutes.ts@@ -1,26 +1,22 @@-import { useMemo } from 'react';-import { useLocation } from 'react-router';+import { useCallback } from 'react';+import { buildAgentProfileTabPath } from '@/features/AgentProfileTabs/tabOptions';import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';-import { useIsMobile } from '@/hooks/useIsMobile';import { useAgentStore } from '@/store/agent';-import { ChatSettingsTabs } from '@/store/global/initialState';+import { isMobileSurface } from '@/utils/mobileSurface';-export const useOpenChatSettings = (tab: ChatSettingsTabs = ChatSettingsTabs.Opening) => {+export const useOpenChatSettings = () => {const activeAgentId = useAgentStore((s) => s.activeAgentId);-- const isMobile = useIsMobile();const navigate = useWorkspaceAwareNavigate();- const location = useLocation();- return useMemo(() => {- if (isMobile)- return () => navigate(`/agent/${activeAgentId}/settings?showMobileWorkspace=true`);+ return useCallback(() => {+ if (!activeAgentId) return;- return () => {- void import('@/routes/(main)/agent/profile/features/AgentSettings').then((m) =>- m.openAgentSettingsModal(),- );- };- }, [activeAgentId, navigate, location.pathname, tab, isMobile]);+ // The mobile bundle keeps its own settings screen.+ navigate(+ isMobileSurface()+ ? `/agent/${activeAgentId}/settings?showMobileWorkspace=true`+ : buildAgentProfileTabPath(activeAgentId, 'opening'),+ );+ }, [activeAgentId, navigate]);};diff --git a/src/routes/(main)/agent/features/routeMeta.ts b/src/routes/(main)/agent/features/routeMeta.tsindex 0d006afc726..9a2646c07fe 100644--- a/src/routes/(main)/agent/features/routeMeta.ts+++ b/src/routes/(main)/agent/features/routeMeta.ts@@ -3,10 +3,12 @@ import {CpuIcon,FileTextIcon,FileUserIcon,+ GitBranchIcon,GraduationCapIcon,LibraryBigIcon,MailIcon,MessageSquare,+ MessageSquareHeartIcon,MessagesSquareIcon,MonitorSmartphoneIcon,RadioTowerIcon,@@ -42,6 +44,16 @@ const TopicsDynamicMeta = lazy(() =>default: module.TopicsDynamicMeta,})),);+const OpeningDynamicMeta = lazy(() =>+ import('@/features/RouteMeta/AgentDynamicMeta').then((module) => ({+ default: module.OpeningDynamicMeta,+ })),+);+const GraphDynamicMeta = lazy(() =>+ import('@/features/RouteMeta/AgentDynamicMeta').then((module) => ({+ default: module.GraphDynamicMeta,+ })),+);const EngineDynamicMeta = lazy(() =>import('@/features/RouteMeta/AgentDynamicMeta').then((module) => ({default: module.EngineDynamicMeta,@@ -268,6 +280,20 @@ export const agentSelfLearningRouteMeta = routeMeta({titleKey: 'navigation.selfLearning',});+export const agentOpeningRouteMeta = routeMeta({+ DynamicMeta: OpeningDynamicMeta,+ icon: MessageSquareHeartIcon,+ Skeleton: createSurfaceSkeleton('form'),+ titleKey: 'navigation.opening',+});++export const agentGraphRouteMeta = routeMeta({+ DynamicMeta: GraphDynamicMeta,+ icon: GitBranchIcon,+ Skeleton: createSurfaceSkeleton('form'),+ titleKey: 'navigation.graph',+});+export const agentPermissionRouteMeta = routeMeta({DynamicMeta: PermissionDynamicMeta,icon: UsersIcon,diff --git a/src/routes/(main)/agent/graph/index.tsx b/src/routes/(main)/agent/graph/index.tsxnew file mode 100644index 00000000000..66b4af21d8b--- /dev/null+++ b/src/routes/(main)/agent/graph/index.tsx@@ -0,0 +1,27 @@+'use client';++import { useTranslation } from 'react-i18next';+import { useParams } from 'react-router';++import AgentSettingsPage from '@/features/AgentSettingsPage';+import GraphSettings from '@/features/AgentSettingsPage/GraphSettings';+import ResourceConfigAccessGate from '@/features/ResourcePermission/ResourceConfigAccessGate';++const AgentGraphPage = () => {+ const { t } = useTranslation('setting');+ const { aid } = useParams<{ aid: string }>();++ return (+ <ResourceConfigAccessGate+ redirectPath={`/agent/${aid ?? ''}`}+ resourceId={aid}+ resourceType="agent"+ >+ <AgentSettingsPage title={t('agentTab.graph')}>+ <GraphSettings />+ </AgentSettingsPage>+ </ResourceConfigAccessGate>+ );+};++export default AgentGraphPage;diff --git a/src/routes/(main)/agent/opening/index.tsx b/src/routes/(main)/agent/opening/index.tsxnew file mode 100644index 00000000000..6eb0ce69aae--- /dev/null+++ b/src/routes/(main)/agent/opening/index.tsx@@ -0,0 +1,27 @@+'use client';++import { useTranslation } from 'react-i18next';+import { useParams } from 'react-router';++import AgentOpening from '@/features/AgentSetting/AgentOpening';+import AgentSettingsPage from '@/features/AgentSettingsPage';+import ResourceConfigAccessGate from '@/features/ResourcePermission/ResourceConfigAccessGate';++const AgentOpeningPage = () => {+ const { t } = useTranslation('setting');+ const { aid } = useParams<{ aid: string }>();++ return (+ <ResourceConfigAccessGate+ redirectPath={`/agent/${aid ?? ''}`}+ resourceId={aid}+ resourceType="agent"+ >+ <AgentSettingsPage title={t('agentTab.opening')}>+ <AgentOpening />+ </AgentSettingsPage>+ </ResourceConfigAccessGate>+ );+};++export default AgentOpeningPage;diff --git a/src/routes/(main)/agent/profile/features/AgentSettings/Content.test.tsx b/src/routes/(main)/agent/profile/features/AgentSettings/Content.test.tsxdeleted file mode 100644index 62ba73a7c13..00000000000--- a/src/routes/(main)/agent/profile/features/AgentSettings/Content.test.tsx+++ /dev/null@@ -1,114 +0,0 @@-import { render, screen } from '@testing-library/react';-import type { ReactNode } from 'react';-import { beforeEach, describe, expect, it, vi } from 'vitest';--import { ChatSettingsTabs } from '@/store/global/initialState';--import Content from './Content';--const mocks = vi.hoisted(() => ({- agentState: {- activeAgentId: 'inbox-agent',- config: {},- isCurrentAgentHeterogeneous: false,- isInbox: true,- meta: {},- optimisticUpdateAgentConfig: vi.fn(),- optimisticUpdateAgentMeta: vi.fn(),- },- userState: { preference: { lab: { enableAgentGraphConfig: false } } },-}));--vi.mock('@/features/AgentSetting', () => ({- AgentSettings: ({ tab }: { tab: ChatSettingsTabs }) => (- <div data-tab={tab} data-testid="agent-settings-content" />- ),- SettingsModalLayout: ({- activeTab,- tabs = [],- children,- }: {- activeTab?: string;- children?: ReactNode;- tabs?: { key: string }[];- }) => (- <div- data-active={activeTab}- data-tabs={tabs.map((tab) => tab.key).join(',')}- data-testid="layout"- >- {children}- </div>- ),-}));--vi.mock('@/store/agent', () => {- const useAgentStore = (selector: (state: typeof mocks.agentState) => unknown) =>- selector(mocks.agentState);- useAgentStore.getState = () => mocks.agentState;-- return { useAgentStore };-});--vi.mock('@/store/agent/selectors', () => ({- agentSelectors: {- currentAgentConfig: (state: typeof mocks.agentState) => state.config,- currentAgentMeta: (state: typeof mocks.agentState) => state.meta,- isCurrentAgentHeterogeneous: (state: typeof mocks.agentState) =>- state.isCurrentAgentHeterogeneous,- },- builtinAgentSelectors: {- isInboxAgent: (state: typeof mocks.agentState) => state.isInbox,- },-}));--vi.mock('@/store/user', () => ({- useUserStore: (selector: (state: typeof mocks.userState) => unknown) => selector(mocks.userState),-}));--vi.mock('@/store/user/selectors', () => ({- labPreferSelectors: {- enableAgentGraphConfig: (state: typeof mocks.userState) =>- state.preference.lab.enableAgentGraphConfig,- },-}));--describe('AgentSettings Content', () => {- beforeEach(() => {- mocks.agentState.isInbox = true;- mocks.agentState.isCurrentAgentHeterogeneous = false;- mocks.userState.preference.lab.enableAgentGraphConfig = false;- });-- it('opens on the opening tab', () => {- render(<Content />);-- const layout = screen.getByTestId('layout');- expect(layout).toHaveAttribute('data-active', ChatSettingsTabs.Opening);- expect(layout).toHaveAttribute('data-tabs', ChatSettingsTabs.Opening);- expect(screen.getByTestId('agent-settings-content')).toHaveAttribute(- 'data-tab',- ChatSettingsTabs.Opening,- );- });-- it('adds the graph tab for custom agents when its Labs switch is on', () => {- mocks.agentState.isInbox = false;- mocks.userState.preference.lab.enableAgentGraphConfig = true;-- render(<Content />);-- expect(screen.getByTestId('layout')).toHaveAttribute(- 'data-tabs',- `${ChatSettingsTabs.Opening},${ChatSettingsTabs.Graph}`,- );- });-- it('keeps the graph tab off for inbox even with its Labs switch on', () => {- mocks.userState.preference.lab.enableAgentGraphConfig = true;-- render(<Content />);-- expect(screen.getByTestId('layout')).toHaveAttribute('data-tabs', ChatSettingsTabs.Opening);- });-});diff --git a/src/routes/(main)/agent/profile/features/AgentSettings/Content.tsx b/src/routes/(main)/agent/profile/features/AgentSettings/Content.tsxdeleted file mode 100644index a1b96d29290..00000000000--- a/src/routes/(main)/agent/profile/features/AgentSettings/Content.tsx+++ /dev/null@@ -1,109 +0,0 @@-'use client';--import { DEFAULT_INBOX_TITLE } from '@lobechat/const';-import { agentDisplayName } from '@lobechat/types';-import isEqual from 'fast-deep-equal';-import { GitBranchIcon, MessageSquareHeartIcon } from 'lucide-react';-import { memo, useEffect, useMemo, useState } from 'react';-import { useTranslation } from 'react-i18next';-import { shallow } from 'zustand/shallow';--import { DEFAULT_INBOX_AVATAR } from '@/const/meta';-import {- AgentSettings as Settings,- SettingsModalLayout,- type SettingsModalTabItem,-} from '@/features/AgentSetting';-import { usePermission } from '@/hooks/usePermission';-import { useAgentStore } from '@/store/agent';-import { agentSelectors, builtinAgentSelectors } from '@/store/agent/selectors';-import { ChatSettingsTabs } from '@/store/global/initialState';-import { useUserStore } from '@/store/user';-import { labPreferSelectors } from '@/store/user/selectors';--const TAB_META = {- [ChatSettingsTabs.Graph]: { icon: GitBranchIcon, labelKey: 'agentTab.graph' },- [ChatSettingsTabs.Opening]: { icon: MessageSquareHeartIcon, labelKey: 'agentTab.opening' },-} as const;--const Content = memo(() => {- const { t } = useTranslation('setting');- const { allowed: canEdit } = usePermission('edit_own_content');- const [agentId, isInbox] = useAgentStore(- (s) => [s.activeAgentId, builtinAgentSelectors.isInboxAgent(s)],- shallow,- );- const config = useAgentStore(agentSelectors.currentAgentConfig, isEqual);- const meta = useAgentStore(agentSelectors.currentAgentMeta, isEqual);- const isHeterogeneous = useAgentStore(agentSelectors.isCurrentAgentHeterogeneous);- const enableAgentGraphConfigLab = useUserStore(labPreferSelectors.enableAgentGraphConfig);- const [tab, setTab] = useState(ChatSettingsTabs.Opening);- const showGraphTab = enableAgentGraphConfigLab && !isInbox && !isHeterogeneous;-- const availableTabs = useMemo(- () =>- [ChatSettingsTabs.Opening, showGraphTab ? ChatSettingsTabs.Graph : null].filter(- Boolean,- ) as ChatSettingsTabs[],- [showGraphTab],- );-- const activeTab = availableTabs.includes(tab) ? tab : availableTabs[0];-- useEffect(() => {- if (activeTab && activeTab !== tab) setTab(activeTab);- }, [activeTab, tab]);-- const updateAgentConfig = async (config: any) => {- if (!canEdit) return;- if (!agentId) return;- await useAgentStore.getState().optimisticUpdateAgentConfig(agentId, config);- };-- const updateAgentMeta = async (meta: any) => {- if (!canEdit) return;- if (!agentId) return;- await useAgentStore.getState().optimisticUpdateAgentMeta(agentId, meta);- };-- const tabs: SettingsModalTabItem[] = useMemo(- () =>- availableTabs.map((key) => {- const entry = TAB_META[key as keyof typeof TAB_META];- return { icon: entry.icon, key, label: t(entry.labelKey) };- }),- [availableTabs, t],- );-- const displayTitle = agentDisplayName(- meta,- isInbox ? DEFAULT_INBOX_TITLE : t('defaultSession', { ns: 'common' }),- );-- return (- <SettingsModalLayout- activeTab={activeTab}- agentId={agentId}- avatar={meta.avatar || (isInbox ? DEFAULT_INBOX_AVATAR : '')}- background={meta.backgroundColor || undefined}- tabs={tabs}- title={displayTitle}- onTabChange={(key) => setTab(key as ChatSettingsTabs)}- >- {activeTab && (- <Settings- config={config}- disabled={!canEdit}- id={agentId}- loading={false}- meta={meta}- tab={activeTab}- onConfigChange={updateAgentConfig}- onMetaChange={updateAgentMeta}- />- )}- </SettingsModalLayout>- );-});--export default Content;diff --git a/src/routes/(main)/agent/profile/features/AgentSettings/index.tsx b/src/routes/(main)/agent/profile/features/AgentSettings/index.tsxdeleted file mode 100644index 4756c319a0e..00000000000--- a/src/routes/(main)/agent/profile/features/AgentSettings/index.tsx+++ /dev/null@@ -1,22 +0,0 @@-'use client';--import { createModal, type ModalInstance } from '@lobehub/ui';--import Content from './Content';--export const openAgentSettingsModal = (): ModalInstance =>- createModal({- content: <Content />,- footer: null,- maskClosable: true,- styles: {- content: {- height: '60vh',- overflow: 'scroll',- padding: 0,- position: 'relative',- },- header: { display: 'none' },- },- width: 960,- });diff --git a/src/routes/(main)/agent/profile/features/Header/index.test.tsx b/src/routes/(main)/agent/profile/features/Header/index.test.tsxindex 41c801fd794..d719402e7d4 100644--- a/src/routes/(main)/agent/profile/features/Header/index.test.tsx+++ b/src/routes/(main)/agent/profile/features/Header/index.test.tsx@@ -300,6 +300,7 @@ describe('Agent profile Header', () => {mocks.shareSupport = { publishable: false, supported: false, visible: false };mocks.serverConfigState.featureFlags.enableAgentShare = undefined;mocks.serverConfigState.serverConfig.enableBusinessFeatures = true;+ vi.stubGlobal('__MOBILE__', false);});describe('Market review entry', () => {@@ -395,7 +396,8 @@ describe('Agent profile Header', () => {it.each([['the role cannot edit content', { canEditResource: true, permission: false }],['General Access is view-only', { canEditResource: false, permission: true }],- ])('disables the config entries when %s', (_label, { canEditResource, permission }) => {+ ])('disables the mobile config entries when %s', (_label, { canEditResource, permission }) => {+ vi.stubGlobal('__MOBILE__', true);mocks.permission.allowed = permission;mocks.resourceAccess.canEditResource = canEditResource;// No global mock reset in this file, so the shared spy carries calls in@@ -444,7 +446,15 @@ describe('Agent profile Header', () => {await waitFor(() => expect(mocks.copyToClipboard).toHaveBeenCalledWith('agent-1'));});+ it('leaves the config entries to the sidebar on desktop', () => {+ render(<Header />);++ expect(screen.queryByRole('button', { name: 'advancedSettings' })).toBeNull();+ expect(screen.queryByRole('button', { name: 'permission.page.entry' })).toBeNull();+ });+it('shows workspace resource permission controls for the LobeAI inbox agent', () => {+ vi.stubGlobal('__MOBILE__', true);mocks.agentState.isInbox = true;render(<Header />);@@ -453,7 +463,8 @@ describe('Agent profile Header', () => {expect(screen.getByTestId('access-level-resource-id')).toHaveTextContent('agent-1');});- it('opens the Permission page from the menu entry', () => {+ it('opens the Permission page from the mobile menu entry', () => {+ vi.stubGlobal('__MOBILE__', true);render(<Header />);fireEvent.click(screen.getByRole('button', { name: 'permission.page.entry' }));@@ -462,6 +473,7 @@ describe('Agent profile Header', () => {});it('keeps the Permission entry on a private workspace agent — its model / environment policies still apply once shared', () => {+ vi.stubGlobal('__MOBILE__', true);mocks.agentState.visibility = 'private';render(<Header />);diff --git a/src/routes/(main)/agent/profile/features/Header/index.tsx b/src/routes/(main)/agent/profile/features/Header/index.tsxindex cd78beaecf4..808f9f335a6 100644--- a/src/routes/(main)/agent/profile/features/Header/index.tsx+++ b/src/routes/(main)/agent/profile/features/Header/index.tsx@@ -1,14 +1,6 @@import { isDesktop } from '@lobechat/const';import { getOptedInPluginIds, type LobeAgentConfig } from '@lobechat/types';-import {- ActionIcon,- cssVar,- DropdownMenu,- Flexbox,- Icon,- type ModalInstance,- toast,-} from '@lobehub/ui';+import { ActionIcon, cssVar, DropdownMenu, Flexbox, Icon, toast } from '@lobehub/ui';import isEqual from 'fast-deep-equal';import type { TFunction } from 'i18next';import {@@ -22,7 +14,7 @@ import {UserRound,UsersIcon,} from 'lucide-react';-import { memo, useCallback, useEffect, useMemo, useRef } from 'react';+import { memo, useCallback, useMemo } from 'react';import { useTranslation } from 'react-i18next';import { useAgentTransferMenuItem } from '@/business/client/hooks/useAgentTransferMenuItem';@@ -43,6 +35,7 @@ import { useResourceAccess } from '@/features/ResourcePermission/useResourceAcceimport ToggleRightPanelButton from '@/features/RightPanel/ToggleRightPanelButton';import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';import { useCopyAgentIdMenuItem } from '@/hooks/useCopyAgentIdMenuItem';+import { useOpenChatSettings } from '@/hooks/useInterceptingRoutes';import { usePermission } from '@/hooks/usePermission';import { useAgentStore } from '@/store/agent';import { agentSelectors, builtinAgentSelectors } from '@/store/agent/selectors';@@ -51,9 +44,9 @@ import { systemStatusSelectors } from '@/store/global/selectors';import { useHomeStore } from '@/store/home';import { useHeaderActionSize } from '@/styles/density';import { getDeleteErrorMessageKey } from '@/utils/forbiddenError';+import { isMobileSurface } from '@/utils/mobileSurface';import { sanitizeFileName } from '@/utils/sanitizeFileName';-import { openAgentSettingsModal } from '../AgentSettings';import { selectors as profileSelectors, useProfileStore } from '../store';import AgentForkTag from './AgentForkTag';import AgentSocialShare from './AgentSocialShare';@@ -259,14 +252,7 @@ const Header = memo<HeaderProps>(({ active = 'profile' }) => {// Ownership handover to a workspace member — separate from the scope moves.const transferToMemberItem = useAgentTransferToMemberMenuItem(activeAgentId ?? undefined, meta);- const settingsModalRef = useRef<ModalInstance | null>(null);- useEffect(- () => () => {- settingsModalRef.current?.close();- settingsModalRef.current = null;- },- [],- );+ const openAdvancedSettings = useOpenChatSettings();const { visible: shareVisible } = useAgentShareSupported(activeAgentId);// External sharing is stronger than General Access `edit`: only the Agent@@ -296,21 +282,25 @@ const Header = memo<HeaderProps>(({ active = 'profile' }) => {const menuItems = useMemo(() => {const businessTransferMenuItems = transferMenuItems ?? [];+ // Desktop reaches these from the profile sidebar; mobile has no sidebar there.+ const showConfigEntries = isMobileSurface();+return [- {- // View/use-level members can't edit the agent config — keep the entry- // visible but disabled (project convention: disabled, not hidden).- disabled: !canConfigure,- icon: <Icon icon={Settings2Icon} />,- key: 'advanced-settings',- label: t('advancedSettings', { ns: 'setting' }),- onClick: () => {- if (!canConfigure) return;- settingsModalRef.current?.close();- settingsModalRef.current = openAgentSettingsModal();- },- },- showPermissionPageEntry+ showConfigEntries+ ? {+ // View/use-level members can't edit the agent config — keep the entry+ // visible but disabled (project convention: disabled, not hidden).+ disabled: !canConfigure,+ icon: <Icon icon={Settings2Icon} />,+ key: 'advanced-settings',+ label: t('advancedSettings', { ns: 'setting' }),+ onClick: () => {+ if (!canConfigure) return;+ openAdvancedSettings();+ },+ }+ : null,+ showConfigEntries && showPermissionPageEntry? {// Same gate the page itself applies (ResourceConfigAccessGate):// without edit-level access it redirects straight back with a@@ -326,7 +316,7 @@ const Header = memo<HeaderProps>(({ active = 'profile' }) => {},}: null,- { type: 'divider' as const },+ showConfigEntries ? { type: 'divider' as const } : null,showMarketSubmission? {disabled: !canSubmitToMarket || marketSubmission.isSubmitting,@@ -408,6 +398,7 @@ const Header = memo<HeaderProps>(({ active = 'profile' }) => {marketSubmission.isSubmitting,marketSubmission.open,navigate,+ openAdvancedSettings,showMarketSubmission,showPermissionPageEntry,t,diff --git a/src/spa/router/agentPageRoutes.tsx b/src/spa/router/agentPageRoutes.tsxindex e0c5b0d1b8d..2e2393b6800 100644--- a/src/spa/router/agentPageRoutes.tsx+++ b/src/spa/router/agentPageRoutes.tsx@@ -11,9 +11,11 @@ import {agentEngineRouteMeta,agentEnvironmentRouteMeta,agentGoalsRouteMeta,+ agentGraphRouteMeta,agentInstructionRouteMeta,agentKnowledgeRouteMeta,agentMailRouteMeta,+ agentOpeningRouteMeta,agentPermissionRouteMeta,agentProfileRouteMeta,agentSelfLearningRouteMeta,@@ -279,6 +281,22 @@ export const agentPageChildren: RouteObject[] = [handle: { meta: routeMeta({ Skeleton: NoRouteSkeleton }) },path: 'self-learning/*',},+ {+ element: dynamicElement(+ () => import('@/routes/(main)/agent/opening'),+ 'Desktop > Chat > Opening Settings',+ ),+ handle: { meta: agentOpeningRouteMeta },+ path: 'opening',+ },+ {+ element: dynamicElement(+ () => import('@/routes/(main)/agent/graph'),+ 'Desktop > Chat > Graph Runtime',+ ),+ handle: { meta: agentGraphRouteMeta },+ path: 'graph',+ },{element: dynamicElement(() => import('@/routes/(main)/agent/permission'),