Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(models): wrap settings model names and keep backups visible
xuzini-xznf76745c4101e
diff --git a/apps/desktop/scripts/fixtures/bot-model-settings/fixture.tsx b/apps/desktop/scripts/fixtures/bot-model-settings/fixture.tsxnew file mode 100644index 0000000000..77955b3ca3--- /dev/null+++ b/apps/desktop/scripts/fixtures/bot-model-settings/fixture.tsx@@ -0,0 +1,48 @@+import { useState } from 'react';+import { useTranslation } from 'react-i18next';+import { mountPage, subscription, ctx } from '../../ui-page/harness';+import { BotModelChainEditor } from '../../../src/renderer/features/bots/BotModelChainEditor';+import { BotTaskModelEditor } from '../../../src/renderer/features/bots/BotTaskModelEditor';+import type { BotModelRoute } from '../../../src/shared/botModelChain';+import { beginProvidersRefresh, commitProvidersSnapshot } from '../../../src/renderer/lib/providersSnapshotStore';+import { getDataOwnerGeneration } from '../../../src/renderer/contexts/dataOwnerGeneration';+import { BUNDLED_CATALOG, type ProviderView } from '@cindy/model-providers';++const model = { id: 'available-model', name: 'Gemini with a very long model display name',+ contextWindow: 200000, efforts: ['low', 'medium', 'high'], defaultEffort: 'high' };+const provider: ProviderView = { ...BUNDLED_CATALOG.providers.find(p => p.id === 'openai')!,+ connected: true, agents: ['codex'], access: { kind: 'subscription' }, models: { codex: [model] } };+const unknown: BotModelRoute = { harness: 'codex', model: 'google/gemini-4-argon', providerId: 'openai', effort: '', fastMode: false };++function Fixture() {+ const { t } = useTranslation();+ const primary = ctx.case === 'available' ? { ...unknown, model: model.id, effort: 'high' } : unknown;+ const [routes, setRoutes] = useState<BotModelRoute[]>([primary,+ ...Array.from({ length: ctx.case === 'four-backups' ? 4 : 1 }, (_, i) => ({ ...unknown,+ model: i ? `vendor/very-long-unbroken-model-identifier-${i}-abcdefghijklmnopqrstuvwxyz` : 'google/gemini-4-argon-backup' }))]);+ const [task, setTask] = useState<BotModelRoute | null>(ctx.case === 'inherited' ? null : { ...unknown, harness: 'pi' });+ return <main className="min-h-screen bg-[var(--surface)] p-4 text-[var(--text-primary)]">+ <div className="mx-auto w-full max-w-[448px]" data-model-settings-fixture>+ <BotModelChainEditor value={routes} onChange={setRoutes} label={t('bots.model.primary')}+ layout={ctx.case === 'global-settings' ? 'settings' : 'inline'}+ settingsRows={{ primaryLabel: t('bots.model.primary'), primaryHint: t('bots.modelChain.description') }} />+ <BotTaskModelEditor value={task} inheritedRoute={routes[0]} onChange={setTask} />+ </div>+ </main>;+}++void mountPage({+ host: () => {+ const owner = getDataOwnerGeneration();+ commitProvidersSnapshot(beginProvidersRefresh(), { dataOwnerId: owner.dataOwnerId,+ ownerGeneration: owner.generation, providers: [provider], providerOrder: ['openai'] });+ return { maker: {+ listAvailableAgents: async () => ['claude-code', 'codex', 'pi'],+ getCapabilities: async () => ({ availableModels: [{ ...model, displayName: model.name }],+ effortLevels: [], permissionModes: [{ id: 'auto', displayName: 'Auto' }],+ turnPermissionPolicy: { supported: { supported: true }, unsupportedPermissionModes: [] } }),+ onProvidersChanged: subscription('providers'),+ } };+ },+ render: () => <Fixture />,+});diff --git a/apps/desktop/scripts/fixtures/bot-model-settings/ui-page.mjs b/apps/desktop/scripts/fixtures/bot-model-settings/ui-page.mjsnew file mode 100644index 0000000000..f3a40be0cb--- /dev/null+++ b/apps/desktop/scripts/fixtures/bot-model-settings/ui-page.mjs@@ -0,0 +1,50 @@+import assert from 'node:assert/strict';++export default {+ name: 'bot-model-settings',+ entry: './fixture.tsx',+ viewport: { width: 440, height: 880 },+ real: 'BotModelChainEditor, BotTaskModelEditor, ModelRouteSelector, ModelSelector, themes and all translations',+ notCovered: 'Live catalog discovery, remote devices, persistence and model execution; fixture supplies providers and local component state',+ stubs: {+ 'src/renderer/hooks/useModelRouteDevices': 'export const useModelRouteDevices = () => ({ devices: undefined });',+ },+ cases: {+ default: { about: 'Unavailable primary, backup and task model; status belongs to the model' },+ available: { about: 'Long available name with reasoning effort; no unavailable status on this model' },+ 'four-backups': { about: 'Four visible backups with unbroken IDs and working reorder/remove controls' },+ inherited: { about: 'Task inherits primary, using the same complete-name presentation' },+ 'global-settings': { about: 'Global settings row uses the same wrapped picker' },+ },+ async ready(page) {+ await page.locator('[data-model-settings-fixture]').waitFor();+ },+ async check(page, ui) {+ const pickers = page.locator('[data-model-settings-fixture] button[aria-haspopup="listbox"]');+ const expected = ui.case === 'four-backups' ? 6 : 3;+ const clipped = await pickers.evaluateAll(buttons => buttons.flatMap(button =>+ [...button.querySelectorAll('span')].filter(span => span.textContent?.trim() &&+ (span.scrollWidth > span.clientWidth + 1 || span.scrollHeight > span.clientHeight + 1))+ .map(span => span.textContent)));+ assert.deepEqual(clipped, [], 'Model text must fit without ellipsis or clipping');+ assert.equal(await pickers.count(), expected, 'Backups are immediately visible');+ const status = await ui.t('settings.auxiliaryModels.unavailable');+ if (ui.case === 'available') {+ assert.equal(await pickers.first().getByText(status, { exact: true }).count(), 0);+ assert.ok(await pickers.first().getByText('Gemini with a very long model display name', { exact: true }).isVisible());+ } else {+ const first = pickers.first();+ assert.equal(await first.getByText(status, { exact: true }).count(), 1);+ const modelBox = await first.getByText('google/gemini-4-argon', { exact: true }).boundingBox();+ const statusBox = await first.getByText(status, { exact: true }).boundingBox();+ assert.ok(statusBox && modelBox && statusBox.y > modelBox.y, 'Status appears below model name');+ }+ if (ui.case === 'four-backups') {+ const add = page.getByRole('button', { name: await ui.t('bots.modelChain.add'), exact: true });+ assert.equal(await add.isDisabled(), true);+ await page.getByRole('button', { name: await ui.t('bots.modelChain.remove'), exact: true }).first().click();+ assert.equal(await pickers.count(), 5);+ assert.equal(await add.isEnabled(), true);+ }+ },+};diff --git a/apps/desktop/src/renderer/__tests__/unifiedModelPanelRendering.test.tsx b/apps/desktop/src/renderer/__tests__/unifiedModelPanelRendering.test.tsxindex eec6494108..77955af6d3 100644--- a/apps/desktop/src/renderer/__tests__/unifiedModelPanelRendering.test.tsx+++ b/apps/desktop/src/renderer/__tests__/unifiedModelPanelRendering.test.tsx@@ -4277,10 +4277,8 @@ it('teammate fallback exposes supported Harness choices and preserves the primarreturn <BotModelChainEditor value={routes} onChange={(next) => { change(next); setRoutes(next); }} />;}const view = render(<Editor />);- const details = view.container.querySelector('details')!;- details.open = true;- fireEvent(details, new Event('toggle'));- fireEvent.click(details.querySelector('button[aria-haspopup="listbox"]')!);+ const fallbacks = view.getByTestId('bot-model-fallbacks');+ fireEvent.click(fallbacks.querySelector('button[aria-haspopup="listbox"]')!);await screen.findByRole('listbox');const flyout = await openRowFlyout('GPT-5.6');const cc = flyout.querySelector('[data-engine-capsule="cc"]') as HTMLElement;diff --git a/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx b/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsxindex 9d6b499538..22cf56a728 100644--- a/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx+++ b/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx@@ -809,8 +809,8 @@ interface ModelSelectorProps {compactToolbar?: boolean;/** 极窄 composer 进一步隐藏模型文字,只保留模型图标和下拉箭头。 */ultraCompactToolbar?: boolean;- /** Trigger presentation: toolbar keeps the compact chat pill; field renders a settings input-like control. */- triggerVariant?: 'toolbar' | 'field';+ /** Toolbar/field stay compact; settings allows the complete model name to wrap. */+ triggerVariant?: 'toolbar' | 'field' | 'settings';/** CREATE AGENT 首页按 Figma 185:2724 使用独立私有 token。 */visualVariant?: 'default' | 'create-agent';/** 仅普通 composer 显式开启 chip → panel 容器形变;设置页/worker 等维持 Radix。 */@@ -878,6 +878,8 @@ interface ModelSelectorProps {* 供展示已持久化偏好的调用方给出诊断性文案,避免把「存过但当前不可用」显示成「没选过」。*/unknownModelLabel?: (modelId: string) => string;+ /** Optional separate status below an unknown model, retaining unknownModelLabel for accessible text. */+ unknownModelDescription?: string;/*** 可及名上下文前缀(如「模型 · chat」)。多实例同屏(IM 目录偏好逐行一个)时前置到* trigger 的 aria-label,行与行才能被读屏区分 —— 与 VendorSegmentedSwitcher.ariaLabel@@ -4037,6 +4039,7 @@ export function ModelSelector({reselectEmitsChange = false,selectedRowClickOpensConfiguration = false,unknownModelLabel,+ unknownModelDescription,ariaContext,currentProviderId,sourceDisconnected = false,@@ -4457,10 +4460,22 @@ export function ModelSelector({const ariaLabel = ariaContext ? `${ariaContext}:${accessibleLabel}` : accessibleLabel;const isBudget = isCodexGatewayWireModel(modelId);const isFieldTrigger = triggerVariant === 'field';+ const isSettingsTrigger = triggerVariant === 'settings';+ const modelDescription = isSettingsTrigger && unknownLabel && !localizedName &&+ !remoteModelLoading && !remoteModelLoadFailed && !fallbackOption?.active+ ? unknownModelDescription : undefined;+ const modelLabelContent = modelDescription ? (+ <>+ <span>{modelId}</span>+ <span className="block text-12 leading-5 text-[var(--model-trigger-meta)]">+ {modelDescription}+ </span>+ </>+ ) : displayLabel;const isCreateAgentVariant = visualVariant === 'create-agent';// compact 是 composer 容器宽度状态,不是 create-agent 的视觉私有状态。// 正常会话在侧栏 + 浏览器 split-pane 下也必须让长模型名承担收缩。- const isCompactToolbar = compactToolbar && !isFieldTrigger;+ const isCompactToolbar = compactToolbar && !isFieldTrigger && !isSettingsTrigger;const isUltraCompactToolbar = ultraCompactToolbar && isCompactToolbar;// ── composer pill 的引擎小标(model-selector-unified §1.1)─────────────────────// 传了 engineMarkVendor 就走新形态:harness 名字文本让位给尾部的一枚 mark,和深度档字@@ -4514,7 +4529,7 @@ export function ModelSelector({) : null;// 保留 useMorphPopover 作用域开关(仅 composer 工具条 opt-in;settings/CreateWorker 用 Radix 回退),// 但去掉 !isCreateAgentVariant —— 新建对话框工具条也走脱身上浮 morph,与会话内统一(2026-07-22)。- const morphEnabled = useMorphPopover && !isFieldTrigger;+ const morphEnabled = useMorphPopover && !isFieldTrigger && !isSettingsTrigger;const budgetGradientStyle: CSSProperties | undefined = isBudget? {background: 'var(--model-budget-gradient)',@@ -4548,9 +4563,12 @@ export function ModelSelector({'rounded-full',// 裸态工具条(2026-07-22 用户定稿):默认无框,hover 才浮现胶囊外框。// create-agent(新建对话框)与会话内共用同一套裸态,不再分叉 —— 静息/hover 逐字一致。- 'h-[30px] max-w-full shrink overflow-hidden px-2.5',+ 'max-w-full shrink px-2.5',+ isSettingsTrigger ? 'min-h-[30px] items-baseline py-1 text-left leading-5' : 'h-[30px] overflow-hidden',// 窄态工具条:钳制唯一可收缩的模型入口,给语音 / 发送固定动作留足空间。- isUltraCompactToolbar+ isSettingsTrigger+ ? 'min-w-0'+ : isUltraCompactToolbar? 'w-[64px] min-w-[64px]': isCompactToolbar? 'w-[148px] min-w-[72px]'@@ -4583,7 +4601,9 @@ export function ModelSelector({isCreateAgentVariant? 'text-[var(--create-agent-control-text)]': 'text-[var(--text-primary)]',- isUltraCompactToolbar+ isSettingsTrigger+ ? 'whitespace-normal [overflow-wrap:anywhere]'+ : isUltraCompactToolbar? 'hidden': isCompactToolbar? 'max-w-[108px] truncate'@@ -4613,7 +4633,9 @@ export function ModelSelector({<spanclassName={cn('min-w-0 font-normal text-[var(--text-primary)]',- isUltraCompactToolbar+ isSettingsTrigger+ ? 'whitespace-normal [overflow-wrap:anywhere]'+ : isUltraCompactToolbar? 'hidden': isCompactToolbar? 'max-w-[108px] truncate'@@ -4625,7 +4647,7 @@ export function ModelSelector({isCreateAgentVariant ? 'text-12' : dense ? 'text-12' : 'text-13',)}>- {displayLabel}+ {modelLabelContent}</span>{/* 来源断开是**来源**的事,引擎身份位照常保留(规格 §1.2:引擎可见性靠一致的结构位,不靠出错才显示)。 */}@@ -4694,7 +4716,9 @@ export function ModelSelector({<spanclassName={cn('min-w-0 font-normal',- isUltraCompactToolbar+ isSettingsTrigger+ ? 'whitespace-normal [overflow-wrap:anywhere]'+ : isUltraCompactToolbar? 'hidden': isCompactToolbar? 'max-w-[108px] truncate'@@ -4711,7 +4735,7 @@ export function ModelSelector({)}style={budgetGradientStyle}>- {displayLabel}+ {modelLabelContent}</span>{/* 引擎小标 + 深度 = pill 的收尾身份组(新形态,见 engineMarkVendor)。旧形态没有 mark,深度前保留「·」分隔;有 mark 时图标本身就是分隔,再加点@@ -4748,7 +4772,9 @@ export function ModelSelector({isCreateAgentVariant? 'text-[var(--create-agent-control-text)]': 'text-[var(--text-primary)]',- engineMarkOption+ isSettingsTrigger+ ? 'max-w-[40%] shrink-0 whitespace-normal [overflow-wrap:anywhere]'+ : engineMarkOption? isCompactToolbar? 'min-w-0 shrink truncate': 'shrink-0 whitespace-nowrap'diff --git a/apps/desktop/src/renderer/features/bots/BotModelChainEditor.tsx b/apps/desktop/src/renderer/features/bots/BotModelChainEditor.tsxindex edd219464f..73d48413e8 100644--- a/apps/desktop/src/renderer/features/bots/BotModelChainEditor.tsx+++ b/apps/desktop/src/renderer/features/bots/BotModelChainEditor.tsx@@ -69,7 +69,6 @@ export function BotModelChainEditor({}) {const { t } = useBotTranslation();const catalog = useDeviceProviders(deviceId);- const [expanded, setExpanded] = useState(false);const [pendingRoute, setPendingRoute] = useState<BotModelRoute | null>(null);const routes = value.slice(0, BOT_MODEL_CHAIN_MAX);// Picker content may be portaled outside a form's disabled fieldset.@@ -124,7 +123,7 @@ export function BotModelChainEditor({effort={route.effort}currentProviderId={route.providerId}agentIdentity={{ vendorKey: vendorFor(route.harness), state: 'current' }}- triggerVariant="toolbar"+ triggerVariant="settings"popoverSide="bottom"ariaContext={t('bots.modelChain.routeLabel', { index: index + 1 })}excludeSubscriptionDirect={remote && !deviceId}@@ -149,6 +148,7 @@ export function BotModelChainEditor({});}}unknownModelLabel={(model) => t('bots.modelUnavailable', { model })}+ unknownModelDescription={t('settings.auxiliaryModels.unavailable')}/>{deviceId && !route.agentDeviceId && route.providerId? (() => {@@ -169,8 +169,8 @@ export function BotModelChainEditor({const fallbackRows = routes.slice(1).map((route, fallbackIndex) => {const index = fallbackIndex + 1;return (- <div key={index} className="flex min-w-0 items-center gap-2">- <span className="w-4 shrink-0 text-11">{index}</span>+ <div key={index} className="flex min-w-0 items-start gap-2">+ <span className="w-4 shrink-0 pt-1 text-11 leading-5">{index}</span>{picker(route, index)}<div className="flex shrink-0 gap-1"><button@@ -208,7 +208,7 @@ export function BotModelChainEditor({});const pendingRow: ReactNode =pendingRoute && routes.length < BOT_MODEL_CHAIN_MAX ? (- <div className="flex min-w-0 items-center gap-2">+ <div className="flex min-w-0 items-start gap-2">{picker(pendingRoute, routes.length)}<Buttonvariant="secondary"@@ -235,14 +235,14 @@ export function BotModelChainEditor({const listItems = [...fallbackRows, ...(pendingRow ? [pendingRow] : [])];return (<div className="min-w-0" data-testid="bot-model-chain-editor">- <div className={cn(SETTINGS_ROW_CLASS, 'cindy-segmented-row')}>+ <div className={cn(SETTINGS_ROW_CLASS, 'cindy-segmented-row flex-wrap')}><div className="flex min-w-0 flex-col gap-1"><p className={SETTINGS_ROW_LABEL_CLASS} style={{ letterSpacing: '0.12px' }}>{settingsRows.primaryLabel}</p><p className={SETTINGS_ROW_HINT_CLASS}>{settingsRows.primaryHint}</p></div>- <div className="flex min-w-0 shrink-0 items-center gap-2">+ <div className="flex min-w-0 max-w-full items-start gap-2">{onRestoreDefault ? (<DefaultOverrideControlsisCustomized@@ -293,54 +293,52 @@ export function BotModelChainEditor({return (<div className="min-w-0" data-testid="bot-model-chain-editor">- <div className="flex min-w-0 items-center gap-3">+ <div className="flex min-w-0 items-start gap-3">{label ? (- <span className="shrink-0 text-12 text-[var(--text-secondary)]">{label}</span>+ <span className="shrink-0 pt-1 text-12 leading-5 text-[var(--text-secondary)]">{label}</span>) : null}{picker(primaryRoute, 0)}</div>- {allowFallbacks && <details+ {allowFallbacks && <divclassName="mt-1 text-12 text-[var(--text-tertiary)]"- onToggle={(event) => setExpanded(event.currentTarget.open)}+ data-testid="bot-model-fallbacks">- <summary className="cursor-pointer py-2">+ <p className="py-2">{t('bots.modelChain.options', { count: Math.max(0, routes.length - 1) })}- </summary>- {expanded ? (- <div className="space-y-2 pt-2">- {fallbackRows}- {pendingRow}+ </p>+ <div className="space-y-2 pt-2">+ {fallbackRows}+ {pendingRow}+ <Button+ variant="secondary"+ size="md"+ tone="quiet"+ compact+ type="button"+ disabled={addDisabled}+ onClick={add}+ >+ <Plus size={14} />+ {t('bots.modelChain.add')}+ </Button>+ {onRestoreDefault ? (<Buttonvariant="secondary"size="md"tone="quiet"compacttype="button"- disabled={addDisabled}- onClick={add}+ disabled={disabled}+ onClick={() => {+ if (!disabled) onRestoreDefault();+ }}+ className="ml-2">- <Plus size={14} />- {t('bots.modelChain.add')}+ {t('bots.model.restoreDefault')}</Button>- {onRestoreDefault ? (- <Button- variant="secondary"- size="md"- tone="quiet"- compact- type="button"- disabled={disabled}- onClick={() => {- if (!disabled) onRestoreDefault();- }}- className="ml-2"- >- {t('bots.model.restoreDefault')}- </Button>- ) : null}- </div>- ) : null}- </details>}+ ) : null}+ </div>+ </div>}</div>);}diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botModelChainEditor.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/botModelChainEditor.test.tsxindex 6713ffa897..9e1a59425e 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/botModelChainEditor.test.tsx+++ b/apps/desktop/src/renderer/features/bots/__tests__/botModelChainEditor.test.tsx@@ -98,17 +98,14 @@ describe('BotModelChainEditor', () => {const firstFallback = { ...primary, model: 'first-fallback' };const secondFallback = { ...primary, model: 'second-fallback' };- function expand(container: HTMLElement) {- const details = container.querySelector('details')!;- details.open = true;- fireEvent(details, new Event('toggle'));- return within(details);+ function fallbackList(container: HTMLElement) {+ return within(container.querySelector('[data-testid="bot-model-fallbacks"]')!);}- it('lists and numbers only fallbacks, and edits the second route without replacing the primary', () => {+ it('immediately lists and numbers only fallbacks, and edits the second route without replacing the primary', () => {const onChange = vi.fn();const view = render(<BotModelChainEditor value={[primary, firstFallback]} onChange={onChange} />);- const fallbacks = expand(view.container);+ const fallbacks = fallbackList(view.container);expect(screen.getAllByTestId('model-selector-primary-model')).toHaveLength(1);expect(fallbacks.queryByTestId('model-selector-primary-model')).toBeNull();@@ -129,7 +126,7 @@ describe('BotModelChainEditor', () => {it('reorders and removes fallbacks while keeping the primary in place', () => {const onChange = vi.fn();const view = render(<BotModelChainEditor value={[primary, firstFallback, secondFallback]} onChange={onChange} />);- const fallbacks = expand(view.container);+ const fallbacks = fallbackList(view.container);const up = fallbacks.getAllByLabelText('bots.modelChain.moveUp');expect((up[0] as HTMLButtonElement).disabled).toBe(true);fireEvent.click(up[0]!);@@ -151,7 +148,7 @@ describe('BotModelChainEditor', () => {it('shows no fallback rows for a primary-only chain and appends the first fallback', () => {const onChange = vi.fn();const view = render(<BotModelChainEditor value={[primary]} onChange={onChange} />);- const fallbacks = expand(view.container);+ const fallbacks = fallbackList(view.container);expect(fallbacks.getByText('bots.modelChain.options:{"count":0}')).toBeTruthy();expect(fallbacks.queryByTestId('model-selector-primary-model')).toBeNull();expect(fallbacks.queryByLabelText('bots.modelChain.remove')).toBeNull();@@ -186,7 +183,7 @@ describe('BotModelChainEditor', () => {vendorKey: 'pi',unifiedPanel: true,unifiedAgents: ['pi', 'claude-code'],- triggerVariant: 'toolbar',+ triggerVariant: 'settings',});});@@ -194,15 +191,12 @@ describe('BotModelChainEditor', () => {const route = { harness: 'codex' as const, model: 'saved-model', providerId: 'openai', effort: '', fastMode: false };const onChange = vi.fn();const restore = vi.fn();- const view = render(<BotModelChainEditor value={[route, { ...route, model: 'backup' }]} onChange={onChange} onRestoreDefault={restore} disabled />);+ render(<BotModelChainEditor value={[route, { ...route, model: 'backup' }]} onChange={onChange} onRestoreDefault={restore} disabled />);expect(modelSelectorProps.mock.lastCall?.[0].disabled).toBe(true);// Simulate callbacks from content portaled outside the disabled trigger.- fireEvent.click(screen.getByText('choose-official-codex-model'));- fireEvent.click(screen.getByText('set-high-effort'));- fireEvent.click(screen.getByText('enable-fast-mode'));- const details = view.container.querySelector('details')!;- details.open = true;- fireEvent(details, new Event('toggle'));+ fireEvent.click(within(screen.getByTestId('model-selector-saved-model')).getByText('choose-official-codex-model'));+ fireEvent.click(within(screen.getByTestId('model-selector-saved-model')).getByText('set-high-effort'));+ fireEvent.click(within(screen.getByTestId('model-selector-saved-model')).getByText('enable-fast-mode'));for (const label of ['bots.modelChain.moveUp', 'bots.modelChain.moveDown', 'bots.modelChain.remove']) {for (const button of screen.getAllByLabelText(label)) {expect((button as HTMLButtonElement).disabled).toBe(true);@@ -226,7 +220,7 @@ describe('BotModelChainEditor', () => {roster.availableVendors = new Set();roster.loaded = false;const onChange = vi.fn();- const view = render(<BotModelChainEditor value={[]} onChange={onChange} />);+ render(<BotModelChainEditor value={[]} onChange={onChange} />);const props = modelSelectorProps.mock.lastCall?.[0];expect(props).toMatchObject({ disabled: false, unifiedAgents: ['pi', 'codex', 'claude-code'],remoteAgent: { devices: [{ deviceId: 'share:one', name: 'Shared account' }] } });@@ -235,9 +229,6 @@ describe('BotModelChainEditor', () => {expect(onChange).toHaveBeenLastCalledWith([{ harness: 'codex', model: 'remote-model', providerId: 'openai',effort: 'medium', fastMode: false, agentDeviceId: 'share:one' }]);onChange.mockClear();- const details = view.container.querySelector('details')!;- details.open = true;- fireEvent(details, new Event('toggle'));fireEvent.click(screen.getByText('bots.modelChain.add'));expect(onChange).not.toHaveBeenCalled();});@@ -248,9 +239,9 @@ describe('BotModelChainEditor', () => {const fallback = { ...route, model: 'fallback-model' };const onChange = vi.fn();render(<BotModelChainEditor value={[route, fallback]} onChange={onChange} />);- fireEvent.click(screen.getByText('set-high-effort'));+ fireEvent.click(within(screen.getByTestId('model-selector-gpt-5.6-sol')).getByText('set-high-effort'));expect(onChange).toHaveBeenLastCalledWith([{ ...route, effort: 'high' }, fallback]);- fireEvent.click(screen.getByText('enable-fast-mode'));+ fireEvent.click(within(screen.getByTestId('model-selector-gpt-5.6-sol')).getByText('enable-fast-mode'));expect(onChange).toHaveBeenLastCalledWith([{ ...route, fastMode: true }, fallback]);expect(modelSelectorProps.mock.calls[0]?.[0].unifiedSelectionPolicy).toBeUndefined();});@@ -272,7 +263,7 @@ describe('BotModelChainEditor', () => {fireEvent.click(screen.getByText('choose-official-claude-model'));expect(onChange).toHaveBeenLastCalledWith([expect.objectContaining({ harness: 'claude', providerId: 'anthropic' })]);- const fallbacks = expand(view.container);+ const fallbacks = fallbackList(view.container);fireEvent.click(fallbacks.getByText('bots.modelChain.add'));onChange.mockClear();fireEvent.click(fallbacks.getByText('choose-official-codex-model'));@@ -293,7 +284,7 @@ describe('BotModelChainEditor', () => {const onChange = vi.fn();const view = render(<BotModelChainEditor deviceId="remote-host" value={[]} onChange={onChange} />);expect(modelSelectorProps.mock.lastCall?.[0].unifiedAgents).toEqual(['pi', 'codex', 'claude-code']);- expect((expand(view.container).getByText('bots.modelChain.add') as HTMLButtonElement).disabled).toBe(false);+ expect((fallbackList(view.container).getByText('bots.modelChain.add') as HTMLButtonElement).disabled).toBe(false);fireEvent.click(screen.getByText('choose-official-codex-model'));expect(onChange).toHaveBeenCalledWith([expect.objectContaining({ harness: 'codex' })]);});@@ -307,7 +298,7 @@ describe('BotModelChainEditor', () => {fireEvent.click(screen.getByText('choose-official-codex-model'));fireEvent.click(screen.getByText('set-high-effort'));fireEvent.click(screen.getByText('enable-fast-mode'));- fireEvent.click(expand(view.container).getByText('bots.modelChain.add'));+ fireEvent.click(fallbackList(view.container).getByText('bots.modelChain.add'));expect(onChange).not.toHaveBeenCalled();});@@ -376,24 +367,19 @@ it('allows explicitly choosing a backup when no valid default is available', ()defaultModel.model = '';const primary = { harness: 'codex' as const, model: 'primary-model', providerId: 'openai', effort: 'medium', fastMode: false };const change = vi.fn();- const view = render(<BotModelChainEditor value={[primary]} onChange={change} />);- const details = view.container.querySelector('details')!;- details.open = true;- fireEvent(details, new Event('toggle'));+ render(<BotModelChainEditor value={[primary]} onChange={change} />);fireEvent.click(screen.getByText('bots.modelChain.add'));expect(change).not.toHaveBeenCalled();- fireEvent.click(within(details).getByRole('button', { name: 'choose-official-codex-model' }));+ fireEvent.click(within(screen.getByTestId('bot-model-fallbacks')).getByRole('button', { name: 'choose-official-codex-model' }));expect(change).toHaveBeenLastCalledWith([primary, { harness: 'codex', model: 'gpt-5.6-sol', providerId: 'openai', effort: 'medium', fastMode: true }]);});it('uses the selected device catalog without SSH subscription exclusions or local default fallbacks', () => {const change = vi.fn();- const view = render(<BotModelChainEditor deviceId="remote-host" value={[]} onChange={change} />);+ render(<BotModelChainEditor deviceId="remote-host" value={[]} onChange={change} />);expect(modelSelectorProps.mock.lastCall?.[0]).toMatchObject({ deviceId: 'remote-host', excludeSubscriptionDirect: false, excludeChatBridgedCodex: false });- const details = view.container.querySelector('details')!;- details.open = true; fireEvent(details, new Event('toggle'));fireEvent.click(screen.getByText('bots.modelChain.add'));expect(change).not.toHaveBeenCalled();- fireEvent.click(within(details).getByRole('button', { name: 'choose-official-codex-model' }));+ fireEvent.click(within(screen.getByTestId('bot-model-fallbacks')).getByRole('button', { name: 'choose-official-codex-model' }));expect(change).toHaveBeenCalledWith([expect.objectContaining({ providerId: 'openai', harness: 'codex' })]);});diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botSettings.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/botSettings.test.tsxindex 31d01fbe66..599fde90df 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/botSettings.test.tsx+++ b/apps/desktop/src/renderer/features/bots/__tests__/botSettings.test.tsx@@ -631,9 +631,6 @@ describe('Bot settings unified autosave', () => {vi.useFakeTimers();const route = capabilities().modelChain[0]!;const view = renderSettings({ capabilities: capabilities({ modelChainOverride: [route] }) });- const details = view.container.querySelector('[data-testid="bot-model-chain-editor"] details')!;- (details as HTMLDetailsElement).open = true;- fireEvent(details, new Event('toggle'));fireEvent.click(screen.getByText('bots.model.restoreDefault'));await act(async () => { await vi.advanceTimersByTimeAsync(1600); });expect(mocks.updateBotProfile.mock.lastCall?.[1]).toMatchObject({diff --git a/apps/mobile/src/__tests__/CompanionModelChain.test.tsx b/apps/mobile/src/__tests__/CompanionModelChain.test.tsxindex 605d7d78d9..46965ae990 100644--- a/apps/mobile/src/__tests__/CompanionModelChain.test.tsx+++ b/apps/mobile/src/__tests__/CompanionModelChain.test.tsx@@ -128,19 +128,14 @@ it("shows the selected remote account and catalog model name without changing itexpect(node.textContent).not.toContain("openai:second");expect(h.change).not.toHaveBeenCalled();});-it("keeps the primary first and reorders separate same-model backup accounts inside the folded chain", async () => {+it("keeps the primary first and reorders separate same-model backup accounts without expanding the chain", async () => {const third = { ...route, providerId: "openai:third" };h.catalog.providers.push(provider("openai:third", "[email protected]"));await render("remote-mac", [{ ...route, providerId: "openai" }, route, third]);const moves = () => node.querySelectorAll('[aria-label="devices.companionProfile.moveModelUp"]');const removes = () => node.querySelectorAll('[aria-label="devices.companionProfile.removeModel"]');- // Folded: only the primary shows, and it can be neither moved nor removed.+ // Backups are visible immediately; the primary still cannot be moved or removed.expect(node.textContent).toContain("devices.companionProfile.backupModels");- expect(node.textContent).not.toContain("[email protected]");- expect(moves()).toHaveLength(0);- expect(removes()).toHaveLength(0);- const toggle = [...node.querySelectorAll('button')].find(button => button.textContent === 'devices.companionProfile.backupModels')!;- await act(async () => toggle.click());expect(node.textContent).toContain("[email protected]");// Backup 1 cannot move above the primary; backup 2 moves above backup 1.expect(moves()).toHaveLength(1);diff --git a/apps/mobile/src/session/CompanionModelChain.tsx b/apps/mobile/src/session/CompanionModelChain.tsxindex 768ca7830b..10ba6c9e9e 100644--- a/apps/mobile/src/session/CompanionModelChain.tsx+++ b/apps/mobile/src/session/CompanionModelChain.tsx@@ -3,9 +3,8 @@ import { findCatalogModel } from '@cindy/model-providers';import { buildMobileModelSections } from './providerModelSections';import { mobileProviderAccountTitle } from './mobileModelRowPresentation';import { iconSize, lineHeight } from '@/theme';-import { useState } from 'react';import { Pressable, StyleSheet, View } from 'react-native';-import { ChevronDown, ChevronRight, ChevronUp, MinusCircle, Plus, ArrowUp } from 'lucide-react-native';+import { ChevronRight, MinusCircle, Plus, ArrowUp } from 'lucide-react-native';import { useTranslation } from 'react-i18next';import { Text } from '@/components/AppText';import { useDeviceProviders } from '@/device-link/useDeviceProviders';@@ -39,7 +38,6 @@ export function CompanionModelChain({ deviceId, values, onChange, onPick, disablcontrolledDeviceId: deviceId, keepDeviceIds: chain.flatMap(route => route.agentDeviceId ? [route.agentDeviceId] : []), keepOnly: true });const following = values.followsDefault === true;const update = (chain: CompanionModelRoute[]) => onChange({ ...values, modelChain: serializeModelRoutes(chain) });- const [showBackups, setShowBackups] = useState(false);const routeRow = (route: CompanionModelRoute, index: number) => {const agent = route.harness === 'claude' ? 'claude-code' : route.harness;const remote = route.agentDeviceId ? routeCatalogs.find(item => item.deviceId === route.agentDeviceId) : undefined;@@ -63,12 +61,10 @@ export function CompanionModelChain({ deviceId, values, onChange, onPick, disabl<View style={styles.row}><Text style={{ ...styles.title, color: colors.textPrimary, flex: 1 }}>{inheritanceLabel ?? t('devices.companionProfile.modelFollowsDefault')}</Text><NativeSwitch accessibilityLabel={inheritanceLabel ?? t('devices.companionProfile.modelFollowsDefault')} value={following} disabled={disabled} onValueChange={value => onChange({ ...values, followsDefault: value })} seedColor={colors.inputCaret} /></View>{chain.length ? routeRow(chain[0], 0) : addRow}{chain.length && !single ? <>- {/* The backup chain stays folded inside this editor, as on Desktop. */}- <Pressable accessibilityRole="button" accessibilityState={{ expanded: showBackups }} onPress={() => setShowBackups(value => !value)} style={styles.row} testID="companionModels.backups">+ <View style={styles.row} testID="companionModels.backups"><Text style={{ color: colors.textSecondary, fontSize: typeScale.footnote, lineHeight: lineHeight.caption, flex: 1 }}>{t('devices.companionProfile.backupModels', { count: chain.length - 1 })}</Text>- {showBackups ? <ChevronUp size={iconSize.md} color={colors.textSecondary} /> : <ChevronDown size={iconSize.md} color={colors.textSecondary} />}- </Pressable>- {showBackups ? <>{chain.slice(1).map((route, offset) => routeRow(route, offset + 1))}{addRow}</> : null}+ </View>+ {chain.slice(1).map((route, offset) => routeRow(route, offset + 1))}{addRow}</> : null}</View>;}