🤯 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: specialize Market auth modal copy per capability scene (#15569)
LiJian5dd0f0c0c929
diff --git a/locales/en-US/marketAuth.json b/locales/en-US/marketAuth.jsonindex 398fc18376b..054bf3799bd 100644--- a/locales/en-US/marketAuth.json+++ b/locales/en-US/marketAuth.json@@ -5,6 +5,12 @@"authorize.footer.agreement": "By continuing, you confirm that you have read and agree to the <terms>Terms and Conditions</terms> and <privacy>Privacy Policy</privacy>.","authorize.footer.privacy": "Privacy Policy","authorize.footer.terms": "Terms of Service",+ "authorize.scenes.mcp.subtitle": "Create a community profile to install and run this skill from the community.",+ "authorize.scenes.mcp.title": "Install Community Skill",+ "authorize.scenes.publish.subtitle": "Create a community profile to publish and manage your listing within the community.",+ "authorize.scenes.publish.title": "Publish to the Community",+ "authorize.scenes.sandbox.subtitle": "Create a community profile to run this tool in the community sandbox.",+ "authorize.scenes.sandbox.title": "Try the Community Sandbox","authorize.subtitle": "Create a community profile to submit and manage listings within the community.","authorize.title": "Create Community Profile","callback.buttons.close": "Close Window",diff --git a/locales/zh-CN/marketAuth.json b/locales/zh-CN/marketAuth.jsonindex 7b421d28b16..54803041c32 100644--- a/locales/zh-CN/marketAuth.json+++ b/locales/zh-CN/marketAuth.json@@ -5,6 +5,12 @@"authorize.footer.agreement": "继续操作即表示你确认已理解并同意<terms>条款和条件</terms>和<privacy>隐私政策</privacy>","authorize.footer.privacy": "隐私政策","authorize.footer.terms": "服务条款",+ "authorize.scenes.mcp.subtitle": "创建社区个人档案,即可安装并运行该社区技能。",+ "authorize.scenes.mcp.title": "安装社区技能",+ "authorize.scenes.publish.subtitle": "创建社区个人档案,以便在社区发布和管理你的上架内容。",+ "authorize.scenes.publish.title": "发布到社区",+ "authorize.scenes.sandbox.subtitle": "创建社区个人档案,即可在社区沙箱中运行该工具。",+ "authorize.scenes.sandbox.title": "试用社区沙箱","authorize.subtitle": "创建社区个人档案,以便在社区上提交和管理上架信息。","authorize.title": "创建社区档案","callback.buttons.close": "关闭窗口",diff --git a/src/features/MCPPluginDetail/Header.tsx b/src/features/MCPPluginDetail/Header.tsxindex 15007f68683..3764f04746a 100644--- a/src/features/MCPPluginDetail/Header.tsx+++ b/src/features/MCPPluginDetail/Header.tsx@@ -99,7 +99,7 @@ const Header = memo<{ inModal?: boolean; mobile?: boolean }>(({ mobile: isMobileconst handleFavoriteClick = async () => {if (!isAuthenticated) {- await signIn();+ await signIn('mcp');return;}diff --git a/src/features/SkillStore/SkillList/Community/Item.tsx b/src/features/SkillStore/SkillList/Community/Item.tsxindex df0791714bf..7f1b7cfdab2 100644--- a/src/features/SkillStore/SkillList/Community/Item.tsx+++ b/src/features/SkillStore/SkillList/Community/Item.tsx@@ -61,7 +61,7 @@ const Item = memo<DiscoverMcpItem>(({ name, description, icon, identifier }) =>const handleInstall = async () => {if (isCloudMcp && !isAuthenticated) {try {- await signIn();+ await signIn('mcp');} catch {return;}diff --git a/src/layout/AuthProvider/MarketAuth/MarketAuthConfirmModal.tsx b/src/layout/AuthProvider/MarketAuth/MarketAuthConfirmModal.tsxindex b577d8c3393..4f6e75c21e6 100644--- a/src/layout/AuthProvider/MarketAuth/MarketAuthConfirmModal.tsx+++ b/src/layout/AuthProvider/MarketAuth/MarketAuthConfirmModal.tsx@@ -10,6 +10,8 @@ import { PRIVACY_URL, TERMS_URL } from '@/const/url';import AuthCard from '@/features/AuthCard';import { useIsDark } from '@/hooks/useIsDark';+import type { MarketAuthScene } from './scenes';+const styles = createStaticStyles(({ css }) => ({container: css`padding-block-start: 32px;@@ -30,13 +32,28 @@ interface MarketAuthConfirmModalProps {onCancel: () => void;onConfirm: () => void;open: boolean;+ scene?: MarketAuthScene;}const MarketAuthConfirmModal = memo<MarketAuthConfirmModalProps>(- ({ open, onConfirm, onCancel }) => {+ ({ open, onConfirm, onCancel, scene = 'default' }) => {const { t } = useTranslation('marketAuth');const isDarkMode = useIsDark();+ // Resolve scene-specific copy, falling back to the generic community-profile+ // wording when a scene has no dedicated key.+ const ts = (key: string, options?: Record<string, unknown>): string => {+ const fallback = t(`authorize.${key}` as any, options as any) as string;+ if (scene === 'default') return fallback;+ return t(+ `authorize.scenes.${scene}.${key}` as any,+ {+ ...options,+ defaultValue: fallback,+ } as any,+ ) as string;+ };+const footer = (<Text align={'center'} as={'div'} fontSize={13} type={'secondary'}><Trans@@ -83,12 +100,12 @@ const MarketAuthConfirmModal = memo<MarketAuthConfirmModalProps>(<AuthCardfooter={footer}paddingBlock={'40px 20px'}- subtitle={t('authorize.subtitle')}- title={t('authorize.title')}+ subtitle={ts('subtitle')}+ title={ts('title')}width={'100%'}><Block padding={16} variant={'filled'}>- <Text align={'center'}>{t('authorize.description', { appName: BRANDING_NAME })}</Text>+ <Text align={'center'}>{ts('description', { appName: BRANDING_NAME })}</Text></Block></AuthCard></Modal>diff --git a/src/layout/AuthProvider/MarketAuth/MarketAuthProvider.tsx b/src/layout/AuthProvider/MarketAuth/MarketAuthProvider.tsxindex ca6d53dbb79..9d6f9d9cb96 100644--- a/src/layout/AuthProvider/MarketAuth/MarketAuthProvider.tsx+++ b/src/layout/AuthProvider/MarketAuth/MarketAuthProvider.tsx@@ -19,6 +19,7 @@ import { marketAuthEvents } from './events';import MarketAuthConfirmModal from './MarketAuthConfirmModal';import { MarketOIDC } from './oidc';import ProfileSetupModal from './ProfileSetupModal';+import type { MarketAuthScene } from './scenes';import {type MarketAuthContextType,type MarketAuthSession,@@ -139,6 +140,7 @@ export const MarketAuthProvider = ({ children, isDesktop }: MarketAuthProviderPrconst [status, setStatus] = useState<'loading' | 'authenticated' | 'unauthenticated'>('loading');const [oidcClient, setOidcClient] = useState<MarketOIDC | null>(null);const [showConfirmModal, setShowConfirmModal] = useState(false);+ const [authScene, setAuthScene] = useState<MarketAuthScene>('default');const [showProfileSetupModal, setShowProfileSetupModal] = useState(false);const [isFirstTimeSetup, setIsFirstTimeSetup] = useState(false);const [pendingSignInResolve, setPendingSignInResolve] = useState<@@ -391,10 +393,11 @@ export const MarketAuthProvider = ({ children, isDesktop }: MarketAuthProviderPr/*** Sign-in method (shows confirmation dialog first)*/- const signIn = useCallback(async (): Promise<number | null> => {+ const signIn = useCallback(async (scene: MarketAuthScene = 'default'): Promise<number | null> => {if (!useUserStore.getState().isSignedIn) {throw new Error('LobeChat session required');}+ setAuthScene(scene);return new Promise<number | null>((resolve, reject) => {setPendingSignInResolve(() => resolve);setPendingSignInReject(() => reject);@@ -633,30 +636,33 @@ export const MarketAuthProvider = ({ children, isDesktop }: MarketAuthProviderPr* Attempts to refresh token first, then triggers signIn if refresh fails* @returns true if successfully re-authenticated, false if user cancelled or failed*/- const handleUnauthorized = useCallback(async (): Promise<boolean> => {- console.info('[MarketAuth] Handling unauthorized error, attempting recovery...');-- // First try to refresh the token- const refreshed = await refreshToken();- if (refreshed) {- console.info('[MarketAuth] Token refresh successful, recovered from 401');- return true;- }-- // Refresh failed, need to re-authenticate- console.info('[MarketAuth] Token refresh failed, triggering signIn...');- try {- const accountId = await signIn();- if (accountId !== null) {- console.info('[MarketAuth] Re-authentication successful');+ const handleUnauthorized = useCallback(+ async (scene: MarketAuthScene = 'default'): Promise<boolean> => {+ console.info('[MarketAuth] Handling unauthorized error, attempting recovery...');++ // First try to refresh the token+ const refreshed = await refreshToken();+ if (refreshed) {+ console.info('[MarketAuth] Token refresh successful, recovered from 401');return true;}- return false;- } catch (error) {- console.error('[MarketAuth] Re-authentication failed:', error);- return false;- }- }, [refreshToken, signIn]);++ // Refresh failed, need to re-authenticate+ console.info('[MarketAuth] Token refresh failed, triggering signIn...');+ try {+ const accountId = await signIn(scene);+ if (accountId !== null) {+ console.info('[MarketAuth] Re-authentication successful');+ return true;+ }+ return false;+ } catch (error) {+ console.error('[MarketAuth] Re-authentication failed:', error);+ return false;+ }+ },+ [refreshToken, signIn],+ );/*** Restore session and fetch user info on initialization@@ -713,11 +719,11 @@ export const MarketAuthProvider = ({ children, isDesktop }: MarketAuthProviderPrif (!refreshed) {// Silent refresh failed — the Market OAuth token is genuinely expired.// Show the Market auth modal so the user can re-authorize.- await handleUnauthorized();+ await handleUnauthorized(event.scene);}return;}- await handleUnauthorized();+ await handleUnauthorized(event.scene);});return unsubscribe;@@ -779,6 +785,7 @@ export const MarketAuthProvider = ({ children, isDesktop }: MarketAuthProviderPr{children}<MarketAuthConfirmModalopen={showConfirmModal}+ scene={authScene}onCancel={handleCancelAuth}onConfirm={handleConfirmAuth}/>diff --git a/src/layout/AuthProvider/MarketAuth/events.ts b/src/layout/AuthProvider/MarketAuth/events.tsindex 4b68aad2556..021d19b11f1 100644--- a/src/layout/AuthProvider/MarketAuth/events.ts+++ b/src/layout/AuthProvider/MarketAuth/events.ts@@ -5,10 +5,13 @@* Market API 401 errors across the application.*/+import type { MarketAuthScene } from './scenes';+export type MarketAuthEventType = 'market-unauthorized';export interface MarketUnauthorizedEvent {path: string;+ scene: MarketAuthScene;timestamp: number;}diff --git a/src/layout/AuthProvider/MarketAuth/index.ts b/src/layout/AuthProvider/MarketAuth/index.tsindex d49cba99ddb..28c961b3cf0 100644--- a/src/layout/AuthProvider/MarketAuth/index.ts+++ b/src/layout/AuthProvider/MarketAuth/index.ts@@ -1,4 +1,5 @@export { MarketAuthProvider, useMarketAuth } from './MarketAuthProvider';+export type { MarketAuthScene } from './scenes';export type {MarketAuthContextType,MarketAuthSession,diff --git a/src/layout/AuthProvider/MarketAuth/scenes.test.ts b/src/layout/AuthProvider/MarketAuth/scenes.test.tsnew file mode 100644index 00000000000..2c00f343c8c--- /dev/null+++ b/src/layout/AuthProvider/MarketAuth/scenes.test.ts@@ -0,0 +1,24 @@+import { describe, expect, it } from 'vitest';++import { pathToMarketAuthScene } from './scenes';++describe('pathToMarketAuthScene', () => {+ it('maps sandbox execution paths to the sandbox scene', () => {+ expect(pathToMarketAuthScene('market.execInSandbox')).toBe('sandbox');+ });++ it('maps Cloud MCP paths to the mcp scene', () => {+ expect(pathToMarketAuthScene('market.callCloudMcpEndpoint')).toBe('mcp');+ expect(pathToMarketAuthScene('market.installCloudMcp')).toBe('mcp');+ });++ it('maps publish/submit paths to the publish scene', () => {+ expect(pathToMarketAuthScene('market.publishAgent')).toBe('publish');+ expect(pathToMarketAuthScene('market.submitVersion')).toBe('publish');+ });++ it('falls back to the default scene for unknown paths', () => {+ expect(pathToMarketAuthScene('market.followUser')).toBe('default');+ expect(pathToMarketAuthScene('market.getUserProfile')).toBe('default');+ });+});diff --git a/src/layout/AuthProvider/MarketAuth/scenes.ts b/src/layout/AuthProvider/MarketAuth/scenes.tsnew file mode 100644index 00000000000..d293ca1d1d7--- /dev/null+++ b/src/layout/AuthProvider/MarketAuth/scenes.ts@@ -0,0 +1,21 @@+/**+ * Market Auth Scenes+ *+ * The Market auth modal can be triggered from different capabilities (running a+ * tool in the sandbox, installing a Cloud MCP skill, publishing to the+ * community, ...). The `scene` lets the modal show capability-specific copy+ * while falling back to the generic community-profile copy when unknown.+ */++export type MarketAuthScene = 'default' | 'sandbox' | 'mcp' | 'publish';++/**+ * Infer the scene from a tRPC procedure path (e.g. `market.execInSandbox`).+ * Used by the 401 error link where only the request path is available.+ */+export const pathToMarketAuthScene = (path: string): MarketAuthScene => {+ if (path.includes('execInSandbox')) return 'sandbox';+ if (path.includes('CloudMcp') || path.includes('callCloudMcpEndpoint')) return 'mcp';+ if (path.includes('publish') || path.includes('submit')) return 'publish';+ return 'default';+};diff --git a/src/layout/AuthProvider/MarketAuth/types.ts b/src/layout/AuthProvider/MarketAuth/types.tsindex 36cec2ffca7..853d93392c6 100644--- a/src/layout/AuthProvider/MarketAuth/types.ts+++ b/src/layout/AuthProvider/MarketAuth/types.ts@@ -1,3 +1,5 @@+import type { MarketAuthScene } from './scenes';+export interface MarketUserInfo {accountId: number;clientId: string;@@ -69,12 +71,17 @@ export interface MarketAuthContextType extends MarketAuthState {/*** Handle unauthorized (401) error from Market API* Attempts to refresh token first, then triggers signIn if refresh fails+ * @param scene - capability that triggered the auth, controls the modal copy* @returns true if successfully re-authenticated, false if user cancelled or failed*/- handleUnauthorized: () => Promise<boolean>;+ handleUnauthorized: (scene?: MarketAuthScene) => Promise<boolean>;openProfileSetup: (onSuccess?: (profile: MarketUserProfile) => void) => void;refreshToken: () => Promise<boolean>;- signIn: () => Promise<number | null>;+ /**+ * Sign in to the Market.+ * @param scene - capability that triggered the auth, controls the modal copy+ */+ signIn: (scene?: MarketAuthScene) => Promise<number | null>;signOut: () => Promise<void>;}diff --git a/src/libs/trpc/client/lambda.ts b/src/libs/trpc/client/lambda.tsindex dac103edd73..3bfaee9aac1 100644--- a/src/libs/trpc/client/lambda.ts+++ b/src/libs/trpc/client/lambda.ts@@ -53,8 +53,11 @@ const errorHandlingLink: TRPCLink<LambdaRouter> = () => {// Dynamically import to avoid circular dependenciesconst { marketAuthEvents } =await import('@/layout/AuthProvider/MarketAuth/events');+ const { pathToMarketAuthScene } =+ await import('@/layout/AuthProvider/MarketAuth/scenes');marketAuthEvents.emit('market-unauthorized', {path: op.path,+ scene: pathToMarketAuthScene(op.path),timestamp: now,});}diff --git a/src/libs/trpc/client/tools.ts b/src/libs/trpc/client/tools.tsindex f0b879311cb..8c0121a3424 100644--- a/src/libs/trpc/client/tools.ts+++ b/src/libs/trpc/client/tools.ts@@ -40,8 +40,11 @@ const errorHandlingLink: TRPCLink<ToolsRouter> = () => {// Emit event for MarketAuthProvider to handleconst { marketAuthEvents } =await import('@/layout/AuthProvider/MarketAuth/events');+ const { pathToMarketAuthScene } =+ await import('@/layout/AuthProvider/MarketAuth/scenes');marketAuthEvents.emit('market-unauthorized', {path: op.path,+ scene: pathToMarketAuthScene(op.path),timestamp: now,});}diff --git a/src/locales/default/marketAuth.ts b/src/locales/default/marketAuth.tsindex 1e93ffa55b1..4e0af527d26 100644--- a/src/locales/default/marketAuth.ts+++ b/src/locales/default/marketAuth.ts@@ -6,6 +6,15 @@ export default {'By continuing, you confirm that you have read and agree to the <terms>Terms and Conditions</terms> and <privacy>Privacy Policy</privacy>.','authorize.footer.privacy': 'Privacy Policy','authorize.footer.terms': 'Terms of Service',+ 'authorize.scenes.mcp.subtitle':+ 'Create a community profile to install and run this skill from the community.',+ 'authorize.scenes.mcp.title': 'Install Community Skill',+ 'authorize.scenes.publish.subtitle':+ 'Create a community profile to publish and manage your listing within the community.',+ 'authorize.scenes.publish.title': 'Publish to the Community',+ 'authorize.scenes.sandbox.subtitle':+ 'Create a community profile to run this tool in the community sandbox.',+ 'authorize.scenes.sandbox.title': 'Try the Community Sandbox','authorize.subtitle':'Create a community profile to submit and manage listings within the community.','authorize.title': 'Create Community Profile',diff --git a/src/routes/(main)/agent/features/Conversation/AgentWelcome/ToolAuthAlert.tsx b/src/routes/(main)/agent/features/Conversation/AgentWelcome/ToolAuthAlert.tsxindex bfc90910ec6..509b69b611d 100644--- a/src/routes/(main)/agent/features/Conversation/AgentWelcome/ToolAuthAlert.tsx+++ b/src/routes/(main)/agent/features/Conversation/AgentWelcome/ToolAuthAlert.tsx@@ -239,7 +239,7 @@ const MarketToolAuthItem = memo<MarketToolAuthItemProps>(({ tool }) => {const handleSignIn = async () => {try {- await signIn();+ await signIn('sandbox');} catch (error) {console.error('[ToolAuthAlert] Market sign in failed:', error);}diff --git a/src/routes/(main)/agent/profile/features/Header/AgentPublishButton/PublishButton.tsx b/src/routes/(main)/agent/profile/features/Header/AgentPublishButton/PublishButton.tsxindex 544144d57a8..9bd3879fc87 100644--- a/src/routes/(main)/agent/profile/features/Header/AgentPublishButton/PublishButton.tsx+++ b/src/routes/(main)/agent/profile/features/Header/AgentPublishButton/PublishButton.tsx@@ -107,7 +107,7 @@ const PublishButton = memo<MarketPublishButtonProps>(({ action, onPublishSuccessif (!isAuthenticated) {try {- await signIn();+ await signIn('publish');// After authentication, proceed with ownership check and publishawait doPublish();} catch (error) {diff --git a/src/routes/(main)/agent/profile/features/Header/index.tsx b/src/routes/(main)/agent/profile/features/Header/index.tsxindex 000419f664c..8896f69916e 100644--- a/src/routes/(main)/agent/profile/features/Header/index.tsx+++ b/src/routes/(main)/agent/profile/features/Header/index.tsx@@ -160,7 +160,7 @@ const Header = memo(() => {onOk: async () => {if (!isAuthenticated) {try {- await signIn();+ await signIn('publish');await doPublish();} catch (error) {console.error(`[MarketPublishButton][${action}] Authorization failed:`, error);diff --git a/src/routes/(main)/community/(detail)/mcp/features/Sidebar/ActionButton/index.tsx b/src/routes/(main)/community/(detail)/mcp/features/Sidebar/ActionButton/index.tsxindex 29ceeac2a9e..b0a5e8733e5 100644--- a/src/routes/(main)/community/(detail)/mcp/features/Sidebar/ActionButton/index.tsx+++ b/src/routes/(main)/community/(detail)/mcp/features/Sidebar/ActionButton/index.tsx@@ -42,7 +42,7 @@ const ActionButton = memo(() => {// If this is a cloud MCP and user is not authenticated, request authorization firstif (isCloudMcp && !isAuthenticated) {try {- await signIn();+ await signIn('mcp');} catch {return; // Don't proceed with installation if auth fails}diff --git a/src/routes/(main)/group/profile/features/Header/AgentPublishButton/PublishButton.tsx b/src/routes/(main)/group/profile/features/Header/AgentPublishButton/PublishButton.tsxindex a09e7f99a8c..d8f1e24bc7a 100644--- a/src/routes/(main)/group/profile/features/Header/AgentPublishButton/PublishButton.tsx+++ b/src/routes/(main)/group/profile/features/Header/AgentPublishButton/PublishButton.tsx@@ -56,7 +56,7 @@ const PublishButton = memo<MarketPublishButtonProps>(content: t('messages.loading', { ns: 'marketAuth' }),key: 'market-auth',});- const accountId = await signIn();+ const accountId = await signIn('publish');message.success({ content: buttonConfig.authSuccessMessage, key: 'market-auth' });// Check ownership after authentication if marketIdentifier existsdiff --git a/src/routes/(main)/group/profile/features/Header/GroupPublishButton/PublishButton.tsx b/src/routes/(main)/group/profile/features/Header/GroupPublishButton/PublishButton.tsxindex 1f157116655..6afa36063fd 100644--- a/src/routes/(main)/group/profile/features/Header/GroupPublishButton/PublishButton.tsx+++ b/src/routes/(main)/group/profile/features/Header/GroupPublishButton/PublishButton.tsx@@ -107,7 +107,7 @@ const PublishButton = memo<GroupPublishButtonProps>(({ action, onPublishSuccessif (!isAuthenticated) {try {- await signIn();+ await signIn('publish');// After authentication, proceed with ownership check and publishawait doPublish();} catch (error) {