Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(agent): stabilize profile editor export (#16157)

AmAzing-ed08cff8d581
diff --git a/locales/en-US/setting.json b/locales/en-US/setting.json
index ac8cce3bf44..ad277db7480 100644
--- a/locales/en-US/setting.json
+++ b/locales/en-US/setting.json
@@ -548,9 +548,11 @@
"settingAgent.export.untitledFileName": "agent-profile",
"settingAgent.name.placeholder": "Enter agent name",
"settingAgent.name.title": "Name",
- "settingAgent.prompt.placeholder": "Enter agent settings, press / to open the command menu",
- "settingAgent.prompt.templatePlaceholder": "#### Goal\nDescribe the main purpose and objective of this agent.\n\n#### Skills\n- List the key capabilities\n- And specialized knowledge areas\n\n#### Workflow\n1. Step-by-step process\n2. How the agent should approach tasks\n3. Expected interactions with users\n\n#### Constraints\n- Important limitations to follow\n- Guidelines for behavior",
- "settingAgent.prompt.title": "Agent Profile",
+ "settingAgent.prompt.desc": "Defines who this agent is, what it is responsible for, and how it works and responds. It serves as a core instruction in every conversation.",
+ "settingAgent.prompt.editorPlaceholder": "Enter core instructions, press / to open the Slash Menu",
+ "settingAgent.prompt.placeholder": "Enter agent instructions",
+ "settingAgent.prompt.title": "Core Instructions",
+ "settingAgent.runtimeConfig.title": "Model & Tools",
"settingAgent.submit": "Update Agent",
"settingAgent.tag.desc": "Agent tags will be displayed in the Agent Community",
"settingAgent.tag.placeholder": "Enter tag",
diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.json
index 69b6af4192e..955d6f32520 100644
--- a/locales/zh-CN/setting.json
+++ b/locales/zh-CN/setting.json
@@ -548,9 +548,11 @@
"settingAgent.export.untitledFileName": "助理档案",
"settingAgent.name.placeholder": "请输入助理名称",
"settingAgent.name.title": "名称",
- "settingAgent.prompt.placeholder": "输入助理设定,按 / 打开命令菜单",
- "settingAgent.prompt.templatePlaceholder": "#### 目标\n描述该智能体的主要用途和目标。\n\n#### 技能\n- 列出关键能力\n- 以及专业知识领域\n\n#### 工作流程\n1. 分步骤的执行流程\n2. 智能体应如何处理任务\n3. 与用户的预期互动方式\n\n#### 限制条件\n- 需要遵守的重要限制\n- 行为准则",
- "settingAgent.prompt.title": "助理设定",
+ "settingAgent.prompt.desc": "定义这个助理的身份、职责、工作方式和回应风格。这里的设定会在每次对话中生效。",
+ "settingAgent.prompt.editorPlaceholder": "输入核心指令,按 / 打开斜杠菜单",
+ "settingAgent.prompt.placeholder": "请输入助理指令",
+ "settingAgent.prompt.title": "核心指令",
+ "settingAgent.runtimeConfig.title": "模型与工具",
"settingAgent.submit": "更新助理信息",
"settingAgent.tag.desc": "助理标签将在助理社区中展示",
"settingAgent.tag.placeholder": "请输入标签",
diff --git a/packages/locales/src/default/setting.ts b/packages/locales/src/default/setting.ts
index 844c0d811df..3d1c3eec3cd 100644
--- a/packages/locales/src/default/setting.ts
+++ b/packages/locales/src/default/setting.ts
@@ -606,21 +606,13 @@ export default {
'settingAgent.export.untitledFileName': 'agent-profile',
'settingAgent.name.placeholder': 'Enter agent name',
'settingAgent.name.title': 'Name',
- 'settingAgent.prompt.placeholder': 'Enter agent settings, press / to open the command menu',
- 'settingAgent.prompt.templatePlaceholder':
- '#### Goal\n' +
- 'Describe the main purpose and objective of this agent.\n\n' +
- '#### Skills\n' +
- '- List the key capabilities\n' +
- '- And specialized knowledge areas\n\n' +
- '#### Workflow\n' +
- '1. Step-by-step process\n' +
- '2. How the agent should approach tasks\n' +
- '3. Expected interactions with users\n\n' +
- '#### Constraints\n' +
- '- Important limitations to follow\n' +
- '- Guidelines for behavior',
- 'settingAgent.prompt.title': 'Agent Profile',
+ 'settingAgent.prompt.desc':
+ 'Defines who this agent is, what it is responsible for, and how it works and responds. It serves as a core instruction in every conversation.',
+ 'settingAgent.prompt.editorPlaceholder':
+ 'Enter core instructions, press / to open the Slash Menu',
+ 'settingAgent.prompt.placeholder': 'Enter agent instructions',
+ 'settingAgent.prompt.title': 'Core Instructions',
+ 'settingAgent.runtimeConfig.title': 'Model & Tools',
'settingAgent.submit': 'Update Agent',
'settingAgent.tag.desc': 'Agent tags will be displayed in the Agent Community',
'settingAgent.tag.placeholder': 'Enter tag',
diff --git a/src/routes/(main)/agent/profile/features/EditorCanvas/index.test.tsx b/src/routes/(main)/agent/profile/features/EditorCanvas/index.test.tsx
index 23ed8c3f777..13f93b694bf 100644
--- a/src/routes/(main)/agent/profile/features/EditorCanvas/index.test.tsx
+++ b/src/routes/(main)/agent/profile/features/EditorCanvas/index.test.tsx
@@ -98,4 +98,11 @@ describe('Agent profile EditorCanvas', () => {
expect(editorProps.last?.editable).toBe(false);
});
+
+ it('uses the rich-editor placeholder key', () => {
+ render(<EditorCanvas />);
+
+ expect(editorProps.last?.lineEmptyPlaceholder).toBe('settingAgent.prompt.editorPlaceholder');
+ expect(editorProps.last?.placeholder).toBe('settingAgent.prompt.editorPlaceholder');
+ });
});
diff --git a/src/routes/(main)/agent/profile/features/EditorCanvas/index.tsx b/src/routes/(main)/agent/profile/features/EditorCanvas/index.tsx
index b2d4d48b46d..fdc13db222d 100644
--- a/src/routes/(main)/agent/profile/features/EditorCanvas/index.tsx
+++ b/src/routes/(main)/agent/profile/features/EditorCanvas/index.tsx
@@ -2,6 +2,8 @@
import { ReactMentionPlugin, ReactTablePlugin, ReactToolbarPlugin } from '@lobehub/editor';
import { Editor } from '@lobehub/editor/react';
+import { Flexbox } from '@lobehub/ui';
+import { createStaticStyles, cssVar } from 'antd-style';
import isEqual from 'fast-deep-equal';
import { memo, useCallback, useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -19,6 +21,34 @@ import { selectors as profileSelectors } from '../store/selectors';
import TypoBar from './TypoBar';
import { useSlashItems } from './useSlashItems';
+const styles = createStaticStyles(({ css }) => ({
+ desc: css`
+ font-size: 13px;
+ line-height: 1.6;
+ color: ${cssVar.colorTextSecondary};
+ `,
+ editorShell: css`
+ min-height: 300px;
+ padding-block: 18px;
+ padding-inline: 18px;
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: ${cssVar.borderRadiusLG};
+
+ background: ${cssVar.colorBgContainer};
+ `,
+ header: css`
+ max-width: 820px;
+ `,
+ root: css`
+ padding-block-end: 16px;
+ `,
+ title: css`
+ font-size: 16px;
+ font-weight: 600;
+ color: ${cssVar.colorText};
+ `,
+}));
+
const EditorCanvas = memo(() => {
const { t } = useTranslation('setting');
const { allowed: canEdit } = usePermission('edit_own_content');
@@ -116,41 +146,48 @@ const EditorCanvas = memo(() => {
}, [editorInit, contentInit, editor, editorData, systemRole, streamingInProgress]);
return (
- <div
- style={editable ? undefined : { cursor: 'not-allowed', opacity: 0.65, pointerEvents: 'none' }}
- onClick={(e) => {
- e.stopPropagation();
- }}
- >
- <EditingIndicator
- holderId={lockedByOther ? lockHolderId : null}
- pending={canEdit && lockPending}
- />
- <Editor
- content={initialLoad}
- editable={editable}
- editor={editor!}
- lineEmptyPlaceholder={t('settingAgent.prompt.placeholder')}
- mentionOption={mentionOptions}
- placeholder={t('settingAgent.prompt.templatePlaceholder')}
- plugins={[
- ...createChatInputRichPlugins(),
- ReactTablePlugin,
- ReactMentionPlugin,
- Editor.withProps(ReactToolbarPlugin, {
- children: <TypoBar />,
- }),
- ]}
- slashOption={{
- items: slashItems,
- }}
- style={{
- paddingBottom: 64,
+ <Flexbox className={styles.root} gap={16}>
+ <Flexbox className={styles.header} gap={4}>
+ <div className={styles.title}>{t('settingAgent.prompt.title')}</div>
+ <div className={styles.desc}>{t('settingAgent.prompt.desc')}</div>
+ </Flexbox>
+ <div
+ className={styles.editorShell}
+ style={
+ editable ? undefined : { cursor: 'not-allowed', opacity: 0.65, pointerEvents: 'none' }
+ }
+ onClick={(e) => {
+ e.stopPropagation();
}}
- onInit={() => setEditorInit(true)}
- onTextChange={handleChange}
- />
- </div>
+ >
+ <EditingIndicator
+ holderId={lockedByOther ? lockHolderId : null}
+ pending={canEdit && lockPending}
+ />
+ <Editor
+ content={initialLoad}
+ editable={editable}
+ editor={editor!}
+ lineEmptyPlaceholder={t('settingAgent.prompt.editorPlaceholder')}
+ mentionOption={mentionOptions}
+ placeholder={t('settingAgent.prompt.editorPlaceholder')}
+ style={{ paddingBottom: 0 }}
+ plugins={[
+ ...createChatInputRichPlugins(),
+ ReactTablePlugin,
+ ReactMentionPlugin,
+ Editor.withProps(ReactToolbarPlugin, {
+ children: <TypoBar />,
+ }),
+ ]}
+ slashOption={{
+ items: slashItems,
+ }}
+ onInit={() => setEditorInit(true)}
+ onTextChange={handleChange}
+ />
+ </div>
+ </Flexbox>
);
});
diff --git a/src/routes/(main)/agent/profile/features/Header/index.test.tsx b/src/routes/(main)/agent/profile/features/Header/index.test.tsx
index 15618d9243b..3de1db43bd0 100644
--- a/src/routes/(main)/agent/profile/features/Header/index.test.tsx
+++ b/src/routes/(main)/agent/profile/features/Header/index.test.tsx
@@ -201,6 +201,7 @@ describe('Agent profile Header', () => {
vi.spyOn(URL, 'createObjectURL').mockReturnValue('blob:agent-profile');
vi.spyOn(URL, 'revokeObjectURL').mockImplementation(() => {});
mocks.agentState.isCurrentAgentHeterogeneous = false;
+ mocks.agentState.systemRole = 'You are helpful.';
mocks.profileState.editor = undefined;
});
@@ -245,4 +246,22 @@ describe('Agent profile Header', () => {
expect(exportedMarkdown).not.toContain('You are helpful.');
expect(exportedMarkdown).not.toContain('settingAgent.prompt.title');
});
+
+ it('should ignore the hidden editor when exporting heterogeneous agent markdown', async () => {
+ const getDocument = vi.fn().mockReturnValue('');
+ mocks.agentState.isCurrentAgentHeterogeneous = true;
+ mocks.profileState.editor = { getDocument };
+
+ render(<Header />);
+
+ fireEvent.click(screen.getByRole('button', { name: 'pageEditor.menu.export.markdown' }));
+
+ await waitFor(() => expect(URL.createObjectURL).toHaveBeenCalled());
+
+ const exportedBlob = getLatestExportedBlob();
+ const exportedMarkdown = await exportedBlob.text();
+
+ expect(getDocument).not.toHaveBeenCalled();
+ expect(exportedMarkdown).toContain('You are helpful.');
+ });
});
diff --git a/src/routes/(main)/agent/profile/features/Header/index.tsx b/src/routes/(main)/agent/profile/features/Header/index.tsx
index 1195d660bc5..fd63cce7b52 100644
--- a/src/routes/(main)/agent/profile/features/Header/index.tsx
+++ b/src/routes/(main)/agent/profile/features/Header/index.tsx
@@ -114,7 +114,9 @@ const Header = memo(() => {
const handleExportMarkdown = useCallback(async () => {
try {
- const editorMarkdown = editor?.getDocument('markdown') as string | null | undefined;
+ const editorMarkdown = isHeterogeneous
+ ? undefined
+ : (editor?.getDocument('markdown') as string | null | undefined);
const profileMarkdown = buildAgentProfileMarkdown({
description: meta?.description,
model: config.model,
@@ -155,7 +157,7 @@ const Header = memo(() => {
console.error('Failed to export agent profile markdown:', error);
message.error(t('settingAgent.export.error', { ns: 'setting' }));
}
- }, [config.model, config.plugins, config.provider, editor, meta, systemRole, t]);
+ }, [config.model, config.plugins, config.provider, editor, isHeterogeneous, meta, systemRole, t]);
const importMenuItem = useBusinessAgentImportMenuItem(activeAgentId ?? undefined);
const transferMenuItems = useAgentTransferMenuItem(activeAgentId ?? undefined);
diff --git a/src/routes/(main)/agent/profile/features/ProfileEditor/index.tsx b/src/routes/(main)/agent/profile/features/ProfileEditor/index.tsx
index 775fbbd0366..379c3636801 100644
--- a/src/routes/(main)/agent/profile/features/ProfileEditor/index.tsx
+++ b/src/routes/(main)/agent/profile/features/ProfileEditor/index.tsx
@@ -3,7 +3,8 @@
import { isDesktop } from '@lobechat/const';
import { isRemoteHeterogeneousType } from '@lobechat/heterogeneous-agents';
import { Flexbox } from '@lobehub/ui';
-import { Divider, Tabs, type TabsProps } from 'antd';
+import { Tabs, type TabsProps } from 'antd';
+import { createStaticStyles, cssVar } from 'antd-style';
import isEqual from 'fast-deep-equal';
import React, { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -21,6 +22,26 @@ import CloudHeterogeneousConfig from './CloudHeterogeneousConfig';
import HeterogeneousAgentStatusCard from './HeterogeneousAgentStatusCard';
import RemoteAgentConfigCard from './RemoteAgentConfigCard';
+const styles = createStaticStyles(({ css }) => ({
+ configLabel: css`
+ font-size: 12px;
+ line-height: 1;
+ color: ${cssVar.colorTextTertiary};
+ `,
+ configPanel: css`
+ padding-block: 12px;
+ padding-inline: 14px;
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: ${cssVar.borderRadiusLG};
+
+ background: ${cssVar.colorFillQuaternary};
+ `,
+ topArea: css`
+ cursor: default;
+ margin-block-end: 28px;
+ `,
+}));
+
const ProfileEditor = memo(() => {
const { t } = useTranslation('setting');
const { allowed: canEdit } = usePermission('edit_own_content');
@@ -91,7 +112,7 @@ const ProfileEditor = memo(() => {
return (
<>
<Flexbox
- style={{ cursor: 'default', marginBottom: 12 }}
+ className={styles.topArea}
onClick={(e) => {
e.stopPropagation();
}}
@@ -115,36 +136,35 @@ const ProfileEditor = memo(() => {
/>
) : (
<>
- {/* Config Bar: Model Selector */}
- <Flexbox
- horizontal
- align={'center'}
- gap={8}
- justify={'flex-start'}
- style={{ marginBottom: 12 }}
- >
- <ModelSelect
- initialWidth
- disabled={!canEdit}
- popupWidth={400}
- value={{
- model: config.model,
- provider: config.provider,
- }}
- onChange={(value) => {
- if (!canEdit) return;
+ <Flexbox className={styles.configPanel} gap={10}>
+ <div className={styles.configLabel}>{t('settingAgent.runtimeConfig.title')}</div>
+ <Flexbox horizontal align={'center'} gap={12} justify={'flex-start'} wrap={'wrap'}>
+ <ModelSelect
+ initialWidth
+ disabled={!canEdit}
+ popupWidth={400}
+ value={{
+ model: config.model,
+ provider: config.provider,
+ }}
+ onChange={(value) => {
+ if (!canEdit) return;
- updateConfig(value);
- }}
- />
+ updateConfig(value);
+ }}
+ />
+ <AgentTool />
+ </Flexbox>
</Flexbox>
- <AgentTool />
</>
)}
</Flexbox>
- <Divider />
- {/* Main Content: Prompt Editor */}
- <EditorCanvas />
+ {/* Main Content: Prompt Editor — built-in model runtime only. Hetero agents
+ (Claude Code / Codex + remote platforms) run an external CLI with its own
+ system prompt, so the agent's systemRole never reaches them. Hide the
+ editor here to avoid a control that looks effective but isn't (mirrors the
+ ModelSelect hiding above). */}
+ {!isHeterogeneous && <EditorCanvas />}
{/* Advanced Settings Modal */}
<AgentSettings />
</>