🤯 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
🐛 fix: preserve empty agent prompt export (#15316)
YuTengjingdc3186a99058
diff --git a/src/routes/(main)/agent/profile/features/Header/index.test.tsx b/src/routes/(main)/agent/profile/features/Header/index.test.tsxindex 4519fa4f53a..014795be080 100644--- a/src/routes/(main)/agent/profile/features/Header/index.test.tsx+++ b/src/routes/(main)/agent/profile/features/Header/index.test.tsx@@ -40,6 +40,9 @@ const mocks = vi.hoisted(() => ({publish: vi.fn(),},navigate: vi.fn(),+ profileState: {+ editor: undefined as { getDocument: (format: string) => string | undefined } | undefined,+ },versionReviewStatus: {isUnderReview: false,},@@ -69,6 +72,8 @@ const renderMenuItems = (items: MockDropdownItem[]) =></div>));+const getLatestExportedBlob = () => vi.mocked(URL.createObjectURL).mock.calls.at(-1)?.[0] as Blob;+vi.mock('@lobehub/ui', () => ({ActionIcon: () => <button aria-label="more" type="button" />,DropdownMenu: ({@@ -192,8 +197,8 @@ vi.mock('@/store/home', () => ({}));vi.mock('../store', () => ({- useProfileStore: (selector: (state: { editor: undefined }) => unknown) =>- selector({ editor: undefined }),+ useProfileStore: (selector: (state: typeof mocks.profileState) => unknown) =>+ selector(mocks.profileState),}));vi.mock('./AgentForkTag', () => ({@@ -232,6 +237,7 @@ describe('Agent profile Header', () => {vi.spyOn(URL, 'revokeObjectURL').mockImplementation(() => {});mocks.agentState.canCurrentAgentPublishToCommunity = true;mocks.agentState.isCurrentAgentHeterogeneous = false;+ mocks.profileState.editor = undefined;});it('should show the community publish action for normal agents', () => {@@ -256,13 +262,32 @@ describe('Agent profile Header', () => {await waitFor(() => expect(URL.createObjectURL).toHaveBeenCalled());- const exportedBlob = vi.mocked(URL.createObjectURL).mock.calls[0][0] as Blob;+ const exportedBlob = getLatestExportedBlob();await expect(exportedBlob.text()).resolves.toContain('# Test Agent');await expect(exportedBlob.text()).resolves.toContain('You are helpful.');expect(HTMLAnchorElement.prototype.click).toHaveBeenCalled();expect(URL.revokeObjectURL).toHaveBeenCalledWith('blob:agent-profile');});+ it('should preserve an empty prompt from the mounted editor when exporting markdown', async () => {+ mocks.profileState.editor = {+ getDocument: vi.fn().mockReturnValue(''),+ };++ 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(exportedMarkdown).toContain('# Test Agent');+ expect(exportedMarkdown).not.toContain('You are helpful.');+ expect(exportedMarkdown).not.toContain('settingAgent.prompt.title');+ });+it('should hide the community publish action for heterogeneous and platform agents', () => {mocks.agentState.canCurrentAgentPublishToCommunity = false;mocks.agentState.isCurrentAgentHeterogeneous = true;diff --git a/src/routes/(main)/agent/profile/features/Header/index.tsx b/src/routes/(main)/agent/profile/features/Header/index.tsxindex 38f0dbdea9c..000419f664c 100644--- a/src/routes/(main)/agent/profile/features/Header/index.tsx+++ b/src/routes/(main)/agent/profile/features/Header/index.tsx@@ -199,13 +199,13 @@ const Header = memo(() => {const handleExportMarkdown = useCallback(async () => {try {- const editorMarkdown = editor?.getDocument('markdown') as string | undefined;+ const editorMarkdown = editor?.getDocument('markdown') as string | null | undefined;const profileMarkdown = buildAgentProfileMarkdown({description: meta?.description,model: config.model,plugins: config.plugins,provider: config.provider,- systemRole: editorMarkdown || systemRole,+ systemRole: editorMarkdown ?? systemRole,t,tags: meta?.tags,title: meta?.title,