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.

✨ feat(model-switch): show rating bars and price multiplier in model list (#19930)

YuTengjing52a2da2c4831
diff --git a/apps/server/src/routers/lambda/__tests__/aiProvider.test.ts b/apps/server/src/routers/lambda/__tests__/aiProvider.test.ts
index 5e201ae1644..b1abd9c48ad 100644
--- a/apps/server/src/routers/lambda/__tests__/aiProvider.test.ts
+++ b/apps/server/src/routers/lambda/__tests__/aiProvider.test.ts
@@ -4,6 +4,7 @@ import { OFFICIAL_PROVIDER_DISABLE_ERROR } from '@lobechat/business-const';
import { RequestTrigger } from '@lobechat/types';
import { beforeEach, describe, expect, it, vi } from 'vitest';
+import { AiModelModel } from '@/database/models/aiModel';
import { AiProviderModel } from '@/database/models/aiProvider';
import { AiInfraRepos } from '@/database/repositories/aiInfra';
import { getServerGlobalConfig } from '@/server/globalConfig';
@@ -22,6 +23,7 @@ vi.mock('@/business/server/aiProvider', () => ({
vi.mock('@/server/globalConfig');
vi.mock('@/server/modules/KeyVaultsEncrypt');
vi.mock('@/database/repositories/aiInfra');
+vi.mock('@/database/models/aiModel');
vi.mock('@/database/models/aiProvider');
vi.mock('@/database/models/user');
vi.mock('@/server/modules/ModelRuntime', () => ({
@@ -70,6 +72,8 @@ describe('aiProviderRouter', () => {
beforeEach(() => {
vi.clearAllMocks();
mockGetHiddenBuiltinModelsForUser.mockResolvedValue([]);
+ // Keep the automock default (no configs) so a per-test override doesn't leak
+ vi.mocked(AiModelModel).prototype.getAllModelReasoningConfigs = vi.fn();
vi.mocked(getServerGlobalConfig).mockReturnValue({
aiProvider: {},
@@ -180,6 +184,21 @@ describe('aiProviderRouter', () => {
expect(mockGetState).toHaveBeenCalledWith(KeyVaultsGateKeeper.getUserKeyVaults);
});
+ it('returns the personal reasoning configs alongside the runtime state', async () => {
+ vi.mocked(AiInfraRepos).prototype.getAiProviderRuntimeState = vi
+ .fn()
+ .mockResolvedValue(mockRuntimeState);
+ const modelReasoningConfigs = { 'openai/gpt-5.6-sol': { gpt5_6ReasoningEffort: 'high' } };
+ vi.mocked(AiModelModel).prototype.getAllModelReasoningConfigs = vi
+ .fn()
+ .mockResolvedValue(modelReasoningConfigs);
+
+ const caller = aiProviderRouter.createCaller(createMockContext());
+ const result = await caller.getAiProviderRuntimeState({});
+
+ expect(result.modelReasoningConfigs).toEqual(modelReasoningConfigs);
+ });
+
it('should append user-scoped hidden builtin models without changing runtime state loading', async () => {
const mockGetState = vi.fn().mockResolvedValue(mockRuntimeState);
const hiddenBuiltinModels = [{ id: 'hidden-model', providerId: 'lobehub' }];
diff --git a/apps/server/src/routers/lambda/aiProvider.ts b/apps/server/src/routers/lambda/aiProvider.ts
index 089de7a70b0..bbc078b2442 100644
--- a/apps/server/src/routers/lambda/aiProvider.ts
+++ b/apps/server/src/routers/lambda/aiProvider.ts
@@ -14,6 +14,7 @@ import {
requireWorkspaceRoleWhenScoped,
wsCompatProcedure,
} from '@/business/server/trpc-middlewares/workspaceAuth';
+import { AiModelModel } from '@/database/models/aiModel';
import { AiProviderModel } from '@/database/models/aiProvider';
import { UserModel } from '@/database/models/user';
import { AiInfraRepos } from '@/database/repositories/aiInfra';
@@ -45,6 +46,7 @@ const aiProviderProcedure = wsCompatProcedure.use(serverDatabase).use(async (opt
aiProvider as Record<string, ProviderConfig>,
ctx.workspaceId ?? undefined,
),
+ aiModelModel: new AiModelModel(ctx.serverDB, ctx.userId, ctx.workspaceId ?? undefined),
aiProviderModel: new AiProviderModel(ctx.serverDB, ctx.userId, ctx.workspaceId ?? undefined),
gateKeeper,
userModel: new UserModel(ctx.serverDB, ctx.userId),
@@ -172,9 +174,15 @@ export const aiProviderRouter = router({
getAiProviderRuntimeState: aiProviderProcedure
.input(z.object({ isLogin: z.boolean().optional() }))
.query(async ({ ctx }): Promise<AiProviderRuntimeState> => {
- const state = await getUserScopedAiProviderRuntimeState(ctx.userId, () =>
- ctx.aiInfraRepos.getAiProviderRuntimeState(KeyVaultsGateKeeper.getUserKeyVaults),
- );
+ const [scopedState, modelReasoningConfigs] = await Promise.all([
+ getUserScopedAiProviderRuntimeState(ctx.userId, () =>
+ ctx.aiInfraRepos.getAiProviderRuntimeState(KeyVaultsGateKeeper.getUserKeyVaults),
+ ),
+ // Loaded here rather than in the shared runtime-state loader: only the
+ // client model list needs it, and server-side callers skip the query
+ ctx.aiModelModel.getAllModelReasoningConfigs(),
+ ]);
+ const state = { ...scopedState, modelReasoningConfigs };
const providerBindingAgentTypes = resolveProviderBindingAgentTypes(state);
// restricted API keys must not exfiltrate decrypted provider credentials
diff --git a/locales/en-US/components.json b/locales/en-US/components.json
index 9e9aec1995d..55f550dc33c 100644
--- a/locales/en-US/components.json
+++ b/locales/en-US/components.json
@@ -225,8 +225,12 @@
"ModelSwitchPanel.detail.releasedAt": "Released {{date}}",
"ModelSwitchPanel.emptyModel": "No enabled model. Please go to settings to enable.",
"ModelSwitchPanel.emptyProvider": "No enabled providers. Please go to settings to enable one.",
+ "ModelSwitchPanel.free": "Free",
"ModelSwitchPanel.goToSettings": "Go to settings",
"ModelSwitchPanel.manageProvider": "Manage Provider",
+ "ModelSwitchPanel.meta.price": "Relative price {{multiplier}}× (1× = $1 per 1M input tokens)",
+ "ModelSwitchPanel.meta.price.credits": "Relative price {{multiplier}}× (1× = 1M credits per 1M input tokens)",
+ "ModelSwitchPanel.meta.rating": "{{dimension}} score {{score}}/100 (relative to the top-rated model)",
"ModelSwitchPanel.provider": "Provider",
"ModelSwitchPanel.searchPlaceholder": "Search models...",
"ModelSwitchPanel.title": "Model",
diff --git a/locales/zh-CN/components.json b/locales/zh-CN/components.json
index a9ae349606d..96026f85b9f 100644
--- a/locales/zh-CN/components.json
+++ b/locales/zh-CN/components.json
@@ -225,8 +225,12 @@
"ModelSwitchPanel.detail.releasedAt": "发布于 {{date}}",
"ModelSwitchPanel.emptyModel": "还没有启用模型。去设置启用后再试",
"ModelSwitchPanel.emptyProvider": "还没有启用模型服务商。去设置启用后再试",
+ "ModelSwitchPanel.free": "免费",
"ModelSwitchPanel.goToSettings": "前往设置",
"ModelSwitchPanel.manageProvider": "管理提供商",
+ "ModelSwitchPanel.meta.price": "相对价格 {{multiplier}}×(1× = 每百万输入 token $1)",
+ "ModelSwitchPanel.meta.price.credits": "相对价格 {{multiplier}}×(1× = 每百万输入 token 100 万积分)",
+ "ModelSwitchPanel.meta.rating": "{{dimension}}评分 {{score}}/100(以评分最高的模型为 100)",
"ModelSwitchPanel.provider": "提供方",
"ModelSwitchPanel.searchPlaceholder": "搜索模型...",
"ModelSwitchPanel.title": "模型",
diff --git a/packages/database/src/models/__tests__/aiModel.test.ts b/packages/database/src/models/__tests__/aiModel.test.ts
index 35fb954811a..dc699fd9883 100644
--- a/packages/database/src/models/__tests__/aiModel.test.ts
+++ b/packages/database/src/models/__tests__/aiModel.test.ts
@@ -320,6 +320,32 @@ describe('AiModelModel', () => {
});
});
+ it('should list every personal reasoning config in one read', async () => {
+ await workspaceAiModelModel.updateModelReasoningConfig('gpt-5.6-sol', 'openai', {
+ gpt5_6ReasoningEffort: 'low',
+ });
+ await aiProviderModel.updateModelReasoningConfig('claude-opus-5', 'anthropic', {
+ reasoningMode: 'pro',
+ });
+ // A row without chatConfig is not a saved preference
+ await aiProviderModel.create({ id: 'gpt-4o', providerId: 'openai' });
+ await new AiModelModel(serverDB, 'user2').updateModelReasoningConfig(
+ 'gpt-5.6-sol',
+ 'openai',
+ {
+ gpt5_6ReasoningEffort: 'high',
+ },
+ );
+
+ const expected = {
+ 'anthropic/claude-opus-5': { reasoningMode: 'pro' },
+ 'openai/gpt-5.6-sol': { gpt5_6ReasoningEffort: 'low' },
+ };
+ expect(await aiProviderModel.getAllModelReasoningConfigs()).toEqual(expected);
+ // Cross-workspace, like the single-model read
+ expect(await workspaceAiModelModel.getAllModelReasoningConfigs()).toEqual(expected);
+ });
+
it('should isolate configs across providers and users', async () => {
await aiProviderModel.updateModelReasoningConfig('gpt-5.6-sol', 'openai', {
gpt5_6ReasoningEffort: 'high',
diff --git a/packages/database/src/models/aiModel.ts b/packages/database/src/models/aiModel.ts
index f7f93777fd5..7be5b945d3f 100644
--- a/packages/database/src/models/aiModel.ts
+++ b/packages/database/src/models/aiModel.ts
@@ -246,6 +246,31 @@ export class AiModelModel {
return (row?.config as AiModelConfig | null)?.chatConfig;
};
+ /**
+ * Bulk counterpart of getModelReasoningConfig (same personal scope): every
+ * saved reasoning default, keyed by `${providerId}/${modelId}`. Lets the
+ * client seed all model-list rows with one read instead of one per model.
+ */
+ getAllModelReasoningConfigs = async (): Promise<Record<string, AiModelReasoningConfig>> => {
+ const rows = await this.db
+ .select({ config: aiModels.config, id: aiModels.id, providerId: aiModels.providerId })
+ .from(aiModels)
+ .where(
+ and(
+ this.personalScopeWhere(),
+ sql`COALESCE(jsonb_exists(${aiModels.config}, 'chatConfig'), false)`,
+ ),
+ );
+
+ const configs: Record<string, AiModelReasoningConfig> = {};
+ for (const row of rows) {
+ const chatConfig = (row.config as AiModelConfig | null)?.chatConfig;
+ if (chatConfig) configs[`${row.providerId}/${row.id}`] = chatConfig;
+ }
+
+ return configs;
+ };
+
/**
* Personal-scope partial update of `config.chatConfig` (see
* getModelReasoningConfig for the scoping rationale).
diff --git a/packages/locales/src/default/components.ts b/packages/locales/src/default/components.ts
index 692d5de4352..d2367180974 100644
--- a/packages/locales/src/default/components.ts
+++ b/packages/locales/src/default/components.ts
@@ -259,7 +259,13 @@ export default {
'ModelSwitchPanel.detail.releasedAt': 'Released {{date}}',
'ModelSwitchPanel.emptyModel': 'No enabled model. Please go to settings to enable.',
'ModelSwitchPanel.emptyProvider': 'No enabled providers. Please go to settings to enable one.',
+ 'ModelSwitchPanel.free': 'Free',
'ModelSwitchPanel.goToSettings': 'Go to settings',
+ 'ModelSwitchPanel.meta.price': 'Relative price {{multiplier}}× (1× = $1 per 1M input tokens)',
+ 'ModelSwitchPanel.meta.price.credits':
+ 'Relative price {{multiplier}}× (1× = 1M credits per 1M input tokens)',
+ 'ModelSwitchPanel.meta.rating':
+ '{{dimension}} score {{score}}/100 (relative to the top-rated model)',
'ModelSwitchPanel.manageProvider': 'Manage Provider',
'ModelSwitchPanel.provider': 'Provider',
'ModelSwitchPanel.searchPlaceholder': 'Search models...',
diff --git a/packages/model-bank/src/types/aiProvider.ts b/packages/model-bank/src/types/aiProvider.ts
index d71bf924da2..2fb43e304d8 100644
--- a/packages/model-bank/src/types/aiProvider.ts
+++ b/packages/model-bank/src/types/aiProvider.ts
@@ -1,6 +1,11 @@
import { z } from 'zod';
-import type { AiModelForSelect, EnabledAiModel, ModelSearchImplementType } from './aiModel';
+import type {
+ AiModelForSelect,
+ AiModelReasoningConfig,
+ EnabledAiModel,
+ ModelSearchImplementType,
+} from './aiModel';
export type ResponseAnimationStyle = 'smooth' | 'fadeIn' | 'none';
export type ResponseAnimation =
@@ -436,6 +441,12 @@ export interface AiProviderRuntimeState {
hiddenBuiltinModels?: BuiltinModelIdentifier[];
/** False when the server could not resolve the current user's hidden-model policy. */
hiddenBuiltinModelsResolved?: boolean;
+ /**
+ * The user's saved per-model reasoning defaults (personal scope, shared across
+ * workspaces), keyed by `${providerId}/${modelId}`. When present it is
+ * complete: a missing key means nothing is saved for that model.
+ */
+ modelReasoningConfigs?: Record<string, AiModelReasoningConfig>;
/**
* Retired `${providerId}/${modelId}` → successor model id (same provider).
* Requests for a key are transparently served by its successor, so clients can
diff --git a/src/components/ModelSelect/index.tsx b/src/components/ModelSelect/index.tsx
index 75e67a730d5..4324be4ee4c 100644
--- a/src/components/ModelSelect/index.tsx
+++ b/src/components/ModelSelect/index.tsx
@@ -16,7 +16,7 @@ import {
} from 'lucide-react';
import { type ModelAbilities } from 'model-bank';
import numeral from 'numeral';
-import { type CSSProperties, type FC } from 'react';
+import { type CSSProperties, type FC, type ReactNode } from 'react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -251,8 +251,14 @@ export const ModelInfoTags = memo<ModelInfoTagsProps>(
interface ModelItemRenderProps extends ChatModelCard, Pick<FlexboxProps, 'className' | 'style'> {
abilities?: ModelAbilities;
audio?: boolean;
+ /** Replaces the default ability tags on the right side of the row */
+ extra?: ReactNode;
+ /** Inline marker after the name (and secondary text), e.g. an image-output icon */
+ nameSuffix?: ReactNode;
newBadgeLabel?: string;
proBadgeLabel?: string;
+ /** Muted text right after the model name, e.g. the current reasoning effort */
+ secondaryText?: string;
showInfoTag?: boolean;
}
@@ -262,11 +268,14 @@ export const ModelItemRender = memo<ModelItemRenderProps>(
abilities,
audio,
contextWindowTokens,
+ extra,
files,
functionCall,
imageOutput,
+ nameSuffix,
newBadgeLabel,
proBadgeLabel,
+ secondaryText,
video,
vision,
id,
@@ -308,6 +317,12 @@ export const ModelItemRender = memo<ModelItemRenderProps>(
>
{displayNameOrId}
</Text>
+ {secondaryText && (
+ <Text style={{ flex: 'none' }} type={'secondary'}>
+ {secondaryText}
+ </Text>
+ )}
+ {nameSuffix}
{newBadgeLabel ? (
<NewModelBadgeCore label={newBadgeLabel} releasedAt={releasedAt} />
) : (
@@ -319,18 +334,19 @@ export const ModelItemRender = memo<ModelItemRenderProps>(
</Tag>
)}
</Flexbox>
- {showInfoTag && (
- <ModelInfoTags
- audio={audio ?? abilities?.audio}
- contextWindowTokens={contextWindowTokens}
- files={files ?? abilities?.files}
- functionCall={functionCall ?? abilities?.functionCall}
- imageOutput={imageOutput ?? abilities?.imageOutput}
- style={{ zoom: 0.9 }}
- video={video ?? abilities?.video}
- vision={vision ?? abilities?.vision}
- />
- )}
+ {extra ??
+ (showInfoTag && (
+ <ModelInfoTags
+ audio={audio ?? abilities?.audio}
+ contextWindowTokens={contextWindowTokens}
+ files={files ?? abilities?.files}
+ functionCall={functionCall ?? abilities?.functionCall}
+ imageOutput={imageOutput ?? abilities?.imageOutput}
+ style={{ zoom: 0.9 }}
+ video={video ?? abilities?.video}
+ vision={vision ?? abilities?.vision}
+ />
+ ))}
</Flexbox>
);
},
diff --git a/src/features/ChatInput/ActionBar/Model/SelectorMenu.tsx b/src/features/ChatInput/ActionBar/Model/SelectorMenu.tsx
index 40a86ebe3e2..5d8566256ea 100644
--- a/src/features/ChatInput/ActionBar/Model/SelectorMenu.tsx
+++ b/src/features/ChatInput/ActionBar/Model/SelectorMenu.tsx
@@ -186,6 +186,9 @@ const SelectorMenu = memo<SelectorMenuProps>(
model={model}
notice={modelNotice}
provider={provider}
+ activeSecondaryText={
+ effortValue ? t(`reasoningEffort.levels.${effortValue}`) : undefined
+ }
onModelChange={onModelChange}
onOpenChange={handleModelPanelOpenChange}
/>
diff --git a/src/features/ChatInput/hooks/useReasoningEffortControl.ts b/src/features/ChatInput/hooks/useReasoningEffortControl.ts
index f5360c5df96..91797485915 100644
--- a/src/features/ChatInput/hooks/useReasoningEffortControl.ts
+++ b/src/features/ChatInput/hooks/useReasoningEffortControl.ts
@@ -10,7 +10,7 @@ import { aiModelSelectors, useAiInfraStore } from '@/store/aiInfra';
import { useChatStore } from '@/store/chat';
import { topicSelectors } from '@/store/chat/slices/topic/selectors';
-type EffortKey = Exclude<keyof AiModelReasoningConfig, 'reasoningMode'>;
+export type EffortKey = Exclude<keyof AiModelReasoningConfig, 'reasoningMode'>;
/** Every level any effort-family param can take — all have a `reasoningEffort.levels.*` label. */
type EffortLevel = NonNullable<AiModelReasoningConfig[EffortKey]>;
type ReasoningMode = NonNullable<AiModelReasoningConfig['reasoningMode']>;
@@ -29,6 +29,32 @@ export interface ReasoningEffortControl {
updating: boolean;
}
+/**
+ * The effort level a model runs at: the saved value when present, otherwise the
+ * same model-dependent fallback as the ControlsForm slider.
+ */
+export const resolveReasoningEffortValue = (
+ model: string,
+ effortKey: EffortKey | undefined,
+ config: AiModelReasoningConfig | undefined,
+): EffortLevel | undefined => {
+ if (!effortKey) return undefined;
+
+ const saved = config?.[effortKey];
+ if (saved) return saved;
+
+ if (effortKey === 'gpt5_2ReasoningEffort' && model === 'gpt-5.5') return 'medium';
+ if (
+ effortKey === 'thinkingLevel' ||
+ effortKey === 'thinkingLevel2' ||
+ effortKey === 'thinkingLevel3' ||
+ effortKey === 'thinkingLevel4'
+ )
+ return resolveDefaultThinkingLevelForModel(model, effortKey);
+
+ return MODEL_REASONING_PARAM_DEFAULTS[effortKey];
+};
+
/**
* Reasoning effort / mode for one model instance.
*
@@ -111,22 +137,10 @@ export const useReasoningEffortControl = (
EffortKey | undefined;
const hasReasoningMode = reasoningParams.includes('reasoningMode');
- // Keep the same model-dependent fallback as the ControlsForm slider
- const effortDefault = effortKey
- ? effortKey === 'gpt5_2ReasoningEffort' && model === 'gpt-5.5'
- ? 'medium'
- : effortKey === 'thinkingLevel' ||
- effortKey === 'thinkingLevel2' ||
- effortKey === 'thinkingLevel3' ||
- effortKey === 'thinkingLevel4'
- ? resolveDefaultThinkingLevelForModel(model, effortKey)
- : MODEL_REASONING_PARAM_DEFAULTS[effortKey]
- : undefined;
-
return {
effortKey,
effortLevels: effortKey ? MODEL_REASONING_PARAM_LEVELS[effortKey] : [],
- effortValue: (effortKey && config?.[effortKey]) ?? effortDefault,
+ effortValue: resolveReasoningEffortValue(model, effortKey, config),
hasReasoningMode,
hasReasoningParams,
modeLevels: MODEL_REASONING_PARAM_LEVELS.reasoningMode,
diff --git a/src/features/ModelSwitchPanel/SubmenuPopup.tsx b/src/features/ModelSwitchPanel/SubmenuPopup.tsx
index 38d7c59bc01..21cdd395f9d 100644
--- a/src/features/ModelSwitchPanel/SubmenuPopup.tsx
+++ b/src/features/ModelSwitchPanel/SubmenuPopup.tsx
@@ -12,6 +12,8 @@ import { PanelContent } from './components/PanelContent';
import { styles } from './styles';
interface ModelSwitchSubmenuPopupProps {
+ /** Muted text shown after the active model's name, e.g. its reasoning effort */
+ activeSecondaryText?: string;
enabledList?: EnabledProviderWithModels[];
model?: string;
notice?: ReactNode;
@@ -27,11 +29,12 @@ interface ModelSwitchSubmenuPopupProps {
* The caller supplies the `DropdownMenuSubmenuRoot` and its trigger row.
*/
export const ModelSwitchSubmenuPopup = memo<ModelSwitchSubmenuPopupProps>(
- ({ enabledList, model, notice, onModelChange, onOpenChange, provider }) => (
+ ({ activeSecondaryText, enabledList, model, notice, onModelChange, onOpenChange, provider }) => (
<DropdownMenuPortal>
<DropdownMenuPositioner alignOffset={-4} anchor={null} placement="right" sideOffset={8}>
<DropdownMenuPopup className={styles.container} onKeyDown={stopPropagation}>
<PanelContent
+ activeSecondaryText={activeSecondaryText}
enabledList={enabledList}
model={model}
notice={notice}
diff --git a/src/features/ModelSwitchPanel/components/List/ListItemRenderer.tsx b/src/features/ModelSwitchPanel/components/List/ListItemRenderer.tsx
index 9ec0773b4f4..dfd379753c1 100644
--- a/src/features/ModelSwitchPanel/components/List/ListItemRenderer.tsx
+++ b/src/features/ModelSwitchPanel/components/List/ListItemRenderer.tsx
@@ -17,21 +17,21 @@ import { useTranslation } from 'react-i18next';
import urlJoin from 'url-join';
import { useActiveWorkspaceSlug } from '@/business/client/hooks/useActiveWorkspaceSlug';
-import { ModelItemRender, ProviderItemRender } from '@/components/ModelSelect';
+import { ProviderItemRender } from '@/components/ModelSelect';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { buildWorkspaceAwarePath } from '@/features/Workspace/workspaceAwarePath';
-import { useUserStore } from '@/store/user';
-import { userGeneralSettingsSelectors } from '@/store/user/selectors';
import { styles } from '../../styles';
import { type ListItem } from '../../types';
import { menuKey } from '../../utils';
import ModelDetailPanel from '../ModelDetailPanel';
+import { ModelRowRender } from './ModelRowRender';
import { MultipleProvidersModelItem } from './MultipleProvidersModelItem';
-import { SingleProviderModelItem } from './SingleProviderModelItem';
interface ListItemRendererProps {
activeKey: string;
+ /** Muted text shown after the active model's name, e.g. its reasoning effort */
+ activeSecondaryText?: string;
isModelRestricted?: (modelId: string, providerId: string) => boolean;
item: ListItem;
newLabel: string;
@@ -46,6 +46,7 @@ interface ListItemRendererProps {
export const ListItemRenderer = memo<ListItemRendererProps>(
({
activeKey,
+ activeSecondaryText,
isModelRestricted,
item,
newLabel,
@@ -59,7 +60,6 @@ export const ListItemRenderer = memo<ListItemRendererProps>(
const { t } = useTranslation('components');
const navigate = useWorkspaceAwareNavigate();
const activeSlug = useActiveWorkspaceSlug();
- const isDevMode = useUserStore((s) => userGeneralSettingsSelectors.config(s).isDevMode);
const [detailOpen, setDetailOpen] = useState(false);
const selectModel = async (modelId: string, providerId: string) => {
@@ -173,12 +173,13 @@ export const ListItemRenderer = memo<ListItemRendererProps>(
void selectModel(item.model.id, item.provider.id);
}}
>
- <ModelItemRender
- {...item.model}
- {...item.model.abilities}
- newBadgeLabel={newLabel}
+ <ModelRowRender
+ activeEffortLabel={activeSecondaryText}
+ isActive={isActive}
+ model={item.model}
+ newLabel={newLabel}
proBadgeLabel={restricted ? proLabel : undefined}
- showInfoTag={isDevMode}
+ provider={item.provider.id}
/>
</DropdownMenuSubmenuTrigger>
<DropdownMenuPortal>
@@ -216,11 +217,13 @@ export const ListItemRenderer = memo<ListItemRendererProps>(
void selectModel(item.data.model.id, singleProvider.id);
}}
>
- <SingleProviderModelItem
- data={item.data}
+ <ModelRowRender
+ activeEffortLabel={activeSecondaryText}
+ isActive={isActive}
+ model={item.data.model}
newLabel={newLabel}
proBadgeLabel={restricted ? proLabel : undefined}
- showInfoTag={isDevMode}
+ provider={singleProvider.id}
/>
</DropdownMenuSubmenuTrigger>
<DropdownMenuPortal>
@@ -240,11 +243,11 @@ export const ListItemRenderer = memo<ListItemRendererProps>(
<Flexbox key={item.data.displayName} style={{ marginBlock: 1, marginInline: 4 }}>
<MultipleProvidersModelItem
activeKey={activeKey}
+ activeSecondaryText={activeSecondaryText}
data={item.data}
isModelRestricted={isModelRestricted}
newLabel={newLabel}
proLabel={proLabel}
- showInfoTag={isDevMode}
onBeforeModelSelect={onBeforeModelSelect}
onClose={onClose}
onModelChange={onModelChange}
diff --git a/src/features/ModelSwitchPanel/components/List/ModelRowMeta.tsx b/src/features/ModelSwitchPanel/components/List/ModelRowMeta.tsx
new file mode 100644
index 00000000000..5a8d9e7d2c9
--- /dev/null
+++ b/src/features/ModelSwitchPanel/components/List/ModelRowMeta.tsx
@@ -0,0 +1,167 @@
+import { BRANDING_PROVIDER } from '@lobechat/business-const';
+import { Flexbox, Icon, Tooltip } from '@lobehub/ui';
+import { createStaticStyles, cssVar } from 'antd-style';
+import { LucideImage } from 'lucide-react';
+import { type AiModelForSelect } from 'model-bank';
+import { memo, useMemo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useBusinessModelPricing } from '@/business/client/hooks/useBusinessModelPricing';
+import { useBusinessModelRating } from '@/business/client/hooks/useBusinessModelRating';
+
+import { getPrice } from '../../hooks/useModelDetailPanel';
+import { formatPriceMultiplier, getInputPriceMultiplier } from '../../utils';
+import {
+ META_COLUMN_GAP,
+ PRICE_COLUMN_WIDTH,
+ RATING_COLORS,
+ RATING_COLUMN_WIDTH,
+ RATING_KEYS,
+ useMetaColumns,
+} from './metaColumns';
+
+const styles = createStaticStyles(({ css, cssVar }) => ({
+ bar: css`
+ overflow: hidden;
+ flex: none;
+
+ width: ${RATING_COLUMN_WIDTH}px;
+ height: 4px;
+ border-radius: 2px;
+
+ background: ${cssVar.colorFillSecondary};
+ `,
+ barFill: css`
+ height: 100%;
+ border-radius: 2px;
+ `,
+ price: css`
+ flex: none;
+
+ width: ${PRICE_COLUMN_WIDTH}px;
+
+ font-size: 12px;
+ font-variant-numeric: tabular-nums;
+ color: ${cssVar.colorTextSecondary};
+ text-align: end;
+ `,
+}));
+
+interface ModelRowMetaProps {
+ model: AiModelForSelect;
+ provider: string;
+}
+
+/**
+ * Right side of a model row: only the facts that tell models apart — benchmark
+ * bars and relative input price. Abilities every model shares
+ * (vision, tools, context length) live in the hover detail panel instead.
+ *
+ * Values carry no labels to keep rows quiet; each one's tooltip says what it
+ * measures and its exact score or price.
+ */
+export const ModelRowMeta = memo<ModelRowMetaProps>(({ model, provider }) => {
+ const { t } = useTranslation('components');
+ const resolvePricing = useBusinessModelPricing();
+ const resolveRating = useBusinessModelRating();
+
+ const pricing = useMemo(
+ () => resolvePricing({ model: model.id, pricing: model.pricing, provider }),
+ [resolvePricing, model.id, model.pricing, provider],
+ );
+ const rating = useMemo(
+ () => resolveRating({ model: model.id, provider }),
+ [resolveRating, model.id, provider],
+ );
+
+ const columns = useMetaColumns();
+ const multiplier = getInputPriceMultiplier(pricing);
+ const bars = RATING_KEYS.map((key) => {
+ const score = rating?.[key]?.score;
+ return { key, score: typeof score === 'number' ? score : undefined };
+ });
+
+ let priceTooltip: React.ReactNode;
+ if (pricing && multiplier !== undefined) {
+ const isCreditPricing = provider === BRANDING_PROVIDER;
+ const price = getPrice(pricing, isCreditPricing);
+ const unitPrefix = isCreditPricing
+ ? 'ModelSwitchPanel.detail.pricing.credits'
+ : 'ModelSwitchPanel.detail.pricing';
+ priceTooltip = (
+ <Flexbox gap={2}>
+ <span>
+ {t(
+ isCreditPricing ? 'ModelSwitchPanel.meta.price.credits' : 'ModelSwitchPanel.meta.price',
+ { multiplier: formatPriceMultiplier(multiplier) },
+ )}
+ </span>
+ <span>
+ {[
+ t(`${unitPrefix}.input` as any, { amount: price.input.current }),
+ t(`${unitPrefix}.output` as any, { amount: price.output.current }),
+ ].join(' · ')}
+ </span>
+ </Flexbox>
+ );
+ }
+
+ if (!columns.rating && !columns.price) return null;
+
+ return (
+ <Flexbox horizontal align={'center'} gap={META_COLUMN_GAP} style={{ flex: 'none' }}>
+ {columns.rating &&
+ bars.map(({ key, score }) =>
+ score === undefined ? (
+ // Keep the column so values stay aligned across rows
+ <div key={key} style={{ flex: 'none', width: RATING_COLUMN_WIDTH }} />
+ ) : (
+ <Tooltip
+ key={key}
+ title={t('ModelSwitchPanel.meta.rating', {
+ dimension: t(`ModelSwitchPanel.detail.rating.dimension.${key}`),
+ score: Math.round(score),
+ })}
+ >
+ <div className={styles.bar}>
+ <div
+ className={styles.barFill}
+ style={{
+ background: RATING_COLORS[key],
+ width: `${Math.min(100, Math.max(0, score))}%`,
+ }}
+ />
+ </div>
+ </Tooltip>
+ ),
+ )}
+ {columns.price &&
+ (multiplier === undefined ? (
+ <div style={{ flex: 'none', width: PRICE_COLUMN_WIDTH }} />
+ ) : (
+ <Tooltip title={priceTooltip}>
+ <div className={styles.price}>
+ {multiplier === 0
+ ? t('ModelSwitchPanel.free')
+ : `${formatPriceMultiplier(multiplier)}x`}
+ </div>
+ </Tooltip>
+ ))}
+ </Flexbox>
+ );
+});
+
+ModelRowMeta.displayName = 'ModelRowMeta';
+
+/** Marks image-generating models right after their name; rare, so it stays inline. */
+export const ImageOutputMark = memo(() => {
+ const { t } = useTranslation('components');
+
+ return (
+ <Tooltip title={t('ModelSelect.featureTag.imageOutput')}>
+ <Icon color={cssVar.colorSuccess} icon={LucideImage} size={14} style={{ flex: 'none' }} />
+ </Tooltip>
+ );
+});
+
+ImageOutputMark.displayName = 'ImageOutputMark';
diff --git a/src/features/ModelSwitchPanel/components/List/ModelRowRender.tsx b/src/features/ModelSwitchPanel/components/List/ModelRowRender.tsx
new file mode 100644
index 00000000000..d3910400899
--- /dev/null
+++ b/src/features/ModelSwitchPanel/components/List/ModelRowRender.tsx
@@ -0,0 +1,41 @@
+import { type AiModelForSelect } from 'model-bank';
+import { memo } from 'react';
+
+import { ModelItemRender } from '@/components/ModelSelect';
+
+import { useModelEffortLabel } from '../../hooks/useModelEffortLabel';
+import { ImageOutputMark, ModelRowMeta } from './ModelRowMeta';
+
+interface ModelRowRenderProps {
+ /**
+ * Effort label from the host for the active row. It wins over the saved
+ * per-model default because a topic can pin its own effort for that model.
+ */
+ activeEffortLabel?: string;
+ isActive?: boolean;
+ model: AiModelForSelect;
+ newLabel: string;
+ proBadgeLabel?: string;
+ provider: string;
+}
+
+/** One model row of the switch panel: name, reasoning effort and comparison meta. */
+export const ModelRowRender = memo<ModelRowRenderProps>(
+ ({ activeEffortLabel, isActive, model, newLabel, proBadgeLabel, provider }) => {
+ const effortLabel = useModelEffortLabel(model.id, provider);
+
+ return (
+ <ModelItemRender
+ {...model}
+ {...model.abilities}
+ extra={<ModelRowMeta model={model} provider={provider} />}
+ nameSuffix={model.abilities?.imageOutput && <ImageOutputMark />}
+ newBadgeLabel={newLabel}
+ proBadgeLabel={proBadgeLabel}
+ secondaryText={(isActive && activeEffortLabel) || effortLabel}
+ />
+ );
+ },
+);
+
+ModelRowRender.displayName = 'ModelRowRender';
diff --git a/src/features/ModelSwitchPanel/components/List/MultipleProvidersModelItem.tsx b/src/features/ModelSwitchPanel/components/List/MultipleProvidersModelItem.tsx
index fac790866bb..87b4f310308 100644
--- a/src/features/ModelSwitchPanel/components/List/MultipleProvidersModelItem.tsx
+++ b/src/features/ModelSwitchPanel/components/List/MultipleProvidersModelItem.tsx
@@ -18,15 +18,18 @@ import { Check } from 'lucide-react';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { ModelItemRender, ProviderItemRender } from '@/components/ModelSelect';
+import { ProviderItemRender } from '@/components/ModelSelect';
import { styles } from '../../styles';
import { type ModelWithProviders } from '../../types';
import { menuKey } from '../../utils';
import ModelDetailPanel from '../ModelDetailPanel';
+import { ModelRowRender } from './ModelRowRender';
interface MultipleProvidersModelItemProps {
activeKey: string;
+ /** Muted text shown after the name when this model is the active one */
+ activeSecondaryText?: string;
data: ModelWithProviders;
defaultProviderId?: string;
isModelRestricted?: (modelId: string, providerId: string) => boolean;
@@ -36,12 +39,12 @@ interface MultipleProvidersModelItemProps {
onModelChange: (modelId: string, providerId: string) => void;
onRestrictedModelClick?: () => void;
proLabel?: string;
- showInfoTag?: boolean;
}
export const MultipleProvidersModelItem = memo<MultipleProvidersModelItemProps>(
({
activeKey,
+ activeSecondaryText,
data,
isModelRestricted,
newLabel,
@@ -50,7 +53,6 @@ export const MultipleProvidersModelItem = memo<MultipleProvidersModelItemProps>(
onClose,
onRestrictedModelClick,
proLabel,
- showInfoTag,
}) => {
const { t } = useTranslation('components');
const [submenuOpen, setSubmenuOpen] = useState(false);
@@ -99,12 +101,13 @@ export const MultipleProvidersModelItem = memo<MultipleProvidersModelItemProps>(
void selectModel(defaultProvider.id);
}}
>
- <ModelItemRender
- {...data.model}
- {...data.model.abilities}
- newBadgeLabel={newLabel}
+ <ModelRowRender
+ activeEffortLabel={activeSecondaryText}
+ isActive={isActive}
+ model={data.model}
+ newLabel={newLabel}
proBadgeLabel={defaultProviderRestricted ? proLabel : undefined}
- showInfoTag={showInfoTag}
+ provider={(activeProvider ?? defaultProvider)?.id ?? ''}
/>
</DropdownMenuSubmenuTrigger>
<DropdownMenuPortal>
diff --git a/src/features/ModelSwitchPanel/components/List/SingleProviderModelItem.tsx b/src/features/ModelSwitchPanel/components/List/SingleProviderModelItem.tsx
deleted file mode 100644
index be1f5464be1..00000000000
--- a/src/features/ModelSwitchPanel/components/List/SingleProviderModelItem.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import { memo } from 'react';
-
-import { ModelItemRender } from '@/components/ModelSelect';
-
-import { type ModelWithProviders } from '../../types';
-
-interface SingleProviderModelItemProps {
- data: ModelWithProviders;
- newLabel: string;
- proBadgeLabel?: string;
- showInfoTag?: boolean;
-}
-
-export const SingleProviderModelItem = memo<SingleProviderModelItemProps>(
- ({ data, newLabel, proBadgeLabel, showInfoTag }) => {
- return (
- <ModelItemRender
- {...data.model}
- {...data.model.abilities}
- newBadgeLabel={newLabel}
- proBadgeLabel={proBadgeLabel}
- showInfoTag={showInfoTag}
- />
- );
- },
-);
-
-SingleProviderModelItem.displayName = 'SingleProviderModelItem';
diff --git a/src/features/ModelSwitchPanel/components/List/__tests__/MultipleProvidersModelItem.test.tsx b/src/features/ModelSwitchPanel/components/List/__tests__/MultipleProvidersModelItem.test.tsx
index 80f5b474f6a..a1db126d3aa 100644
--- a/src/features/ModelSwitchPanel/components/List/__tests__/MultipleProvidersModelItem.test.tsx
+++ b/src/features/ModelSwitchPanel/components/List/__tests__/MultipleProvidersModelItem.test.tsx
@@ -126,7 +126,6 @@ describe('MultipleProvidersModelItem', () => {
<MultipleProvidersModelItem
activeKey="lobehub/gpt-5.4"
newLabel="new"
- showInfoTag={false}
data={{
displayName: 'GPT-5.4',
model: {
@@ -158,7 +157,6 @@ describe('MultipleProvidersModelItem', () => {
activeKey="anthropic/claude-opus-4-7"
newLabel="new"
proLabel="pro"
- showInfoTag={false}
data={{
displayName: 'Claude Opus 4.7',
model: {
diff --git a/src/features/ModelSwitchPanel/components/List/index.tsx b/src/features/ModelSwitchPanel/components/List/index.tsx
index c9894a82f4e..f506107ddd8 100644
--- a/src/features/ModelSwitchPanel/components/List/index.tsx
+++ b/src/features/ModelSwitchPanel/components/List/index.tsx
@@ -4,6 +4,8 @@ import { useCallback, useLayoutEffect, useMemo, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { useBusinessModelListGuard } from '@/business/client/hooks/useBusinessModelListGuard';
+import { useBusinessModelPricing } from '@/business/client/hooks/useBusinessModelPricing';
+import { useBusinessModelRating } from '@/business/client/hooks/useBusinessModelRating';
import { useEnabledChatModels } from '@/hooks/useEnabledChatModels';
import { useSingleton } from '@/hooks/useSingleton';
import type { EnabledProviderWithModels } from '@/types/aiProvider';
@@ -18,8 +20,11 @@ import { menuKey } from '../../utils';
import type { PricingMode } from '../ModelDetailPanel';
import GenerationListItemRenderer from './GenerationListItemRenderer';
import { ListItemRenderer } from './ListItemRenderer';
+import { MetaColumnsContext, resolveMetaColumns } from './metaColumns';
interface ListProps {
+ /** Muted text shown after the active model's name, e.g. its reasoning effort */
+ activeSecondaryText?: string;
enabledList?: EnabledProviderWithModels[];
groupMode: GroupMode;
model?: string;
@@ -33,6 +38,7 @@ interface ListProps {
export const List: FC<ListProps> = ({
ModelItemComponent,
+ activeSecondaryText,
enabledList: enabledListProp,
groupMode,
model: modelProp,
@@ -57,6 +63,13 @@ export const List: FC<ListProps> = ({
});
const listItems = useBuildListItems(enabledList, groupMode, searchKeyword, sortModelLast);
+ const resolvePricing = useBusinessModelPricing();
+ const resolveRating = useBusinessModelRating();
+ const metaColumns = useMemo(
+ () => resolveMetaColumns(listItems, resolvePricing, resolveRating),
+ [listItems, resolvePricing, resolveRating],
+ );
+
const panelHeight = useMemo(
() =>
enabledList.length === 0
@@ -115,59 +128,62 @@ export const List: FC<ListProps> = ({
style={{ minHeight: 0 }}
onScroll={handleListScroll}
>
- {listItems.map((item, index) => {
- const itemKey = menuKey(
- 'provider' in item && item.provider ? item.provider.id : '',
- 'model' in item && item.model
- ? item.model.id
- : 'data' in item && item.data
- ? item.data.displayName
- : `${item.type}-${index}`,
- );
- const isActive =
- (item.type === 'provider-model-item' &&
- menuKey(item.provider.id, item.model.id) === activeKey) ||
- (item.type === 'model-item-single' &&
- menuKey(item.data.providers[0].id, item.data.model.id) === activeKey) ||
- (item.type === 'model-item-multiple' &&
- item.data.providers.some((p) => menuKey(p.id, item.data.model.id) === activeKey));
-
- const renderItem = (key?: string) =>
- ModelItemComponent ? (
- <GenerationListItemRenderer
- ModelItemComponent={ModelItemComponent}
- activeKey={activeKey}
- enabledList={enabledList}
- item={item}
- key={key}
- pricingMode={pricingMode}
- onClose={handleClose}
- onModelChange={handleModelChange}
- />
+ <MetaColumnsContext value={metaColumns}>
+ {listItems.map((item, index) => {
+ const itemKey = menuKey(
+ 'provider' in item && item.provider ? item.provider.id : '',
+ 'model' in item && item.model
+ ? item.model.id
+ : 'data' in item && item.data
+ ? item.data.displayName
+ : `${item.type}-${index}`,
+ );
+ const isActive =
+ (item.type === 'provider-model-item' &&
+ menuKey(item.provider.id, item.model.id) === activeKey) ||
+ (item.type === 'model-item-single' &&
+ menuKey(item.data.providers[0].id, item.data.model.id) === activeKey) ||
+ (item.type === 'model-item-multiple' &&
+ item.data.providers.some((p) => menuKey(p.id, item.data.model.id) === activeKey));
+
+ const renderItem = (key?: string) =>
+ ModelItemComponent ? (
+ <GenerationListItemRenderer
+ ModelItemComponent={ModelItemComponent}
+ activeKey={activeKey}
+ enabledList={enabledList}
+ item={item}
+ key={key}
+ pricingMode={pricingMode}
+ onClose={handleClose}
+ onModelChange={handleModelChange}
+ />
+ ) : (
+ <ListItemRenderer
+ activeKey={activeKey}
+ activeSecondaryText={activeSecondaryText}
+ isModelRestricted={isModelRestricted}
+ item={item}
+ key={key}
+ newLabel={newLabel}
+ proLabel={proLabel}
+ subscribeScroll={subscribeScroll}
+ onBeforeModelSelect={onBeforeModelSelect}
+ onClose={handleClose}
+ onModelChange={handleModelChange}
+ onRestrictedModelClick={onRestrictedModelClick}
+ />
+ );
+
+ return isActive ? (
+ <div key={itemKey} ref={activeItemRef}>
+ {renderItem()}
+ </div>
) : (
- <ListItemRenderer
- activeKey={activeKey}
- isModelRestricted={isModelRestricted}
- item={item}
- key={key}
- newLabel={newLabel}
- proLabel={proLabel}
- subscribeScroll={subscribeScroll}
- onBeforeModelSelect={onBeforeModelSelect}
- onClose={handleClose}
- onModelChange={handleModelChange}
- onRestrictedModelClick={onRestrictedModelClick}
- />
+ renderItem(itemKey)
);
-
- return isActive ? (
- <div key={itemKey} ref={activeItemRef}>
- {renderItem()}
- </div>
- ) : (
- renderItem(itemKey)
- );
- })}
+ })}
+ </MetaColumnsContext>
</Flexbox>
);
};
diff --git a/src/features/ModelSwitchPanel/components/List/metaColumns.ts b/src/features/ModelSwitchPanel/components/List/metaColumns.ts
new file mode 100644
index 00000000000..a9cd6558882
--- /dev/null
+++ b/src/features/ModelSwitchPanel/components/List/metaColumns.ts
@@ -0,0 +1,70 @@
+import { cssVar } from 'antd-style';
+import { type AiModelForSelect, type ModelRating, type Pricing } from 'model-bank';
+import { createContext, useContext } from 'react';
+
+import { type BusinessModelPricingParams } from '@/business/client/hooks/useBusinessModelPricing';
+import { type BusinessModelRatingParams } from '@/business/client/hooks/useBusinessModelRating';
+
+import { type ListItem } from '../../types';
+import { getInputPriceMultiplier } from '../../utils';
+
+export const RATING_KEYS = ['intelligence', 'speed'] as const;
+export type RatingKey = (typeof RATING_KEYS)[number];
+
+export const RATING_COLORS: Record<RatingKey, string> = {
+ intelligence: cssVar.colorInfo,
+ speed: cssVar.colorSuccess,
+};
+
+/** Fixed column widths keep bars and multipliers aligned from row to row. */
+export const META_COLUMN_GAP = 8;
+export const RATING_COLUMN_WIDTH = 24;
+export const PRICE_COLUMN_WIDTH = 36;
+
+export interface MetaColumns {
+ price: boolean;
+ rating: boolean;
+}
+
+/**
+ * Which comparison columns the current list shows. Rows reserve a column's width
+ * even when their own value is missing, so the other columns stay aligned.
+ */
+export const MetaColumnsContext = createContext<MetaColumns>({ price: true, rating: true });
+
+export const useMetaColumns = () => useContext(MetaColumnsContext);
+
+const listItemModels = (item: ListItem): { model: AiModelForSelect; provider: string }[] => {
+ switch (item.type) {
+ case 'provider-model-item': {
+ return [{ model: item.model, provider: item.provider.id }];
+ }
+ case 'model-item-single':
+ case 'model-item-multiple': {
+ return item.data.providers.map((p) => ({ model: item.data.model, provider: p.id }));
+ }
+ default: {
+ return [];
+ }
+ }
+};
+
+export const resolveMetaColumns = (
+ items: ListItem[],
+ resolvePricing: (params: BusinessModelPricingParams) => Pricing | undefined,
+ resolveRating: (params: BusinessModelRatingParams) => ModelRating | undefined,
+): MetaColumns => {
+ const columns: MetaColumns = { price: false, rating: false };
+ for (const { model, provider } of items.flatMap(listItemModels)) {
+ if (!columns.price) {
+ const pricing = resolvePricing({ model: model.id, pricing: model.pricing, provider });
+ columns.price = getInputPriceMultiplier(pricing) !== undefined;
+ }
+ if (!columns.rating) {
+ const rating = resolveRating({ model: model.id, provider });
+ columns.rating = RATING_KEYS.some((key) => typeof rating?.[key]?.score === 'number');
+ }
+ if (columns.price && columns.rating) break;
+ }
+ return columns;
+};
diff --git a/src/features/ModelSwitchPanel/components/PanelContent.tsx b/src/features/ModelSwitchPanel/components/PanelContent.tsx
index d56fc98fe1a..10ac7802691 100644
--- a/src/features/ModelSwitchPanel/components/PanelContent.tsx
+++ b/src/features/ModelSwitchPanel/components/PanelContent.tsx
@@ -18,6 +18,8 @@ import type { PricingMode } from './ModelDetailPanel';
import { Toolbar } from './Toolbar';
interface PanelContentProps {
+ /** Muted text shown after the active model's name, e.g. its reasoning effort */
+ activeSecondaryText?: string;
enabledList?: EnabledProviderWithModels[];
model?: string;
ModelItemComponent?: ComponentType<any>;
@@ -30,6 +32,7 @@ interface PanelContentProps {
export const PanelContent: FC<PanelContentProps> = ({
ModelItemComponent,
+ activeSecondaryText,
enabledList: enabledListProp,
model: modelProp,
notice,
@@ -69,6 +72,7 @@ export const PanelContent: FC<PanelContentProps> = ({
/>
<List
ModelItemComponent={ModelItemComponent}
+ activeSecondaryText={activeSecondaryText}
enabledList={enabledList}
groupMode={groupMode}
model={modelProp}
diff --git a/src/features/ModelSwitchPanel/hooks/useModelDetailPanel.ts b/src/features/ModelSwitchPanel/hooks/useModelDetailPanel.ts
index 49aa5f4cd55..1432a3982e9 100644
--- a/src/features/ModelSwitchPanel/hooks/useModelDetailPanel.ts
+++ b/src/features/ModelSwitchPanel/hooks/useModelDetailPanel.ts
@@ -98,7 +98,7 @@ const getFormattedUnitPrice = (
};
};
-const getPrice = (pricing: Pricing, isCreditPricing: boolean): TextPriceSummary => {
+export const getPrice = (pricing: Pricing, isCreditPricing: boolean): TextPriceSummary => {
return {
cachedInput: getFormattedUnitPrice(pricing, 'textInput_cacheRead', isCreditPricing),
input: getFormattedUnitPrice(pricing, 'textInput', isCreditPricing),
diff --git a/src/features/ModelSwitchPanel/hooks/useModelEffortLabel.ts b/src/features/ModelSwitchPanel/hooks/useModelEffortLabel.ts
new file mode 100644
index 00000000000..8b5f9201594
--- /dev/null
+++ b/src/features/ModelSwitchPanel/hooks/useModelEffortLabel.ts
@@ -0,0 +1,46 @@
+import isEqual from 'fast-deep-equal';
+import { useEffect } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import {
+ type EffortKey,
+ resolveReasoningEffortValue,
+} from '@/features/ChatInput/hooks/useReasoningEffortControl';
+import { aiModelSelectors, useAiInfraStore } from '@/store/aiInfra';
+
+/**
+ * The reasoning effort a model would run at if picked now: the user's saved
+ * per-model default, else the model's fallback level. Returns `undefined` for
+ * models without an effort param and while the saved value is still loading,
+ * so a row never flashes the fallback before the real value arrives.
+ *
+ * Values come from the runtime-state response, which seeds every enabled
+ * model's entry in one read. `ensureModelReasoningConfig` is only a fallback
+ * for models the snapshot missed; it is a no-op once a key is cached
+ * (including "nothing saved").
+ */
+export const useModelEffortLabel = (model: string, provider: string): string | undefined => {
+ const { t } = useTranslation('chat');
+ const reasoningParams = useAiInfraStore(
+ aiModelSelectors.modelReasoningExtendParams(model, provider),
+ isEqual,
+ );
+ // modelReasoningExtendParams only returns reasoning-family params, so every
+ // entry other than reasoningMode is an effort key
+ const effortKey = reasoningParams.find((param) => param !== 'reasoningMode') as
+ EffortKey | undefined;
+
+ const ensureModelReasoningConfig = useAiInfraStore((s) => s.ensureModelReasoningConfig);
+ useEffect(() => {
+ if (effortKey) void ensureModelReasoningConfig(model, provider);
+ }, [effortKey, ensureModelReasoningConfig, model, provider]);
+
+ const loaded = useAiInfraStore(aiModelSelectors.isModelReasoningConfigLoaded(model, provider));
+ const config = useAiInfraStore(aiModelSelectors.modelReasoningConfig(model, provider), isEqual);
+
+ if (!effortKey || !loaded) return undefined;
+
+ const value = resolveReasoningEffortValue(model, effortKey, config);
+
+ return value ? t(`reasoningEffort.levels.${value}`) : undefined;
+};
diff --git a/src/features/ModelSwitchPanel/utils.test.ts b/src/features/ModelSwitchPanel/utils.test.ts
new file mode 100644
index 00000000000..40bd32a67a1
--- /dev/null
+++ b/src/features/ModelSwitchPanel/utils.test.ts
@@ -0,0 +1,79 @@
+import { USD_TO_CNY } from '@lobechat/const/currency';
+import { type Pricing } from 'model-bank';
+import { describe, expect, it } from 'vitest';
+
+import { formatPriceMultiplier, getInputPriceMultiplier } from './utils';
+
+describe('getInputPriceMultiplier', () => {
+ it('uses the USD input rate per 1M tokens as the multiplier', () => {
+ const pricing = {
+ units: [
+ { name: 'textInput', rate: 3, strategy: 'fixed', unit: 'millionTokens' },
+ { name: 'textOutput', rate: 15, strategy: 'fixed', unit: 'millionTokens' },
+ ],
+ } as Pricing;
+
+ expect(getInputPriceMultiplier(pricing)).toBe(3);
+ });
+
+ it('converts CNY pricing to USD', () => {
+ const pricing = {
+ currency: 'CNY',
+ units: [
+ { name: 'textInput', rate: USD_TO_CNY * 2, strategy: 'fixed', unit: 'millionTokens' },
+ ],
+ } as Pricing;
+
+ expect(getInputPriceMultiplier(pricing)).toBeCloseTo(2);
+ });
+
+ it('uses the first tier of tiered pricing', () => {
+ const pricing = {
+ units: [
+ {
+ name: 'textInput',
+ strategy: 'tiered',
+ tiers: [
+ { rate: 1.25, upTo: 200_000 },
+ { rate: 2.5, upTo: 'infinity' },
+ ],
+ unit: 'millionTokens',
+ },
+ ],
+ } as Pricing;
+
+ expect(getInputPriceMultiplier(pricing)).toBe(1.25);
+ });
+
+ it('keeps free models at 0', () => {
+ const pricing = {
+ units: [{ name: 'textInput', rate: 0, strategy: 'fixed', unit: 'millionTokens' }],
+ } as Pricing;
+
+ expect(getInputPriceMultiplier(pricing)).toBe(0);
+ });
+
+ it('returns undefined without a text input price', () => {
+ expect(getInputPriceMultiplier(undefined)).toBeUndefined();
+ expect(
+ getInputPriceMultiplier({
+ units: [{ name: 'imageGeneration', rate: 0.04, strategy: 'fixed', unit: 'image' }],
+ } as Pricing),
+ ).toBeUndefined();
+ });
+});
+
+describe('formatPriceMultiplier', () => {
+ it.each([
+ [0.0125, '0.013'],
+ [0.05, '0.05'],
+ [0.3, '0.3'],
+ [1, '1'],
+ [1.25, '1.25'],
+ [2.555, '2.56'],
+ [15, '15'],
+ [37.5, '38'],
+ ])('formats %s as %s', (input, expected) => {
+ expect(formatPriceMultiplier(input)).toBe(expected);
+ });
+});
diff --git a/src/features/ModelSwitchPanel/utils.ts b/src/features/ModelSwitchPanel/utils.ts
index c2ebdeff0fe..9441f6c3f06 100644
--- a/src/features/ModelSwitchPanel/utils.ts
+++ b/src/features/ModelSwitchPanel/utils.ts
@@ -1,3 +1,7 @@
+import { USD_TO_CNY } from '@lobechat/const/currency';
+import { getTextInputUnitRate } from '@lobechat/utils';
+import { type Pricing } from 'model-bank';
+
import { type ListItem } from './types';
export const menuKey = (provider: string, model: string) => `${provider}-${model}`;
@@ -22,3 +26,23 @@ export const getListItemKey = (item: ListItem): string => {
}
}
};
+
+/**
+ * Input price relative to the $1 / 1M input tokens baseline, so the model list
+ * can compare cost at a glance. Tiered pricing uses its first (cheapest) tier.
+ * Returns `undefined` when the model has no text input price.
+ */
+export const getInputPriceMultiplier = (pricing?: Pricing): number | undefined => {
+ const rate = getTextInputUnitRate(pricing);
+ if (typeof rate !== 'number' || !Number.isFinite(rate) || rate < 0) return undefined;
+
+ return pricing?.currency === 'CNY' ? rate / USD_TO_CNY : rate;
+};
+
+/** 0.0125 → "0.013", 0.3 → "0.3", 1.25 → "1.25", 15 → "15" */
+export const formatPriceMultiplier = (multiplier: number): string => {
+ if (multiplier >= 10) return String(Math.round(multiplier));
+ if (multiplier >= 0.1) return String(Number(multiplier.toFixed(2)));
+
+ return String(Number(multiplier.toPrecision(2)));
+};
diff --git a/src/store/aiInfra/slices/aiModel/initialState.test.ts b/src/store/aiInfra/slices/aiModel/initialState.test.ts
new file mode 100644
index 00000000000..c3536f610e9
--- /dev/null
+++ b/src/store/aiInfra/slices/aiModel/initialState.test.ts
@@ -0,0 +1,58 @@
+import { describe, expect, it } from 'vitest';
+
+import { seedModelReasoningConfigMap } from './initialState';
+
+describe('seedModelReasoningConfigMap', () => {
+ const models = [
+ { id: 'gpt-5.6-sol', providerId: 'openai' },
+ { id: 'claude-opus-5', providerId: 'anthropic' },
+ ];
+
+ it('marks every listed model as loaded, with undefined when nothing is saved', () => {
+ const map = seedModelReasoningConfigMap(
+ {},
+ { 'openai/gpt-5.6-sol': { gpt5_6ReasoningEffort: 'high' } },
+ models,
+ [],
+ );
+
+ expect(map).toEqual({
+ 'anthropic/claude-opus-5': undefined,
+ 'openai/gpt-5.6-sol': { gpt5_6ReasoningEffort: 'high' },
+ });
+ expect('anthropic/claude-opus-5' in map).toBe(true);
+ });
+
+ it('replaces stale values with the server snapshot', () => {
+ const map = seedModelReasoningConfigMap(
+ { 'openai/gpt-5.6-sol': { gpt5_6ReasoningEffort: 'low' } },
+ {},
+ models,
+ [],
+ );
+
+ expect(map['openai/gpt-5.6-sol']).toBeUndefined();
+ });
+
+ it('keeps the optimistic value of a key with an in-flight save', () => {
+ const map = seedModelReasoningConfigMap(
+ { 'openai/gpt-5.6-sol': { gpt5_6ReasoningEffort: 'xhigh' } },
+ { 'openai/gpt-5.6-sol': { gpt5_6ReasoningEffort: 'low' } },
+ models,
+ ['openai/gpt-5.6-sol'],
+ );
+
+ expect(map['openai/gpt-5.6-sol']).toEqual({ gpt5_6ReasoningEffort: 'xhigh' });
+ });
+
+ it('keeps saved configs of models outside the enabled list', () => {
+ const map = seedModelReasoningConfigMap(
+ {},
+ { 'azure/gpt-5.6-sol': { gpt5_6ReasoningEffort: 'medium' } },
+ [],
+ [],
+ );
+
+ expect(map).toEqual({ 'azure/gpt-5.6-sol': { gpt5_6ReasoningEffort: 'medium' } });
+ });
+});
diff --git a/src/store/aiInfra/slices/aiModel/initialState.ts b/src/store/aiInfra/slices/aiModel/initialState.ts
index ddf5a5a663a..ac3d978b33e 100644
--- a/src/store/aiInfra/slices/aiModel/initialState.ts
+++ b/src/store/aiInfra/slices/aiModel/initialState.ts
@@ -1,6 +1,7 @@
import {
type AiModelReasoningConfig,
type AiProviderModelListItem,
+ type EnabledAiModel,
type LobeDefaultAiModelListItem,
} from 'model-bank';
@@ -31,3 +32,30 @@ export const initialAIModelState: AIModelsState = {
};
export const modelReasoningConfigKey = (provider: string, model: string) => `${provider}/${model}`;
+
+/**
+ * Merges a complete server snapshot of saved reasoning configs into the map.
+ * Every listed model gets an entry (`undefined` = nothing saved), which turns
+ * later `ensureModelReasoningConfig` calls into no-ops, so the model list does
+ * not fetch one config per row. Keys with an in-flight save keep their
+ * optimistic value.
+ */
+export const seedModelReasoningConfigMap = (
+ current: AIModelsState['modelReasoningConfigMap'],
+ configs: Record<string, AiModelReasoningConfig>,
+ models: Pick<EnabledAiModel, 'id' | 'providerId'>[],
+ updatingKeys: string[],
+): AIModelsState['modelReasoningConfigMap'] => {
+ const next = { ...current };
+ const keys = new Set([
+ ...models.map((model) => modelReasoningConfigKey(model.providerId, model.id)),
+ ...Object.keys(configs),
+ ]);
+
+ for (const key of keys) {
+ if (updatingKeys.includes(key)) continue;
+ next[key] = configs[key];
+ }
+
+ return next;
+};
diff --git a/src/store/aiInfra/slices/aiProvider/action.ts b/src/store/aiInfra/slices/aiProvider/action.ts
index d6b6b1218bc..a55741cb906 100644
--- a/src/store/aiInfra/slices/aiProvider/action.ts
+++ b/src/store/aiInfra/slices/aiProvider/action.ts
@@ -34,6 +34,8 @@ import {
import { AiProviderSourceEnum } from '@/types/aiProvider';
import { filterEnabledProvidersByModelType, filterHiddenBuiltinModels } from '@/utils/aiProvider';
+import { seedModelReasoningConfigMap } from '../aiModel/initialState';
+
export { filterEnabledProvidersByModelType, filterHiddenBuiltinModels } from '@/utils/aiProvider';
interface UserScopedBuiltinModelState {
@@ -707,6 +709,8 @@ export class AiProviderActionImpl {
onSuccess: (data) => {
if (!data) return;
+ const state = this.#get();
+
this.#set(
{
aiProviderRuntimeConfig: data.runtimeConfig,
@@ -721,6 +725,14 @@ export class AiProviderActionImpl {
hiddenBuiltinModels: data.hiddenBuiltinModels,
isInitAiProviderRuntimeState: true,
modelRedirects: data.modelRedirects,
+ ...(data.modelReasoningConfigs && {
+ modelReasoningConfigMap: seedModelReasoningConfigMap(
+ state.modelReasoningConfigMap,
+ data.modelReasoningConfigs,
+ data.enabledAiModels,
+ state.modelReasoningConfigUpdatingKeys,
+ ),
+ }),
providerBindingAgentTypes: data.providerBindingAgentTypes ?? {},
},
false,