Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(model-picker): preserve full compact-label semantics
Chris230cd63383b7
diff --cc apps/desktop/src/renderer/__tests__/modelSelectorTriggerVariant.test.tsindex f6cd2a521a,b246f6cd08..5f3a72c8d6--- a/apps/desktop/src/renderer/__tests__/modelSelectorTriggerVariant.test.ts+++ b/apps/desktop/src/renderer/__tests__/modelSelectorTriggerVariant.test.ts@@@ -1441,23 -1432,6 +1441,35 @@@ describe('ModelSelector trigger variant);});+ it('uses stable English effort ids for compact row and trigger labels', () => {+ const t = (key: string, options?: { defaultValue?: string }) =>+ key === 'effortLevels.xhigh' ? '超高' : (options?.defaultValue ?? key);++ expect(+ modelCompactEffortLabel(+ 'en-US',+ t,+ { effortDisplayNames: { xhigh: 'Extra High' } },+ 'xhigh',+ '特高',+ ),+ ).toBe('XHi');+ expect(modelCompactEffortLabel('en-US', t, null, 'medium', '中')).toBe('Mid');+ expect(modelCompactEffortLabel('zh-CN', t, null, 'xhigh', 'Extra High')).toBe('超高');++ expect(++ modelCompactEffortLabel(++ 'en-US',++ t,++ { effortDisplayNames: { 'adaptive-fast': 'Adaptive Fast' } },++ 'adaptive-fast',++ 'Capability Fast',++ ),++ ).toBe('Adaptive Fast');++ expect(modelCompactEffortLabel('en-US', t, null, 'adaptive-safe', 'Adaptive Safe')).toBe(++ 'Adaptive Safe',++ );+ });+it.each([{agentKind: 'claude-code' as const,diff --cc apps/desktop/src/renderer/components/new-chat/ModelSelector.tsxindex 51270afb02,f92dca123a..2d9fa7affa--- a/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx+++ b/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx@@@ -442,24 -441,6 +442,25 @@@ export function modelEffortLabel});}+export function modelCompactEffortLabel(+ language: string,+ t: Translate,+ m: Pick<RowModel, 'effortDisplayNames'> | null | undefined,+ e: Effort,+ agentDisplayName?: string,+): string {++ const fullLabel = modelEffortLabel(t, m, e, agentDisplayName);+ return language.toLowerCase().startsWith('en')- ? compactEnglishEffortLabel(e)- : modelEffortLabel(t, m, e, agentDisplayName);++ ? compactEnglishEffortLabel(e, fullLabel)++ : fullLabel;+}++function resolvedTranslationLanguage(+ i18n: { resolvedLanguage?: string; language?: string } | undefined,+): string {+ return i18n?.resolvedLanguage ?? i18n?.language ?? '';+}+function ModelPromotionBadge({ children }: { children: ReactNode }) {return (<spandiff --cc apps/mobile/src/__tests__/mobileModelPickerLayout.test.tsindex ae66070a2b,0000000000..0ffae83e42mode 100644,000000..100644--- a/apps/mobile/src/__tests__/mobileModelPickerLayout.test.ts+++ b/apps/mobile/src/__tests__/mobileModelPickerLayout.test.ts@@@ -1,49 -1,0 +1,50 @@@+/**+ * Mobile model-picker row layout contract.+ *+ * React Native components cannot load in the Node Vitest environment, so this test locks the+ * source structure that keeps secondary metadata from consuming the model-name line.+ */+import { readFileSync } from 'node:fs';+import { resolve } from 'node:path';+import { describe, expect, it } from 'vitest';++const source = readFileSync(+ resolve(process.cwd(), 'src/session/MobileModelPickerList.tsx'),+ 'utf8',+).replace(/\s+/g, ' ');++describe('MobileModelPickerList compact rows', () => {+ it('gives provider-aware model names a dedicated primary line', () => {+ const modelName = source.indexOf('{row.model.displayName}');+ const metadata = source.indexOf(+ '{isSubscription || rowEffort || fastOn ? (',+ modelName,+ );++ expect(modelName).toBeGreaterThan(-1);+ expect(metadata).toBeGreaterThan(modelName);+ expect(source.slice(modelName, metadata)).toContain('</View>');+ });++ it('keeps subscription, effort and Fast in the secondary line', () => {+ expect(source).toContain('<View style={styles.optionMetaRow}>');+ expect(source).toMatch(+ /\{t\(["']models\.picker\.subscriptionBadgeCompact["']\)\}/,+ );+ expect(source).toContain('{compactEffortLabelFor(');+ expect(source).toContain('{fastOn ? (');++ expect(source.match(/accessibilityLabel=\{rowAccessibilityLabel\}/g)).toHaveLength(2);+ });++ it('uses the same primary and secondary hierarchy for flat fallback rows', () => {+ const modelName = source.indexOf('{option.label}');+ const metadata = source.indexOf(+ '{rowEffort || (fastEditable && selected && selectedFastMode) ? (',+ modelName,+ );++ expect(modelName).toBeGreaterThan(-1);+ expect(metadata).toBeGreaterThan(modelName);+ expect(source.slice(modelName, metadata)).toContain('</View>');+ });+});diff --cc apps/mobile/src/__tests__/modelPickerRows.test.tsindex cf64100641,dabf5ace3c..a7d9c567c7--- a/apps/mobile/src/__tests__/modelPickerRows.test.ts+++ b/apps/mobile/src/__tests__/modelPickerRows.test.ts@@@ -16,6 -15,6 +16,7 @@@ importeffortLabelFor,formatContextWindow,formatPriceLine,++ modelRowAccessibilityLabel,providerDisplayTitle,rowEffortOf,rowFastEditable,@@@ -113,34 -106,6 +114,98 @@@ describe('effortLabelFor —— 五级�});});+describe('compactEffortLabelFor —— 英文列表短码', () => {+ it('英文按稳定 effort id 显示 2–3 字母,非英文仍用本地化全称', async () => {+ const previousLanguage = i18n.language;+ try {+ await i18n.changeLanguage('en');+ expect(effortLabelFor({}, 'xhigh', capabilities)).toBe('Extra High');+ expect(+ compactEffortLabelFor({ effortDisplayNames: { xhigh: '特高' } }, 'xhigh', capabilities),+ ).toBe('XHi');+ expect(compactEffortLabelFor({}, 'minimal', capabilities)).toBe('Min');+ expect(compactEffortLabelFor({}, 'low', capabilities)).toBe('Lo');+ expect(compactEffortLabelFor({}, 'medium', capabilities)).toBe('Mid');+ expect(compactEffortLabelFor({}, 'high', capabilities)).toBe('Hi');+ expect(compactEffortLabelFor({}, 'ultra', capabilities)).toBe('Ult');+ expect(compactEffortLabelFor({}, 'max', capabilities)).toBe('Max');++ expect(++ compactEffortLabelFor(++ { effortDisplayNames: { 'adaptive-fast': 'Adaptive Fast' } },++ 'adaptive-fast',++ capabilities,++ ),++ ).toBe('Adaptive Fast');++ expect(++ compactEffortLabelFor({}, 'adaptive-safe', {++ ...capabilities,++ effortLevels: [{ id: 'adaptive-safe', label: 'Adaptive Safe' }],++ }),++ ).toBe('Adaptive Safe');++ await i18n.changeLanguage('zh-CN');+ expect(compactEffortLabelFor({}, 'high', null)).toBe('高');+ await i18n.changeLanguage('ja');+ expect(compactEffortLabelFor({}, 'ultra', null)).toBe('究極');+ await i18n.changeLanguage('ko');+ expect(compactEffortLabelFor({}, 'medium', null)).toBe('보통');+ } finally {+ await i18n.changeLanguage(previousLanguage);+ }+ });+});+++describe('modelRowAccessibilityLabel —— 父行保留完整元信息', () => {++ it('无元信息时只读基础选择动作', () => {++ expect(modelRowAccessibilityLabel({ baseLabel: 'Select Luna' })).toBe('Select Luna');++ });++++ it.each([++ ['en', 'Select Luna from OpenAI', 'Subscription', 'Reasoning effort Extra High', 'Fast Mode'],++ ['zh-CN', '选择来源 OpenAI 的模型 Luna', '订阅', '推理强度 超高', '快速模式'],++ ['zh-TW', '選擇來源 OpenAI 的模型 Luna', '訂閱', '推理強度 超高', '快速模式'],++ ['ja', 'OpenAI のモデル Luna を選択', 'サブスク', '推論強度 超高', '高速モード'],++ ['ko', 'OpenAI의 모델 Luna 선택', '구독', '추론 강도 초고', '빠른 모드'],++ ])('在 %s 下把订阅、完整 effort 和 Fast 纳入行级名称', async (++ language,++ expectedBase,++ expectedSubscription,++ expectedEffort,++ expectedFast,++ ) => {++ const previousLanguage = i18n.language;++ try {++ await i18n.changeLanguage(language);++ const baseLabel = i18n.t('models.picker.selectProviderModelAccessibility', {++ provider: 'OpenAI',++ model: 'Luna',++ });++ const subscriptionLabel = i18n.t('models.picker.subscriptionBadge');++ const effortLabel = i18n.t('models.options.reasoningEffortAccessibility', {++ label: i18n.t('models.options.effortLevels.xhigh'),++ });++ const fastLabel = i18n.t('models.options.fastMode');++++ expect([baseLabel, subscriptionLabel, effortLabel, fastLabel]).toEqual([++ expectedBase,++ expectedSubscription,++ expectedEffort,++ expectedFast,++ ]);++ expect(++ modelRowAccessibilityLabel({++ baseLabel,++ subscriptionLabel,++ effortLabel,++ fastLabel,++ }),++ ).toBe([expectedBase, expectedSubscription, expectedEffort, expectedFast].join(', '));++ } finally {++ await i18n.changeLanguage(previousLanguage);++ }++ });++});++describe('rowEffortOf(桌面同口径:选中 live / 非选中记忆→默认)', () => {const model = { id: 'gpt-5.5', efforts: ['low', 'medium', 'high'], defaultEffort: 'medium' };diff --cc apps/mobile/src/session/MobileModelPickerList.tsxindex 7db378e56e,1ec23897e1..ed3ab068ad--- a/apps/mobile/src/session/MobileModelPickerList.tsx+++ b/apps/mobile/src/session/MobileModelPickerList.tsx@@@ -30,8 -30,7 +30,9 @@@ import { useSessionModelMirrorVersionimport {budgetDisabledHint,budgetRowDisabled,+ compactEffortLabelFor,effortLabelFor,++ modelRowAccessibilityLabel,rowEffortOf,rowFastEditable,rowFastOn,@@@ -232,6 -225,6 +233,20 @@@ export function MobileModelPickerList(fastEditable,memory: modelMemory,});++ const fullEffortLabel = rowEffort++ ? effortLabelFor(row.model, rowEffort, capabilities ?? null)++ : null;++ const rowAccessibilityLabel = modelRowAccessibilityLabel({++ baseLabel: t('models.picker.selectProviderModelAccessibility', {++ provider: row.provider.name,++ model: row.model.displayName,++ }),++ subscriptionLabel: isSubscription ? t('models.picker.subscriptionBadge') : null,++ effortLabel: fullEffortLabel++ ? t('models.options.reasoningEffortAccessibility', { label: fullEffortLabel })++ : null,++ fastLabel: fastOn ? t('models.options.fastMode') : null,++ });// 行内配置入口:置灰行不给;有 effort 档或 fast 可编辑才有意义;非选中行还要有记忆可写// (无记忆场景写不进任何地方 → 不显示,避免假开关)。const hasOptions =@@@ -242,10 -235,10 +257,7 @@@(selected || !!modelMemory);return (<Pressable-- accessibilityLabel={t('models.picker.selectProviderModelAccessibility', {-- provider: row.provider.name,-- model: row.model.displayName,-- })}++ accessibilityLabel={rowAccessibilityLabel}accessibilityRole="button"accessibilityState={{ selected, disabled: disabled || rowDisabled }}disabled={disabled || rowDisabled}@@@ -275,38 -268,20 +287,34 @@@<View style={styles.optionMain}><View style={styles.optionTitleRow}><Text numberOfLines={1} style={styles.optionText}>{row.model.displayName}</Text>- {isSubscription ? (- <View style={styles.subscriptionBadge}>- <Text style={styles.subscriptionBadgeText}>{t('models.picker.subscriptionBadge')}</Text>- </View>- ) : null}- {rowEffort ? (- <Text numberOfLines={1} style={styles.effortLabel}>- {effortLabelFor(row.model, rowEffort, capabilities ?? null)}- </Text>- ) : null}- {fastOn ? (- <Zap color={colors.textTertiary} size={iconSize.sm} strokeWidth={iconStroke.regular} />- ) : null}</View>+ {isSubscription || rowEffort || fastOn ? (+ <View style={styles.optionMetaRow}>+ {isSubscription ? (+ <View style={styles.subscriptionBadge}>+ <Text+ accessibilityLabel={t('models.picker.subscriptionBadge')}+ numberOfLines={1}+ style={styles.subscriptionBadgeText}+ >+ {t('models.picker.subscriptionBadgeCompact')}+ </Text>+ </View>+ ) : null}+ {rowEffort ? (+ <Text- accessibilityLabel={effortLabelFor(- row.model,- rowEffort,- capabilities ?? null,- )}++ accessibilityLabel={fullEffortLabel ?? undefined}+ numberOfLines={1}+ style={styles.effortLabel}+ >+ {compactEffortLabelFor(row.model, rowEffort, capabilities ?? null)}+ </Text>+ ) : null}+ {fastOn ? (+ <Zap color={colors.textTertiary} size={iconSize.sm} strokeWidth={iconStroke.regular} />+ ) : null}+ </View>+ ) : null}{rowDisabled ? (<Text numberOfLines={1} style={styles.disabledHint}>{budgetDisabledHint()}</Text>) : null}@@@ -355,9 -330,9 +363,20 @@@agentKind: agentKind ?? null,}): null;++ const fullEffortLabel = rowEffort++ ? effortLabelFor(option, rowEffort, capabilities ?? null)++ : null;++ const rowAccessibilityLabel = modelRowAccessibilityLabel({++ baseLabel: t('models.picker.selectModelAccessibility', { model: option.label }),++ effortLabel: fullEffortLabel++ ? t('models.options.reasoningEffortAccessibility', { label: fullEffortLabel })++ : null,++ fastLabel:++ fastEditable && selected && selectedFastMode ? t('models.options.fastMode') : null,++ });return (<Pressable-- accessibilityLabel={t('models.picker.selectModelAccessibility', { model: option.label })}++ accessibilityLabel={rowAccessibilityLabel}accessibilityRole="button"accessibilityState={{ selected, disabled }}disabled={disabled}@@@ -379,27 -354,15 +398,23 @@@<View style={styles.optionMain}><View style={styles.optionTitleRow}><Text numberOfLines={1} style={styles.optionText}>{option.label}</Text>- {rowEffort ? (- <Text numberOfLines={1} style={styles.effortLabel}>- {effortLabelFor(option, rowEffort, capabilities ?? null)}- </Text>- ) : null}- {fastEditable && selected && selectedFastMode ? (- <Zap color={colors.textTertiary} size={iconSize.sm} strokeWidth={iconStroke.regular} />- ) : null}</View>+ {rowEffort || (fastEditable && selected && selectedFastMode) ? (+ <View style={styles.optionMetaRow}>+ {rowEffort ? (+ <Text- accessibilityLabel={effortLabelFor(- option,- rowEffort,- capabilities ?? null,- )}++ accessibilityLabel={fullEffortLabel ?? undefined}+ numberOfLines={1}+ style={styles.effortLabel}+ >+ {compactEffortLabelFor(option, rowEffort, capabilities ?? null)}+ </Text>+ ) : null}+ {fastEditable && selected && selectedFastMode ? (+ <Zap color={colors.textTertiary} size={iconSize.sm} strokeWidth={iconStroke.regular} />+ ) : null}+ </View>+ ) : null}</View>{selected ? <Check color={colors.textPrimary} size={iconSize.lg} strokeWidth={iconStroke.medium} /> : null}{hasOptions ? (diff --cc apps/mobile/src/session/modelPickerRows.tsindex 331fa35c55,e8bdae1a41..e986cd22fe--- a/apps/mobile/src/session/modelPickerRows.ts+++ b/apps/mobile/src/session/modelPickerRows.ts@@@ -113,23 -109,6 +113,36 @@@ export function effortLabelForreturn level?.label ?? MOBILE_EFFORT_LABELS[effort] ?? effort;}+/**+ * 一级列表使用稳定 effort id 生成英文短码,避免被控端下发的长文案或混合语言挤占模型名。+ * 非英文界面继续使用完整本地化标签;完整英文名称仍由模型选项页展示。+ */+export function compactEffortLabelFor(+ model: Pick<PickerRowModel, 'effortDisplayNames'>,+ effort: string,+ capabilities: MobileAgentCapabilities | null,+): string {++ const fullLabel = effortLabelFor(model, effort, capabilities);+ const language = (i18n.resolvedLanguage ?? i18n.language).toLowerCase();+ if (!language.startsWith('en')) {- return effortLabelFor(model, effort, capabilities);++ return fullLabel;+ }+- return compactEnglishEffortLabel(effort);++ return compactEnglishEffortLabel(effort, fullLabel);++}++++/** 父 Pressable 的完整无障碍名称:基础选择动作 + 当前可见元信息的完整语义。 */++export function modelRowAccessibilityLabel(args: {++ baseLabel: string;++ subscriptionLabel?: string | null;++ effortLabel?: string | null;++ fastLabel?: string | null;++}): string {++ return [args.baseLabel, args.subscriptionLabel, args.effortLabel, args.fastLabel]++ .filter((label): label is string => !!label)++ .join(', ');+}+/** 选中行判定:分段模式比 (providerId, modelId) 双键;flat(providerId null)只比模型 id。 */export function isSelectedRow(args: {providerId: string | null;diff --cc packages/maker-shared/src/__tests__/agentCapabilities.test.tsindex 29ffe6d7ab,030be5dcdf..780eaf7afe--- a/packages/maker-shared/src/__tests__/agentCapabilities.test.ts+++ b/packages/maker-shared/src/__tests__/agentCapabilities.test.ts@@@ -45,15 -44,6 +45,19 @@@ const desktopCapabilitiesPayload =};describe('agent capabilities shared model', () => {+ it('uses the same 2–3 letter English effort codes on desktop and mobile', () => {+ expect(+ ['minimal', 'low', 'medium', 'high', 'xhigh', 'ultra', 'max'].map(+ compactEnglishEffortLabel,+ ),+ ).toEqual(['Min', 'Lo', 'Mid', 'Hi', 'XHi', 'Ult', 'Max']);+ expect(compactEnglishEffortLabel('extra-high')).toBe('XHi');++ expect(compactEnglishEffortLabel('adaptive-fast', 'Adaptive Fast')).toBe('Adaptive Fast');++ expect(compactEnglishEffortLabel('adaptive-safe', 'Adaptive Safe')).toBe('Adaptive Safe');++ expect(compactEnglishEffortLabel('adaptive-fast')).toBe('adaptive-fast');++ expect(compactEnglishEffortLabel('adaptive-safe')).toBe('adaptive-safe');+ });+it('normalizes desktop capability payloads for runtime controls', () => {const capabilities = normalizeMobileAgentCapabilities(desktopCapabilitiesPayload);diff --cc packages/maker-shared/src/agentCapabilities.tsindex 1e6e904b96,617f40f7e3..9ea9e8b374--- a/packages/maker-shared/src/agentCapabilities.ts+++ b/packages/maker-shared/src/agentCapabilities.ts@@@ -87,42 -88,6 +87,37 @@@ export const MOBILE_EFFORT_LABELS: Recoultra: '极致',};+const ENGLISH_COMPACT_EFFORT_LABELS: Record<string, string> = {+ auto: 'Aut',+ balanced: 'Bal',+ default: 'Def',+ extrahigh: 'XHi',+ high: 'Hi',+ low: 'Lo',+ max: 'Max',+ maximum: 'Max',+ medium: 'Mid',+ minimal: 'Min',+ none: 'Off',+ off: 'Off',+ standard: 'Std',+ ultra: 'Ult',+ xhigh: 'XHi',+};+- /** Windows、macOS 与移动端模型选择器共用的英文 effort 短码。 */- export function compactEnglishEffortLabel(effort: string): string {++/**++ * Windows、macOS 与移动端模型选择器共用的英文 effort 短码。++ * 仅已知标准档位缩写;未知档位保留下发的完整显示名(没有显示名时保留完整 id),++ * 避免不同技术 id 被截成同一个不可区分的前三字符。++ */++export function compactEnglishEffortLabel(effort: string, displayName?: string): string {+ const normalizedEffort = effort.toLowerCase().replace(/[^a-z0-9]/g, '');+ const standardLabel = ENGLISH_COMPACT_EFFORT_LABELS[normalizedEffort];+ if (standardLabel) return standardLabel;+- const words = effort.match(/[a-z0-9]+/gi) ?? [];- if (words.length > 1) {- return words- .slice(0, 3)- .map((word) => word[0]?.toUpperCase() ?? '')- .join('');- }-- const word = words[0] ?? effort;- return `${word.slice(0, 1).toUpperCase()}${word.slice(1, 3).toLowerCase()}`;++ return displayName?.trim() || effort;+}+const FALLBACK_EFFORT_OPTIONS: MobileChoiceOption[] = [{ id: 'low', label: MOBILE_EFFORT_LABELS.low },{ id: 'medium', label: MOBILE_EFFORT_LABELS.medium },