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.

💄 style(agent-profile): simplify navigation and instruction editing (#23275)

AmAzing-e2037af3e3ec
diff --git a/.agents/ux/lobe-design-rules.md b/.agents/ux/lobe-design-rules.md
index 170ae1bcdd4..29291350494 100644
--- a/.agents/ux/lobe-design-rules.md
+++ b/.agents/ux/lobe-design-rules.md
@@ -157,3 +157,15 @@ Source: user correction (2026-11-12): headers showed only "16:29", so a scrolled
Use the shared form's `autoSubmitOnTimeout` result for countdown wording. Provider-owned option IDs suppress inferred answers, so those cards must say they close unanswered instead of promising option 1. Keep the legacy fallback wording only where the form actually submits fallback answers. Do not infer the policy from a renderer's provider name.
Enforcement: `packages/shared-tool-ui/src/AskUserQuestion/useAskUserForm.test.ts` checks the exposed policy together with actual timeout submission and non-submission. Verify both countdown messages on the rendered cards. Source: real Codex question-card acceptance (2026-11-17), where the footer promised option 1 despite the hook correctly refusing to select it.
+
+## LOBE-UX-022 — Check icon–label optical alignment, not only bounding boxes
+
+For an icon beside a text label, equal CSS centerlines do not prove visual centering: the font's visible glyphs can sit above the line-box center. Inspect a tight rendered crop, including the hover background, before declaring alignment fixed. Use the shared component's flex alignment first and inspect its line height, font metrics, and SVG viewBox before changing it. Do not compensate with per-instance pixel translations or relative positioning; resolve an established typography or icon issue at its owning layer instead.
+
+Enforcement: visual review of the actual icon and localized label at the target scale, alongside the row's computed geometry; reject unexplained positioning offsets in icon–label alignment changes. Source: user corrections on the Agent profile return row: geometry checks missed the perceived misalignment, and a subsequent 1px icon translation was correctly rejected as a hack.
+
+## LOBE-UX-023 — Keep page editor modes outside the writing surface
+
+On a dedicated instruction-editing page, place view-mode switches alongside the page title, not in an extra toolbar row inside the input boundary. The editor's boundary should identify where to type without becoming the page's strongest visual element on focus. Use the neutral outlined surface; do not turn its entire perimeter into a primary-colored focus frame. Preserve the editor caret and the mode buttons' keyboard focus indicators.
+
+Enforcement: `EditorCanvas/index.test.tsx` checks that both mode controls remain outside the outlined input surface. Inspect the page at rest and while editing. Source: user correction on the Agent instruction editor: moving mode switches into the frame wasted a writing row, and a black focus border was too prominent.
diff --git a/locales/en-US/setting.json b/locales/en-US/setting.json
index 948638dee71..3aee0fcd5d6 100644
--- a/locales/en-US/setting.json
+++ b/locales/en-US/setting.json
@@ -1636,7 +1636,7 @@
"settingAgent.identity.saveFailed": "Could not save the identity, please try again",
"settingAgent.identity.saved": "Saved",
"settingAgent.identity.untitled": "Unnamed agent",
- "settingAgent.instruction.desc": "Who it is and how it should behave. It reads this before every reply.",
+ "settingAgent.instruction.description": "Define the agent’s identity, responsibilities, working methods, and response style. These instructions apply in every conversation.",
"settingAgent.instruction.title": "Instruction",
"settingAgent.knowledgePage.addFile": "Add file",
"settingAgent.knowledgePage.addLibrary": "Add library",
diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.json
index c3bbf3c9231..70f7e411c4e 100644
--- a/locales/zh-CN/setting.json
+++ b/locales/zh-CN/setting.json
@@ -1636,7 +1636,7 @@
"settingAgent.identity.saveFailed": "身份信息保存失败,请重试",
"settingAgent.identity.saved": "已保存",
"settingAgent.identity.untitled": "未命名助理",
- "settingAgent.instruction.desc": "它是谁、该怎么做事。每次回复前它都会先读这一段。",
+ "settingAgent.instruction.description": "设定助理的身份、职责、工作方式和回复风格。这些指令会在每次对话中生效。",
"settingAgent.instruction.title": "指令",
"settingAgent.knowledgePage.addFile": "添加文件",
"settingAgent.knowledgePage.addLibrary": "添加知识库",
diff --git a/packages/locales/src/default/setting.ts b/packages/locales/src/default/setting.ts
index f6703e6cfa5..59d701505f8 100644
--- a/packages/locales/src/default/setting.ts
+++ b/packages/locales/src/default/setting.ts
@@ -1409,8 +1409,8 @@ export default {
'settingAgent.environment.title': 'Environment',
'settingAgent.environment.desc': 'Where it runs, and what it needs there.',
'settingAgent.instruction.title': 'Instruction',
- 'settingAgent.instruction.desc':
- 'Who it is and how it should behave. It reads this before every reply.',
+ 'settingAgent.instruction.description':
+ 'Define the agent’s identity, responsibilities, working methods, and response style. These instructions apply in every conversation.',
'settingAgent.knowledgePage.title': 'Knowledge Base',
'settingAgent.knowledgePage.desc': 'The libraries and files it can search when it answers.',
'settingAgent.knowledgePage.libraries.title': 'Libraries',
diff --git a/src/features/AgentSidebar/Header/Nav.test.tsx b/src/features/AgentSidebar/Header/Nav.test.tsx
index 3dfb992f98f..882cfb9eba8 100644
--- a/src/features/AgentSidebar/Header/Nav.test.tsx
+++ b/src/features/AgentSidebar/Header/Nav.test.tsx
@@ -5,7 +5,18 @@ import { fireEvent, render, screen } from '@testing-library/react';
import type { ReactNode } from 'react';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
-import Nav from './Nav';
+import Nav from './index';
+
+vi.mock('./Agent', () => ({ default: () => null }));
+vi.mock('@/features/NavPanel/backOrigin', () => ({ useBackButtonProps: () => ({}) }));
+vi.mock('@/features/NavPanel/SideBarHeaderLayout', () => ({
+ default: ({ left, right }: { left: ReactNode; right?: ReactNode }) => (
+ <header>
+ {left}
+ {right}
+ </header>
+ ),
+}));
const mutateMock = vi.hoisted(() => vi.fn());
const openNewTopicOrSaveTopicMock = vi.hoisted(() => vi.fn());
@@ -104,14 +115,19 @@ vi.mock('@/store/global', () => ({
}));
interface ServerConfigTestState {
- featureFlags: { isAgentEditable: boolean };
+ featureFlags: { isAgentEditable: boolean | undefined };
serverConfigInit: boolean;
}
+const serverConfigMock = vi.hoisted((): ServerConfigTestState => ({
+ featureFlags: { isAgentEditable: true },
+ serverConfigInit: true,
+}));
+
vi.mock('@/store/serverConfig', () => ({
featureFlagsSelectors: (state: ServerConfigTestState) => state.featureFlags,
useServerConfigStore: (selector: (state: ServerConfigTestState) => unknown) =>
- selector({ featureFlags: { isAgentEditable: true }, serverConfigInit: true }),
+ selector(serverConfigMock),
}));
vi.mock('@/store/user', () => ({
@@ -129,6 +145,10 @@ vi.mock('@/store/user/selectors', () => ({
}));
describe('Agent sidebar header nav', () => {
+ afterEach(() => {
+ vi.unstubAllGlobals();
+ });
+
beforeEach(() => {
mutateMock.mockReset();
openNewTopicOrSaveTopicMock.mockReset();
@@ -137,6 +157,7 @@ describe('Agent sidebar header nav', () => {
toggleCommandMenuMock.mockReset();
useParamsMock.mockReset();
usePathnameMock.mockReset();
+ serverConfigMock.featureFlags.isAgentEditable = true;
permissionMock.create_content = true;
permissionMock.edit_own_content = true;
labMock.enableSelfLearning = true;
@@ -199,7 +220,8 @@ describe('Agent sidebar header nav', () => {
['/agent/agt_eH4zL98zBx5u/channel'],
['/agent/agt_eH4zL98zBx5u/channel/slack'],
['/agent/agt_eH4zL98zBx5u/statistics'],
- ])('keeps the profile entry active on %s', (pathname) => {
+ ])('keeps the mobile profile entry active on %s', (pathname) => {
+ vi.stubGlobal('__MOBILE__', true);
usePathnameMock.mockReturnValue(pathname);
render(<Nav />);
@@ -210,6 +232,34 @@ describe('Agent sidebar header nav', () => {
);
});
+ it('opens the agent profile from the desktop header settings button', () => {
+ usePathnameMock.mockReturnValue('/agent/agt_eH4zL98zBx5u');
+
+ render(<Nav />);
+ const settingsButton = screen.getByRole('button', { name: 'tab.profile' });
+ expect(screen.getByRole('banner')).toContainElement(settingsButton);
+ fireEvent.click(settingsButton);
+
+ expect(switchTopicMock).toHaveBeenCalledWith(null, { skipRefreshMessage: true });
+ expect(pushMock).toHaveBeenCalledWith('/agent/agt_eH4zL98zBx5u/profile');
+ });
+
+ it.each([
+ [false, false],
+ [false, undefined],
+ [true, false],
+ [true, undefined],
+ ])('hides profile when mobile=%s and isAgentEditable=%s', (mobile, isAgentEditable) => {
+ vi.stubGlobal('__MOBILE__', mobile);
+ serverConfigMock.featureFlags.isAgentEditable = isAgentEditable;
+ usePathnameMock.mockReturnValue('/agent/agt_eH4zL98zBx5u');
+
+ render(<Nav />);
+
+ expect(screen.queryByRole('button', { name: 'tab.profile' })).not.toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'title' })).toBeInTheDocument();
+ });
+
it('navigates to the agent goals page', () => {
usePathnameMock.mockReturnValue('/agent/agt_eH4zL98zBx5u');
@@ -297,14 +347,19 @@ describe('Agent sidebar header nav', () => {
});
});
- it('places topics above profile, goals, self-learning, and tasks in the agent navigation', () => {
+ it('places topics above goals and tasks, with profile settings in the header', () => {
usePathnameMock.mockReturnValue('/agent/agt_eH4zL98zBx5u');
render(<Nav />);
const labels = screen.getAllByRole('button').map((button) => button.textContent);
- expect(labels.indexOf('management.sidebarEntry')).toBeLessThan(labels.indexOf('tab.profile'));
- expect(labels.indexOf('tab.profile')).toBeLessThan(labels.indexOf('goalList.title'));
+ expect(labels).not.toContain('tab.profile');
+ expect(screen.getByRole('banner')).toContainElement(
+ screen.getByRole('button', { name: 'tab.profile' }),
+ );
+ expect(labels.indexOf('management.sidebarEntry')).toBeLessThan(
+ labels.indexOf('goalList.title'),
+ );
expect(labels.indexOf('goalList.title')).toBeLessThan(labels.indexOf('tab.tasks'));
});
diff --git a/src/features/AgentSidebar/Header/Nav.tsx b/src/features/AgentSidebar/Header/Nav.tsx
index 51b2a741548..77dad6d93b4 100644
--- a/src/features/AgentSidebar/Header/Nav.tsx
+++ b/src/features/AgentSidebar/Header/Nav.tsx
@@ -10,12 +10,10 @@ import {
SearchIcon,
TargetIcon,
} from 'lucide-react';
-import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import urlJoin from 'url-join';
import NavItem from '@/features/NavPanel/components/NavItem';
-import { useResourceAccess } from '@/features/ResourcePermission/useResourceAccess';
import { useSelfLearningSurface } from '@/features/SelfLearning/SurfaceGate/useSelfLearningSurface';
import { useActiveLocation } from '@/hooks/useActiveLocation';
import { useActiveRouteParams } from '@/hooks/useActiveRouteParams';
@@ -26,14 +24,18 @@ import { topicActionKeys } from '@/libs/swr/keys';
import { useChatStore } from '@/store/chat';
import { topicSelectors } from '@/store/chat/selectors';
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';
-const Nav = memo(() => {
+interface NavProps {
+ onOpenProfile: () => void;
+ showProfile: boolean;
+}
+
+const Nav = ({ onOpenProfile, showProfile }: NavProps) => {
const { t } = useTranslation('chat');
const { t: tTopic } = useTranslation('topic');
const { t: tSelfLearning } = useTranslation('selfLearning');
@@ -53,15 +55,7 @@ const Nav = memo(() => {
const isTopicsActive = pathname.endsWith('/topics');
const router = useQueryRoute();
const { allowed: canCreateTopic } = usePermission('create_content');
- const { allowed: canEditContent } = usePermission('edit_own_content');
- const { canEditResource } = useResourceAccess('agent', agentId);
- const { isAgentEditable } = useServerConfigStore(featureFlagsSelectors);
const toggleCommandMenu = useGlobalStore((s) => s.toggleCommandMenu);
- // Only a server-confirmed edit denial hides the entry. `canEditResource` stays
- // permissive while workspace access is loading, so the entry no longer drops
- // out each time an agent is opened; the profile page itself is still guarded by
- // `ResourceConfigAccessGate`.
- const hideProfile = !isAgentEditable || !canEditContent || !canEditResource;
const switchTopic = useChatStore((s) => s.switchTopic);
const [openNewTopicOrSaveTopic] = useChatStore((s) => [s.openNewTopicOrSaveTopic]);
const isNewTopicSendInFlight = useChatStore(topicSelectors.isNewTopicSendInFlight);
@@ -69,7 +63,7 @@ const Nav = memo(() => {
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 showSelfLearningEntry = enableSelfLearning && (!showProfile || isMobileSurface());
const { mutate } = useActionSWR(topicActionKeys.openNewOrSave(), openNewTopicOrSaveTopic);
const handleNewTopic = () => {
@@ -107,15 +101,12 @@ const Nav = memo(() => {
router.push(urlJoin('/agent', agentId!, 'topics'));
}}
/>
- {!hideProfile && (
+ {showProfile && isMobileSurface() && (
<NavItem
active={isProfileActive}
icon={BotPromptIcon}
title={t('tab.profile')}
- onClick={() => {
- switchTopic(null, { skipRefreshMessage: true });
- router.push(urlJoin('/agent', agentId!, 'profile'));
- }}
+ onClick={onOpenProfile}
/>
)}
{showSelfLearningEntry && (
@@ -151,6 +142,6 @@ const Nav = memo(() => {
/>
</Flexbox>
);
-});
+};
export default Nav;
diff --git a/src/features/AgentSidebar/Header/index.tsx b/src/features/AgentSidebar/Header/index.tsx
index 95243592efa..175d08dfa8e 100644
--- a/src/features/AgentSidebar/Header/index.tsx
+++ b/src/features/AgentSidebar/Header/index.tsx
@@ -1,20 +1,60 @@
'use client';
+import { ActionIcon } from '@lobehub/ui';
+import { SettingsIcon } from 'lucide-react';
import { type PropsWithChildren } from 'react';
+import { useTranslation } from 'react-i18next';
+import urlJoin from 'url-join';
+import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { useBackButtonProps } from '@/features/NavPanel/backOrigin';
import SideBarHeaderLayout from '@/features/NavPanel/SideBarHeaderLayout';
+import { useResourceAccess } from '@/features/ResourcePermission/useResourceAccess';
+import { useActiveRouteParams } from '@/hooks/useActiveRouteParams';
+import { usePermission } from '@/hooks/usePermission';
+import { useQueryRoute } from '@/hooks/useQueryRoute';
+import { useChatStore } from '@/store/chat';
+import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
+import { isMobileSurface } from '@/utils/mobileSurface';
import Agent from './Agent';
import Nav from './Nav';
const HeaderInfo = (_props: PropsWithChildren) => {
const back = useBackButtonProps();
+ const { t } = useTranslation('chat');
+ const { aid: agentId } = useActiveRouteParams();
+ const router = useQueryRoute();
+ const switchTopic = useChatStore((s) => s.switchTopic);
+ const { allowed: canEditContent } = usePermission('edit_own_content');
+ const { canEditResource } = useResourceAccess('agent', agentId);
+ const { isAgentEditable } = useServerConfigStore(featureFlagsSelectors);
+ // Keep the entry while resource access is loading; only a confirmed denial
+ // hides it. The profile page still enforces ResourceConfigAccessGate.
+ const showProfile = !!agentId && !!isAgentEditable && canEditContent && canEditResource;
+ const openProfile = () => {
+ if (!showProfile) return;
+ switchTopic(null, { skipRefreshMessage: true });
+ router.push(urlJoin('/agent', agentId!, 'profile'));
+ };
return (
<>
- <SideBarHeaderLayout {...back} left={<Agent />} />
- <Nav />
+ <SideBarHeaderLayout
+ {...back}
+ left={<Agent />}
+ right={
+ showProfile && !isMobileSurface() ? (
+ <ActionIcon
+ aria-label={t('tab.profile')}
+ icon={SettingsIcon}
+ size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ onClick={openProfile}
+ />
+ ) : undefined
+ }
+ />
+ <Nav showProfile={showProfile} onOpenProfile={openProfile} />
</>
);
};
diff --git a/src/features/AgentSidebar/ProfileNav.tsx b/src/features/AgentSidebar/ProfileNav.tsx
index 46d3461d023..959b620864f 100644
--- a/src/features/AgentSidebar/ProfileNav.tsx
+++ b/src/features/AgentSidebar/ProfileNav.tsx
@@ -1,6 +1,6 @@
'use client';
-import { Button, Flexbox, Text } from '@lobehub/ui';
+import { Flexbox, Text } from '@lobehub/ui';
import type { LucideIcon } from 'lucide-react';
import {
ChartColumnBigIcon,
@@ -29,8 +29,8 @@ import {
} from '@/features/AgentProfileTabs/tabOptions';
import { useAgentProfileTabOptions } from '@/features/AgentProfileTabs/useAgentProfileTabOptions';
import NavItem from '@/features/NavPanel/components/NavItem';
-import SideBarHeaderLayout from '@/features/NavPanel/SideBarHeaderLayout';
import SideBarLayout from '@/features/NavPanel/SideBarLayout';
+import ToggleLeftPanelButton from '@/features/NavPanel/ToggleLeftPanelButton';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useActiveRouteParams } from '@/hooks/useActiveRouteParams';
@@ -96,19 +96,17 @@ const ProfileNav = ({ active }: ProfileNavProps) => {
}
header={
<>
- <SideBarHeaderLayout
- showBack={false}
- left={
- <Button
- icon={ChevronLeftIcon}
- size={'small'}
- type={'text'}
- onClick={() => navigate(urlJoin('/agent', agentId))}
- >
- {t('tab.backToChat')}
- </Button>
- }
- />
+ <Flexbox horizontal align={'center'} paddingBlock={8} paddingInline={4}>
+ <NavItem
+ as={'button'}
+ flex={1}
+ icon={ChevronLeftIcon}
+ style={{ textAlign: 'start' }}
+ title={t('tab.backToChat')}
+ onClick={() => navigate(urlJoin('/agent', agentId))}
+ />
+ <ToggleLeftPanelButton />
+ </Flexbox>
<Flexbox paddingBlock={'0 8px'} paddingInline={6}>
<Agent />
</Flexbox>
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 98da241919d..4b221ef8628 100644
--- a/src/routes/(main)/agent/profile/features/EditorCanvas/index.test.tsx
+++ b/src/routes/(main)/agent/profile/features/EditorCanvas/index.test.tsx
@@ -366,12 +366,25 @@ describe('Agent profile EditorCanvas', () => {
expect(onWrapperClick).not.toHaveBeenCalled();
});
- it('moves the prompt description into the title tooltip', () => {
+ it('keeps editor controls without repeating the instruction page heading and help', () => {
render(<EditorCanvas />);
+ expect(screen.queryByText('settingAgent.prompt.title')).not.toBeInTheDocument();
expect(screen.queryByText('settingAgent.prompt.desc')).not.toBeInTheDocument();
- expect(screen.getByTestId('prompt-description-tooltip')).toHaveAccessibleName(
- 'settingAgent.prompt.desc',
+ expect(screen.queryByTestId('prompt-description-tooltip')).not.toBeInTheDocument();
+ expect(
+ screen.getByRole('button', { name: 'settingAgent.prompt.mode.visual' }),
+ ).toBeInTheDocument();
+ expect(
+ screen.getByRole('button', { name: 'settingAgent.prompt.mode.source' }),
+ ).toBeInTheDocument();
+ const inputSurface = screen.getByTestId('profile-editor').closest('[data-variant="outlined"]');
+ expect(inputSurface).toBeInTheDocument();
+ expect(inputSurface).not.toContainElement(
+ screen.getByRole('button', { name: 'settingAgent.prompt.mode.visual' }),
+ );
+ expect(inputSurface).not.toContainElement(
+ screen.getByRole('button', { name: 'settingAgent.prompt.mode.source' }),
);
});
diff --git a/src/routes/(main)/agent/profile/features/EditorCanvas/index.tsx b/src/routes/(main)/agent/profile/features/EditorCanvas/index.tsx
index 1d50e9dc5ad..da7cb1dd472 100644
--- a/src/routes/(main)/agent/profile/features/EditorCanvas/index.tsx
+++ b/src/routes/(main)/agent/profile/features/EditorCanvas/index.tsx
@@ -3,15 +3,15 @@
import type { IEditor } from '@lobehub/editor';
import { ReactMentionPlugin, ReactTablePlugin, ReactToolbarPlugin } from '@lobehub/editor';
import { Editor } from '@lobehub/editor/react';
-import { ActionIcon, createStaticStyles, cssVar, Flexbox, toast } from '@lobehub/ui';
+import { ActionIcon, Block, createStaticStyles, Flexbox, toast } from '@lobehub/ui';
import isEqual from 'fast-deep-equal';
import { CodeXmlIcon, LetterTextIcon } from 'lucide-react';
+import type { ReactNode } from 'react';
import { memo, useCallback, useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import CodeEditorPane from '@/components/CodeEditorPane';
import AutoSaveHint from '@/components/Editor/AutoSaveHint';
-import InfoTooltip from '@/components/InfoTooltip';
import { createChatInputRichPlugins } from '@/features/ChatInput/InputEditor/plugins';
import { EditingIndicator } from '@/features/EditLock';
import { useResourceAccess } from '@/features/ResourcePermission/useResourceAccess';
@@ -30,24 +30,23 @@ import { useSlashItems } from './useSlashItems';
const styles = createStaticStyles(({ css }) => ({
editorShell: css`
min-height: 300px;
- padding-block: 18px;
- `,
- root: css`
- padding-block-end: 16px;
+
+ [contenteditable] {
+ min-height: 300px;
+ }
`,
sourceEditor: css`
- min-height: 262px;
+ min-height: 300px;
background: transparent;
`,
- title: css`
- cursor: default;
- font-size: 16px;
- font-weight: 600;
- color: ${cssVar.colorText};
- `,
}));
-interface AgentEditorCanvasProps {
+interface EditorCanvasProps {
+ description?: ReactNode;
+ title?: ReactNode;
+}
+
+interface AgentEditorCanvasProps extends EditorCanvasProps {
agentId: string;
}
@@ -87,7 +86,7 @@ const usePromptEditorMode = () => {
} as const;
};
-const AgentEditorCanvas = memo<AgentEditorCanvasProps>(({ agentId }) => {
+const AgentEditorCanvas = memo<AgentEditorCanvasProps>(({ agentId, description, title }) => {
const { t } = useTranslation('setting');
const { allowed: hasEditPermission } = usePermission('edit_own_content');
const [editorInit, setEditorInit] = useState(false);
@@ -419,18 +418,11 @@ const AgentEditorCanvas = memo<AgentEditorCanvasProps>(({ agentId }) => {
]);
return (
- <Flexbox className={styles.root} gap={16}>
+ <Flexbox gap={24}>
<Flexbox gap={4}>
- <Flexbox horizontal align={'center'} distribution={'space-between'} gap={8}>
- <Flexbox horizontal align={'center'} gap={6}>
- <div className={styles.title}>{t('settingAgent.prompt.title')}</div>
- <InfoTooltip
- iconStyle={{ cursor: 'help' }}
- size={'small'}
- title={t('settingAgent.prompt.desc')}
- />
- </Flexbox>
- <Flexbox horizontal align={'center'} gap={4}>
+ <Flexbox horizontal align={'center'} gap={16} justify={'space-between'}>
+ {title}
+ <Flexbox horizontal align={'center'} gap={4} justify={'flex-end'}>
{promptSaveStatus !== 'idle' && (
<AutoSaveHint
lastUpdatedTime={promptLastUpdatedTime}
@@ -468,59 +460,62 @@ const AgentEditorCanvas = memo<AgentEditorCanvasProps>(({ agentId }) => {
</Flexbox>
</Flexbox>
</Flexbox>
+ {description}
</Flexbox>
- <div
- className={styles.editorShell}
- style={
- editable ? undefined : { cursor: 'not-allowed', opacity: 0.65, pointerEvents: 'none' }
- }
- onClick={(e) => {
- e.stopPropagation();
- }}
- >
- <EditingIndicator
- holderId={lockedByOther ? lockHolderId : null}
- pending={canEdit && lockPending}
- />
- <div hidden={activeEditorMode !== 'visual'}>
- <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}
+ <Block padding={16} variant={'outlined'}>
+ <div
+ className={styles.editorShell}
+ style={
+ editable ? undefined : { cursor: 'not-allowed', opacity: 0.65, pointerEvents: 'none' }
+ }
+ onClick={(e) => {
+ e.stopPropagation();
+ }}
+ >
+ <EditingIndicator
+ holderId={lockedByOther ? lockHolderId : null}
+ pending={canEdit && lockPending}
/>
+ <div hidden={activeEditorMode !== 'visual'}>
+ <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>
+ {activeEditorMode === 'source' && contentInit && (
+ <CodeEditorPane
+ className={styles.sourceEditor}
+ language={'markdown'}
+ readOnly={!editable || streamingInProgress}
+ value={sourceMarkdown}
+ onChange={handleSourceChange}
+ />
+ )}
</div>
- {activeEditorMode === 'source' && contentInit && (
- <CodeEditorPane
- className={styles.sourceEditor}
- language={'markdown'}
- readOnly={!editable || streamingInProgress}
- value={sourceMarkdown}
- onChange={handleSourceChange}
- />
- )}
- </div>
+ </Block>
</Flexbox>
);
});
-const EditorCanvas = memo(() => {
+const EditorCanvas = memo<EditorCanvasProps>(({ description, title }) => {
const { t } = useTranslation();
const agentId = useAgentStore((s) => s.activeAgentId);
const flushSave = useProfileStore((s) => s.flushSave);
@@ -548,7 +543,9 @@ const EditorCanvas = memo(() => {
if (!agentId) return null;
- return <AgentEditorCanvas agentId={agentId} key={agentId} />;
+ return (
+ <AgentEditorCanvas agentId={agentId} description={description} key={agentId} title={title} />
+ );
});
export default EditorCanvas;
diff --git a/src/routes/(main)/agent/profile/features/InstructionEditor/index.tsx b/src/routes/(main)/agent/profile/features/InstructionEditor/index.tsx
index 6d20df19d8a..7ba4cd3e5cd 100644
--- a/src/routes/(main)/agent/profile/features/InstructionEditor/index.tsx
+++ b/src/routes/(main)/agent/profile/features/InstructionEditor/index.tsx
@@ -15,14 +15,15 @@ const InstructionEditor = memo(() => {
const { t } = useTranslation('setting');
return (
- <Flexbox gap={24} paddingBlock={'8px 48px'}>
- <Flexbox gap={4}>
- <Text fontSize={24} weight={600}>
- {t('settingAgent.instruction.title')}
- </Text>
- <Text type={'secondary'}>{t('settingAgent.instruction.desc')}</Text>
- </Flexbox>
- <EditorCanvas />
+ <Flexbox paddingBlock={'8px 48px'}>
+ <EditorCanvas
+ description={<Text type={'secondary'}>{t('settingAgent.instruction.description')}</Text>}
+ title={
+ <Text fontSize={24} weight={600}>
+ {t('settingAgent.instruction.title')}
+ </Text>
+ }
+ />
</Flexbox>
);
});