Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
refactor(desktop): 「通用」页各节改用统一设置行
kirozeng60ed6e81e951
diff --git a/apps/desktop/src/renderer/components/settings/AgentResourceSection.tsx b/apps/desktop/src/renderer/components/settings/AgentResourceSection.tsxindex 75cf717c7b..1c33710589 100644--- a/apps/desktop/src/renderer/components/settings/AgentResourceSection.tsx+++ b/apps/desktop/src/renderer/components/settings/AgentResourceSection.tsx@@ -17,6 +17,13 @@ import { cn } from '@/lib/utils';import { toast } from '@/lib/toast';import { DefaultOverrideControls } from './DefaultOverrideControls';import { SettingsTextInput } from './SettingsTextInput';+import {+ SETTINGS_CARD_CLASS,+ SETTINGS_ROW_CLASS,+ SETTINGS_ROW_DIVIDER_CLASS,+ SETTINGS_ROW_HINT_CLASS,+ SETTINGS_ROW_LABEL_CLASS,+} from './settingsRowClasses';type Wire = AgentResourceSettingsWire;type SettingKey = 'maxConcurrentCommands' | 'processPriority' | 'capToolchainThreads';@@ -30,17 +37,12 @@ const MAX_CONCURRENT_CAP = 64;const PRESET_HINT_KEYS = ['full', 'balanced', 'background', 'custom'] as const;/** 带分割线的多行卡片:卡片自身不留内边距,由每行 `px-4 py-4` 承担(房规见 SubagentModelSection 卡 2)。 */-const CARD_CLASS = cn(- 'flex flex-col rounded-xl',- 'bg-[var(--settings-theme-card-bg)]',- 'border border-[var(--settings-theme-card-border)]',-);+const CARD_CLASS = SETTINGS_CARD_CLASS;/** 卡片内一行:左侧标签 + 说明,右侧控件相对整块垂直居中(设置页各 section 通用版式)。 */-const ROW_CLASS = 'flex items-center justify-between gap-3 px-4 py-4';-const ROW_LABEL_CLASS = 'text-13 font-medium text-[var(--settings-section-sublabel)]';-const ROW_HINT_CLASS = 'text-12 leading-[1.4] text-[var(--settings-section-sublabel)] opacity-70';-/** 行间分割线:左右缩进与行内边距对齐。 */-const DIVIDER_CLASS = 'mx-4 h-px bg-[var(--settings-theme-card-border)]';+const ROW_CLASS = SETTINGS_ROW_CLASS;+const ROW_LABEL_CLASS = SETTINGS_ROW_LABEL_CLASS;+const ROW_HINT_CLASS = SETTINGS_ROW_HINT_CLASS;+const DIVIDER_CLASS = SETTINGS_ROW_DIVIDER_CLASS;/** 数字输入复用标准 Input md 档,设置封装保留旧局部主题覆盖,原生步进器不自绘。 */diff --git a/apps/desktop/src/renderer/components/settings/BetaChannelCell.tsx b/apps/desktop/src/renderer/components/settings/BetaChannelCell.tsxindex 9ea1da7fa2..6e4eeb35cc 100644--- a/apps/desktop/src/renderer/components/settings/BetaChannelCell.tsx+++ b/apps/desktop/src/renderer/components/settings/BetaChannelCell.tsx@@ -13,7 +13,6 @@ import { useCallback, useState } from 'react';import { useTranslation } from 'react-i18next';import { Switch } from '@/components/ui/switch';-import { cn } from '@/lib/utils';import { toast } from '@/lib/toast';import { useConfirmDialog } from '@/components/ui/confirm-dialog-provider';import { useBetaChannelSettings } from '@/hooks/useBetaChannelSettings';@@ -82,13 +81,7 @@ export function BetaChannelCell() {);return (- <div- className={cn(- 'flex flex-col gap-3 rounded-xl p-5',- 'bg-[var(--settings-theme-card-bg)]',- 'border border-[var(--settings-theme-card-border)]',- )}- >+ <div className="flex flex-col gap-3 px-4 py-4"><div className="flex items-start justify-between gap-3"><div className="flex min-w-0 flex-col gap-1"><pdiff --git a/apps/desktop/src/renderer/components/settings/CollaborationSection.tsx b/apps/desktop/src/renderer/components/settings/CollaborationSection.tsxindex d09974008c..02b6d742b3 100644--- a/apps/desktop/src/renderer/components/settings/CollaborationSection.tsx+++ b/apps/desktop/src/renderer/components/settings/CollaborationSection.tsx@@ -4,24 +4,24 @@import { useState, useEffect } from 'react';import { useTranslation } from 'react-i18next';-import { cn } from '@/lib/utils';import { toast } from '@/lib/toast';import { DefaultOverrideControls } from './DefaultOverrideControls';import { SettingsTextInput } from './SettingsTextInput';+import {+ SETTINGS_CARD_CLASS,+ SETTINGS_ROW_CLASS,+ SETTINGS_ROW_DIVIDER_CLASS,+ SETTINGS_ROW_HINT_CLASS,+ SETTINGS_ROW_LABEL_CLASS,+} from './settingsRowClasses';/** 带分割线的多行卡片:卡片自身不留内边距,由每行 `px-4 py-4` 承担(房规见 SubagentModelSection 卡 2)。 */-const CARD_CLASS = cn(- 'flex flex-col rounded-xl',- 'bg-[var(--settings-theme-card-bg)]',- 'border border-[var(--settings-theme-card-border)]',-);+const CARD_CLASS = SETTINGS_CARD_CLASS;/** 卡片内一行:左侧标签 + 说明,右侧控件相对整块垂直居中。 */-const ROW_CLASS = 'flex items-center justify-between gap-3 px-4 py-4';-const ROW_LABEL_CLASS = 'text-13 font-medium text-[var(--settings-section-sublabel)]';-const ROW_HINT_CLASS =- 'text-12 leading-[1.4] text-[var(--settings-section-sublabel)] opacity-70';-/** 行间分割线:左右缩进与行内边距对齐。 */-const DIVIDER_CLASS = 'mx-4 h-px bg-[var(--settings-theme-card-border)]';+const ROW_CLASS = SETTINGS_ROW_CLASS;+const ROW_LABEL_CLASS = SETTINGS_ROW_LABEL_CLASS;+const ROW_HINT_CLASS = SETTINGS_ROW_HINT_CLASS;+const DIVIDER_CLASS = SETTINGS_ROW_DIVIDER_CLASS;/** 数字输入复用标准 Input md 档,设置封装保留旧局部主题覆盖,原生步进器不自绘。 */diff --git a/apps/desktop/src/renderer/components/settings/ComposerSendShortcutSection.tsx b/apps/desktop/src/renderer/components/settings/ComposerSendShortcutSection.tsxindex 7976bdb32c..db3c8a2dd4 100644--- a/apps/desktop/src/renderer/components/settings/ComposerSendShortcutSection.tsx+++ b/apps/desktop/src/renderer/components/settings/ComposerSendShortcutSection.tsx@@ -8,6 +8,13 @@ import {} from '@/hooks/useComposerSendShortcutPreference';import { toast } from '@/lib/toast';import { DefaultOverrideControls } from './DefaultOverrideControls';+import {+ SETTINGS_CARD_CLASS,+ SETTINGS_ROW_CLASS,+ SETTINGS_ROW_HINT_CLASS,+ SETTINGS_ROW_LABEL_CLASS,+ SETTINGS_SECTION_TITLE_CLASS,+} from './settingsRowClasses';export function ComposerSendShortcutSection() {const { t } = useTranslation();@@ -21,19 +28,15 @@ export function ComposerSendShortcutSection() {return (<div className="flex flex-col gap-[14px]">- <div className="flex flex-col gap-1">- <h2 className="text-16 font-medium leading-[1.2] text-[var(--settings-section-title)]">- {t('settings.composer.title')}- </h2>- </div>+ <h2 className={SETTINGS_SECTION_TITLE_CLASS}>{t('settings.composer.title')}</h2>- <div className="flex flex-col gap-[14px] rounded-xl border border-[var(--settings-theme-card-border)] bg-[var(--settings-theme-card-bg)] p-4">- <div className="flex flex-wrap items-start justify-between gap-3">- <div className="min-w-0 flex-1">- <p className="text-14 font-medium leading-[1.3] text-[var(--text-primary)]">+ <div className={SETTINGS_CARD_CLASS}>+ <div className={SETTINGS_ROW_CLASS}>+ <div className="flex min-w-0 flex-col gap-1">+ <p className={SETTINGS_ROW_LABEL_CLASS} style={{ letterSpacing: '0.12px' }}>{t('settings.composer.sendShortcut.label', { shortcut })}</p>- <p className="mt-1 text-12 leading-[1.5] text-[var(--text-secondary)]">+ <p className={SETTINGS_ROW_HINT_CLASS}>{t('settings.composer.sendShortcut.hint', { shortcut })}</p></div>diff --git a/apps/desktop/src/renderer/components/settings/ExperimentalSection.tsx b/apps/desktop/src/renderer/components/settings/ExperimentalSection.tsxindex cdbe118011..d35fc878c8 100644--- a/apps/desktop/src/renderer/components/settings/ExperimentalSection.tsx+++ b/apps/desktop/src/renderer/components/settings/ExperimentalSection.tsx@@ -2,30 +2,39 @@ import { Button } from '@/components/ui/button';/*** ExperimentalSection — Settings → General 的"实验功能"区块。*- * 风格对齐 NotificationSection:rounded-xl card、相同的 settings CSS variables。+ * 各项是同一张卡片里的设置行(settingsRowClasses),行间分割线只出现在可见行之间。** LSP 这类实验能力有专用 IPC 行;普通实验功能由 EXPERIMENTAL_FEATURES 驱动。* 全员可见(2026-07 与 Lizi 定案):原 admin 门控随产品级 role 退役——实验* 开关都是本地 flag、默认关闭,对普通用户无破坏性。*/+import { Fragment, type ReactNode } from 'react';import { useNavigate } from 'react-router-dom';import { useTranslation } from 'react-i18next';import { Switch } from '@/components/ui/switch';-import { cn } from '@/lib/utils';import {EXPERIMENTAL_FEATURES,useExperimentalFlag,type ExperimentalFeatureMeta,} from '@/hooks/useExperimentalFeatures';import { LspBetaCell } from './LspBetaCell';+import { SETTINGS_CARD_CLASS, SETTINGS_ROW_DIVIDER_CLASS } from './settingsRowClasses';import { BetaChannelCell } from './BetaChannelCell';export function ExperimentalSection() {const { t } = useTranslation();const betaChannelSupported =window.electronAPI?.supportsBetaUpdateChannel ?? window.electronAPI?.platform !== 'linux';+ const rows: { key: string; node: ReactNode }[] = [+ { key: 'lsp', node: <LspBetaCell /> },+ ...(betaChannelSupported ? [{ key: 'beta-channel', node: <BetaChannelCell /> }] : []),+ ...EXPERIMENTAL_FEATURES.map((feature) => ({+ key: feature.key,+ node: <ExperimentalFeatureRow feature={feature} />,+ })),+ ];return (<div className="flex flex-col gap-[14px]">@@ -33,11 +42,12 @@ export function ExperimentalSection() {{t('settings.experimental.title')}</h2>- <div className="flex flex-col gap-3">- <LspBetaCell />- {betaChannelSupported ? <BetaChannelCell /> : null}- {EXPERIMENTAL_FEATURES.map((feature) => (- <ExperimentalFeatureRow key={feature.key} feature={feature} />+ <div className={SETTINGS_CARD_CLASS}>+ {rows.map((row, index) => (+ <Fragment key={row.key}>+ {index > 0 ? <div className={SETTINGS_ROW_DIVIDER_CLASS} /> : null}+ {row.node}+ </Fragment>))}</div></div>@@ -58,13 +68,7 @@ function ExperimentalFeatureRow({ feature }: { feature: ExperimentalFeatureMeta});return (- <div- className={cn(- 'flex flex-col gap-3 rounded-xl p-5',- 'bg-[var(--settings-theme-card-bg)]',- 'border border-[var(--settings-theme-card-border)]',- )}- >+ <div className="flex flex-col gap-3 px-4 py-4"><div className="flex items-start justify-between gap-3"><div className="flex min-w-0 flex-col gap-1"><pdiff --git a/apps/desktop/src/renderer/components/settings/GitSafetySection.tsx b/apps/desktop/src/renderer/components/settings/GitSafetySection.tsxindex 2c99e4de6d..4e9f7dff8b 100644--- a/apps/desktop/src/renderer/components/settings/GitSafetySection.tsx+++ b/apps/desktop/src/renderer/components/settings/GitSafetySection.tsx@@ -44,7 +44,7 @@ export function GitSafetySection() {<divclassName={cn(- 'flex flex-col gap-3 rounded-xl p-5',+ 'flex flex-col gap-3 rounded-xl px-4 py-4','bg-[var(--settings-theme-card-bg)]','border border-[var(--settings-theme-card-border)]',)}diff --git a/apps/desktop/src/renderer/components/settings/LinkOpenSection.tsx b/apps/desktop/src/renderer/components/settings/LinkOpenSection.tsxindex 3a2635e121..c1549d39e8 100644--- a/apps/desktop/src/renderer/components/settings/LinkOpenSection.tsx+++ b/apps/desktop/src/renderer/components/settings/LinkOpenSection.tsx@@ -18,7 +18,6 @@ import { useTranslation } from 'react-i18next';import { SegmentedControl } from '@/components/ui/segmented-control';-import { cn } from '@/lib/utils';import { toast } from '@/lib/toast';import {LINK_OPEN_DEFAULTS,@@ -27,6 +26,12 @@ import {type LinkOpenPreference,} from '@/hooks/useLinkOpenPreference';import { DefaultOverrideControls } from './DefaultOverrideControls';+import {+ SETTINGS_CARD_CLASS,+ SETTINGS_ROW_DIVIDER_CLASS,+ SETTINGS_ROW_HINT_CLASS,+ SETTINGS_ROW_LABEL_CLASS,+} from './settingsRowClasses';const OPTIONS: Array<{ value: LinkOpenPreference; labelKey: string }> = [{ value: 'sidebar', labelKey: 'settings.linkOpen.options.sidebar' },@@ -34,15 +39,11 @@ const OPTIONS: Array<{ value: LinkOpenPreference; labelKey: string }> = [];/** 带分割线的多行卡片:卡片自身不留内边距,由每行 `px-4 py-4` 承担。 */-const CARD_CLASS = cn(- 'flex flex-col rounded-xl',- 'bg-[var(--settings-theme-card-bg)]',- 'border border-[var(--settings-theme-card-border)]',-);+const CARD_CLASS = SETTINGS_CARD_CLASS;const ROW_CLASS = 'cindy-segmented-row px-4 py-4';-const ROW_LABEL_CLASS = 'text-13 font-medium text-[var(--settings-section-sublabel)]';-const ROW_HINT_CLASS = 'text-12 leading-[1.4] text-[var(--settings-section-sublabel)] opacity-70';-const DIVIDER_CLASS = 'mx-4 h-px bg-[var(--settings-theme-card-border)]';+const ROW_LABEL_CLASS = SETTINGS_ROW_LABEL_CLASS;+const ROW_HINT_CLASS = SETTINGS_ROW_HINT_CLASS;+const DIVIDER_CLASS = SETTINGS_ROW_DIVIDER_CLASS;function LinkOpenPreferenceRow({ kind }: { kind: LinkOpenKind }) {const { t } = useTranslation();diff --git a/apps/desktop/src/renderer/components/settings/LspBetaCell.tsx b/apps/desktop/src/renderer/components/settings/LspBetaCell.tsxindex ed150e82b7..37757d4645 100644--- a/apps/desktop/src/renderer/components/settings/LspBetaCell.tsx+++ b/apps/desktop/src/renderer/components/settings/LspBetaCell.tsx@@ -1,7 +1,7 @@/*** LspBetaCell — Settings → 实验功能区块下的 "LSP 代码智能 (Beta)" 卡片。*- * 风格对齐 ExperimentalFeatureRow: rounded-xl card + Switch + 副标题描述。+ * 实验功能卡片里的一行(与 ExperimentalFeatureRow 同样式): Switch + 副标题描述。* IPC + localStorage 同步对齐 CompatModeCell。** 行为:@@ -19,7 +19,6 @@ import { useCallback, useState } from 'react';import { useTranslation } from 'react-i18next';import { Switch } from '@/components/ui/switch';-import { cn } from '@/lib/utils';import { toast } from '@/lib/toast';import { createLogger } from '@/lib/logger';import { useLspMode } from '@/hooks/useLspMode';@@ -62,13 +61,7 @@ export function LspBetaCell() {const description = t('settings.lspMode.cell.description');return (- <div- className={cn(- 'flex flex-col gap-3 rounded-xl p-5',- 'bg-[var(--settings-theme-card-bg)]',- 'border border-[var(--settings-theme-card-border)]',- )}- >+ <div className="flex flex-col gap-3 px-4 py-4"><div className="flex items-start justify-between gap-3"><div className="flex min-w-0 flex-col gap-1"><pdiff --git a/apps/desktop/src/renderer/components/settings/NotificationSection.tsx b/apps/desktop/src/renderer/components/settings/NotificationSection.tsxindex 2d3be31bbb..a0c916c92b 100644--- a/apps/desktop/src/renderer/components/settings/NotificationSection.tsx+++ b/apps/desktop/src/renderer/components/settings/NotificationSection.tsx@@ -27,7 +27,7 @@ export function NotificationSection() {{/* 桌面通知 — 沿用原有卡片样式 */}<divclassName={cn(- 'flex items-center justify-between gap-3 rounded-xl p-5',+ 'flex items-center justify-between gap-3 rounded-xl px-4 py-4','bg-[var(--settings-theme-card-bg)]','border border-[var(--settings-theme-card-border)]',)}diff --git a/apps/desktop/src/renderer/components/settings/WindowBehaviorSection.tsx b/apps/desktop/src/renderer/components/settings/WindowBehaviorSection.tsxindex a6b4d372db..b29439dd8f 100644--- a/apps/desktop/src/renderer/components/settings/WindowBehaviorSection.tsx+++ b/apps/desktop/src/renderer/components/settings/WindowBehaviorSection.tsx@@ -10,17 +10,25 @@* 3. 「后台窗口首次左键点击仅激活不透传」(swallowActivationClick,PR #446):仅* macOS + Windows 有实际效果,Linux 上两条底层路径均 no-op,故该行在 Linux 隐藏。*- * 卡片样式沿用 NotificationSection 的规格(rounded 12 / Card bg / 1px Board /- * padding 20)以保持视觉一致。+ * 各项放在同一张卡片里、以分割线隔开,与「协同」「Agent 资源占用」同一套设置行样式+ * (settingsRowClasses)。平台不支持的行不渲染,分割线只出现在可见行之间。*/-import { useEffect, useState, type ReactNode } from 'react';+import { Fragment, useEffect, useState, type ReactNode } from 'react';import { useTranslation } from 'react-i18next';import { SegmentedControl } from '@/components/ui/segmented-control';import { Switch } from '@/components/ui/switch';import { cn } from '@/lib/utils';+import {+ SETTINGS_CARD_CLASS,+ SETTINGS_ROW_CLASS,+ SETTINGS_ROW_DIVIDER_CLASS,+ SETTINGS_ROW_HINT_CLASS,+ SETTINGS_ROW_LABEL_CLASS,+ SETTINGS_SECTION_TITLE_CLASS,+} from './settingsRowClasses';import { useSwallowActivationClickSettings } from '@/hooks/useSwallowActivationClickSettings';import { useKeepAwakeSetting } from '@/hooks/useKeepAwakeSetting';import { useLoginItemSetting } from '@/hooks/useLoginItemSetting';@@ -34,8 +42,8 @@ import {type DesktopCloseBehavior = LinuxCloseBehavior | WindowsCloseBehavior;-/** 一张开关卡片:左侧标签 + 说明(+ 可选补充说明行),右侧开关。 */-function BehaviorCard({+/** 一行开关:左侧标签 + 说明(+ 可选补充说明行),右侧开关。 */+function BehaviorRow({id,label,hint,@@ -55,22 +63,12 @@ function BehaviorCard({disabled?: boolean;}) {return (- <div- id={id}- className={cn(- 'flex items-center justify-between gap-3 rounded-xl p-5',- 'bg-[var(--settings-theme-card-bg)]',- 'border border-[var(--settings-theme-card-border)]',- )}- >+ <div id={id} className={SETTINGS_ROW_CLASS}><div className="flex min-w-0 flex-col gap-1">- <p- className="text-13 font-medium text-[var(--settings-section-sublabel)]"- style={{ letterSpacing: '0.12px' }}- >+ <p className={SETTINGS_ROW_LABEL_CLASS} style={{ letterSpacing: '0.12px' }}>{label}</p>- <p className="whitespace-pre-line text-12 leading-[1.4] text-[var(--settings-section-sublabel)] opacity-70">+ <p className={cn('whitespace-pre-line', SETTINGS_ROW_HINT_CLASS)}>{hint}</p>{note}@@ -138,23 +136,27 @@ export function WindowBehaviorSection() {? ['minimize', 'quit']: ['tray', 'quit'];- return (- <div className="flex flex-col gap-[14px]">- <h2 className="text-16 font-medium leading-[1.2] text-[var(--settings-section-title)]">- {t('settings.windowBehavior.title')}- </h2>-- <BehaviorCard- id="settings-search-settings-devices-keepAwake"- label={t('settings.devices.keepAwake')}- hint={t('settings.devices.keepAwakeHint')}- checked={keepAwake}- onCheckedChange={(v) => void setKeepAwake(v)}- ariaLabel={t('settings.devices.keepAwake')}- />+ const rows: { key: string; node: ReactNode }[] = [+ {+ key: 'keep-awake',+ node: (+ <BehaviorRow+ id="settings-search-settings-devices-keepAwake"+ label={t('settings.devices.keepAwake')}+ hint={t('settings.devices.keepAwakeHint')}+ checked={keepAwake}+ onCheckedChange={(v) => void setKeepAwake(v)}+ ariaLabel={t('settings.devices.keepAwake')}+ />+ ),+ },+ ];- {loginItem.supported && (- <BehaviorCard+ if (loginItem.supported) {+ rows.push({+ key: 'login-item',+ node: (+ <BehaviorRowid="settings-search-login-item"label={t('settings.windowBehavior.loginItem.label')}hint={t('settings.windowBehavior.loginItem.hint')}@@ -177,10 +179,15 @@ export function WindowBehaviorSection() {</div>}/>- )}+ ),+ });+ }- {menubar.available && (- <BehaviorCard+ if (menubar.available) {+ rows.push({+ key: 'menubar',+ node: (+ <BehaviorRowid="settings-search-menubar"label={t('settings.windowBehavior.menubar.label')}hint={t('settings.windowBehavior.menubar.hint')}@@ -189,24 +196,23 @@ export function WindowBehaviorSection() {onCheckedChange={(enabled) => void menubar.setEnabled(enabled)}ariaLabel={t('settings.windowBehavior.menubar.label')}/>- )}-- {(isWindows || isLinux) && (- <div- className={cn(- 'cindy-segmented-row rounded-xl p-5',- 'bg-[var(--settings-theme-card-bg)]',- 'border border-[var(--settings-theme-card-border)]',- )}- >+ ),+ });+ }++ if (isWindows || isLinux) {+ rows.push({+ key: 'close-behavior',+ node: (+ <div className="cindy-segmented-row px-4 py-4"><div className="flex min-w-0 flex-col gap-1"><p id="settings-search-settings-windowBehavior-closeBehavior-label"- className="text-13 font-medium text-[var(--settings-section-sublabel)]"+ className={SETTINGS_ROW_LABEL_CLASS}style={{ letterSpacing: '0.12px' }}>{t('settings.windowBehavior.closeBehavior.label')}</p>- <p className="text-12 leading-[1.4] text-[var(--settings-section-sublabel)] opacity-70">+ <p className={SETTINGS_ROW_HINT_CLASS}>{t('settings.windowBehavior.closeBehavior.hint')}</p></div>@@ -221,16 +227,21 @@ export function WindowBehaviorSection() {}))}/></div>- )}+ ),+ });+ }- {showsSwallowActivationClick && (- <BehaviorCard+ if (showsSwallowActivationClick) {+ rows.push({+ key: 'activation-click',+ node: (+ <BehaviorRowid="settings-search-activation-click"label={t('settings.windowBehavior.swallowActivationClickLabel')}hint={t('settings.windowBehavior.swallowActivationClickHint')}note={isMac ? (- <p className="text-12 leading-[1.4] text-[var(--settings-section-sublabel)] opacity-70">+ <p className={SETTINGS_ROW_HINT_CLASS}>{t('settings.windowBehavior.macRestartNote')}</p>) : undefined@@ -239,7 +250,24 @@ export function WindowBehaviorSection() {onCheckedChange={setEnabled}ariaLabel={t('settings.windowBehavior.swallowActivationClickAria')}/>- )}+ ),+ });+ }++ return (+ <div className="flex flex-col gap-[14px]">+ <h2 className={SETTINGS_SECTION_TITLE_CLASS}>+ {t('settings.windowBehavior.title')}+ </h2>++ <div className={SETTINGS_CARD_CLASS}>+ {rows.map((row, index) => (+ <Fragment key={row.key}>+ {index > 0 ? <div className={SETTINGS_ROW_DIVIDER_CLASS} /> : null}+ {row.node}+ </Fragment>+ ))}+ </div></div>);}diff --git a/apps/desktop/src/renderer/features/bots/BotModelChainEditor.tsx b/apps/desktop/src/renderer/features/bots/BotModelChainEditor.tsxindex 67bafcf05a..f1b359f326 100644--- a/apps/desktop/src/renderer/features/bots/BotModelChainEditor.tsx+++ b/apps/desktop/src/renderer/features/bots/BotModelChainEditor.tsx@@ -1,8 +1,16 @@import { Button } from '@/components/ui/button';-import { useState } from 'react';+import { Fragment, useState, type ReactNode } from 'react';import { ArrowDown, ArrowUp, Plus, Trash2 } from 'lucide-react';import { ModelSelector } from '@/components/new-chat/ModelSelector';+import { DefaultOverrideControls } from '@/components/settings/DefaultOverrideControls';+import {+ SETTINGS_ROW_CLASS,+ SETTINGS_ROW_DIVIDER_CLASS,+ SETTINGS_ROW_HINT_CLASS,+ SETTINGS_ROW_LABEL_CLASS,+} from '@/components/settings/settingsRowClasses';+import { cn } from '@/lib/utils';import type { AgentKind } from '@/hooks/useAgentCapabilities';import { useDeviceProviders } from '@/hooks/useDeviceProviders';import { providerAccountLabel, providerDisplayName } from '@/lib/providerDisplayName';@@ -43,6 +51,8 @@ export function BotModelChainEditor({onRestoreDefault,onNavigateToProviders,allowFallbacks = true,+ layout = 'inline',+ settingsRows,}: {value: BotModelRoute[];onChange: (next: BotModelRoute[]) => void;@@ -55,6 +65,13 @@ export function BotModelChainEditor({onRestoreDefault?: () => void;onNavigateToProviders?: () => void;allowFallbacks?: boolean;+ /**+ * `settings`:设置页卡片行排法——首选模型一行(左名称说明、右选择器与恢复默认),+ * 备用模型一行(左名称说明、右添加按钮),已有备用逐条列在其下。需传 `settingsRows`。+ * 默认 `inline` 保持伙伴页等既有排法不变。+ */+ layout?: 'inline' | 'settings';+ settingsRows?: { primaryLabel: string; primaryHint: string };}) {const { t } = useBotTranslation();const { availableVendors, loaded } = useAvailableAgents(deviceId);@@ -116,8 +133,8 @@ export function BotModelChainEditor({else setPendingRoute(route);};- const picker = (route: BotModelRoute, index: number) => (- <div className="min-w-0 flex-1">+ const picker = (route: BotModelRoute, index: number, wrapperClassName = 'min-w-0 flex-1') => (+ <div className={wrapperClassName}><ModelSelectordisabled={disabled || waitingForLocalRoster}deviceId={deviceId}@@ -167,16 +184,138 @@ export function BotModelChainEditor({: null}</div>);+ 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>+ {picker(route, index)}+ <div className="flex shrink-0 gap-1">+ <button+ type="button"+ disabled={disabled || index === 1}+ onClick={() => move(index, -1)}+ aria-label={t('bots.modelChain.moveUp')}+ className="rounded-lg p-1.5 hover:bg-[var(--surface-hover)] disabled:opacity-30"+ >+ <ArrowUp size={14} />+ </button>+ <button+ type="button"+ disabled={disabled || index === routes.length - 1}+ onClick={() => move(index, 1)}+ aria-label={t('bots.modelChain.moveDown')}+ className="rounded-lg p-1.5 hover:bg-[var(--surface-hover)] disabled:opacity-30"+ >+ <ArrowDown size={14} />+ </button>+ {routes.length > 1 ? (+ <button+ type="button"+ disabled={disabled}+ onClick={() => onChange(routes.filter((_, at) => at !== index))}+ aria-label={t('bots.modelChain.remove')}+ className="rounded-lg p-1.5 hover:bg-[var(--danger-bg-soft)] hover:text-[var(--text-danger)]"+ >+ <Trash2 size={14} />+ </button>+ ) : null}+ </div>+ </div>+ );+ });+ const pendingRow: ReactNode =+ pendingRoute && routes.length < BOT_MODEL_CHAIN_MAX ? (+ <div className="flex min-w-0 items-center gap-2">+ {picker(pendingRoute, routes.length)}+ <Button+ variant="secondary"+ tone="quiet"+ size="md"+ compact+ type="button"+ disabled={disabled}+ onClick={() => setPendingRoute(null)}+ >+ {t('bots.cancel')}+ </Button>+ </div>+ ) : null;+ const addDisabled =+ disabled ||+ pendingRoute !== null ||+ routes.length >= BOT_MODEL_CHAIN_MAX ||+ visibleVendors.length === 0;+ const primaryRoute =+ routes[0] ?? { harness: 'pi' as const, model: '', providerId: null, effort: '', fastMode: false };++ if (layout === 'settings' && settingsRows) {+ 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="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">+ {onRestoreDefault ? (+ <DefaultOverrideControls+ isCustomized+ disabled={disabled}+ onReset={() => {+ if (!disabled) onRestoreDefault();+ }}+ />+ ) : null}+ {picker(primaryRoute, 0, 'min-w-0')}+ </div>+ </div>+ {allowFallbacks ? (+ <>+ <div className={SETTINGS_ROW_DIVIDER_CLASS} />+ <div className={SETTINGS_ROW_CLASS}>+ <div className="flex min-w-0 flex-col gap-1">+ <p className={SETTINGS_ROW_LABEL_CLASS} style={{ letterSpacing: '0.12px' }}>+ {t('bots.modelChain.options', { count: Math.max(0, routes.length - 1) })}+ </p>+ <p className={SETTINGS_ROW_HINT_CLASS}>{t('bots.modelChain.description')}</p>+ </div>+ <Button+ variant="secondary"+ size="md"+ compact+ type="button"+ className="shrink-0"+ disabled={addDisabled}+ onClick={add}+ >+ <Plus size={14} />+ {t('bots.modelChain.add')}+ </Button>+ </div>+ {listItems.length > 0 ? (+ <div className="space-y-2 px-4 pb-4 text-12 text-[var(--text-tertiary)]">+ {listItems.map((item, at) => (+ <Fragment key={at}>{item}</Fragment>+ ))}+ </div>+ ) : null}+ </>+ ) : null}+ </div>+ );+ }+return (<div className="min-w-0" data-testid="bot-model-chain-editor"><div className="flex min-w-0 items-center gap-3">{label ? (<span className="shrink-0 text-12 text-[var(--text-secondary)]">{label}</span>) : null}- {picker(- routes[0] ?? { harness: 'pi', model: '', providerId: null, effort: '', fastMode: false },- 0,- )}+ {picker(primaryRoute, 0)}</div>{allowFallbacks && <detailsclassName="mt-1 text-12 text-[var(--text-tertiary)]"@@ -187,74 +326,15 @@ export function BotModelChainEditor({</summary>{expanded ? (<div className="space-y-2 pt-2">- {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>- {picker(route, index)}- <div className="flex shrink-0 gap-1">- <button- type="button"- disabled={disabled || index === 1}- onClick={() => move(index, -1)}- aria-label={t('bots.modelChain.moveUp')}- className="rounded-lg p-1.5 hover:bg-[var(--surface-hover)] disabled:opacity-30"- >- <ArrowUp size={14} />- </button>- <button- type="button"- disabled={disabled || index === routes.length - 1}- onClick={() => move(index, 1)}- aria-label={t('bots.modelChain.moveDown')}- className="rounded-lg p-1.5 hover:bg-[var(--surface-hover)] disabled:opacity-30"- >- <ArrowDown size={14} />- </button>- {routes.length > 1 ? (- <button- type="button"- disabled={disabled}- onClick={() => onChange(routes.filter((_, at) => at !== index))}- aria-label={t('bots.modelChain.remove')}- className="rounded-lg p-1.5 hover:bg-[var(--danger-bg-soft)] hover:text-[var(--text-danger)]"- >- <Trash2 size={14} />- </button>- ) : null}- </div>- </div>- );- })}- {pendingRoute && routes.length < BOT_MODEL_CHAIN_MAX ? (- <div className="flex min-w-0 items-center gap-2">- {picker(pendingRoute, routes.length)}- <Button- variant="secondary"- tone="quiet"- size="md"- compact- type="button"- disabled={disabled}- onClick={() => setPendingRoute(null)}- >- {t('bots.cancel')}- </Button>- </div>- ) : null}+ {fallbackRows}+ {pendingRow}<Buttonvariant="secondary"size="md"tone="quiet"compacttype="button"- disabled={- disabled ||- pendingRoute !== null ||- routes.length >= BOT_MODEL_CHAIN_MAX ||- visibleVendors.length === 0- }+ disabled={addDisabled}onClick={add}><Plus size={14} />diff --git a/apps/desktop/src/renderer/features/bots/BotsGlobalSettingsSection.tsx b/apps/desktop/src/renderer/features/bots/BotsGlobalSettingsSection.tsxindex b7ea2a7874..f12db06582 100644--- a/apps/desktop/src/renderer/features/bots/BotsGlobalSettingsSection.tsx+++ b/apps/desktop/src/renderer/features/bots/BotsGlobalSettingsSection.tsx@@ -3,6 +3,11 @@ import { useEffect, useRef, useState } from 'react';import { useBotTranslation } from './botPronounContext';import { cn } from '@/lib/utils';+import {+ SETTINGS_CARD_CLASS,+ SETTINGS_ROW_HINT_CLASS,+ SETTINGS_SECTION_TITLE_CLASS,+} from '@/components/settings/settingsRowClasses';import { useProviders } from '@/hooks/useProviders';import { useAvailableAgents } from '@/hooks/useAvailableAgents';import {@@ -14,16 +19,6 @@ import {} from './botStore';import { BotModelChainEditor } from './BotModelChainEditor';-const CARD_CLASS = cn(- 'rounded-xl p-5',- 'bg-[var(--settings-theme-card-bg)]',- 'border border-[var(--settings-theme-card-border)]',-);--const ROW_LABEL_CLASS = 'text-13 font-medium text-[var(--settings-section-sublabel)]';-const ROW_HINT_CLASS =- 'text-12 leading-[1.4] text-[var(--settings-section-sublabel)] opacity-70';-export function BotsGlobalSettingsSection() {const { t } = useBotTranslation();// Re-render derived defaults when the shared picker inputs change, including@@ -56,14 +51,16 @@ export function BotsGlobalSettingsSection() {return (<div className="flex flex-col gap-[14px]">- <h2 className="text-16 font-medium leading-[1.2] text-[var(--settings-section-title)]">- {t('bots.globalSettings.title')}- </h2>+ <h2 className={SETTINGS_SECTION_TITLE_CLASS}>{t('bots.globalSettings.title')}</h2>- <div className={cn(CARD_CLASS, 'flex flex-col gap-4')}>- <p className={ROW_LABEL_CLASS}>{t('bots.modelLabel')}</p>+ <div className={SETTINGS_CARD_CLASS}><fieldset disabled={pending} aria-busy={pending} className="min-w-0"><BotModelChainEditor+ layout="settings"+ settingsRows={{+ primaryLabel: t('bots.globalSettings.defaultModel'),+ primaryHint: t('bots.globalSettings.defaultModelHint'),+ }}disabled={pending}value={modelChain}onChange={(next) => changeModelChain(() => setBotGlobalModelChain(next))}@@ -73,7 +70,7 @@ export function BotsGlobalSettingsSection() {/></fieldset>{notice ? (- <p className={ROW_HINT_CLASS} role="status">+ <p className={cn(SETTINGS_ROW_HINT_CLASS, 'px-4 pb-4')} role="status">{notice}</p>) : null}