🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(agent): restore Market review submission flow (#19376)
AmAzing-71b8e2eb4add
diff --git a/locales/en-US/setting.json b/locales/en-US/setting.jsonindex a1ca79b34cb..86e60f53c90 100644--- a/locales/en-US/setting.json+++ b/locales/en-US/setting.json@@ -593,7 +593,19 @@"llm.proxyUrl.title": "API proxy URL","llm.waitingForMore": "More models are <1>planned to be added</1>, stay tuned","llm.waitingForMoreLinkAriaLabel": "Open the Provider request form",+ "marketPublish.status.archived": "Archived",+ "marketPublish.status.deprecated": "Deprecated",+ "marketPublish.status.published": "Published","marketPublish.status.underReview": "Under Review",+ "marketPublish.status.unpublished": "Unpublished",+ "marketSubmission.confirm": "“{{name}}” will become a public agent when published to Market. Make sure its profile and prompt contain no private information or secrets.",+ "marketSubmission.entry": "Publish",+ "marketSubmission.failed": "Could not submit. Please try again.",+ "marketSubmission.linkFailed": "Submitted, but could not save the Market link locally ({{identifier}}). Keep this identifier and avoid resubmitting as a new agent.",+ "marketSubmission.required": "Add an agent name and prompt before publishing.",+ "marketSubmission.submit": "Publish",+ "marketSubmission.success": "Submitted. Your agent is under review and will appear in Market after approval.",+ "marketSubmission.title": "Publish to Market","memory.effort.desc": "Control how aggressively the AI retrieves and updates memory.","memory.effort.high": "High — Proactive retrieval and updates","memory.effort.level.high": "High",diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.jsonindex f1628347577..72ac187eb14 100644--- a/locales/zh-CN/setting.json+++ b/locales/zh-CN/setting.json@@ -593,7 +593,19 @@"llm.proxyUrl.title": "API 代理地址","llm.waitingForMore": "更多模型正在 <1>计划接入</1> 中,敬请期待","llm.waitingForMoreLinkAriaLabel": "打开模型服务商接入需求表单",+ "marketPublish.status.archived": "已归档",+ "marketPublish.status.deprecated": "已弃用",+ "marketPublish.status.published": "已发布","marketPublish.status.underReview": "审核中",+ "marketPublish.status.unpublished": "未发布",+ "marketSubmission.confirm": "「{{name}}」发布到市场后将成为公开 Agent。请确认其资料和提示词不包含私人信息或密钥。",+ "marketSubmission.entry": "发布",+ "marketSubmission.failed": "提交失败,请重试。",+ "marketSubmission.linkFailed": "已提交,但未能在本地保存 Market 关联({{identifier}})。请保留此标识,避免重复创建助手。",+ "marketSubmission.required": "请先填写 Agent 名称和提示词,再发布。",+ "marketSubmission.submit": "发布",+ "marketSubmission.success": "提交成功,Agent 审核中,通过后将在市场展示。",+ "marketSubmission.title": "发布到市场","memory.effort.desc": "控制 AI 检索和更新记忆的积极程度。","memory.effort.high": "高 — 主动检索和更新","memory.effort.level.high": "高",diff --git a/packages/locales/src/default/setting.ts b/packages/locales/src/default/setting.tsindex 5c2f5e5c5fc..a9cb3aa5920 100644--- a/packages/locales/src/default/setting.ts+++ b/packages/locales/src/default/setting.ts@@ -1,4 +1,19 @@export default {+ 'marketSubmission.entry': 'Publish',+ 'marketSubmission.title': 'Publish to Market',+ 'marketSubmission.submit': 'Publish',+ 'marketSubmission.confirm':+ '“{{name}}” will become a public agent when published to Market. Make sure its profile and prompt contain no private information or secrets.',+ 'marketSubmission.required': 'Add an agent name and prompt before publishing.',+ 'marketSubmission.success':+ 'Submitted. Your agent is under review and will appear in Market after approval.',+ 'marketSubmission.failed': 'Could not submit. Please try again.',+ 'marketSubmission.linkFailed':+ 'Submitted, but could not save the Market link locally ({{identifier}}). Keep this identifier and avoid resubmitting as a new agent.',+ 'marketPublish.status.published': 'Published',+ 'marketPublish.status.unpublished': 'Unpublished',+ 'marketPublish.status.archived': 'Archived',+ 'marketPublish.status.deprecated': 'Deprecated','completionSound.title': 'In-app completion sound','completionSound.enabled': 'Play completion sound','completionSound.desc':diff --git a/src/features/AgentMarketSubmission/useAgentMarketSubmission.test.ts b/src/features/AgentMarketSubmission/useAgentMarketSubmission.test.tsnew file mode 100644index 00000000000..0176663843d--- /dev/null+++ b/src/features/AgentMarketSubmission/useAgentMarketSubmission.test.ts@@ -0,0 +1,235 @@+import { confirmModal, toast } from '@lobehub/ui/base-ui';+import { act, renderHook } from '@testing-library/react';+import { beforeEach, describe, expect, it, vi } from 'vitest';++import { useAgentMarketSubmission } from './useAgentMarketSubmission';++const mocks = vi.hoisted(() => ({+ authenticated: true,+ close: vi.fn(),+ config: {+ chatConfig: { historyCount: 7, runtimeEnv: { workingDirectory: '/private' } },+ model: 'test-model',+ params: { temperature: 0.3, top_p: 0.8 },+ plugins: ['search', { identifier: 'disabled-tool', mode: 'disabled' }],+ provider: 'test-provider',+ systemRole: 'Older saved prompt',+ },+ meta: { marketIdentifier: undefined as string | undefined, title: 'Review agent' },+ signIn: vi.fn(),+ state: { activeAgentId: 'agent-a', updateAgentMetaById: vi.fn() },+ submit: vi.fn(),+ workspace: false,+ workspaceIdentity: vi.fn(),+}));++vi.mock('@lobehub/ui/base-ui', async (importOriginal) => ({+ ...(await importOriginal<object>()),+ confirmModal: vi.fn(() => ({ close: mocks.close, destroy: vi.fn() })),+ toast: { error: vi.fn(), success: vi.fn(), warning: vi.fn() },+}));+vi.mock('@/business/client/hooks/useHasActiveWorkspace', () => ({+ useHasActiveWorkspace: () => mocks.workspace,+}));+vi.mock('@/layout/AuthProvider/MarketAuth', () => ({+ useMarketAuth: () => ({ isAuthenticated: mocks.authenticated, signIn: mocks.signIn }),+}));+vi.mock('@/libs/trpc/client', () => ({+ lambdaClient: {+ market: { agent: { publishOrCreate: { mutate: mocks.submit } } },+ workspace: { ensureMarketOrganization: { mutate: mocks.workspaceIdentity } },+ },+}));+vi.mock('@/store/agent', () => ({ useAgentStore: { getState: () => mocks.state } }));+vi.mock('@/store/agent/selectors', () => ({+ agentSelectors: {+ getAgentConfigById: () => () => mocks.config,+ getAgentMetaById: () => () => mocks.meta,+ },+}));++const getPrompt = () => ({ editorData: { text: 'Current draft' }, systemRole: 'Current draft' });+const confirmation = () => vi.mocked(confirmModal).mock.calls.at(-1)![0];+const renderSubmission = (canSubmit = true) =>+ renderHook(() => useAgentMarketSubmission({ agentId: 'agent-a', canSubmit, getPrompt }));++describe('Market review submission', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ mocks.authenticated = true;+ mocks.workspace = false;+ mocks.state.activeAgentId = 'agent-a';+ mocks.meta.marketIdentifier = undefined;+ mocks.submit.mockResolvedValue({ identifier: 'market-a', isNewAgent: true, success: true });+ mocks.state.updateAgentMetaById.mockResolvedValue(undefined);+ mocks.workspaceIdentity.mockResolvedValue({ marketAccountId: 42 });+ });++ it('requires confirmation and submits the current draft, excluding disabled tools and private runtime settings', async () => {+ const { result } = renderSubmission();+ await act(() => result.current.open());+ expect(mocks.submit).not.toHaveBeenCalled();+ expect(result.current.isUnderReview).toBe(false);+ await act(async () => confirmation().onOk?.());+ expect(mocks.submit).toHaveBeenCalledWith(+ expect.objectContaining({+ config: {+ chatConfig: expect.objectContaining({ historyCount: 7, temperature: 0.3, topP: 0.8 }),+ description: undefined,+ locale: expect.any(String),+ model: {+ model: 'test-model',+ parameters: { temperature: 0.3, top_p: 0.8 },+ provider: 'test-provider',+ },+ plugins: ['search'],+ systemRole: 'Current draft',+ },+ editorData: { text: 'Current draft' },+ name: 'Review agent',+ }),+ );+ expect(JSON.stringify(mocks.submit.mock.calls[0])).not.toContain('/private');+ expect(mocks.state.updateAgentMetaById).toHaveBeenCalledWith('agent-a', {+ marketIdentifier: 'market-a',+ });+ expect(toast.success).toHaveBeenCalledWith('marketSubmission.success');+ expect(result.current.revision).toBe(1);+ expect(result.current.isUnderReview).toBe(true);+ });++ it('does not show another agent as under review after navigating during submission', async () => {+ let resolve!: (value: { identifier: string; isNewAgent: boolean; success: boolean }) => void;+ mocks.submit.mockReturnValue(+ new Promise((done) => {+ resolve = done;+ }),+ );+ const { result, rerender } = renderHook(+ ({ agentId }) => useAgentMarketSubmission({ agentId, canSubmit: true, getPrompt }),+ { initialProps: { agentId: 'agent-a' } },+ );+ await act(() => result.current.open());+ let pending: void | Promise<void>;+ act(() => {+ pending = confirmation().onOk?.();+ });+ expect(result.current.isUnderReview).toBe(false);+ mocks.state.activeAgentId = 'agent-b';+ rerender({ agentId: 'agent-b' });+ await act(async () => {+ resolve({ identifier: 'market-a', isNewAgent: true, success: true });+ await pending;+ });+ expect(result.current.isUnderReview).toBe(false);+ });++ it('submits existing listings as new versions under the workspace identity', async () => {+ mocks.workspace = true;+ mocks.workspaceIdentity.mockImplementation(async (input) => {+ if (!input?.autoProvision) throw new Error('Community profile setup required');+ return { marketAccountId: 42 };+ });+ mocks.meta.marketIdentifier = 'existing';+ mocks.submit.mockResolvedValue({ identifier: 'existing', isNewAgent: false, success: true });+ const { result } = renderSubmission();+ await act(() => result.current.open());+ await act(async () => confirmation().onOk?.());+ expect(mocks.submit).toHaveBeenCalledWith(+ expect.objectContaining({ actAs: 42, identifier: 'existing' }),+ );+ expect(mocks.state.updateAgentMetaById).not.toHaveBeenCalled();+ expect(result.current.revision).toBe(1);+ });++ it('does not authorize or submit when access is denied', async () => {+ const { result } = renderSubmission(false);+ await act(() => result.current.open());+ expect(confirmModal).not.toHaveBeenCalled();+ expect(mocks.signIn).not.toHaveBeenCalled();+ expect(mocks.submit).not.toHaveBeenCalled();+ });++ it('stops when Market authorization is cancelled', async () => {+ mocks.authenticated = false;+ mocks.signIn.mockRejectedValueOnce(new Error('User cancelled authorization'));+ const { result } = renderSubmission();+ await act(() => result.current.open());+ expect(mocks.signIn).toHaveBeenCalledOnce();+ expect(confirmModal).not.toHaveBeenCalled();+ expect(mocks.submit).not.toHaveBeenCalled();+ expect(toast.error).not.toHaveBeenCalled();++ mocks.signIn.mockResolvedValueOnce(true);+ await act(() => result.current.open());+ expect(confirmModal).toHaveBeenCalledOnce();+ });++ it('reports real authorization failures without submitting', async () => {+ mocks.authenticated = false;+ mocks.signIn.mockRejectedValueOnce(new Error('Authorization state mismatch'));+ const { result } = renderSubmission();+ await act(() => result.current.open());+ expect(toast.error).toHaveBeenCalledWith('marketSubmission.failed');+ expect(confirmModal).not.toHaveBeenCalled();+ expect(mocks.submit).not.toHaveBeenCalled();+ });++ it('does not fall back to personal submission when workspace provisioning fails', async () => {+ mocks.workspace = true;+ mocks.workspaceIdentity.mockRejectedValueOnce(new Error('Provisioning failed'));+ const { result } = renderSubmission();+ await act(() => result.current.open());+ await act(async () => {+ await expect(confirmation().onOk?.()).rejects.toThrow('Provisioning failed');+ });+ expect(mocks.submit).not.toHaveBeenCalled();+ expect(toast.success).not.toHaveBeenCalled();+ expect(result.current.isUnderReview).toBe(false);+ expect(result.current.isSubmitting).toBe(false);++ await act(async () => confirmation().onOk?.());+ expect(mocks.submit).toHaveBeenCalledWith(expect.objectContaining({ actAs: 42 }));+ });++ it('keeps the originating agent ID and suppresses duplicate submissions during a route change', async () => {+ let resolve!: (value: { identifier: string; isNewAgent: boolean; success: boolean }) => void;+ mocks.submit.mockReturnValue(+ new Promise((done) => {+ resolve = done;+ }),+ );+ const { result } = renderSubmission();+ await act(() => result.current.open());+ let pending: void | Promise<void>;+ act(() => {+ pending = confirmation().onOk?.();+ });+ mocks.state.activeAgentId = 'agent-b';+ await act(async () => confirmation().onOk?.());+ expect(mocks.submit).toHaveBeenCalledOnce();+ await act(async () => {+ resolve({ identifier: 'market-a', isNewAgent: true, success: true });+ await pending;+ });+ expect(mocks.state.updateAgentMetaById).toHaveBeenCalledWith('agent-a', {+ marketIdentifier: 'market-a',+ });+ });++ it('does not report success on failure and allows retry', async () => {+ mocks.submit.mockRejectedValueOnce(new Error('Rejected'));+ const { result } = renderSubmission();+ await act(() => result.current.open());+ await act(async () => {+ await expect(confirmation().onOk?.()).rejects.toThrow('Rejected');+ });+ expect(toast.success).not.toHaveBeenCalled();+ expect(mocks.state.updateAgentMetaById).not.toHaveBeenCalled();+ expect(result.current.isSubmitting).toBe(false);+ expect(result.current.isUnderReview).toBe(false);+ await act(async () => confirmation().onOk?.());+ expect(toast.success).toHaveBeenCalledOnce();+ expect(result.current.isUnderReview).toBe(true);+ });+});diff --git a/src/features/AgentMarketSubmission/useAgentMarketSubmission.ts b/src/features/AgentMarketSubmission/useAgentMarketSubmission.tsnew file mode 100644index 00000000000..7244b464273--- /dev/null+++ b/src/features/AgentMarketSubmission/useAgentMarketSubmission.ts@@ -0,0 +1,134 @@+import { getActivePluginIds, type LobeAgentConfig } from '@lobechat/types';+import { confirmModal, toast } from '@lobehub/ui/base-ui';+import { useEffect, useRef, useState } from 'react';+import { useTranslation } from 'react-i18next';++import { useHasActiveWorkspace } from '@/business/client/hooks/useHasActiveWorkspace';+import { useMarketAuth } from '@/layout/AuthProvider/MarketAuth';+import { lambdaClient } from '@/libs/trpc/client';+import { useAgentStore } from '@/store/agent';+import { agentSelectors } from '@/store/agent/selectors';++interface Options {+ agentId?: string | null;+ canSubmit: boolean;+ getPrompt: () => Pick<LobeAgentConfig, 'editorData' | 'systemRole'>;+}++/** Submit a snapshot for Market review; never call the manual publish endpoint. */+export const useAgentMarketSubmission = ({ agentId, canSubmit, getPrompt }: Options) => {+ const { i18n, t } = useTranslation('setting');+ const { isAuthenticated, signIn } = useMarketAuth();+ const hasActiveWorkspace = useHasActiveWorkspace();+ const [isSubmitting, setIsSubmitting] = useState(false);+ const [revision, setRevision] = useState(0);+ const [submittedAgentId, setSubmittedAgentId] = useState<string>();+ const busy = useRef(false);+ const modal = useRef<ReturnType<typeof confirmModal> | null>(null);++ useEffect(() => () => modal.current?.close(), [agentId, canSubmit]);++ const open = async () => {+ if (!canSubmit || !agentId || busy.current) return;+ const state = useAgentStore.getState();+ const config = agentSelectors.getAgentConfigById(agentId)(state);+ const meta = agentSelectors.getAgentMetaById(agentId)(state);+ if (!config) return;++ // Read before any await: changing routes during authorization must not submit+ // another agent's prompt or write the Market identifier onto that agent.+ const prompt = getPrompt();+ const snapshot = structuredClone({ ...config, ...prompt });+ const name = meta.title?.trim();+ if (!name || !snapshot.systemRole?.trim()) {+ toast.error(t('marketSubmission.required'));+ return;+ }++ busy.current = true;+ try {+ if (!isAuthenticated && !(await signIn())) return;+ if (useAgentStore.getState().activeAgentId !== agentId) return;+ modal.current?.close();+ modal.current = confirmModal({+ cancelText: t('cancel', { ns: 'common' }),+ content: t('marketSubmission.confirm', { name: meta.title }),+ okText: t('marketSubmission.submit'),+ onOk: async () => {+ if (busy.current) return;+ busy.current = true;+ setIsSubmitting(true);+ try {+ const actAs = hasActiveWorkspace+ ? (+ await lambdaClient.workspace.ensureMarketOrganization.mutate({+ autoProvision: true,+ })+ ).marketAccountId+ : undefined;+ const result = await lambdaClient.market.agent.publishOrCreate.mutate({+ actAs,+ avatar: meta.avatar,+ config: {+ chatConfig: {+ enableHistoryCount: snapshot.chatConfig?.enableHistoryCount,+ historyCount: snapshot.chatConfig?.historyCount,+ maxTokens: snapshot.params?.max_tokens,+ searchMode: snapshot.chatConfig?.searchMode,+ temperature: snapshot.params?.temperature,+ topP: snapshot.params?.top_p,+ },+ description: meta.description,+ locale: i18n.resolvedLanguage || i18n.language,+ model: {+ model: snapshot.model,+ parameters: snapshot.params,+ provider: snapshot.provider,+ },+ plugins: getActivePluginIds(snapshot.plugins),+ systemRole: snapshot.systemRole,+ },+ description: meta.description || '',+ editorData: snapshot.editorData,+ identifier: meta.marketIdentifier,+ name,+ tags: meta.tags,+ });++ if (result.isNewAgent) {+ try {+ await useAgentStore.getState().updateAgentMetaById(agentId, {+ marketIdentifier: result.identifier,+ });+ } catch (error) {+ console.error('Failed to save submitted Market identifier:', error);+ toast.warning(t('marketSubmission.linkFailed', { identifier: result.identifier }));+ }+ }+ setSubmittedAgentId(agentId);+ setRevision((value) => value + 1);+ toast.success(t('marketSubmission.success'));+ } catch (error) {+ console.error('Failed to submit agent for Market review:', error);+ toast.error(t('marketSubmission.failed'));+ // Keep confirmation open so the user can retry after an API failure.+ throw error;+ } finally {+ busy.current = false;+ setIsSubmitting(false);+ }+ },+ title: t('marketSubmission.title'),+ });+ } catch (error) {+ // MarketAuthProvider rejects signIn when its authorization dialog is cancelled.+ if (error instanceof Error && error.message === 'User cancelled authorization') return;+ console.error('Failed to authorize Market submission:', error);+ toast.error(t('marketSubmission.failed'));+ } finally {+ busy.current = false;+ }+ };++ return { isSubmitting, isUnderReview: !!agentId && submittedAgentId === agentId, open, revision };+};diff --git a/src/routes/(main)/agent/profile/features/Header/AgentVersionReviewTag.tsx b/src/routes/(main)/agent/profile/features/Header/AgentVersionReviewTag.tsxindex c11e999a128..ee8657e7cfd 100644--- a/src/routes/(main)/agent/profile/features/Header/AgentVersionReviewTag.tsx+++ b/src/routes/(main)/agent/profile/features/Header/AgentVersionReviewTag.tsx@@ -8,6 +8,8 @@ import { marketApiService } from '@/services/marketApi';import { useAgentStore } from '@/store/agent';import { agentSelectors } from '@/store/agent/selectors';+import AgentStatusTag from './AgentStatusTag';+interface AgentVersion {isLatest: boolean;isValidated: boolean;@@ -21,7 +23,7 @@ interface AgentVersion {* Agent Version Review Tag Component* Displays "Under Review" tag when the latest version is not validated*/-const AgentVersionReviewTag = memo(() => {+const AgentVersionReviewTag = memo(({ submitted = false }: { submitted?: boolean }) => {const { t } = useTranslation('setting');const [versions, setVersions] = useState<AgentVersion[] | null>(null);const [loading, setLoading] = useState(false);@@ -58,7 +60,9 @@ const AgentVersionReviewTag = memo(() => {return versions[0].isValidated === false;}, [versions]);- if (loading || !showReviewTag) return null;+ // A successful submission is authoritative even when the detail endpoint+ // omits pending versions. Do not infer review status from "unpublished" alone.+ if (!submitted && (loading || !showReviewTag)) return <AgentStatusTag />;return (<Tag color="orange" style={{ marginRight: 8 }}>diff --git a/src/routes/(main)/agent/profile/features/Header/index.test.tsx b/src/routes/(main)/agent/profile/features/Header/index.test.tsxindex 6af9a32dc56..226e98eb754 100644--- a/src/routes/(main)/agent/profile/features/Header/index.test.tsx+++ b/src/routes/(main)/agent/profile/features/Header/index.test.tsx@@ -7,6 +7,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';import Header from './index';const mocks = vi.hoisted(() => ({+ marketSubmission: { isSubmitting: false, isUnderReview: false, open: vi.fn(), revision: 0 },agentState: {activeAgentId: 'agent-1',authorId: undefined as string | undefined,@@ -167,6 +168,10 @@ vi.mock('@/features/AgentBreadcrumb', () => ({default: () => null,}));+vi.mock('@/features/AgentMarketSubmission/useAgentMarketSubmission', () => ({+ useAgentMarketSubmission: () => mocks.marketSubmission,+}));+vi.mock('@/business/client/hooks/useHasActiveWorkspace', () => ({useHasActiveWorkspace: () => mocks.hasActiveWorkspace,}));@@ -275,24 +280,28 @@ vi.mock('./AgentForkTag', () => ({}));vi.mock('./AgentStatusTag', () => ({- default: () => null,+ default: () => <span>Unpublished</span>,}));-vi.mock('./AgentVersionReviewTag', () => ({- default: () => null,+vi.mock('@/services/marketApi', () => ({+ marketApiService: { getAgentDetail: vi.fn().mockResolvedValue({ status: 'unpublished' }) },}));describe('Agent profile Header', () => {beforeEach(() => {+ mocks.marketSubmission.isUnderReview = false;vi.spyOn(HTMLAnchorElement.prototype, 'click').mockImplementation(() => {});vi.spyOn(URL, 'createObjectURL').mockReturnValue('blob:agent-profile');vi.spyOn(URL, 'revokeObjectURL').mockImplementation(() => {});mocks.agentState.isCurrentAgentHeterogeneous = false;+ mocks.agentState.isBuiltinAgent = false;mocks.agentState.isInbox = false;mocks.agentState.systemRole = 'You are helpful.';mocks.agentState.visibility = 'public';mocks.globalState.showAgentBuilderPanel = false;mocks.profileState.editor = undefined;+ mocks.profileState.lockState.pending = false;+ mocks.profileState.lockState.lockedByOther = false;mocks.permission.allowed = true;mocks.resourceAccess.canEditResource = true;mocks.resourceAccess.canManageResource = true;@@ -301,6 +310,52 @@ describe('Agent profile Header', () => {mocks.serverConfigState.serverConfig.enableBusinessFeatures = true;});+ describe('Market review entry', () => {+ it('replaces the unpublished status with under review after submission', () => {+ const { rerender } = render(<Header />);+ expect(screen.getByText('Unpublished')).toBeVisible();+ expect(screen.queryByText('Under Review')).toBeNull();++ mocks.marketSubmission.isUnderReview = true;+ rerender(<Header key="submitted" />);++ expect(screen.getByText('Under Review')).toBeVisible();+ expect(screen.queryByText('Unpublished')).toBeNull();+ });++ it('keeps publishing inside the collapsed actions menu, not directly in the header', () => {+ render(<Header />);++ const entry = screen.getByRole('button', { name: 'marketSubmission.entry' });+ expect(screen.getByTestId('agent-profile-menu')).toContainElement(entry);+ expect(entry).toBeVisible();+ });++ it('offers submission independently of the share rollout flag', () => {+ mocks.serverConfigState.featureFlags.enableAgentShare = false;+ render(<Header />);+ expect(screen.getByText('marketSubmission.entry')).toBeEnabled();+ });++ it.each(['builtin', 'heterogeneous'] as const)('hides submission for %s agents', (kind) => {+ mocks.agentState.isBuiltinAgent = kind === 'builtin';+ mocks.agentState.isCurrentAgentHeterogeneous = kind === 'heterogeneous';+ render(<Header />);+ expect(screen.queryByText('marketSubmission.entry')).toBeNull();+ });++ it.each(['role', 'resource', 'lock'] as const)(+ 'disables submission when blocked by %s',+ (kind) => {+ mocks.permission.allowed = kind !== 'role';+ mocks.resourceAccess.canManageResource = kind !== 'resource';+ mocks.profileState.lockState.lockedByOther = kind === 'lock';+ render(<Header />);+ expect(screen.getByText('marketSubmission.entry')).toBeDisabled();+ },+ );+ });+describe('share entry', () => {// Agent sharing is personal-only, so the entry needs a personal agent;// the rollout flag is on unless a case says otherwise.diff --git a/src/routes/(main)/agent/profile/features/Header/index.tsx b/src/routes/(main)/agent/profile/features/Header/index.tsxindex 0b427ce191e..b3c88548211 100644--- a/src/routes/(main)/agent/profile/features/Header/index.tsx+++ b/src/routes/(main)/agent/profile/features/Header/index.tsx@@ -12,6 +12,7 @@ import {Settings2Icon,Share2Icon,Trash,+ UploadCloud,UserRound,UsersIcon,} from 'lucide-react';@@ -25,6 +26,7 @@ import { useBusinessAgentImportMenuItem } from '@/business/client/hooks/useBusinimport { useHasActiveWorkspace } from '@/business/client/hooks/useHasActiveWorkspace';import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';import AgentBreadcrumb from '@/features/AgentBreadcrumb';+import { useAgentMarketSubmission } from '@/features/AgentMarketSubmission/useAgentMarketSubmission';import AgentProfileTabs, { AGENT_PROFILE_TABS_CENTER_STYLE } from '@/features/AgentProfileTabs';import { useAgentShareSupported } from '@/features/AgentShareSettings/useAgentShareSupported';import NavHeader from '@/features/NavHeader';@@ -45,7 +47,6 @@ import { sanitizeFileName } from '@/utils/sanitizeFileName';import { openAgentSettingsModal } from '../AgentSettings';import { selectors as profileSelectors, useProfileStore } from '../store';import AgentForkTag from './AgentForkTag';-import AgentStatusTag from './AgentStatusTag';import AgentVersionReviewTag from './AgentVersionReviewTag';type HeaderTranslation = TFunction<@@ -253,6 +254,19 @@ const Header = memo(() => {const { visible: shareVisible } = useAgentShareSupported(activeAgentId);const canShareAgent = shareVisible === true && canConfigure;+ const showMarketSubmission = !!config && !isBuiltinAgent && !isHeterogeneous;+ const canSubmitToMarket = showMarketSubmission && canManage && !lockedByOther && !lockPending;+ const marketSubmission = useAgentMarketSubmission({+ agentId: activeAgentId,+ canSubmit: canSubmitToMarket,+ getPrompt: () => ({+ editorData: editor+ ? (editor.getDocument('json') as LobeAgentConfig['editorData'])+ : config?.editorData,+ systemRole: editor ? (editor.getDocument('markdown') as unknown as string) : systemRole,+ }),+ });+// Share settings are a sibling tab of the profile group, not a popup — the// shortcut just jumps to that tab.const handleOpenShare = useCallback(() => {@@ -294,6 +308,15 @@ const Header = memo(() => {}: null,{ type: 'divider' as const },+ showMarketSubmission+ ? {+ disabled: !canSubmitToMarket || marketSubmission.isSubmitting,+ icon: <Icon icon={UploadCloud} />,+ key: 'submit-to-market',+ label: t('marketSubmission.entry'),+ onClick: marketSubmission.open,+ }+ : null,{children: [{@@ -355,12 +378,16 @@ const Header = memo(() => {authorName,canConfigure,canManage,+ canSubmitToMarket,createdAt,dateLocale,handleExportMarkdown,handleDelete,isInbox,+ marketSubmission.isSubmitting,+ marketSubmission.open,navigate,+ showMarketSubmission,showPermissionPageEntry,t,importMenuItem,@@ -376,8 +403,10 @@ const Header = memo(() => {<Flexbox horizontal align={'center'} gap={8}>{/* No section title — the Segmented beside it names the current tab. */}{activeAgentId && <AgentBreadcrumb agentId={activeAgentId} />}- <AgentStatusTag />- <AgentVersionReviewTag />+ <AgentVersionReviewTag+ key={`review-${activeAgentId}-${marketSubmission.revision}`}+ submitted={marketSubmission.isUnderReview}+ /><AgentForkTag /><AccessLevelTagresourceId={showPermissionsEntry ? (activeAgentId ?? undefined) : undefined}