🤯 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
💄 style: compact the OAuth provider card and add credit reset copy (#17736)
René Wang871d9e2cb295
diff --git a/locales/en-US/modelProvider.json b/locales/en-US/modelProvider.jsonindex 8e481bbf6a4..3bbd77d2266 100644--- a/locales/en-US/modelProvider.json+++ b/locales/en-US/modelProvider.json@@ -190,7 +190,7 @@"providerModels.config.oauth.authorizedDesc": "You have connected to {{name}}. Click to disconnect.","providerModels.config.oauth.cancel": "Cancel","providerModels.config.oauth.codeExpired": "Authorization code has expired. Please try again.",- "providerModels.config.oauth.connect": "Connect with {{name}}",+ "providerModels.config.oauth.connect": "Connect","providerModels.config.oauth.connectDesc": "Click to authorize via browser. No API key required.","providerModels.config.oauth.connected": "Connected","providerModels.config.oauth.connecting": "Connecting...",@@ -199,11 +199,9 @@"providerModels.config.oauth.desc": "Authorize with your {{name}} account to access models through your subscription.","providerModels.config.oauth.disconnect": "Disconnect","providerModels.config.oauth.disconnectConfirm": "Are you sure you want to disconnect? You will need to re-authorize to use this provider.",- "providerModels.config.oauth.enterCode": "Enter the code on the opened page:",- "providerModels.config.oauth.openBrowser": "Open browser to authorize",+ "providerModels.config.oauth.enterCode": "Enter the code below on the authorization page. If it did not open automatically, go to:","providerModels.config.oauth.polling": "Waiting for authorization...","providerModels.config.oauth.retry": "Retry",- "providerModels.config.oauth.serviceNote": "Service provided by {{name}}","providerModels.config.oauth.title": "OAuth Authorization","providerModels.config.responsesApi.desc": "Uses OpenAI's next-generation request format specification to unlock advanced features like chain-of-thought (supported by OpenAI models only)","providerModels.config.responsesApi.title": "Use Responses API Specification",@@ -335,7 +333,6 @@"providerModels.list.search": "Search Models...","providerModels.list.searchResult": "{{count}} models found","providerModels.list.title": "Model List",- "providerModels.list.total": "{{count}} models available","providerModels.searchNotFound": "No search results found","providerModels.tabs.all": "All","providerModels.tabs.asr": "ASR",diff --git a/locales/en-US/subscription.json b/locales/en-US/subscription.jsonindex 6d4bce200b3..6f370df8a5d 100644--- a/locales/en-US/subscription.json+++ b/locales/en-US/subscription.json@@ -589,6 +589,11 @@"usage.overview.included": "Plan Usage","usage.overview.onDemand": "On-demand","usage.overview.product": "Product Item",+ "usage.overview.resetsInHours_one": "Resets in {{count}} hour",+ "usage.overview.resetsInHours_other": "Resets in {{count}} hours",+ "usage.overview.resetsIn_one": "Resets in {{count}} day",+ "usage.overview.resetsIn_other": "Resets in {{count}} days",+ "usage.overview.resetsToday": "Resets today","usage.overview.title": "Overview","usage.remaining": "Remaining","usage.storage.embeddings.used": "Vector Storage",diff --git a/locales/zh-CN/modelProvider.json b/locales/zh-CN/modelProvider.jsonindex 292a0bfcebb..41dd6fb309c 100644--- a/locales/zh-CN/modelProvider.json+++ b/locales/zh-CN/modelProvider.json@@ -190,7 +190,7 @@"providerModels.config.oauth.authorizedDesc": "你已连接到 {{name}}。点击断开连接。","providerModels.config.oauth.cancel": "取消","providerModels.config.oauth.codeExpired": "授权码已过期,请重试。",- "providerModels.config.oauth.connect": "连接 {{name}}",+ "providerModels.config.oauth.connect": "连接","providerModels.config.oauth.connectDesc": "点击通过浏览器授权,无需 API Key。","providerModels.config.oauth.connected": "已连接","providerModels.config.oauth.connecting": "连接中...",@@ -199,11 +199,9 @@"providerModels.config.oauth.desc": "通过你的 {{name}} 账号授权,使用你的订阅访问模型。","providerModels.config.oauth.disconnect": "断开连接","providerModels.config.oauth.disconnectConfirm": "确定要断开连接吗?你需要重新授权才能使用此服务商。",- "providerModels.config.oauth.enterCode": "请在打开的页面中输入以下验证码:",- "providerModels.config.oauth.openBrowser": "打开浏览器授权",+ "providerModels.config.oauth.enterCode": "请在授权页面输入下面的验证码。如果页面没有自动打开,请访问:","providerModels.config.oauth.polling": "等待授权中...","providerModels.config.oauth.retry": "重试",- "providerModels.config.oauth.serviceNote": "服务由 {{name}} 提供","providerModels.config.oauth.title": "OAuth 授权","providerModels.config.responsesApi.desc": "采用 OpenAI 新一代请求格式规范,解锁思维链等进阶特性 (仅 OpenAI 模型支持)","providerModels.config.responsesApi.title": "使用 Responses API 规范",@@ -335,7 +333,6 @@"providerModels.list.search": "搜索模型…","providerModels.list.searchResult": "搜索到 {{count}} 个模型","providerModels.list.title": "模型列表",- "providerModels.list.total": "共 {{count}} 个模型可用","providerModels.searchNotFound": "未找到搜索结果","providerModels.tabs.all": "全部","providerModels.tabs.asr": "ASR",diff --git a/locales/zh-CN/subscription.json b/locales/zh-CN/subscription.jsonindex f6982cf5d45..70840f10575 100644--- a/locales/zh-CN/subscription.json+++ b/locales/zh-CN/subscription.json@@ -589,6 +589,11 @@"usage.overview.included": "计划内使用","usage.overview.onDemand": "按需使用","usage.overview.product": "产品项目",+ "usage.overview.resetsInHours_one": "{{count}} 小时后重置",+ "usage.overview.resetsInHours_other": "{{count}} 小时后重置",+ "usage.overview.resetsIn_one": "{{count}} 天后重置",+ "usage.overview.resetsIn_other": "{{count}} 天后重置",+ "usage.overview.resetsToday": "今天重置","usage.overview.title": "总览","usage.remaining": "剩余","usage.storage.embeddings.used": "向量存储",diff --git a/packages/locales/src/default/modelProvider.ts b/packages/locales/src/default/modelProvider.tsindex 9440625988a..b7246132bbd 100644--- a/packages/locales/src/default/modelProvider.ts+++ b/packages/locales/src/default/modelProvider.ts@@ -212,7 +212,7 @@ export default {'You have connected to {{name}}. Click to disconnect.','providerModels.config.oauth.cancel': 'Cancel','providerModels.config.oauth.codeExpired': 'Authorization code has expired. Please try again.',- 'providerModels.config.oauth.connect': 'Connect with {{name}}',+ 'providerModels.config.oauth.connect': 'Connect','providerModels.config.oauth.connectDesc': 'Click to authorize via browser. No API key required.','providerModels.config.oauth.connected': 'Connected','providerModels.config.oauth.connecting': 'Connecting...',@@ -223,11 +223,10 @@ export default {'providerModels.config.oauth.disconnect': 'Disconnect','providerModels.config.oauth.disconnectConfirm':'Are you sure you want to disconnect? You will need to re-authorize to use this provider.',- 'providerModels.config.oauth.enterCode': 'Enter the code on the opened page:',- 'providerModels.config.oauth.openBrowser': 'Open browser to authorize',+ 'providerModels.config.oauth.enterCode':+ 'Enter the code below on the authorization page. If it did not open automatically, go to:','providerModels.config.oauth.polling': 'Waiting for authorization...','providerModels.config.oauth.retry': 'Retry',- 'providerModels.config.oauth.serviceNote': 'Service provided by {{name}}','providerModels.config.oauth.title': 'OAuth Authorization','providerModels.config.responsesApi.desc':"Uses OpenAI's next-generation request format specification to unlock advanced features like chain-of-thought (supported by OpenAI models only)",@@ -421,7 +420,6 @@ export default {'providerModels.list.search': 'Search Models...','providerModels.list.searchResult': '{{count}} models found','providerModels.list.title': 'Model List',- 'providerModels.list.total': '{{count}} models available','providerModels.searchNotFound': 'No search results found','providerModels.tabs.all': 'All','providerModels.tabs.asr': 'ASR',diff --git a/packages/locales/src/default/subscription.ts b/packages/locales/src/default/subscription.tsindex 677bdd9448e..657c32d8429 100644--- a/packages/locales/src/default/subscription.ts+++ b/packages/locales/src/default/subscription.ts@@ -693,6 +693,11 @@ export default {'usage.overview.onDemand': 'On-demand','usage.overview.product': 'Product Item','usage.overview.currentPlan': 'You are on {{plan}} plan',+ 'usage.overview.resetsIn_one': 'Resets in {{count}} day',+ 'usage.overview.resetsIn_other': 'Resets in {{count}} days',+ 'usage.overview.resetsInHours_one': 'Resets in {{count}} hour',+ 'usage.overview.resetsInHours_other': 'Resets in {{count}} hours',+ 'usage.overview.resetsToday': 'Resets today','usage.overview.title': 'Overview','usage.storage.embeddings.used': 'Vector Storage','usage.storage.file.used': 'File Usage',diff --git a/src/routes/(main)/settings/provider/(list)/ProviderGrid/Card.tsx b/src/routes/(main)/settings/provider/(list)/ProviderGrid/Card.tsxindex 168dcb992b6..7472a1bc256 100644--- a/src/routes/(main)/settings/provider/(list)/ProviderGrid/Card.tsx+++ b/src/routes/(main)/settings/provider/(list)/ProviderGrid/Card.tsx@@ -15,6 +15,14 @@ import { styles } from './style';const isCodingPlanProvider = (id: string) => id.endsWith('codingplan');+/**+ * ChatGPT is an OpenAI subscription, so its icon config points at the OpenAI+ * mark — ProviderCombine renders the OpenAI wordmark and the card reads as a+ * duplicate of the OpenAI one right beside it. Name these providers after the+ * plan instead, the way the detail page header does.+ */+const sharesVendorMark = (id: string) => id === 'chatgpt';+interface ProviderCardProps extends AiProviderListItem {loading?: boolean;onProviderSelect: (provider: string) => void;@@ -52,12 +60,24 @@ const ProviderCard = memo<ProviderCardProps>(<Flexbox horizontal align={'center'} justify={'space-between'}>{source === 'builtin' ? (<Flexbox horizontal align={'center'} gap={8}>- <ProviderCombine- provider={id}- size={24}- style={{ color: cssVar.colorText }}- title={name}- />+ {sharesVendorMark(id) ? (+ <Flexbox horizontal align={'center'} gap={12}>+ <ProviderIcon+ provider={id}+ size={24}+ style={{ borderRadius: 6 }}+ type={'avatar'}+ />+ <Text style={{ fontSize: 16, fontWeight: 'bold' }}>{name || id}</Text>+ </Flexbox>+ ) : (+ <ProviderCombine+ provider={id}+ size={24}+ style={{ color: cssVar.colorText }}+ title={name}+ />+ )}{isCodingPlanProvider(id) && <Tag color={'geekblue'}>{'Coding Plan'}</Tag>}</Flexbox>) : (diff --git a/src/routes/(main)/settings/provider/_layout/Desktop/Container.tsx b/src/routes/(main)/settings/provider/_layout/Desktop/Container.tsxindex 136600386be..c8aa4aecde3 100644--- a/src/routes/(main)/settings/provider/_layout/Desktop/Container.tsx+++ b/src/routes/(main)/settings/provider/_layout/Desktop/Container.tsx@@ -1,18 +1,32 @@'use client';import { Flexbox } from '@lobehub/ui';-import { type FC, type PropsWithChildren } from 'react';+import { type FC, type PropsWithChildren, useLayoutEffect, useRef } from 'react';+import { useLocation } from 'react-router';import NavHeader from '@/features/NavHeader';import SettingContainer from '@/features/Setting/SettingContainer';const Container: FC<PropsWithChildren> = ({ children }) => {+ // This layout outlives a provider switch, so its scroll box keeps whatever+ // offset the previous provider was left at and the next one opens partway+ // down the page. Keyed on pathname rather than the route param: `:providerId`+ // is matched by the child route, so it is not visible from this layout.+ const { pathname } = useLocation();+ const scrollRef = useRef<HTMLElement>(null);++ // Before paint, so switching providers never flashes the old offset.+ useLayoutEffect(() => {+ if (scrollRef.current) scrollRef.current.scrollTop = 0;+ }, [pathname]);+return (<Flexbox height={'100%'} width={'100%'}><NavHeader /><SettingContainermaxWidth={1024}padding={24}+ ref={scrollRef}style={{minHeight: '100%',}}diff --git a/src/routes/(main)/settings/provider/detail/default/CustomProviderDetail.tsx b/src/routes/(main)/settings/provider/detail/default/CustomProviderDetail.tsxindex ce1c1427296..9149dc42407 100644--- a/src/routes/(main)/settings/provider/detail/default/CustomProviderDetail.tsx+++ b/src/routes/(main)/settings/provider/detail/default/CustomProviderDetail.tsx@@ -23,7 +23,8 @@ const CustomProviderDetail = memo<{ id: string }>(({ id }) => {if (isLoading || !data || !data.id) return <Loading debugId="Provider > CustomProviderDetail" />;return (- <Flexbox gap={24} paddingBlock={8}>+ // No block padding of its own — SettingContainer already insets the page.+ <Flexbox gap={24}><ProviderConfig {...data} id={id} name={data.name || ''} /><ModelList id={id} /></Flexbox>diff --git a/src/routes/(main)/settings/provider/detail/default/index.tsx b/src/routes/(main)/settings/provider/detail/default/index.tsxindex e0cc14ce6fb..7706d5afe3c 100644--- a/src/routes/(main)/settings/provider/detail/default/index.tsx+++ b/src/routes/(main)/settings/provider/detail/default/index.tsx@@ -22,7 +22,8 @@ const ProviderDetail = memo<ProviderDetailProps>(({ showConfig = true, ...card }useFetchAiProviderItem(card.id);return (- <Flexbox gap={24} paddingBlock={8}>+ // No block padding of its own — SettingContainer already insets the page.+ <Flexbox gap={24}>{showConfig && <ProviderConfig {...card} />}<ModelList id={card.id} {...card.settings} /></Flexbox>diff --git a/src/routes/(main)/settings/provider/features/ModelList/ModelTitle/index.tsx b/src/routes/(main)/settings/provider/features/ModelList/ModelTitle/index.tsxindex 54ed66ba776..db7fe78ba4a 100644--- a/src/routes/(main)/settings/provider/features/ModelList/ModelTitle/index.tsx+++ b/src/routes/(main)/settings/provider/features/ModelList/ModelTitle/index.tsx@@ -28,7 +28,6 @@ const ModelTitle = memo<ModelFetcherProps>(const { allowed: canManageProvider, reason } = usePermission('manage_provider_key');const [searchKeyword,- totalModels,isEmpty,hasRemoteModels,fetchRemoteModelList,@@ -37,7 +36,6 @@ const ModelTitle = memo<ModelFetcherProps>(useFetchAiProviderModels,] = useAiInfraStore((s) => [s.modelSearchKeyword,- aiModelSelectors.totalAiProviderModelList(s),aiModelSelectors.isEmptyAiProviderModelList(s),aiModelSelectors.hasRemoteModels(s),s.fetchRemoteModelList,@@ -77,29 +75,22 @@ const ModelTitle = memo<ModelFetcherProps>({t('providerModels.list.title')}</Text>- {isLoading ? (- <Skeleton.Button active style={{ height: 22 }} />- ) : (- <Text style={{ fontSize: 12 }} type={'secondary'}>- <div style={{ display: 'flex', lineHeight: '24px' }}>- {t('providerModels.list.total', { count: totalModels })}- {hasRemoteModels && (- <ActionIcon- disabled={!canManageProvider}- icon={CircleX}- loading={clearRemoteModelsLoading}- size={'small'}- title={canManageProvider ? t('providerModels.list.fetcher.clear') : undefined}- onClick={async () => {- if (!canManageProvider) return;- setClearRemoteModelsLoading(true);- await clearObtainedModels(provider);- setClearRemoteModelsLoading(false);- }}- />- )}- </div>- </Text>+ {/* Only meaningful once the list has loaded, so it waits rather+ than holding a skeleton next to the title. */}+ {!isLoading && hasRemoteModels && (+ <ActionIcon+ disabled={!canManageProvider}+ icon={CircleX}+ loading={clearRemoteModelsLoading}+ size={'small'}+ title={canManageProvider ? t('providerModels.list.fetcher.clear') : undefined}+ onClick={async () => {+ if (!canManageProvider) return;+ setClearRemoteModelsLoading(true);+ await clearObtainedModels(provider);+ setClearRemoteModelsLoading(false);+ }}+ />)}</Flexbox>{isLoading ? (diff --git a/src/routes/(main)/settings/provider/features/ProviderConfig/OAuthDeviceFlowAuth/index.tsx b/src/routes/(main)/settings/provider/features/ProviderConfig/OAuthDeviceFlowAuth/index.tsxindex 32a39729c08..f9a063e3c60 100644--- a/src/routes/(main)/settings/provider/features/ProviderConfig/OAuthDeviceFlowAuth/index.tsx+++ b/src/routes/(main)/settings/provider/features/ProviderConfig/OAuthDeviceFlowAuth/index.tsx@@ -1,14 +1,14 @@'use client';import { CheckCircleFilled } from '@ant-design/icons';-import { ProviderIcon } from '@lobehub/icons';-import { CopyButton, Flexbox, Icon } from '@lobehub/ui';-import { Button, confirmModal } from '@lobehub/ui/base-ui';-import { Avatar, Typography } from 'antd';+import { MAX_WIDTH } from '@lobechat/const';+import { Avatar, CopyButton, Flexbox, Icon } from '@lobehub/ui';+import { Button, confirmModal, Modal } from '@lobehub/ui/base-ui';+import { Typography } from 'antd';import { createStaticStyles, cssVar } from 'antd-style';-import { ExternalLinkIcon, Loader2Icon, LogOutIcon, UnplugIcon } from 'lucide-react';+import { Loader2Icon, LogOutIcon, UnplugIcon } from 'lucide-react';import { type ReactNode } from 'react';-import { memo, useCallback, useEffect, useRef, useState } from 'react';+import { memo, useCallback, useState } from 'react';import { useTranslation } from 'react-i18next';import { usePermission } from '@/hooks/usePermission';@@ -22,8 +22,9 @@ const styles = createStaticStyles(({ css, cssVar }) => ({card: css`overflow: hidden;+ /* matches the borderless form below so both boxes end on the same edge */width: 100%;- margin-block-end: 24px;+ max-width: ${MAX_WIDTH}px;border: 1px solid ${cssVar.colorBorderSecondary};border-radius: 12px;`,@@ -47,34 +48,32 @@ const styles = createStaticStyles(({ css, cssVar }) => ({content: css`display: flex;flex-direction: column;- gap: 20px;+ gap: 16px;align-items: center;- margin-block: 0 40px;- padding-inline: 48px;+ padding-block: 8px 4px;`,errorText: css`color: ${cssVar.colorError};`,header: css`display: flex;+ gap: 12px;align-items: center;justify-content: space-between;- padding-block: 16px;- padding-inline: 24px;- border-block-end: 1px solid ${cssVar.colorBorderSecondary};+ padding-block: 12px;+ padding-inline: 16px;`,- hero: css`- display: flex;- flex-direction: column;- gap: 16px;- align-items: center;- justify-content: center;+ // Prose, so it reads from the left edge rather than being centred with the+ // code box below it.+ hint: css`+ width: 100%;- padding-block: 48px 32px;- padding-inline: 24px;- border-radius: 16px 16px 0 0;+ font-size: 13px;+ line-height: 1.6;+ color: ${cssVar.colorTextSecondary};+ text-align: start;`,pollingHint: css`display: flex;@@ -91,11 +90,6 @@ const styles = createStaticStyles(({ css, cssVar }) => ({background: ${cssVar.colorFillQuaternary};`,- serviceNote: css`- font-size: 13px;- color: ${cssVar.colorTextDescription};- text-align: center;- `,successBadge: css`display: flex;gap: 6px;@@ -104,37 +98,29 @@ const styles = createStaticStyles(({ css, cssVar }) => ({font-size: 13px;color: ${cssVar.colorSuccess};`,- userAvatar: css`- border: 2px solid ${cssVar.colorBorderSecondary};- box-shadow: 0 4px 12px ${cssVar.colorFillSecondary};- `,- userInfo: css`- display: flex;- flex-direction: column;- gap: 6px;- align-items: center;- `,username: css`- font-size: 16px;- font-weight: 600;- color: ${cssVar.colorText};+ font-size: 13px;+ color: ${cssVar.colorTextSecondary};`,}));export interface OAuthDeviceFlowAuthProps {+ /**+ * Whether the provider is switched on. The connect action only shows up once+ * the provider is enabled, so the row stays a single toggle until then.+ */+ enabled?: boolean;extra?: ReactNode;- name: string;onAuthChange?: () => void;providerId: string;title?: ReactNode;}const OAuthDeviceFlowAuth = memo<OAuthDeviceFlowAuthProps>(- ({ providerId, name, onAuthChange, title, extra }) => {+ ({ providerId, onAuthChange, title, extra, enabled }) => {const { t } = useTranslation('modelProvider');const { allowed: canManageProvider } = usePermission('manage_provider_key');const [isAuthenticating, setIsAuthenticating] = useState(false);- const hasAutoClosedRef = useRef(false);const utils = lambdaQuery.useUtils();@@ -182,8 +168,10 @@ const OAuthDeviceFlowAuth = memo<OAuthDeviceFlowAuthProps>(const handleStartAuth = useCallback(async () => {if (!canManageProvider) return;+ // Retry re-enters from the dialog's error state, where isAuthenticating+ // is still true — so only a genuinely in-flight attempt blocks a restart.+ if (isAuthenticating && state !== 'error') return;- hasAutoClosedRef.current = false;setIsAuthenticating(true);const info = await startAuth();@@ -192,202 +180,146 @@ const OAuthDeviceFlowAuth = memo<OAuthDeviceFlowAuthProps>(// it. The manual "open browser" button stays as a fallback when blocked.const uri = info?.verificationUriComplete || info?.verificationUri;if (uri) window.open(uri, '_blank');- }, [canManageProvider, startAuth]);+ }, [canManageProvider, isAuthenticating, startAuth, state]);const handleCancelAuth = useCallback(() => {setIsAuthenticating(false);cancelAuth();}, [cancelAuth]);- const handleOpenBrowser = useCallback(() => {- // Prefer the code-prefilled URI so the user doesn't need to type the code- const uri = deviceCodeInfo?.verificationUriComplete || deviceCodeInfo?.verificationUri;- if (uri) {- window.open(uri, '_blank');- }- }, [deviceCodeInfo?.verificationUri, deviceCodeInfo?.verificationUriComplete]);+ // The inline action that trails the enable switch in the header row. The+ // device-code flow runs in a dialog, so the button stays put and spins+ // rather than being swapped out while pairing is in flight.+ const renderAction = () => {+ if (!enabled) return null;- // Reset hasAutoClosedRef when starting new auth- useEffect(() => {- if (state === 'success' && !hasAutoClosedRef.current) {- hasAutoClosedRef.current = true;- }- }, [state]);-- // Render Hero section with provider logo- const renderHero = () => (- <div className={styles.hero}>- <ProviderIcon provider={providerId} size={72} type={'avatar'} />- </div>- );-- // Render content based on authentication state- const renderContent = () => {- // Authenticated state - show user info- // Show when authenticated and not in the middle of authenticating process- if (isAuthenticated && !isAuthenticating) {+ if (isAuthenticated)return (- <div className={styles.content}>- <Flexbox align="center" gap={16}>- {avatarUrl && <Avatar className={styles.userAvatar} size={56} src={avatarUrl} />}- <div className={styles.userInfo}>- {username && <span className={styles.username}>{username}</span>}- <div className={styles.successBadge}>- <CheckCircleFilled />- <span>{t('providerModels.config.oauth.connected')}</span>- </div>- </div>- </Flexbox>+ <>+ {username && (+ <Flexbox horizontal align={'center'} gap={6}>+ {avatarUrl && <Avatar avatar={avatarUrl} size={20} title={username} />}+ <span className={styles.username}>{username}</span>+ </Flexbox>+ )}<Buttondisabled={!canManageProvider}- icon={<Icon icon={LogOutIcon} />}+ icon={LogOutIcon}loading={revokeAuth.isPending}+ size={'small'}onClick={handleDisconnect}>{t('providerModels.config.oauth.disconnect')}</Button>- <div className={styles.serviceNote}>- {t('providerModels.config.oauth.serviceNote', { name })}- </div>- </div>+ </>);- }- // Authenticating state - show device code- if (isAuthenticating) {- // Loading state- if (state === 'requesting' || !deviceCodeInfo) {- return (- <div className={styles.content}>- <Icon spin icon={Loader2Icon} size={24} />- <Text type="secondary">{t('providerModels.config.oauth.connecting')}</Text>- </div>- );- }-- // Error state- if (state === 'error' && error) {- const errorKey = `providerModels.config.oauth.${error}`;- return (- <div className={styles.content}>- <Flexbox horizontal align="center" gap={8}>- <Icon color={cssVar.colorError} icon={UnplugIcon} size={20} />- <Text className={styles.errorText}>{t(errorKey as any)}</Text>- </Flexbox>- <Flexbox gap={12} style={{ width: '100%' }} width={280}>- <Button- block- disabled={!canManageProvider}- type="primary"- onClick={handleStartAuth}- >- {t('providerModels.config.oauth.retry')}- </Button>- <Button block type="text" onClick={handleCancelAuth}>- {t('providerModels.config.oauth.cancel')}- </Button>- </Flexbox>- </div>- );- }+ return (+ <Button+ disabled={!canManageProvider}+ loading={isAuthenticating}+ size={'small'}+ type={'primary'}+ onClick={handleStartAuth}+ >+ {t('providerModels.config.oauth.connect')}+ </Button>+ );+ };- // Device code display+ // Dialog body for the device-code flow. The dialog itself owns dismissal,+ // so only the error branch needs an explicit way out.+ const renderAuthPanel = () => {+ // Loading state+ if (state === 'requesting' || !deviceCodeInfo)return (<div className={styles.content}>- <Flexbox align="center" gap={12} style={{ width: '100%' }} width={320}>- <Text type="secondary">{t('providerModels.config.oauth.enterCode')}</Text>- <Flexbox horizontal align="center" gap={12} style={{ width: '100%' }}>- <div className={styles.codeBox}>{deviceCodeInfo.userCode}</div>- <CopyButton content={deviceCodeInfo.userCode} />- </Flexbox>- </Flexbox>-- <Flexbox gap={12} style={{ width: '100%' }} width={280}>- <Button- block- icon={<Icon icon={ExternalLinkIcon} />}- size="large"- type="primary"- onClick={handleOpenBrowser}- >- {t('providerModels.config.oauth.openBrowser')}- </Button>- </Flexbox>-- <Link- href={deviceCodeInfo.verificationUri}- style={{ fontSize: 13 }}- target="_blank"- type="secondary"- >- {deviceCodeInfo.verificationUri}- </Link>-- <div className={styles.pollingHint}>- <Icon spin icon={Loader2Icon} />- <span>{t('providerModels.config.oauth.polling')}</span>- </div>-- <Button type="text" onClick={handleCancelAuth}>- {t('providerModels.config.oauth.cancel')}- </Button>+ <Icon spin icon={Loader2Icon} size={24} />+ <Text type="secondary">{t('providerModels.config.oauth.connecting')}</Text></div>);- }- // Error state (not authenticating)+ // Error stateif (state === 'error' && error) {const errorKey = `providerModels.config.oauth.${error}`;return (<div className={styles.content}><Flexbox horizontal align="center" gap={8}>- <Icon color={cssVar.colorError} icon={UnplugIcon} size={18} />+ <Icon color={cssVar.colorError} icon={UnplugIcon} size={20} /><Text className={styles.errorText}>{t(errorKey as any)}</Text></Flexbox>- <Button- disabled={!canManageProvider}- size="large"- type="primary"- onClick={handleStartAuth}- >- {t('providerModels.config.oauth.connect', { name })}- </Button>- <div className={styles.serviceNote}>- {t('providerModels.config.oauth.serviceNote', { name })}- </div>+ <Flexbox gap={12} style={{ width: '100%' }}>+ <Button block disabled={!canManageProvider} type="primary" onClick={handleStartAuth}>+ {t('providerModels.config.oauth.retry')}+ </Button>+ <Button block type="text" onClick={handleCancelAuth}>+ {t('providerModels.config.oauth.cancel')}+ </Button>+ </Flexbox></div>);}- // Default state - show connect button+ // Device code display. The authorization page is opened for the user on+ // Connect, so the link is the fallback for when a popup blocker ate it —+ // and the only route when authorizing on a second device.return (<div className={styles.content}>- <Button- disabled={!canManageProvider}- size="large"- type="primary"- onClick={handleStartAuth}- >- {t('providerModels.config.oauth.connect', { name })}- </Button>- <div className={styles.serviceNote}>- {t('providerModels.config.oauth.serviceNote', { name })}+ <div className={styles.hint}>+ {t('providerModels.config.oauth.enterCode')}{' '}+ <Link href={deviceCodeInfo.verificationUri} target="_blank">+ {deviceCodeInfo.verificationUri}+ </Link>+ </div>++ <Flexbox horizontal align="center" gap={12} style={{ width: '100%' }}>+ <div className={styles.codeBox}>{deviceCodeInfo.userCode}</div>+ <CopyButton content={deviceCodeInfo.userCode} />+ </Flexbox>++ <div className={styles.pollingHint}>+ <Icon spin icon={Loader2Icon} />+ <span>{t('providerModels.config.oauth.polling')}</span></div></div>);};return (- <div className={styles.card}>- {(title || extra) && (+ <>+ <div className={styles.card}><div className={styles.header}>- <div>{title}</div>- <div>{extra}</div>+ {/* The badge is a property of the provider, not an action on it, so+ it sits with the name rather than among the controls. */}+ <Flexbox horizontal align={'center'} gap={8}>+ {title}+ {enabled && isAuthenticated && (+ <div className={styles.successBadge}>+ <CheckCircleFilled />+ <span>{t('providerModels.config.oauth.connected')}</span>+ </div>+ )}+ </Flexbox>+ <Flexbox horizontal align={'center'} gap={8}>+ {extra}+ {renderAction()}+ </Flexbox></div>- )}- {renderHero()}- {renderContent()}- </div>+ </div>+ {/* Dismissing the dialog abandons the pairing, which is what a user+ closing it means — the code is dead once we stop polling for it. */}+ <Modal+ centered+ destroyOnHidden+ footer={null}+ open={isAuthenticating}+ title={t('providerModels.config.oauth.title')}+ width={420}+ onCancel={handleCancelAuth}+ >+ {renderAuthPanel()}+ </Modal>+ </>);},);diff --git a/src/routes/(main)/settings/provider/features/ProviderConfig/index.tsx b/src/routes/(main)/settings/provider/features/ProviderConfig/index.tsxindex 793d2508d75..b957584fa3a 100644--- a/src/routes/(main)/settings/provider/features/ProviderConfig/index.tsx+++ b/src/routes/(main)/settings/provider/features/ProviderConfig/index.tsx@@ -2,7 +2,7 @@import { BRANDING_PROVIDER } from '@lobechat/business-const';import { AES_GCM_URL, BASE_PROVIDER_DOC_URL, FORM_STYLE } from '@lobechat/const';-import { ProviderCombine } from '@lobehub/icons';+import { ProviderCombine, ProviderIcon } from '@lobehub/icons';import { type FormGroupItemType, type FormItemProps } from '@lobehub/ui';import {Avatar,@@ -71,6 +71,11 @@ const styles = createStaticStyles(({ css, cssVar }) => ({}`,form: css`+ /* The group header is the first thing on the page, so its own top padding+ reads as dead space under the nav bar. The page inset is enough. */+ .${prefixCls}-collapse-header {+ padding-block-start: 0 !important;+ }.${prefixCls}-form-item-control:has(.${prefixCls}-input,.${prefixCls}-select) {flex: none;}@@ -456,7 +461,11 @@ const ProviderConfig = memo<ProviderConfigProps>(style={{height: 24,maxHeight: 24,- ...(enabled ? {} : { filter: 'grayscale(100%)', maxHeight: 24, opacity: 0.66 }),+ // OAuth providers keep full-colour branding while off: the enable+ // switch sits right beside them, so dimming only adds noise+ ...(enabled || isOAuthProvider+ ? {}+ : { filter: 'grayscale(100%)', maxHeight: 24, opacity: 0.66 }),}}>{isCustom ? (@@ -470,7 +479,24 @@ const ProviderConfig = memo<ProviderConfigProps>(</Flexbox>) : (<>- {title ?? <ProviderCombine provider={id} size={24} />}+ {title ??+ // OAuth providers sell a subscription plan rather than the vendor+ // platform, so the plan name reads truer than the vendor wordmark+ // the combined logo would render (e.g. ChatGPT vs. OpenAI).+ (isOAuthProvider ? (+ <Flexbox horizontal align={'center'} gap={8}>+ <ProviderIcon+ provider={id}+ shape={'square'}+ size={24}+ style={{ borderRadius: 6 }}+ type={'avatar'}+ />+ {name}+ </Flexbox>+ ) : (+ <ProviderCombine provider={id} size={24} />+ ))}<Tooltip title={t('providerModels.config.helpDoc')}><ahref={urlJoin(BASE_PROVIDER_DOC_URL, id)}@@ -494,7 +520,9 @@ const ProviderConfig = memo<ProviderConfigProps>({isCustom && <UpdateProviderInfo />}{canDeactivate && !(enableBusinessFeatures && id === BRANDING_PROVIDER) && (<>- {!isCustom && (+ {/* OAuth providers pair the switch with a connect action, so the+ built-in notice would crowd the row */}+ {!isCustom && !isOAuthProvider && (<Tooltip title={t('providerModels.config.builtinNotice')}><Iconcolor={cssVar.colorTextTertiary}@@ -524,8 +552,10 @@ const ProviderConfig = memo<ProviderConfigProps>(<>{isOAuthProvider && (<OAuthDeviceFlowAuth+ // when the provider cannot be deactivated there is no switch to+ // gate on, so the connect action stays available+ enabled={!canDeactivate || enabled}extra={headerExtra}- name={name || id}providerId={id}title={headerTitle}onAuthChange={handleOAuthChange}