Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(design-system): DS-4 Button 与 Input 标准组件 (#3920)
Kirozengede0f7739af5
diff --git a/apps/desktop/src/renderer/__tests__/providersSectionAssetModule.test.tsx b/apps/desktop/src/renderer/__tests__/providersSectionAssetModule.test.tsxindex 02e9f8ac0c..16c2acea66 100644--- a/apps/desktop/src/renderer/__tests__/providersSectionAssetModule.test.tsx+++ b/apps/desktop/src/renderer/__tests__/providersSectionAssetModule.test.tsx@@ -270,11 +270,11 @@ describe('ProvidersSection — Cindy AI 账户资产模块', () => {);const buyPlan = screen.getByText('settings.providers.xd.asset.buyPlan').closest('button');- expect(buyPlan?.style.backgroundColor).toBe('var(--accent-cta-bg-pure)');- expect(buyPlan?.style.color).toBe('var(--accent-pure-cta-fg)');+ expect(buyPlan?.className).toContain('bg-[var(--accent-cta-bg-pure)]');+ expect(buyPlan?.className).toContain('text-[var(--accent-pure-cta-fg)]');const usageButton = screen.getByText('settings.providers.xd.asset.viewUsage').closest('button');- expect(usageButton?.style.backgroundColor).toBe('var(--settings-btn-secondary-bg)');- expect(usageButton?.style.color).toBe('var(--settings-btn-secondary-text)');+ expect(usageButton?.className).toContain('bg-[var(--surface-elevated)]');+ expect(usageButton?.className).toContain('text-[var(--text-primary)]');expect(screen.queryByText('billing.settings.topupCard.action')).toBeNull();expect(screen.queryByText('settings.providers.xd.asset.upgradePlan')).toBeNull();@@ -292,8 +292,8 @@ describe('ProvidersSection — Cindy AI 账户资产模块', () => {expect(screen.queryByText('billing.settings.topupCard.action')).toBeNull();const upgrade = screen.getByText('settings.providers.xd.asset.upgradePlan').closest('button');- expect(upgrade?.style.backgroundColor).toBe('var(--accent-cta-bg-pure)');- expect(upgrade?.style.color).toBe('var(--accent-pure-cta-fg)');+ expect(upgrade?.className).toContain('bg-[var(--accent-cta-bg-pure)]');+ expect(upgrade?.className).toContain('text-[var(--accent-pure-cta-fg)]');fireEvent.click(screen.getByText('settings.providers.xd.asset.upgradePlan'));await waitFor(() =>@@ -313,8 +313,8 @@ describe('ProvidersSection — Cindy AI 账户资产模块', () => {expect(screen.queryByText('settings.providers.xd.asset.upgradePlan')).toBeNull();const topup = screen.getByText('billing.settings.topupCard.action').closest('button');- expect(topup?.style.backgroundColor).toBe('var(--accent-cta-bg-pure)');- expect(topup?.style.color).toBe('var(--accent-pure-cta-fg)');+ expect(topup?.className).toContain('bg-[var(--accent-cta-bg-pure)]');+ expect(topup?.className).toContain('text-[var(--accent-pure-cta-fg)]');fireEvent.click(screen.getByText('billing.settings.topupCard.action'));await waitFor(() =>diff --git a/apps/desktop/src/renderer/components/settings/AgentResourceSection.tsx b/apps/desktop/src/renderer/components/settings/AgentResourceSection.tsxindex d48cf815f0..60c9278a02 100644--- a/apps/desktop/src/renderer/components/settings/AgentResourceSection.tsx+++ b/apps/desktop/src/renderer/components/settings/AgentResourceSection.tsx@@ -10,6 +10,7 @@import { useEffect, useMemo, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';+import { Input } from '@/components/ui/input';import { Switch } from '@/components/ui/switch';import { cn } from '@/lib/utils';import { toast } from '@/lib/toast';@@ -40,18 +41,7 @@ const ROW_HINT_CLASS =/** 行间分割线:左右缩进与行内边距对齐。 */const DIVIDER_CLASS = 'mx-4 h-px bg-[var(--settings-theme-card-border)]';-/**- * 数字输入框的框体规格,与设置页统一输入框 `SettingsTextInput` 的 md 档一致- * (DESIGN.md §4-5:单行输入走药丸圆角;fill 必须是 `--surface-elevated` —— 设置卡片- * 本身是 ivory,ivory 输入压在 ivory 卡上会与背景同色、填充对比度归零)。- * 上下调节沿用浏览器原生步进器,不自绘 —— 设置页的控件样式统一是独立议题,留待整体收敛。- */-const NUMBER_INPUT_CLASS = cn(- 'h-9 w-24 shrink-0 rounded-full px-4 text-13 outline-none transition-colors',- 'bg-[var(--surface-elevated)] text-[var(--settings-input-text)]',- 'border border-[var(--settings-input-border)] focus:border-[var(--settings-input-border-focus)]',- 'focus:ring-2 focus:ring-[var(--focus-ring)]',-);+/** 数字输入走标准 Input md 档(32/36/40 中的 36px),原生步进器不自绘。 *//*** 均衡档并发值:本机核数的一半,至少 2(与 main 侧 toolchain-thread-cap 的口径一致),@@ -308,13 +298,13 @@ export function AgentResourceSection() {{t('settings.agentResource.maxConcurrentHint')}</span></span>- <input+ <Inputtype="number"min={0}max={MAX_CONCURRENT_CAP}disabled={applyingPreset}value={maxDraft ?? String(settings.maxConcurrentCommands)}- onChange={(e) => setMaxDraft(e.target.value)}+ onChange={setMaxDraft}onBlur={() => {// 唯一提交点(DESIGN §14.3:Settings 单行编辑器 Enter 不得提交):// 仅 0..64 的整数且与当前值不同才写盘;非法/未变草稿作废,@@ -327,7 +317,8 @@ export function AgentResourceSection() {if (raw === settings.maxConcurrentCommands) return;persist('maxConcurrentCommands', raw);}}- className={NUMBER_INPUT_CLASS}+ size="md"+ className="w-24 shrink-0"/></label>diff --git a/apps/desktop/src/renderer/components/settings/CollaborationSection.tsx b/apps/desktop/src/renderer/components/settings/CollaborationSection.tsxindex cf2bc6cdd1..69d0f1f5bb 100644--- a/apps/desktop/src/renderer/components/settings/CollaborationSection.tsx+++ b/apps/desktop/src/renderer/components/settings/CollaborationSection.tsx@@ -4,6 +4,7 @@import { useState, useEffect } from 'react';import { useTranslation } from 'react-i18next';+import { Input } from '@/components/ui/input';import { cn } from '@/lib/utils';import { toast } from '@/lib/toast';import { DefaultOverrideControls } from './DefaultOverrideControls';@@ -22,18 +23,7 @@ const ROW_HINT_CLASS =/** 行间分割线:左右缩进与行内边距对齐。 */const DIVIDER_CLASS = 'mx-4 h-px bg-[var(--settings-theme-card-border)]';-/**- * 数字输入框的框体规格,与设置页统一输入框 `SettingsTextInput` 的 md 档一致- * (DESIGN.md §4-5:单行输入走药丸圆角;fill 必须是 `--surface-elevated` —— 设置卡片- * 本身是 ivory,ivory 输入压在 ivory 卡上会与背景同色、填充对比度归零)。- * 上下调节沿用浏览器原生步进器,不自绘 —— 设置页的控件样式统一是独立议题,留待整体收敛。- */-const NUMBER_INPUT_CLASS = cn(- 'h-9 w-24 shrink-0 rounded-full px-4 text-13 outline-none transition-colors',- 'bg-[var(--surface-elevated)] text-[var(--settings-input-text)]',- 'border border-[var(--settings-input-border)] focus:border-[var(--settings-input-border-focus)]',- 'focus:ring-2 focus:ring-[var(--focus-ring)]',-);+/** 数字输入走标准 Input md 档(32/36/40 中的 36px),原生步进器不自绘。 */interface CollaborationSettings {workerSoftLimit: number;@@ -114,16 +104,17 @@ export function CollaborationSection() {{t('settings.collaboration.workerSoftLimitHint')}</span></span>- <input+ <Inputtype="number"min={1}max={settings.workerHardLimit}- value={settings.workerSoftLimit}- onChange={(e) => {- const v = Math.max(1, Math.min(settings.workerHardLimit, Number(e.target.value) || 1));+ value={String(settings.workerSoftLimit)}+ onChange={(text) => {+ const v = Math.max(1, Math.min(settings.workerHardLimit, Number(text) || 1));persist('workerSoftLimit', v);}}- className={NUMBER_INPUT_CLASS}+ size="md"+ className="w-24 shrink-0"/></label>@@ -139,16 +130,20 @@ export function CollaborationSection() {{t('settings.collaboration.workerHardLimitHint')}</span></span>- <input+ <Inputtype="number"min={settings.workerSoftLimit}max={20}- value={settings.workerHardLimit}- onChange={(e) => {- const v = Math.max(settings.workerSoftLimit, Math.min(20, Number(e.target.value) || settings.workerSoftLimit));+ value={String(settings.workerHardLimit)}+ onChange={(text) => {+ const v = Math.max(+ settings.workerSoftLimit,+ Math.min(20, Number(text) || settings.workerSoftLimit),+ );persist('workerHardLimit', v);}}- className={NUMBER_INPUT_CLASS}+ size="md"+ className="w-24 shrink-0"/></label>@@ -164,17 +159,18 @@ export function CollaborationSection() {{t('settings.collaboration.idleReleaseHint')}</span></span>- <input+ <Inputtype="number"min={0}max={120}- value={settings.workerIdleReleaseMinutes}- onChange={(e) => {- const raw = Number(e.target.value);+ value={String(settings.workerIdleReleaseMinutes)}+ onChange={(text) => {+ const raw = Number(text);const v = Math.max(0, Math.min(120, Number.isFinite(raw) ? Math.trunc(raw) : 0));persist('workerIdleReleaseMinutes', v);}}- className={NUMBER_INPUT_CLASS}+ size="md"+ className="w-24 shrink-0"/></label></div>diff --git a/apps/desktop/src/renderer/components/settings/ProvidersSection.tsx b/apps/desktop/src/renderer/components/settings/ProvidersSection.tsxindex c0ccf27e83..476bfa6ce0 100644--- a/apps/desktop/src/renderer/components/settings/ProvidersSection.tsx+++ b/apps/desktop/src/renderer/components/settings/ProvidersSection.tsx@@ -44,6 +44,7 @@ import { useModelAccessStatus } from '@/hooks/useModelAccessStatus';import { useModelAccessCreditUsage } from '@/hooks/useModelAccessCreditUsage';import { useXdAssetPrimaryAction } from '@/hooks/useXdAssetPrimaryAction';import { useReducedMotion } from '@/hooks/useReducedMotion';+import { Button } from '@/components/ui/button';import { useConfirmDialog } from '@/components/ui/confirm-dialog-provider';import { useSignInToCindy } from '@/hooks/useSignInToCindy';import { useProviderOAuthDeviceCode } from '@/hooks/useProviderOAuthDeviceCode';@@ -201,23 +202,9 @@ function PillButton({disabled?: boolean;}) {return (- <button- type="button"- onClick={onClick}- disabled={disabled}- className={cn(- 'flex h-8 shrink-0 items-center justify-center rounded-full px-6 text-13 font-medium transition-colors',- 'border',- disabled && 'cursor-not-allowed opacity-60',- )}- style={{- backgroundColor: 'var(--settings-btn-secondary-bg)',- borderColor: 'var(--settings-btn-secondary-border)',- color: 'var(--settings-btn-secondary-text)',- }}- >+ <Button variant="secondary" size="md" onClick={onClick} disabled={disabled}>{label}- </button>+ </Button>);}@@ -238,24 +225,9 @@ function CtaPillButton({className?: string;}) {return (- <button- type="button"- onClick={onClick}- className={cn(- 'flex shrink-0 items-center justify-center rounded-full px-6 text-13 font-medium transition-opacity hover:opacity-90',- size === 'lg' ? 'h-9' : 'h-8',- className,- )}- style={{- // Black Pill(最高强调档)按 DESIGN.md §4 用 pure 对:--accent-cta-bg-pure- // (Light 纯黑 / Dark 纯白反转)配 --accent-pure-cta-fg。--accent-cta-bg 在- // 默认 Light 下是 #262626,与规范的 #000000 差一档,不能混用。- backgroundColor: 'var(--accent-cta-bg-pure)',- color: 'var(--accent-pure-cta-fg)',- }}- >+ <Button variant="cta" size={size} onClick={onClick} className={className}>{label}- </button>+ </Button>);}diff --git a/apps/desktop/src/renderer/components/settings/SettingsTextInput.tsx b/apps/desktop/src/renderer/components/settings/SettingsTextInput.tsxindex 4d1f382192..89cd83fce7 100644--- a/apps/desktop/src/renderer/components/settings/SettingsTextInput.tsx+++ b/apps/desktop/src/renderer/components/settings/SettingsTextInput.tsx@@ -1,160 +1,12 @@/**- * SettingsTextInput —— 设置页统一的单行文本 / 密钥输入框。+ * SettingsTextInput —— `components/ui/input` 的设置页薄封装。*- * 收敛背景:设置页各处原本各写一份私有 TextInput(高度 32 / 36 / 40 / 42px 混杂),- * 密钥字段的「明文切换」只在 CustomProviderDialog 做了——同一个 API key 在「添加供应商」- * 向导里看不见、在编辑弹窗里看得见。本组件以 CustomProviderDialog 那份为基线(它是唯一- * 走 DESIGN.md §4-5 药丸圆角的实现),把 eye 显形收进 `secret`,调用点不再各自手写- * showKey state + 按钮。- *- * `secret` 只显形**用户本次输入的草稿**(草稿本就在 renderer state 里)。已存密钥要不要- * 回显由调用方决定:内置 API-key 走 MAIN_ONLY 的 builtinApiKey* IPC,renderer 架构上读不到- * 明文,回显无从谈起;自定义供应商的 key 由调用方显式读回。本组件不触碰凭证读取边界。- *- * 尺寸:DESIGN.md §4 锁定单行输入的 radius(9999px)与颜色 token,未锁高度,因此保留- * sm / md / lg 三档以贴合各调用点既有版式。radius 与 `--settings-input-*` token 不可变。- */-import { useState } from 'react';-import { Eye, EyeOff } from 'lucide-react';-import { useTranslation } from 'react-i18next';--import { cn } from '@/lib/utils';--export type SettingsTextInputSize = 'sm' | 'md' | 'lg';-export type SettingsTextInputSurface = 'elevated' | 'ivory';--/**- * 底色:默认 `elevated` = DESIGN.md §4 `input/text` 规定的 fill(`--surface-elevated`)。- *- * `ivory` 是给「输入压在白色弹窗面板上」的调用点保留的既有底色(`--settings-input-bg`,- * 解析到 `--surface-card-ivory`)。这份 ivory 在设计文档里没有任何背书,属 colors.ts 的- * 无文档漂移;它在白面板上能给出 fill 抬升,所以不在本 PR 里翻成白色,但也不能当默认——- * settings 卡片本身就是 ivory(`--settings-theme-card-bg`),ivory 输入压在 ivory 卡上会和- * 背景同色,填充对比度归零。settings 域这处 ivory / elevated 的收口是独立议题。+ * DS-4 把实现升格进 `components/ui/input.tsx`。本文件保留原导出名与类型别名,+ * 让既有设置页调用点零行为改动(除 ivory 登记债与 placeholder 已收口到+ * `--text-placeholder`)。新代码请直接 import `{ Input }` from `@/components/ui/input`。*/-const SURFACE_STYLES: Record<SettingsTextInputSurface, string> = {- elevated: 'bg-[var(--surface-elevated)]',- ivory: 'bg-[var(--settings-input-bg)]',-};--/** 各档的框体几何 + 无 trailing 时的右内边距(有 trailing 时统一让位给按钮)。 */-const SIZE_STYLES: Record<- SettingsTextInputSize,- { box: string; paddingLeft: string; paddingRight: string; trailingPaddingRight: string }-> = {- sm: {- box: 'h-8 text-12',- paddingLeft: 'pl-3',- paddingRight: 'pr-3',- trailingPaddingRight: 'pr-8',- },- md: {- box: 'h-9 text-13',- paddingLeft: 'pl-4',- paddingRight: 'pr-4',- trailingPaddingRight: 'pr-9',- },- lg: {- box: 'h-[40px] text-14',- paddingLeft: 'pl-[12px]',- paddingRight: 'pr-[12px]',- trailingPaddingRight: 'pr-9',- },-};--/** eye 按钮:小号框用小图标 / 更贴边,避免挤压 32px 行高。 */-const EYE_STYLES: Record<SettingsTextInputSize, { iconSize: number; offset: string }> = {- sm: { iconSize: 14, offset: 'right-[10px]' },- md: { iconSize: 16, offset: 'right-[12px]' },- lg: { iconSize: 16, offset: 'right-[12px]' },-};--export function SettingsTextInput({- value,- onChange,- onBlur,- placeholder,- type = 'text',- size = 'lg',- surface = 'elevated',- mono = false,- secret = false,- trailing,- className,-}: {- value: string;- onChange: (v: string) => void;- onBlur?: () => void;- placeholder?: string;- /** `secret` 为真时由组件接管(明文 / 遮罩切换),此处传值无效。 */- type?: string;- size?: SettingsTextInputSize;- /** 底色档:默认 §4 规定的 `--surface-elevated`;`ivory` 见 SURFACE_STYLES 注释。 */- surface?: SettingsTextInputSurface;- /** 等宽字体——密钥、ID 这类需要逐字核对的值。 */- mono?: boolean;- /** 密钥字段:遮罩输入 + 自带明文切换按钮。 */- secret?: boolean;- /** 自定义尾随元素(需自行绝对定位)。`secret` 优先,两者不叠加。 */- trailing?: React.ReactNode;- /** 附加到**外层容器**(内层 input 恒为 w-full),供 flex 行传 `flex-1 min-w-0`。 */- className?: string;-}) {- const { t } = useTranslation();- const [revealed, setRevealed] = useState(false);- const sizeStyle = SIZE_STYLES[size];- const eyeStyle = EYE_STYLES[size];-- const eyeButton = secret ? (- <button- type="button"- onClick={() => setRevealed((v) => !v)}- className={cn(- 'absolute top-1/2 -translate-y-1/2 text-[var(--settings-eye-icon)] transition-colors hover:text-[var(--settings-eye-icon-hover)]',- // globals.css 的 F3 全局规则把 *:focus-visible 的 outline 抹掉了(只有 input /- // textarea 恢复),按钮不自带焦点提示——键盘用户看不出焦点落在眼睛上。按 DESIGN.md- // 的 Focus Blue 约定补 ring(--focus-ring),写法与其它图标按钮一致。- 'rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',- eyeStyle.offset,- )}- aria-label={revealed ? t('settings.apiKey.hideKey') : t('settings.apiKey.showKey')}- >- {revealed ? <Eye size={eyeStyle.iconSize} /> : <EyeOff size={eyeStyle.iconSize} />}- </button>- ) : null;- const trailingNode = eyeButton ?? trailing;-- return (- <div className={cn('relative', className)}>- <input- type={secret ? (revealed ? 'text' : 'password') : type}- value={value}- onChange={(e) => onChange(e.target.value)}- onBlur={onBlur}- placeholder={placeholder}- // 只对密钥关掉:密码管理器建议和拼写红线对密钥是干扰,但普通文本字段(显示名称、- // baseUrl、模型名、请求头)该保留浏览器的自动补全与拼写检查,不能一并禁掉。- autoComplete={secret ? 'off' : undefined}- spellCheck={secret ? false : undefined}- className={cn(- // 单行输入按设计规范走药丸圆角(DESIGN.md §4-5:9999px,明令禁止 10px)。- 'w-full rounded-full outline-none transition-colors',- sizeStyle.box,- sizeStyle.paddingLeft,- trailingNode ? sizeStyle.trailingPaddingRight : sizeStyle.paddingRight,- mono && 'font-mono',- 'text-[var(--settings-input-text)] placeholder:text-[var(--settings-input-placeholder)]',- SURFACE_STYLES[surface],- 'border border-[var(--settings-input-border)] focus:border-[var(--settings-input-border-focus)]',- // Focus Blue 环(DESIGN.md §4 Inputs 的 focus 槽 + §「Focus Blue」的 --focus-ring):- // 迁移进来的密钥输入原本就带 focus:ring-2,不能在收敛时丢掉——同一个表单里紧邻的- // 名称框仍是蓝环,只留 border 变色会让上下两个框焦点表现不一致。用 opaque- // --focus-ring 而非 --focus-ring-soft:与这些框的原值、以及相邻未迁移输入一致。- 'focus:ring-2 focus:ring-[var(--focus-ring)]',- )}- style={{ userSelect: 'text', WebkitUserSelect: 'text' }}- />- {trailingNode}- </div>- );-}+export { Input as SettingsTextInput } from '@/components/ui/input';+export type {+ InputSize as SettingsTextInputSize,+ InputSurface as SettingsTextInputSurface,+} from '@/components/ui/input';diff --git a/apps/desktop/src/renderer/components/ui/__tests__/button.test.tsx b/apps/desktop/src/renderer/components/ui/__tests__/button.test.tsxnew file mode 100644index 0000000000..a6f6313d7e--- /dev/null+++ b/apps/desktop/src/renderer/components/ui/__tests__/button.test.tsx@@ -0,0 +1,116 @@+// @vitest-environment jsdom++/**+ * DS-4 Button 样式合同(Level 1 静态守卫)。+ *+ * 只锁「token 表达式 / 圆角 / 字号字重 / 尺寸档 / 禁用态」这些设计合同,不锁实现细节。+ * 状态值本身是否在各主题下可区分由 themes/__tests__/buttonStateContrast.test.ts 守。+ */+import { cleanup, render, screen } from '@testing-library/react';+import { afterEach, describe, expect, it } from 'vitest';++import { Button, type ButtonVariant } from '../button';++/** 合同表:每个变体必须出现的 token 表达式。改绑 token 会在这里红。 */+const CONTRACT: Record<ButtonVariant, string[]> = {+ primary: [+ 'bg-[var(--surface-chip)]',+ 'text-[var(--text-primary)]',+ 'enabled:hover:bg-[var(--button-primary-hover)]',+ 'enabled:active:bg-[var(--button-primary-pressed)]',+ ],+ secondary: [+ 'bg-[var(--surface-elevated)]',+ 'border-[var(--border-default)]',+ 'text-[var(--text-primary)]',+ 'enabled:hover:bg-[var(--button-secondary-hover)]',+ 'enabled:active:bg-[var(--button-secondary-pressed)]',+ ],+ cta: [+ 'bg-[var(--accent-cta-bg-pure)]',+ 'text-[var(--accent-pure-cta-fg)]',+ 'enabled:hover:bg-[var(--button-cta-hover)]',+ 'enabled:active:bg-[var(--button-cta-pressed)]',+ ],+};++/** 一律禁止出现的写法。 */+const FORBIDDEN = [+ 'hover:opacity', // G2:禁用透明度 hover+ 'settings-btn-secondary', // G5:不继承设置页域 alias+ 'h-10', // G1:按钮不设 40px 档+ 'h-[40px]',+ 'rounded-lg', // §5:按钮一律胶囊+ 'rounded-xl',+];++function classOf(name: string): string {+ return screen.getByRole('button', { name }).className;+}++function missing(cls: string, required: string[]): string[] {+ return required.filter((token) => !cls.includes(token));+}++describe('Button 样式合同', () => {+ afterEach(cleanup);++ for (const variant of Object.keys(CONTRACT) as ButtonVariant[]) {+ it(`${variant}:token 绑定齐全、胶囊圆角、text-13/500`, () => {+ render(<Button variant={variant}>{variant}</Button>);+ const cls = classOf(variant);++ expect(missing(cls, CONTRACT[variant]), `${variant} 缺失 token`).toEqual([]);+ expect(cls).toContain('rounded-full');+ expect(cls).toContain('text-13');+ expect(cls).toContain('font-medium');+ for (const banned of FORBIDDEN) {+ expect(cls, `${variant} 不应出现 ${banned}`).not.toContain(banned);+ }+ });+ }++ it('尺寸只有 32 / 36 两档', () => {+ render(+ <>+ <Button size="md">Md</Button>+ <Button size="lg">Lg</Button>+ </>,+ );+ expect(classOf('Md')).toContain('h-8');+ expect(classOf('Lg')).toContain('h-9');+ });++ it('focus-visible 走 --focus-ring;禁用态走普通指针 + 60% 不透明度', () => {+ render(<Button disabled>Disabled</Button>);+ const cls = classOf('Disabled');+ expect(cls).toContain('focus-visible:ring-[var(--focus-ring)]');+ expect(cls).toContain('disabled:cursor-not-allowed');+ expect(cls).toContain('disabled:opacity-60');+ });++ it('禁用态不得再触发 hover / active 换色(hover 一律带 enabled: 前缀)', () => {+ // CSS 的 :hover 对 disabled 元素照样匹配。不带 enabled: 前缀时,禁用按钮+ // 鼠标悬停仍会换底色——旧 PillButton 根本没有 hover,属迁移引入的行为回归。+ for (const variant of Object.keys(CONTRACT) as ButtonVariant[]) {+ cleanup();+ render(<Button variant={variant} disabled>{variant}</Button>);+ const cls = classOf(variant);+ const bare = cls+ .split(/\s+/)+ .filter((c) => (c.startsWith('hover:') || c.startsWith('active:')));+ expect(bare, `${variant} 存在无 enabled: 前缀的交互态`).toEqual([]);+ }+ });++ it('自证伪:合同表被改错时守卫必然红', () => {+ render(<Button variant="secondary">S</Button>);+ const cls = classOf('S');+ // 装作有人把 secondary 改回设置页域 alias:合同检查必须报缺失。+ expect(missing(cls, ['bg-[var(--settings-btn-secondary-bg)]'])).toEqual([+ 'bg-[var(--settings-btn-secondary-bg)]',+ ]);+ // 装作有人把透明度 hover 加回来:禁令检查必须命中。+ expect('hover:opacity-90').toMatch(/hover:opacity/);+ });+});diff --git a/apps/desktop/src/renderer/components/ui/__tests__/input.test.tsx b/apps/desktop/src/renderer/components/ui/__tests__/input.test.tsxnew file mode 100644index 0000000000..ebad108344--- /dev/null+++ b/apps/desktop/src/renderer/components/ui/__tests__/input.test.tsx@@ -0,0 +1,122 @@+// @vitest-environment jsdom++import { cleanup, render, screen } from '@testing-library/react';+import { afterEach, describe, expect, it, vi } from 'vitest';++vi.mock('react-i18next', () => ({+ useTranslation: () => ({ t: (key: string) => key, i18n: { language: 'zh-CN' } }),+}));++import { Input, Textarea } from '../input';++function inputClass(): string {+ return (screen.getByRole('textbox') as HTMLInputElement).className;+}++describe('Input', () => {+ afterEach(cleanup);++ it('binds §4 fill / text / border / placeholder tokens and stays a pill', () => {+ render(<Input value="" onChange={() => {}} placeholder="hint" />);+ const cls = inputClass();+ expect(cls).toContain('rounded-full');+ expect(cls).toContain('bg-[var(--surface-elevated)]');+ expect(cls).toContain('text-[var(--text-primary)]');+ expect(cls).toContain('placeholder:text-[var(--text-placeholder)]');+ expect(cls).toContain('border-[var(--border-default)]');+ expect(cls).toContain('focus:ring-[var(--focus-ring)]');+ expect(cls).not.toContain('settings-input-placeholder');+ });++ it('keeps sm/md/lg at 32/36/40px', () => {+ const { rerender } = render(<Input value="" onChange={() => {}} size="sm" />);+ expect(inputClass()).toContain('h-8');+ rerender(<Input value="" onChange={() => {}} size="md" />);+ expect(inputClass()).toContain('h-9');+ rerender(<Input value="" onChange={() => {}} size="lg" />);+ expect(inputClass()).toContain('h-[40px]');+ });++ it('keeps ivory as an explicit registered-debt variant', () => {+ render(<Input value="" onChange={() => {}} surface="ivory" />);+ expect(inputClass()).toContain('bg-[var(--settings-input-bg)]');+ expect(inputClass()).not.toContain('bg-[var(--surface-elevated)]');+ });++ it('uses --error-* tokens in the error state', () => {+ render(<Input value="" onChange={() => {}} error />);+ const cls = inputClass();+ expect(cls).toContain('border-[var(--error-border)]');+ expect(cls).toContain('focus:border-[var(--error-fg)]');+ });++ it('masks secret fields and exposes a reveal control', () => {+ render(<Input value="secret" onChange={() => {}} secret />);+ const field = document.querySelector('input');+ expect(field?.getAttribute('type')).toBe('password');+ expect(screen.getByRole('button', { name: 'settings.apiKey.showKey' })).toBeTruthy();+ });++ it('keeps caller inline style instead of silently dropping it', () => {+ render(+ <Input value="" onChange={() => {}} style={{ textAlign: 'center', width: 120 }} />,+ );+ const el = screen.getByRole('textbox') as HTMLInputElement;+ expect(el.style.textAlign).toBe('center');+ expect(el.style.width).toBe('120px');+ // 组件内置的文本选择样式仍在,未被调用方清空。+ expect(el.style.userSelect).toBe('text');+ });++ it('lets caller override the built-in userSelect when explicitly asked', () => {+ render(<Input value="" onChange={() => {}} style={{ userSelect: 'none' }} />);+ expect((screen.getByRole('textbox') as HTMLInputElement).style.userSelect).toBe('none');+ });+});++describe('Textarea', () => {+ afterEach(cleanup);++ it('uses the 8px inner-control radius and --text-placeholder', () => {+ render(<Textarea value="" onChange={() => {}} placeholder="notes" />);+ const cls = screen.getByRole('textbox').className;+ expect(cls).toContain('rounded-lg');+ expect(cls).not.toContain('rounded-full');+ expect(cls).toContain('placeholder:text-[var(--text-placeholder)]');+ expect(cls).toContain('bg-[var(--surface-elevated)]');+ });++ it('keeps caller inline style on the same merge order as Input', () => {+ render(<Textarea value="" onChange={() => {}} style={{ textAlign: 'right' }} />);+ const el = screen.getByRole('textbox') as HTMLTextAreaElement;+ expect(el.style.textAlign).toBe('right');+ expect(el.style.userSelect).toBe('text');+ });+});++describe('Input 合同自证伪', () => {+ afterEach(cleanup);++ it('绑 Tier-1 slot,不再消费 settings 域 alias(focus 边框同理)', () => {+ render(<Input value="" onChange={() => {}} />);+ const cls = inputClass();+ for (const banned of [+ 'var(--settings-input-border)',+ 'var(--settings-input-text)',+ 'var(--settings-input-placeholder)',+ 'var(--settings-input-border-focus)',+ ]) {+ expect(cls, `不应再消费 ${banned}`).not.toContain(banned);+ }+ expect(cls).toContain('focus:border-[var(--text-tertiary-stone)]');+ });++ it('自证伪:断言机制能抓到 token 漂移', () => {+ render(<Input value="" onChange={() => {}} />);+ const cls = inputClass();+ // 装作有人把 border 改回域 alias:下面这条必须为假。+ expect(cls.includes('border-[var(--settings-input-border)]')).toBe(false);+ // 而现行绑定必须为真,证明检查不是恒假。+ expect(cls.includes('border-[var(--border-default)]')).toBe(true);+ });+});diff --git a/apps/desktop/src/renderer/components/ui/button.tsx b/apps/desktop/src/renderer/components/ui/button.tsxnew file mode 100644index 0000000000..edb69206e2--- /dev/null+++ b/apps/desktop/src/renderer/components/ui/button.tsx@@ -0,0 +1,77 @@+/**+ * Button —— DESIGN.md §4 三变体标准控件(primary / secondary / cta)。+ *+ * 升格自 ProvidersSection 的 PillButton / CtaPillButton。圆角一律胶囊(§5)。+ * 高度双档 32/36px,不设 40(DS-4 G1,拍板人 = 用户/设计师,2026-09-03)。+ * hover 走换色 token,禁用透明度 hover(G2)。pressed 进最低状态矩阵(G3)。+ * hover / pressed 由 colors.ts 的 color-mix 派生(见那里的注释):暗色下+ * surface-hover 与 surface-chip 同值,直接 alias 会让悬停不可见。+ * 字号字重 text-13 / 500(G4)。secondary 绑 Tier-1,不继承 settings 域 alias(G5)。+ *+ * 禁用态指针遵循既有「禁用统一普通指针」裁决(#3246):class 仍写+ * disabled:cursor-not-allowed,globals.css 把它收成普通箭头。+ *+ * loading 首批调用点未用到,本张不做。+ */++import * as React from 'react';++import { cn } from '@/lib/utils';++export type ButtonVariant = 'primary' | 'secondary' | 'cta';+export type ButtonSize = 'md' | 'lg';++export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {+ variant?: ButtonVariant;+ size?: ButtonSize;+}++const SIZE_STYLES: Record<ButtonSize, string> = {+ md: 'h-8',+ lg: 'h-9',+};++/**+ * hover / active 一律带 `enabled:` 前缀。CSS 的 :hover 对 disabled 元素照样匹配,+ * 不加前缀时禁用按钮鼠标悬停仍会换底色(globals.css 只把禁用态指针收成普通箭头,+ * 不管背景)—— 旧的 PillButton 完全没有 hover,所以这属迁移引入的行为回归。+ */+const VARIANT_STYLES: Record<ButtonVariant, string> = {+ primary: [+ 'border border-[var(--surface-chip)] bg-[var(--surface-chip)] text-[var(--text-primary)]',+ 'enabled:hover:bg-[var(--button-primary-hover)] enabled:hover:border-[var(--button-primary-hover)]',+ 'enabled:active:bg-[var(--button-primary-pressed)] enabled:active:border-[var(--button-primary-pressed)]',+ ].join(' '),+ secondary: [+ 'border border-[var(--border-default)] bg-[var(--surface-elevated)] text-[var(--text-primary)]',+ 'enabled:hover:bg-[var(--button-secondary-hover)]',+ 'enabled:active:bg-[var(--button-secondary-pressed)]',+ ].join(' '),+ cta: [+ 'border border-[var(--accent-cta-bg-pure)] bg-[var(--accent-cta-bg-pure)] text-[var(--accent-pure-cta-fg)]',+ 'enabled:hover:bg-[var(--button-cta-hover)] enabled:hover:border-[var(--button-cta-hover)]',+ 'enabled:active:bg-[var(--button-cta-pressed)] enabled:active:border-[var(--button-cta-pressed)]',+ ].join(' '),+};++const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(+ ({ className, variant = 'primary', size = 'md', type = 'button', disabled, ...props }, ref) => (+ <button+ ref={ref}+ type={type}+ disabled={disabled}+ className={cn(+ 'inline-flex shrink-0 items-center justify-center rounded-full px-6 text-13 font-medium transition-colors',+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',+ SIZE_STYLES[size],+ VARIANT_STYLES[variant],+ 'disabled:cursor-not-allowed disabled:opacity-60',+ className,+ )}+ {...props}+ />+ ),+);+Button.displayName = 'Button';++export { Button };diff --git a/apps/desktop/src/renderer/components/ui/input.tsx b/apps/desktop/src/renderer/components/ui/input.tsxnew file mode 100644index 0000000000..2a8e2de624--- /dev/null+++ b/apps/desktop/src/renderer/components/ui/input.tsx@@ -0,0 +1,220 @@+/**+ * Input —— DESIGN.md §4 单行输入标准控件,升格自 SettingsTextInput。+ *+ * 尺寸:sm/md/lg = 32/36/40px(DS-4 G1;输入框保留三档,按钮不设 40)。+ * 圆角:单行一律胶囊(§5);textarea 变体一律 8px。+ * placeholder 一律 `--text-placeholder`(§4 G3)。+ *+ * `surface="ivory"` 是登记债(DS-4 G6,拍板人 = 用户/设计师,2026-09-03):+ * colors.ts 的无文档漂移,仅供白弹窗面板场合。独立议题收口,本张不翻案。+ * API 原样搬:secret 眼睛显形、mono、trailing。+ *+ * FormField(label + 说明 + 错误行)首批调用点未用到,本张不建。+ */++import { useState, type InputHTMLAttributes, type ReactNode, type TextareaHTMLAttributes } from 'react';+import { Eye, EyeOff } from 'lucide-react';+import { useTranslation } from 'react-i18next';++import { cn } from '@/lib/utils';++export type InputSize = 'sm' | 'md' | 'lg';+export type InputSurface = 'elevated' | 'ivory';++/**+ * 底色:默认 `elevated` = DESIGN.md §4 `input/text` 规定的 fill(`--surface-elevated`)。+ *+ * `ivory` 是给「输入压在白色弹窗面板上」的调用点保留的既有底色(`--settings-input-bg`,+ * 解析到 `--surface-card-ivory`)。这份 ivory 在设计文档里没有任何背书,属 colors.ts 的+ * 无文档漂移;它在白面板上能给出 fill 抬升,所以不在本 PR 里翻成白色,但也不能当默认——+ * settings 卡片本身就是 ivory(`--settings-theme-card-bg`),ivory 输入压在 ivory 卡上会和+ * 背景同色,填充对比度归零。settings 域这处 ivory / elevated 的收口是独立议题。+ */+const SURFACE_STYLES: Record<InputSurface, string> = {+ elevated: 'bg-[var(--surface-elevated)]',+ ivory: 'bg-[var(--settings-input-bg)]',+};++/** 各档的框体几何 + 无 trailing 时的右内边距(有 trailing 时统一让位给按钮)。 */+const SIZE_STYLES: Record<+ InputSize,+ { box: string; paddingLeft: string; paddingRight: string; trailingPaddingRight: string }+> = {+ sm: {+ box: 'h-8 text-12',+ paddingLeft: 'pl-3',+ paddingRight: 'pr-3',+ trailingPaddingRight: 'pr-8',+ },+ md: {+ box: 'h-9 text-13',+ paddingLeft: 'pl-4',+ paddingRight: 'pr-4',+ trailingPaddingRight: 'pr-9',+ },+ lg: {+ box: 'h-[40px] text-14',+ paddingLeft: 'pl-[12px]',+ paddingRight: 'pr-[12px]',+ trailingPaddingRight: 'pr-9',+ },+};++/** eye 按钮:小号框用小图标 / 更贴边,避免挤压 32px 行高。 */+const EYE_STYLES: Record<InputSize, { iconSize: number; offset: string }> = {+ sm: { iconSize: 14, offset: 'right-[10px]' },+ md: { iconSize: 16, offset: 'right-[12px]' },+ lg: { iconSize: 16, offset: 'right-[12px]' },+};++/**+ * 边框 / 文字 / placeholder 一律绑 Tier-1 slot,不继承 `--settings-input-*` 域 alias+ * (与 G5 对 button/secondary 的同一条判据:primitive 不继承域 alias,防设置页私有+ * 决定泄漏成全局默认)。这几个 alias 的默认值本就 forward-resolve 到同一批 slot,+ * 11 个内置主题与外部主题导入 allowlist 均未 override 它们,故默认外观逐值不变;+ * 变的是 override 面 —— 手写过 `settings-input-*` 的用户本地主题不再作用于本组件。+ * `--settings-input-border-focus` 亦同(其默认值 = `--text-tertiary-stone`)。+ */+const FIELD_CHROME =+ 'text-[var(--text-primary)] placeholder:text-[var(--text-placeholder)] border border-[var(--border-default)] focus:border-[var(--text-tertiary-stone)] focus:ring-2 focus:ring-[var(--focus-ring)]';++const ERROR_CHROME =+ 'border-[var(--error-border)] focus:border-[var(--error-fg)] focus:ring-[var(--error-fg)]';++export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'onChange'> {+ value: string;+ onChange: (v: string) => void;+ size?: InputSize;+ /** 底色档:默认 §4 规定的 `--surface-elevated`;`ivory` 见 SURFACE_STYLES 注释。 */+ surface?: InputSurface;+ /** 等宽字体——密钥、ID 这类需要逐字核对的值。 */+ mono?: boolean;+ /** 密钥字段:遮罩输入 + 自带明文切换按钮。`secret` 为真时由组件接管 type。 */+ secret?: boolean;+ /** 自定义尾随元素(需自行绝对定位)。`secret` 优先,两者不叠加。 */+ trailing?: ReactNode;+ /** 错误态:边框 / focus 环切到 `--error-*` 族。 */+ error?: boolean;+ /** 附加到**外层容器**(内层 input 恒为 w-full),供 flex 行传 `flex-1 min-w-0`。 */+ className?: string;+}++export function Input({+ value,+ onChange,+ onBlur,+ placeholder,+ type = 'text',+ size = 'lg',+ surface = 'elevated',+ mono = false,+ secret = false,+ trailing,+ error = false,+ className,+ disabled,+ autoComplete,+ spellCheck,+ style,+ ...rest+}: InputProps) {+ const { t } = useTranslation();+ const [revealed, setRevealed] = useState(false);+ const sizeStyle = SIZE_STYLES[size];+ const eyeStyle = EYE_STYLES[size];++ const eyeButton = secret ? (+ <button+ type="button"+ onClick={() => setRevealed((v) => !v)}+ className={cn(+ 'absolute top-1/2 -translate-y-1/2 text-[var(--settings-eye-icon)] transition-colors hover:text-[var(--settings-eye-icon-hover)]',+ // globals.css 的 F3 全局规则把 *:focus-visible 的 outline 抹掉了(只有 input /+ // textarea 恢复),按钮不自带焦点提示——键盘用户看不出焦点落在眼睛上。按 DESIGN.md+ // 的 Focus Blue 约定补 ring(--focus-ring),写法与其它图标按钮一致。+ 'rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',+ eyeStyle.offset,+ )}+ aria-label={revealed ? t('settings.apiKey.hideKey') : t('settings.apiKey.showKey')}+ >+ {revealed ? <Eye size={eyeStyle.iconSize} /> : <EyeOff size={eyeStyle.iconSize} />}+ </button>+ ) : null;+ const trailingNode = eyeButton ?? trailing;++ return (+ <div className={cn('relative', className)}>+ <input+ {...rest}+ type={secret ? (revealed ? 'text' : 'password') : type}+ value={value}+ onChange={(e) => onChange(e.target.value)}+ onBlur={onBlur}+ placeholder={placeholder}+ disabled={disabled}+ // 只对密钥关掉:密码管理器建议和拼写红线对密钥是干扰,但普通文本字段(显示名称、+ // baseUrl、模型名、请求头)该保留浏览器的自动补全与拼写检查,不能一并禁掉。+ autoComplete={secret ? 'off' : autoComplete}+ spellCheck={secret ? false : spellCheck}+ className={cn(+ 'w-full rounded-full outline-none transition-colors',+ sizeStyle.box,+ sizeStyle.paddingLeft,+ trailingNode ? sizeStyle.trailingPaddingRight : sizeStyle.paddingRight,+ mono && 'font-mono',+ FIELD_CHROME,+ SURFACE_STYLES[surface],+ error && ERROR_CHROME,+ disabled && 'cursor-not-allowed opacity-60',+ )}+ // 调用方内联样式后置于组件内置的文本选择样式之后:caller 可以覆盖+ // userSelect 等任何键,内置样式不再静默丢弃调用方的 style(Greptile P2)。+ style={{ userSelect: 'text', WebkitUserSelect: 'text', ...style }}+ />+ {trailingNode}+ </div>+ );+}++export interface TextareaProps+ extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'onChange'> {+ value: string;+ onChange: (v: string) => void;+ surface?: InputSurface;+ error?: boolean;+}++/** 多行输入:圆角一律 8px(§5),不走胶囊。 */+export function Textarea({+ value,+ onChange,+ onBlur,+ placeholder,+ surface = 'elevated',+ error = false,+ className,+ disabled,+ style,+ ...rest+}: TextareaProps) {+ return (+ <textarea+ value={value}+ onChange={(e) => onChange(e.target.value)}+ onBlur={onBlur}+ placeholder={placeholder}+ disabled={disabled}+ className={cn(+ 'w-full rounded-lg px-3 py-2 text-13 outline-none transition-colors',+ FIELD_CHROME,+ SURFACE_STYLES[surface],+ error && ERROR_CHROME,+ disabled && 'cursor-not-allowed opacity-60',+ className,+ )}+ {...rest}+ // 与 Input 相同的合并次序:内置文本选择样式在前,调用方 style 在后。+ style={{ userSelect: 'text', WebkitUserSelect: 'text', ...style }}+ />+ );+}diff --git a/apps/desktop/src/renderer/themes/__tests__/buttonStateContrast.test.ts b/apps/desktop/src/renderer/themes/__tests__/buttonStateContrast.test.tsnew file mode 100644index 0000000000..46699f40a6--- /dev/null+++ b/apps/desktop/src/renderer/themes/__tests__/buttonStateContrast.test.ts@@ -0,0 +1,130 @@+/**+ * DS-4 Button 状态梯守卫。+ *+ * 起因是一个真实缺陷:`--button-primary-hover` 曾 alias 到 `--surface-hover`,而+ * 暗色下 `--surface-hover` 与 `--surface-chip`(primary 的 rest 底色)本就同值,+ * default-dark / cindy-dark / one-dark-pro / monokai-pro 四个主题的悬停完全没有反馈;+ * `--button-secondary-pressed` 同理与 hover 撞色。DESIGN.md §10 双模式交付门槛把+ * 「状态不可区分」定为真实缺陷,必须交付前修。+ *+ * 本守卫对**每个内置主题**逐档解析 rest → hover → pressed,要求相邻两档+ * 至少差 MIN_DELTA(单通道 8/255)。它是 Level 1 静态守卫,改任一状态 token+ * 或改任一主题的 chip / elevated / accent 值都会被它复核。+ */+import { describe, expect, it } from 'vitest';++import { colorRegistry } from '../color-registry';+import '../colors';+import { builtinThemes } from '../registry';+import { resolveThemeValue } from '../theme-service';+import type { Theme } from '../types';++/** 单通道最小可见差;低于它人眼在实机上看不出状态变化。 */+const MIN_DELTA = 8;++interface Rgb {+ r: number;+ g: number;+ b: number;+}++function parseHex(value: string): Rgb {+ const hex = value.slice(1);+ const full = hex.length === 3 ? [...hex].map((d) => d.repeat(2)).join('') : hex;+ const n = Number.parseInt(full, 16);+ return { r: (n >> 16) & 255, g: (n >> 8) & 255, b: n & 255 };+}++const MIX_RE = /^color-mix\(in srgb,\s*(.+?)\s+(\d+)%,\s*(.+?)\)$/;+const VAR_RE = /^var\(--([a-z0-9-]+)\)$/;++/**+ * 把一个 token 解析成 RGB。支持三种形态:hex 字面量、`var(--x)` 转发、+ * `color-mix(in srgb, A p%, B)`(DS-4 状态梯用的形态,允许嵌套)。+ * 其余形态 fail closed —— 守卫宁可红,也不猜。+ */+function resolveRgb(theme: Theme, expr: string, depth = 0): Rgb {+ if (depth > 8) throw new Error(`token 解析层数过深: ${expr}`);+ const text = expr.trim();++ const varMatch = VAR_RE.exec(text);+ if (varMatch) {+ const next = resolveThemeValue(theme, varMatch[1]);+ if (next == null) throw new Error(`解析不到 token --${varMatch[1]}`);+ return resolveRgb(theme, next, depth + 1);+ }++ const mix = MIX_RE.exec(text);+ if (mix) {+ const a = resolveRgb(theme, mix[1], depth + 1);+ const b = resolveRgb(theme, mix[3], depth + 1);+ const k = Number(mix[2]) / 100;+ return {+ r: Math.round(a.r * k + b.r * (1 - k)),+ g: Math.round(a.g * k + b.g * (1 - k)),+ b: Math.round(a.b * k + b.b * (1 - k)),+ };+ }++ if (/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(text)) return parseHex(text);+ throw new Error(`守卫不认识的颜色形态: ${text}`);+}++function tokenRgb(theme: Theme, id: string): Rgb {+ const value = resolveThemeValue(theme, id);+ if (value == null) throw new Error(`主题 ${theme.id} 解析不到 --${id}`);+ return resolveRgb(theme, value);+}++function delta(a: Rgb, b: Rgb): number {+ return Math.max(Math.abs(a.r - b.r), Math.abs(a.g - b.g), Math.abs(a.b - b.b));+}++/** 与 components/ui/button.tsx 的 VARIANT_STYLES 一一对应。 */+const LADDERS = [+ { variant: 'primary', rest: 'surface-chip', hover: 'button-primary-hover', pressed: 'button-primary-pressed' },+ { variant: 'secondary', rest: 'surface-elevated', hover: 'button-secondary-hover', pressed: 'button-secondary-pressed' },+ { variant: 'cta', rest: 'accent-cta-bg-pure', hover: 'button-cta-hover', pressed: 'button-cta-pressed' },+] as const;++describe('DS-4 · Button 状态梯在每个内置主题都可区分', () => {+ it('六个状态 token 都已注册', () => {+ for (const ladder of LADDERS) {+ expect(colorRegistry.resolveDefault(ladder.hover, 'light'), ladder.hover).toBeTruthy();+ expect(colorRegistry.resolveDefault(ladder.pressed, 'light'), ladder.pressed).toBeTruthy();+ }+ });++ for (const theme of Object.values(builtinThemes)) {+ for (const ladder of LADDERS) {+ it(`${theme.id} · ${ladder.variant}:rest → hover → pressed 每档 ΔRGB ≥ ${MIN_DELTA}`, () => {+ const rest = tokenRgb(theme, ladder.rest);+ const hover = tokenRgb(theme, ladder.hover);+ const pressed = tokenRgb(theme, ladder.pressed);++ expect(+ delta(rest, hover),+ `${theme.id} ${ladder.variant} 悬停不可见:rest 与 hover 同色`,+ ).toBeGreaterThanOrEqual(MIN_DELTA);+ expect(+ delta(hover, pressed),+ `${theme.id} ${ladder.variant} 按下不可见:hover 与 pressed 同色`,+ ).toBeGreaterThanOrEqual(MIN_DELTA);+ });+ }+ }++ it('自证伪:把 hover 换回撞色的 --surface-hover,暗色主题必然红', () => {+ const darkTheme = builtinThemes['default-dark'];+ expect(darkTheme).toBeTruthy();+ // 复刻修复前的绑定:primary hover alias 到 --surface-hover。+ const rest = tokenRgb(darkTheme!, 'surface-chip');+ const brokenHover = tokenRgb(darkTheme!, 'surface-hover');+ expect(delta(rest, brokenHover)).toBeLessThan(MIN_DELTA);+ });++ it('自证伪:不认识的颜色形态 fail closed,不静默放行', () => {+ const theme = builtinThemes["default-light"];+ expect(() => resolveRgb(theme, 'oklch(0.5 0.1 200)')).toThrow(/不认识的颜色形态/);+ });+});diff --git a/apps/desktop/src/renderer/themes/__tests__/fixtures/desktop-color-defaults.json b/apps/desktop/src/renderer/themes/__tests__/fixtures/desktop-color-defaults.jsonindex e740170c8d..21c170da3f 100644--- a/apps/desktop/src/renderer/themes/__tests__/fixtures/desktop-color-defaults.json+++ b/apps/desktop/src/renderer/themes/__tests__/fixtures/desktop-color-defaults.json@@ -1,6 +1,6 @@{"source": "apps/desktop/src/renderer/themes/colors.ts",- "count": 514,+ "count": 520,"colors": [{"id": "surface",@@ -2571,6 +2571,36 @@"id": "caret-accent","light": "var(--accent-cta-bg)","dark": "var(--accent-cta-bg)"+ },+ {+ "id": "button-primary-hover",+ "light": "color-mix(in srgb, var(--surface-chip) 92%, var(--text-primary))",+ "dark": "color-mix(in srgb, var(--surface-chip) 92%, var(--text-primary))"+ },+ {+ "id": "button-primary-pressed",+ "light": "color-mix(in srgb, var(--button-primary-hover) 90%, var(--text-primary))",+ "dark": "color-mix(in srgb, var(--button-primary-hover) 90%, var(--text-primary))"+ },+ {+ "id": "button-secondary-hover",+ "light": "color-mix(in srgb, var(--surface-elevated) 92%, var(--text-primary))",+ "dark": "color-mix(in srgb, var(--surface-elevated) 92%, var(--text-primary))"+ },+ {+ "id": "button-secondary-pressed",+ "light": "color-mix(in srgb, var(--button-secondary-hover) 90%, var(--text-primary))",+ "dark": "color-mix(in srgb, var(--button-secondary-hover) 90%, var(--text-primary))"+ },+ {+ "id": "button-cta-hover",+ "light": "var(--accent-hover)",+ "dark": "var(--accent-hover)"+ },+ {+ "id": "button-cta-pressed",+ "light": "color-mix(in srgb, var(--button-cta-hover) 90%, var(--accent-pure-cta-fg))",+ "dark": "color-mix(in srgb, var(--button-cta-hover) 90%, var(--accent-pure-cta-fg))"}]}diff --git a/apps/desktop/src/renderer/themes/colors.ts b/apps/desktop/src/renderer/themes/colors.tsindex ed80d50c73..01fe2dcadb 100644--- a/apps/desktop/src/renderer/themes/colors.ts+++ b/apps/desktop/src/renderer/themes/colors.ts@@ -2299,3 +2299,43 @@ registerColor('caret-accent', {light: 'var(--accent-cta-bg)',dark: 'var(--accent-cta-bg)',}, 'Editable caret accent; CINDY overrides to focus blue #417CDD per user decision 2026-07-18(撤红改蓝)');++// DS-4 Button 状态矩阵(G2 hover 换色 / G3 pressed)。拍板人 = 用户/设计师,2026-09-03。+//+// 为什么 hover / pressed 是 color-mix 派生值而不是 alias 到既有 slot:+// 暗色下 `--surface-hover` 与 `--surface-chip` 本就同值(default-dark / cindy-dark /+// one-dark-pro / monokai-pro 实测),primary rest 与 hover 会撞成同色 —— 悬停零反馈,+// 违反 DESIGN.md §10 双模式交付门槛「状态不可区分即真实缺陷」。secondary 的+// `--surface-hover-soft` 同样在 atom-one-light / cindy-dark / eclipse / github-dark+// 贴着 `--surface-elevated`(CINDY 暗色只差 2/255)。+// 因此改为「从本变体的 rest 底色朝本变体的前景色推一档」:hover 8%、pressed 再 10%。+// 这套派生按主题自动跟随(rest 与前景都是被 override 的 token),11 个内置主题实测+// 每一级 ΔRGB ≥ 8;也不再引入不跟主题的字面量。运行期派生值按治理合同 §3.4+// 留在代码中、只登记不进 DTCG 影子层(classification 里为+// runtime-derived-or-protected)。+registerColor('button-primary-hover', {+ light: 'color-mix(in srgb, var(--surface-chip) 92%, var(--text-primary))',+ dark: 'color-mix(in srgb, var(--surface-chip) 92%, var(--text-primary))',+}, 'DS-4 button/primary hover — rest 底色朝 text-primary 推 8%');+registerColor('button-primary-pressed', {+ light: 'color-mix(in srgb, var(--button-primary-hover) 90%, var(--text-primary))',+ dark: 'color-mix(in srgb, var(--button-primary-hover) 90%, var(--text-primary))',+}, 'DS-4 button/primary pressed — 自 hover 再推 10%,保证梯子单调');+registerColor('button-secondary-hover', {+ light: 'color-mix(in srgb, var(--surface-elevated) 92%, var(--text-primary))',+ dark: 'color-mix(in srgb, var(--surface-elevated) 92%, var(--text-primary))',+}, 'DS-4 button/secondary hover — rest 底色朝 text-primary 推 8%');+registerColor('button-secondary-pressed', {+ light: 'color-mix(in srgb, var(--button-secondary-hover) 90%, var(--text-primary))',+ dark: 'color-mix(in srgb, var(--button-secondary-hover) 90%, var(--text-primary))',+}, 'DS-4 button/secondary pressed — 自 hover 再推 10%');+// cta hover 沿用 §4 既有规定的 --accent-hover(其注释本写明 "CTA pressed/hover"),+// 只给 Button 一个组件级名字,便于 DS-8 生成 component 层时落回 semantic。+registerColor('button-cta-hover', {+ light: 'var(--accent-hover)',+ dark: 'var(--accent-hover)',+}, 'DS-4 button/cta hover — 沿用 --accent-hover(DESIGN.md §4)');+registerColor('button-cta-pressed', {+ light: 'color-mix(in srgb, var(--button-cta-hover) 90%, var(--accent-pure-cta-fg))',+ dark: 'color-mix(in srgb, var(--button-cta-hover) 90%, var(--accent-pure-cta-fg))',+}, 'DS-4 button/cta pressed — 自 cta hover 朝 CTA 前景再推 10%');diff --git a/docs/design-evidence/2026-09-04/README.md b/docs/design-evidence/2026-09-04/README.mdnew file mode 100644index 0000000000..99c21514b9--- /dev/null+++ b/docs/design-evidence/2026-09-04/README.md@@ -0,0 +1,83 @@+# DS-4 证据 · 2026-09-04++- 分支:`ds/4-button-input-primitives`+- 基点 SHA(开工时 `origin/main`):`c4033acd07910b9b3c993772589dcda877188fb1`+- 平台:Desktop+- 实机沙箱:`CindyGlobal-dev2-ds-4-button-input-fcdc92`,`node scripts/desktop-whoami.mjs` 报 MATCH 本 worktree+- 主题:CINDY Light 与 CINDY Dark(实机)+ 默认主题 token 对照图++## Level 2 实机逐格(`cells/`)++对真实运行的 Desktop 用 CDP `CSS.forcePseudoState` 强制伪类后裁剪截图,`background-color`+取自 `CSS.getComputedStyleForNode`。目标是 `设置 → 模型供应商 → OpenAI` 详情里的+「断开」按钮,即 `ui/button` 的 `variant="secondary"`。++| 主题 | rest | hover | pressed | disabled + hover |+| --- | --- | --- | --- | --- |+| CINDY Light | `#FDFDF8` | `235,235,230` | `214,214,210` | `#FDFDF8`(不变) |+| CINDY Dark | `#1F1F1F` | `45,45,45` | `62,62,62` | `#1F1F1F`(不变) |++两条要点:++- **暗色梯度成立**。修复前 CINDY Dark 的 secondary hover 距 rest 只有 2/255,实测已拉到 14。+- **禁用态悬停不再换色**。`disabled + hover` 回到 rest 值,证明 `enabled:` 前缀生效。++`variant="primary"` 在本张没有生产消费者(`PillButton` → secondary、`CtaPillButton` → cta),+因此没有实机格;它由 Level 1 的 11 主题状态梯守卫覆盖。`cta` 的实机格需要 XD 资产模块+处于可购买态,本次沙箱未构造出该状态。++## 其余文件++| 文件 | 内容 |+| --- | --- |+| `live-settings-providers.png` | 实机:设置 → 模型供应商 |+| `live-add-provider-wizard.png` | 实机:添加供应商向导 |+| `ds4-g5-secondary-compare.png` | G5 同值性对照:现状灰底 / 规范白底 secondary / 规范灰底 primary |+| `ds4-button-input-state-matrix.png` | 默认主题 token 值对照图(画的,非实机) |++⚠ `ds4-button-input-state-matrix.png` 是 2026-09-04 上午按**修复前**的 token 值画的,+其中的 hover / pressed 色号已不代表现行实现;现行值以上表实机测量为准。保留它是为了+留下「初版为何看不出暗色缺陷」的痕迹。++## Level 1 静态守卫++| 守卫 | 锁什么 |+| --- | --- |+| `themes/__tests__/buttonStateContrast.test.ts` | 11 个内置主题 × 3 变体,rest → hover → pressed 每档 ΔRGB ≥ 8;含自证伪(把 hover 换回撞色的 `--surface-hover` 必然红) |+| `components/ui/__tests__/button.test.tsx` | 变体 token 合同表、胶囊圆角、text-13/500、尺寸只两档、禁用态无裸 `hover:`;含自证伪 |+| `components/ui/__tests__/input.test.tsx` | fill / text / placeholder / focus token、三档高度、ivory variant、error 态、secret 显形;含自证伪 |+| `packages/design-tokens` classification | 5 个运行期派生状态值必须登记为 `runtime-derived-or-protected`(治理合同 §3.4) |+| `themes/__tests__/desktopColorDefaultsFreeze.test.ts` | DS-2b 快照与实时注册逐值一致 |++## 有意可见差异(设计师已批)++1. **G5 secondary 统一成白底**:设置页 `PillButton` 从 `--settings-btn-secondary-*` 改绑+ `--surface-elevated`。CINDY Light 下与卡片同色,读成空心描边。用户 2026-09-03 看默认+ 主题对照后选统一成白底,2026-09-04 看实机后确认「可以,没问题」。+ (实机批准时还看了「设置 → 通用」的退出登录 / 登录更多账号两颗按钮;该截图含账号邮箱与+ 组织信息,**不入库**——本仓公开,个人数据不进 Git 历史。同一按钮变体的可入库证据见+ `live-settings-providers.png` 与 `cells/`。)+2. **G2 Cta hover**:私有原型 `hover:opacity-90` 换成换色。文字不再跟着变淡。+3. **状态梯改为派生,hover 8% / pressed 10%**:用户 2026-09-04 批准。取代 09-03 原定的+ 「从 `--surface-hover` 族现值取」——那样在 4 个暗色主题里状态不可区分。落地时比例尚未+ 获批、事后补批,该流程越界已记入 `design-decision-log.md` 09-04 条。++## 次要差异(2026-09-04 已逐项裁决,详见 decision-log 同日条)++1. **输入框禁用态 60% 不透明度 —— 保留。** 全仓 19 个输入调用点只有 1 个会传 `disabled`+ (Agent 资源占用的「并发命令上限」,仅预设写盘在途)。该输入框改造前就已传 `disabled`+ 却无视觉表现,而同 section 的预设按钮改造前就带 `opacity-60` —— 本项是补齐同屏不一致,+ 不是新增观感。CINDY Light 合成值:边框 `#E4E4DF`→`#EEEEE9`、数字 `#1A1A1A`→`#757573`。+2. **`ui/input` 保持绑 Tier-1 —— 不回退域 alias。** 分裂只在「新建本地副本」导出型本地主题+ 下可见(导出把 520 个 token 全部展平成字面量);导入型 VSCode / Obsidian 主题零影响。+ 该断层线既存:全仓直接读 `border-default` 513 处 vs 读 `settings-input-border` 138 处,+ DS-4 只是把 6 个调用点挪到人多的一侧。138 处收口已登记为 **DS-5 待办**(台账+ `desktop.settings` 下一动作)。++## 缺口如实登记++- `variant="primary"` 与 `cta` 无实机逐格截图,原因见上。+- 「声明零视觉的迁移逐像素一致」**未做**,且本张已不适用:secondary 换白底、输入框禁用态+ 两处都是真实视觉变化,已在上面逐条列出,不再声称零视觉。+- `DESIGN.md §4` 单行输入 focus 环的 spec 与实现不一致,登记进+ `design-governance.md §10` 待裁决表,本张不擅自统一。diff --git a/docs/design-evidence/2026-09-04/cells/cindy-dark-secondary-disabled-hover.png b/docs/design-evidence/2026-09-04/cells/cindy-dark-secondary-disabled-hover.pngnew file mode 100644index 0000000000..ff71d4dea3Binary files /dev/null and b/docs/design-evidence/2026-09-04/cells/cindy-dark-secondary-disabled-hover.png differdiff --git a/docs/design-evidence/2026-09-04/cells/cindy-dark-secondary-hover.png b/docs/design-evidence/2026-09-04/cells/cindy-dark-secondary-hover.pngnew file mode 100644index 0000000000..dd12f2f923Binary files /dev/null and b/docs/design-evidence/2026-09-04/cells/cindy-dark-secondary-hover.png differdiff --git a/docs/design-evidence/2026-09-04/cells/cindy-dark-secondary-pressed.png b/docs/design-evidence/2026-09-04/cells/cindy-dark-secondary-pressed.pngnew file mode 100644index 0000000000..68aff31892Binary files /dev/null and b/docs/design-evidence/2026-09-04/cells/cindy-dark-secondary-pressed.png differdiff --git a/docs/design-evidence/2026-09-04/cells/cindy-dark-secondary-rest.png b/docs/design-evidence/2026-09-04/cells/cindy-dark-secondary-rest.pngnew file mode 100644index 0000000000..3591d4738eBinary files /dev/null and b/docs/design-evidence/2026-09-04/cells/cindy-dark-secondary-rest.png differdiff --git a/docs/design-evidence/2026-09-04/cells/cindy-light-secondary-disabled-hover.png b/docs/design-evidence/2026-09-04/cells/cindy-light-secondary-disabled-hover.pngnew file mode 100644index 0000000000..f298295b2fBinary files /dev/null and b/docs/design-evidence/2026-09-04/cells/cindy-light-secondary-disabled-hover.png differdiff --git a/docs/design-evidence/2026-09-04/cells/cindy-light-secondary-hover.png b/docs/design-evidence/2026-09-04/cells/cindy-light-secondary-hover.pngnew file mode 100644index 0000000000..d580644325Binary files /dev/null and b/docs/design-evidence/2026-09-04/cells/cindy-light-secondary-hover.png differdiff --git a/docs/design-evidence/2026-09-04/cells/cindy-light-secondary-pressed.png b/docs/design-evidence/2026-09-04/cells/cindy-light-secondary-pressed.pngnew file mode 100644index 0000000000..248e55d5c9Binary files /dev/null and b/docs/design-evidence/2026-09-04/cells/cindy-light-secondary-pressed.png differdiff --git a/docs/design-evidence/2026-09-04/cells/cindy-light-secondary-rest.png b/docs/design-evidence/2026-09-04/cells/cindy-light-secondary-rest.pngnew file mode 100644index 0000000000..0d2b1032c1Binary files /dev/null and b/docs/design-evidence/2026-09-04/cells/cindy-light-secondary-rest.png differdiff --git a/docs/design-evidence/2026-09-04/ds4-button-input-state-matrix.png b/docs/design-evidence/2026-09-04/ds4-button-input-state-matrix.pngnew file mode 100644index 0000000000..6ecd885114Binary files /dev/null and b/docs/design-evidence/2026-09-04/ds4-button-input-state-matrix.png differdiff --git a/docs/design-evidence/2026-09-04/ds4-g5-secondary-compare.png b/docs/design-evidence/2026-09-04/ds4-g5-secondary-compare.pngnew file mode 100644index 0000000000..d95f9cc674Binary files /dev/null and b/docs/design-evidence/2026-09-04/ds4-g5-secondary-compare.png differdiff --git a/docs/design-evidence/2026-09-04/live-add-provider-wizard.png b/docs/design-evidence/2026-09-04/live-add-provider-wizard.pngnew file mode 100644index 0000000000..5bdf689ec0Binary files /dev/null and b/docs/design-evidence/2026-09-04/live-add-provider-wizard.png differdiff --git a/docs/design-evidence/2026-09-04/live-settings-providers.png b/docs/design-evidence/2026-09-04/live-settings-providers.pngnew file mode 100644index 0000000000..24f787366dBinary files /dev/null and b/docs/design-evidence/2026-09-04/live-settings-providers.png differdiff --git a/docs/design-rules/DESIGN.md b/docs/design-rules/DESIGN.mdindex 6d5daa3407..6f714a46ca 100644--- a/docs/design-rules/DESIGN.md+++ b/docs/design-rules/DESIGN.md@@ -187,8 +187,13 @@ button/primary (Gray Pill)border 1px solid --surface-chip (same as fill)radius 9999px (pill)padding 10px 24px- height ⚠ not yet specified (only padding is normative)+ height 32px (md) / 36px (lg) — no 40px size (DS-4 G1, 2026-09-03)+ type text-13 / font-medium 500 (DS-4 G4, 2026-09-03)+ hover --button-primary-hover rest fill mixed 8% toward --text-primary (swap-color, never opacity; DS-4 G2)+ pressed --button-primary-pressed hover mixed a further 10% toward --text-primary (DS-4 G3)+ disabled opacity 60%; ordinary pointer (#3246)note understated, grayscale, always a pill+ impl components/ui/button.tsx variant="primary"button/secondary (White Pill)fill --surface-elevated #ffffff / #2c2c2a@@ -196,16 +201,30 @@ button/secondary (White Pill)border --border-default #d7d7d4 / #3c3c3aradius 9999px (pill)padding 10px 24px- note visually lighter than primary+ height 32px (md) / 36px (lg) — no 40px size (DS-4 G1)+ type text-13 / font-medium 500 (DS-4 G4)+ hover --button-secondary-hover rest fill mixed 8% toward --text-primary+ pressed --button-secondary-pressed hover mixed a further 10% toward --text-primary+ disabled opacity 60%; ordinary pointer+ note visually lighter than primary; binds Tier-1, not --settings-btn-secondary-* (DS-4 G5)+ impl components/ui/button.tsx variant="secondary"button/cta (Black Pill — maximum emphasis)fill --accent-cta-bg-pure #000000 / #fffffftext --accent-pure-cta-fg #ffffff / #000000radius 9999px (pill)padding 10px 24px- note pure black on white (inverts in Dark)+ height 32px (md) / 36px (lg) — no 40px size (DS-4 G1)+ type text-13 / font-medium 500 (DS-4 G4)+ hover --button-cta-hover = --accent-hover #262626 / #e5e5e5 (swap-color; was opacity-90 on the private prototype, DS-4 G2, intentional)+ pressed --button-cta-pressed cta hover mixed a further 10% toward --accent-pure-cta-fg+ disabled opacity 60%; ordinary pointer+ note pure black on white (inverts in Dark); at most one per screen+ impl components/ui/button.tsx variant="cta"```+**Why hover / pressed are derived, not aliased** (DS-4; ratios ruled by the designer 2026-09-04): in Dark, `--surface-hover` and `--surface-chip` resolve to the same value in default-dark / cindy-dark / one-dark-pro / monokai-pro, so aliasing primary's hover to `--surface-hover` made the hover state invisible; `--surface-hover-soft` sat within 2/255 of `--surface-elevated` in cindy-dark, breaking secondary the same way. Each state is therefore mixed off **its own variant's rest fill toward its own foreground** — 8% for hover, a further 10% for pressed. The ladder follows any theme override automatically and introduces no theme-blind literals. Guard: `themes/__tests__/buttonStateContrast.test.ts` asserts every builtin theme keeps each step at ΔRGB ≥ 8. These are runtime-derived values, registered but not modeled in the DTCG shadow layer (governance §3.4).+### Cards & Containers```@@ -226,11 +245,17 @@ input/texttext --text-primary #262626 / #d4d4d4border --border-default #d7d7d4 / #3c3c3aradius 9999px (pill — single-line inputs)+ height 32px (sm) / 36px (md) / 40px (lg) (DS-4 G1; three sizes, shared 4px step with buttons)focus --focus-ring-soft rgba(65,124,221,0.5) (50% of #417CDD; opaque border variant = --focus-ring)+ ⚠ known implementation deviation: components/ui/input.tsx ships the opaque --focus-ring, inherited from the SettingsTextInput convergence. DS-4 did NOT amend this spec value; the gap is registered in design-governance.md §10 pending a designer ruling.placeholder --text-placeholder #c4c4c4 / #525252+ error --error-border / --error-fg+ impl components/ui/input.tsx+ disabled 60% opacity + ordinary pointer (new in DS-4; the pre-DS-4 SettingsTextInput had no disabled styling and none of its 6 consumers passed it)+ ivory surface="ivory" → --settings-input-bg (--surface-card-ivory). Registered debt (DS-4 G6, 2026-09-03) — colors.ts undocumented drift for white-panel dialogs; do not make it the default. Close as a separate issue.```-- **Multi-line inputs (textarea) take the 8px inner-control radius — never the pill** (tall frames deform it), whether nested in a container or standing alone in a form (§5 three-tier scale; single rule, no nesting condition).+- **Multi-line inputs (textarea) take the 8px inner-control radius — never the pill** (tall frames deform it), whether nested in a container or standing alone in a form (§5 three-tier scale; single rule, no nesting condition). Implementation: `components/ui/input.tsx` `Textarea`.- Placeholders must **read as clearly empty** — Silver (`#a3a3a3`) is too prominent against either Card surface (≈5:1 Dark / ≈2.6:1 Light) and reads as real input; forbidden. **Every input surface's placeholder (chat / ask / settings / plan-action-fb) resolves to `--text-placeholder`** (2026-06 G3, archived in `design-decision-log.md`); non-default themes express their own placeholder color by overriding `text-placeholder`.### Select & Dropdowndiff --git a/docs/design-rules/cindy-design-system.md b/docs/design-rules/cindy-design-system.mdindex 79032a50ba..ac12756b8d 100644--- a/docs/design-rules/cindy-design-system.md+++ b/docs/design-rules/cindy-design-system.md@@ -23,6 +23,8 @@## 版本记录+- **2026-09-04(DS-4 Button 与 Input 标准组件)**:`components/ui/button.tsx` / `input.tsx` 落地;§4 回写高度 / hover 换色 / pressed / 字号字重 / secondary 绑 Tier-1 / ivory 登记债(拍板人 = 用户/设计师,2026-09-03)。影子包新建 component 层。路线图 DS-3 已是 #3798;DS-4 号待本张合入后回填。 同日 self-review 收口三处:hover / pressed 改为从本变体 rest 底色朝前景 color-mix 派生(初版 alias 到 `--surface-hover` 在四个暗色主题里状态不可区分,违反 §10 双模式门槛;字面量 pressed 不跟主题),新增守卫 `themes/__tests__/buttonStateContrast.test.ts` 锁 11 主题每档 ΔRGB ≥ 8;按钮 hover / active 加 `enabled:` 前缀,修禁用态仍会 hover 换色的行为回归;§4 单行输入 focus 环还原为 `--focus-ring-soft`,spec 与实现的偏差改为登记进 [`design-governance.md`](./design-governance.md) §10 待裁决表,不擅自统一。+- **2026-09-02(Desktop 登录成功回调页 UX 覆盖)**:成功态移除返回 Cindy 按钮,改为 560×500 紧凑内容流卡片,底部显示本地化 3 秒倒计时并在结束时先移除文字再调用 `window.close()`;失败 / Warning 继续使用 680×680 卡片与返回操作。同步更新 `DESIGN.md §16`、`figma-component-spec.md §6`、`token-decision-table.md §4` 与客户端模板测试。- **2026-09-02(DS-3 最小语义 Token 影子层)**:新建 `packages/design-tokens`(标准 DTCG JSON,reference → semantic 两层)。数据源为 DS-2b 冻结快照,零运行时接线;弃坑复查日期 2026-11-01。不改台账、不改产品代码。路线图 DS-2b 回填为 #3700。diff --git a/docs/design-rules/design-decision-log.md b/docs/design-rules/design-decision-log.mdindex 30899a5335..505ac0fdf2 100644--- a/docs/design-rules/design-decision-log.md+++ b/docs/design-rules/design-decision-log.md@@ -10,6 +10,113 @@> 2026-07-25 起 `§15` CINDY 皮肤族的决策史(红色体系重构、caret 改稿、vibrancy> 定稿等)已随 §15 保号重构迁入本文件,`DESIGN.md §15` 只保留现行规范。+## 2026-09++- **09-03** **DS-4 Button / Input 规格缺口六项裁决(拍板人 = 用户/设计师)**——+ 背景:`DESIGN.md §4` 按钮 `height ⚠ not yet specified`,hover / pressed / 字号字重 /+ secondary token 归属 / SettingsTextInput ivory 底均未写死。本张把既有+ PillButton / CtaPillButton / SettingsTextInput 升格进 `components/ui/`,+ 规格按下列裁决回写 §4(去掉 `⚠ not yet specified`)。+ 1. **G1 高度**:按钮双档 32/36px、输入框三档 32/36/40px,共用 4px 步进;按钮不设 40,+ 不为对称造无消费者的档。+ 2. **G2 hover**:机制统一为换色 token,禁用透明度 hover。Cta 私有原型的+ `hover:opacity-90` 换成 `--accent-hover` 是**有意视觉变化**。+ 3. **G3 pressed**:进最低状态矩阵。+ **值的实现方式在 2026-09-04 self-review 后改过一轮**:初版把 hover 记账成+ 既有 slot 的 alias(primary hover → `--surface-hover`、secondary pressed →+ `--surface-chip`),pressed 用字面量(`#cfcfcd` / `#4a4a48` / `#1a1a1a`)。+ 复核发现两类问题:+ - **暗色状态不可区分(真实缺陷)**:暗色下 `--surface-hover` 与 `--surface-chip`+ 同值,default-dark / cindy-dark / one-dark-pro / monokai-pro 四个主题+ primary 悬停零反馈;`--surface-hover-soft` 在 cindy-dark 距+ `--surface-elevated` 仅 2/255,secondary 同样失效。违反 `DESIGN.md §10`+ 双模式交付门槛。+ - **字面量 pressed 不跟主题**:monokai-pro 色板 `#403E41`,按下会跳到+ 无关的 `#4a4a48`。+ **改法与比例经用户 2026-09-04 补批**(越界经过见下方 09-04 条):每一档从+ **本变体的 rest 底色朝本变体的前景色**混色——hover 8%、pressed 自 hover 再 10%;+ cta hover 仍是 `--accent-hover`,另给组件名 `--button-cta-hover` 便于 DS-8+ 落回 semantic。11 个内置主题实测每档 ΔRGB ≥ 8。守卫+ `themes/__tests__/buttonStateContrast.test.ts`。这五个派生值按治理合同 §3.4+ 只登记不进 DTCG 影子层。+ 4. **G4 字号字重**:text-13 + font-medium(500),直接写进 §4。+ 5. **G5 secondary token**:`ui/button` secondary 绑 Tier-1+ (`--surface-elevated` + `--border-default`),不继承 `--settings-btn-secondary-*`。+ 同值性核查(默认 Light/Dark 快照):**不同值**——Light fill+ `settings-btn-secondary-bg` → `--surface-chip-alt` `#e5e5e5` vs+ `--surface-elevated` `#ffffff`;Dark fill 同值 `#2c2c2a`。用户 2026-09-03+ 看对照图后裁决**接受有意统一成白底**(设置页这批灰药丸改成规范次级;+ 亮色从灰变白,暗色几乎不变)。2026-09-04 用户在隔离沙箱实机+ (CINDY Light,设置通用 / 模型供应商)确认空心描边「可以,没问题」。+ 6. **G6 ivory**:保留为显式 `surface="ivory"` variant,三处标登记债+ (§4 / 台账 `desktop.settings` 下一动作 / 组件注释)。本张不翻案。+ 落点:`DESIGN.md §4`、`components/ui/button.tsx`、`components/ui/input.tsx`、+ `colors.ts` `button-*` token、影子包 `src/component/color.json`。++- **09-04** **Button 状态梯改为派生,比例 hover 8% / pressed 10%(拍板人 = 用户/设计师)**——+ 取代 09-03 G2/G3 原本的「值从 `--surface-hover` 族现值取 / 用现有 chip-hover token+ 加深一档」。**改法的动因是缺陷,比例是新裁决**:+ - 照原指令实现后,`--surface-hover` 在暗色下与 `--surface-chip` 同值,+ default-dark / cindy-dark / one-dark-pro / monokai-pro 的 primary 悬停零反馈;+ `--surface-hover-soft` 在 cindy-dark 距 `--surface-elevated` 仅 2/255,secondary 同样失效。+ 字面量 pressed 则不跟主题(monokai-pro 色板 `#403E41`,按下会跳到无关的 `#4a4a48`)。+ - 定案:每档从本变体 rest 底色朝本变体前景色混色,**hover 8%、pressed 自 hover 再 10%**。+ 这与 G2 当初选换色 token 的理由同向——「能被主题 override,直接关系换风格只改颜料表」;+ 派生跟随任何主题覆盖,固定色号做不到。+ - 实机验证(CINDY Dark,即修复前坏得最厉害的主题):secondary rest `#1F1F1F` →+ hover `45,45,45` → pressed `62,62,62`,悬停差值由 2 拉到 14。++ **同时记下一次流程越界,供后续张次引用**:计划 §5 要求「六项裁决之外若再遇现状差异,+ 列出报告,不擅自统一」,G2/G3 也明确「值走记账,设计师 review 批」。执行方虽然报告了+ 暗色撞色这一差异,但在收到「全部修」后**自行选定了派生方案与 8% / 10% 两个比例并直接落地**,+ 没有把方案本身回交裁决——落地时这两个比例处于未获批状态,直到 2026-09-04 用户补批。+ 治理合同 §1.1 把这类具体色号列为「记账值」,合法改值路径是「同 PR 更新快照 + 交证据 ++ 设计师批准」;前三步当时已完成,缺的正是第四步。**结论不是「派生错了」,而是+ 「修缺陷可以自主,定值不可以」**——本条留档,避免被后人当成「执行方可自行发明设计值」的先例。++- **09-04** **DS-4 两项次要差异裁决:输入框禁用态保留、域 alias 不回退(拍板人 = 用户/设计师)**——+ 这两项是 self-review 时补申报、当时尚未单独获批的差异。逐条走查后裁决:+ 1. **输入框禁用态 60% 不透明度:保留。** 全仓 19 个输入调用点里**只有 1 个**会传+ `disabled`(`AgentResourceSection` 的「并发命令上限」,仅在三档预设写盘在途时为真)。+ 关键事实:该输入框**改造前就已经传 `disabled`**,只是没有任何视觉表现;而**同一+ section 的三档预设按钮改造前就带 `opacity-60`**(`AgentResourceSection.tsx` 既有代码)。+ 所以改造前的实际观感是「按钮变淡、紧邻的数字框不变」——本项不是新增禁用观感,+ 是补齐同屏不一致。CINDY Light 合成后:边框 `#E4E4DF`→`#EEEEE9`、数字+ `#1A1A1A`→`#757573`、填充与卡片同色故无变化。+ 2. **`ui/input` 保持绑 Tier-1,不回退域 alias。** 分裂风险已量化:仅在用户持有+ **「新建本地副本」导出型本地主题**时可见。该导出把全部 520 个 token 解析成**字面量**+ 写进 JSON(`theme-service.ts` `exportThemeColors` 遍历整个 colorRegistry),而+ `resolveThemeValue` 优先读本地主题字面量——于是这类用户改 `border-default` 时,+ 标准输入框(6 处)跟着变,被字面量钉住的 `--settings-input-border` 消费者(138 处)不变。+ 判定保留的三条理由:(a) **导入型 VSCode / Obsidian 主题零影响**——导入器只写 108 个+ token、不含 `settings-input-*`,那批消费者会向上回落到同一个 slot,一致;+ (b) **这条断层线既存、非 DS-4 新造**:导出型主题里「直接读 `border-default`」(全仓+ 513 处)与「读 `settings-input-border`」(138 处)本来就会因改其一而分裂,DS-4 只是把+ 6 个调用点从 138 那侧挪到 513 那侧,即让标准件站到人多的一侧;+ (c) `settings-input-placeholder` 一项本就被 `local-themes-normalize` 丢弃并转成+ `text-placeholder`,零影响。+ **代价照实登记**:那 138 处(连同同族共 49 个文件)的收口作为 **DS-5 待办**写入+ `design-inventory.md` 的 `desktop.settings` 人工区下一动作;因其跨 6 个其它 surface,+ 须整族一次收口,不按 surface 零敲。修的方向是把未收口的一侧拉过来,而非把标准件退回去。+ 本条不带任何产品代码改动——两项实现在 self-review 时已落地,这里只补裁决与登记。++- **09-04** **DS-4 self-review 追加的三项收口(非新裁决,是修缺陷与补申报)**——+ 1. **禁用态不再触发 hover 换色**:`ui/button` 的 hover / active 一律加 `enabled:`+ 前缀。CSS 的 `:hover` 对 disabled 元素照样匹配,而 `globals.css` 只把禁用态+ 指针收成普通箭头、不管背景;旧 `PillButton` 根本没有 hover,所以这属 DS-4+ 迁移引入的行为回归(ProvidersSection 多处传 `disabled={busy}`)。+ 2. **`§4 input/text` 的 focus 槽还原为 `--focus-ring-soft`**:初版把规范值改成+ opaque `--focus-ring` 去迁就实现,但这不在六项裁决里。按「六项裁决之外遇到+ 现状差异只登记、不擅自统一」还原 spec,偏差登记进 `design-governance.md §10`+ 待裁决表。+ 3. **`ui/input` 换绑 Tier-1 的事实补申报**:border / text / placeholder /+ focus-border 从 `--settings-input-*` 域 alias 改绑+ `--border-default` / `--text-primary` / `--text-placeholder` /+ `--text-tertiary-stone`(与 G5 对 button/secondary 同一条判据)。11 个内置+ 主题与外部主题导入 allowlist 均未 override 这些 alias,故默认外观逐值不变;+ 变的是 override 面——手写过 `settings-input-*` 的用户本地主题不再作用于本组件。+ 旧 token ID 一个未删,兼容红线未破。+## 2026-08- **08-29** **圆角三档写死:按钮一律胶囊、4px 不入档(拍板人 = 用户)**——diff --git a/docs/design-rules/design-governance.md b/docs/design-rules/design-governance.mdindex bc5a2d33b8..0c322c21d1 100644--- a/docs/design-rules/design-governance.md+++ b/docs/design-rules/design-governance.md@@ -213,6 +213,7 @@ ls apps/desktop/src/renderer/themes/builtin/*.ts | wc -l| --- | --- | --- | --- || PermissionPrompt 圆角 | **已关闭(2026-08-29 裁决,#3619 回写)**:三档不变、按钮一律胶囊(唯一豁免 = 已登记的裸文字按钮)、8px = textarea 一律 8px + 盒内非按钮、4px 不入档(含裸 `rounded` / `rounded-sm` 等价写法,**前提 = 主题未覆盖 `colors.radius`**;存量为债、新代码禁止)、「看起来小」不是改档理由。`DESIGN.md §5` 已加硬,全文归档于 [`design-decision-log.md`](./design-decision-log.md)「08-29」条 | 设计师 | 已按 `DESIGN.md §13` 机制回写并归档(与回写同一 PR 生效) || `radius` 主题覆盖 | 待裁决(随 DS-7 棘轮设计一并关):本地主题 JSON 可覆盖 `colors.radius`(`resolveThemeValue` 优先 `theme.colors[id]`),届时 `rounded-sm`/`rounded-md` 的 computed 值整体平移、不再等于 4px/6px。是否冻结 `radius` 为不可覆盖不变量(涉及 `local-themes-normalize` 白名单 + 既有本地主题兼容红线);裁决前 DS-7 按类名建基线、以默认主题 computed 值为准 | 设计师 | 未关闭前 DS-7 棘轮不得把覆盖了 `radius` 的本地主题报为违规;结论回写 `DESIGN.md` §5 与 decision-log |+| 单行输入 focus 环:spec 与实现不一致 | 待裁决(DS-4 2026-09-04 登记):`DESIGN.md §4` `input/text` 规定 focus 用 `--focus-ring-soft`(50% 蓝),而 `components/ui/input.tsx`(升格自 SettingsTextInput)实到的是 opaque `--focus-ring`——该偏差在收敛 SettingsTextInput 时即存在,理由是与相邻未迁移输入保持一致。DS-4 只登记不擅自统一:改 spec 会追认一个没人裁决过的值,改实现会动 6 个既有消费者的观感 | 设计师 | 未关闭前 `ui/input` 维持 opaque `--focus-ring`,§4 保留 ⚠ 标注;结论回写 `DESIGN.md §4` 并归档 decision-log || Permission 迁移余项 | 待裁决:允许/拒绝按钮的视觉主次、危险授权样式、Desktop 与 Mobile 权限弹窗几何是否一致 | 设计师 | 余项未关闭前,Permission 相关文件不得进入任何迁移 PR 的 diff(DS-6 前置);结论同样回写 `DESIGN.md` 并归档 |## 11. 存量门禁与文档处置表diff --git a/docs/design-rules/design-inventory.md b/docs/design-rules/design-inventory.mdindex 2bc947c479..4442dbda4f 100644--- a/docs/design-rules/design-inventory.md+++ b/docs/design-rules/design-inventory.md@@ -37,7 +37,7 @@| `desktop.overlay.toast` | desktop | Toast | App 常驻 ToastContainer(用户可见出口,不展开业务逻辑) | Toast, ToastContainer | apps/desktop/src/renderer/components/ui/toast/Toast.tsx, apps/desktop/src/renderer/components/ui/toast/ToastContainer.tsx, apps/desktop/src/renderer/components/ui/toast/index.ts | 4 | 4 | 2 || `desktop.plugins.app-main` | desktop | 插件主视图 | hash `/apps/:ghostId`(GhostMainViewFeatureLayout) | GhostMainViewFeatureLayout, GhostMainViewHost | apps/desktop/src/renderer/features/plugin/GhostMainViewFeatureLayout.tsx, apps/desktop/src/renderer/features/plugin/GhostMainViewHost.tsx | 0 | 0 | 0 || `desktop.plugins.installed` | desktop | 已装插件 | hash `/plugins`(GhostPluginPage) | AddMarketplaceDialog, GhostPluginDetailView, GhostPluginPage, MarketPluginDetailView, MyPublishesSection, PluginManagementLayout, PluginScopePicker, UpdateAllDialog | apps/desktop/src/renderer/features/plugin/AddMarketplaceDialog.tsx, apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx, apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx, apps/desktop/src/renderer/features/plugin/MarketPluginDetailView.tsx, apps/desktop/src/renderer/features/plugin/MyPublishesSection.tsx, apps/desktop/src/renderer/features/plugin/PluginManagementLayout.tsx, apps/desktop/src/renderer/features/plugin/PluginScopePicker.tsx, apps/desktop/src/renderer/features/plugin/UpdateAllDialog.tsx, apps/desktop/src/renderer/features/plugin/plugin-motion.css | 49 | 0 | 81 |-| `desktop.settings` | desktop | 设置 | hash `/settings`(SettingsView;tab 含 general / personalization / providers / billing / usage / voice-input / im-bot / shortcuts / agent-island / import / remote-control / ghosts / builtin-tools / computer-use / help / about) | SettingsView | apps/desktop/src/renderer/components/settings/AboutSection.tsx, apps/desktop/src/renderer/components/settings/AccountDeletionSection.tsx, apps/desktop/src/renderer/components/settings/AddProviderWizard.tsx, apps/desktop/src/renderer/components/settings/AgentIslandSection.tsx, apps/desktop/src/renderer/components/settings/AgentResourceSection.tsx, apps/desktop/src/renderer/components/settings/AppearanceSection.tsx, apps/desktop/src/renderer/components/settings/AuxiliaryModelSection.tsx, apps/desktop/src/renderer/components/settings/BetaChannelCell.tsx, apps/desktop/src/renderer/components/settings/BrowserBackendSubsection.tsx, apps/desktop/src/renderer/components/settings/BrowserRealProfileSubsection.tsx, apps/desktop/src/renderer/components/settings/BuiltinToolsSection.tsx, apps/desktop/src/renderer/components/settings/ChatEmbeddingCell.tsx, apps/desktop/src/renderer/components/settings/ChipMetricsSection.tsx, apps/desktop/src/renderer/components/settings/CollaborationSection.tsx, apps/desktop/src/renderer/components/settings/CompactionSection.tsx, apps/desktop/src/renderer/components/settings/ComposerSendShortcutSection.tsx, apps/desktop/src/renderer/components/settings/ComputerPermissionGuideWindow.tsx, apps/desktop/src/renderer/components/settings/ComputerUseSection.tsx, apps/desktop/src/renderer/components/settings/CustomProviderDialog.tsx, apps/desktop/src/renderer/components/settings/CustomProviderRuntimeFillOverlay.tsx, apps/desktop/src/renderer/components/settings/DefaultOverrideControls.tsx, apps/desktop/src/renderer/components/settings/DingTalkBotSection.tsx, apps/desktop/src/renderer/components/settings/DiscordBotSection.tsx, apps/desktop/src/renderer/components/settings/DownloadMeter.tsx, apps/desktop/src/renderer/components/settings/ExperimentalSection.tsx, apps/desktop/src/renderer/components/settings/FeishuBotNotificationSection.tsx, apps/desktop/src/renderer/components/settings/FeishuBotSection.tsx, apps/desktop/src/renderer/components/settings/FontFamilyPicker.tsx, apps/desktop/src/renderer/components/settings/GenericGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/GitSafetySection.tsx, apps/desktop/src/renderer/components/settings/HelpAssistantPanel.tsx, apps/desktop/src/renderer/components/settings/HelpSection.tsx, apps/desktop/src/renderer/components/settings/HelpThreadView.tsx, apps/desktop/src/renderer/components/settings/HookConnectionsSection.tsx, apps/desktop/src/renderer/components/settings/HookWorkspacePrefsEditor.tsx, apps/desktop/src/renderer/components/settings/ImBotSection.tsx, apps/desktop/src/renderer/components/settings/ImChannelSettingsCard.tsx, apps/desktop/src/renderer/components/settings/ImDefaultSettingsSection.tsx, apps/desktop/src/renderer/components/settings/ImLifecycleAnnouncementSection.tsx, apps/desktop/src/renderer/components/settings/InputDeviceConnectionStatus.tsx, apps/desktop/src/renderer/components/settings/JoyConGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/KeyboardShortcutsSection.tsx, apps/desktop/src/renderer/components/settings/LanguageSection.tsx, apps/desktop/src/renderer/components/settings/LayoutResetControl.tsx, apps/desktop/src/renderer/components/settings/LinkOpenSection.tsx, apps/desktop/src/renderer/components/settings/LocalOllamaInstall.tsx, apps/desktop/src/renderer/components/settings/LocalPackagingTag.tsx, apps/desktop/src/renderer/components/settings/LogoutSection.tsx, apps/desktop/src/renderer/components/settings/LspBetaCell.tsx, apps/desktop/src/renderer/components/settings/McpServerDialog.tsx, apps/desktop/src/renderer/components/settings/McpServersSection.tsx, apps/desktop/src/renderer/components/settings/MemorySection.tsx, apps/desktop/src/renderer/components/settings/MessageNavRailCell.tsx, apps/desktop/src/renderer/components/settings/ModelPriceOverrideDialog.tsx, apps/desktop/src/renderer/components/settings/MyDevicesPanel.tsx, apps/desktop/src/renderer/components/settings/NotificationSection.tsx, apps/desktop/src/renderer/components/settings/OAuthDeviceCodeCard.tsx, apps/desktop/src/renderer/components/settings/OllamaProviderDetail.tsx, apps/desktop/src/renderer/components/settings/PiPackagesSection.tsx, apps/desktop/src/renderer/components/settings/PlayStationGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/ProfileEditDialog.tsx, apps/desktop/src/renderer/components/settings/ProvidersSection.tsx, apps/desktop/src/renderer/components/settings/RemoteControlSection.tsx, apps/desktop/src/renderer/components/settings/RemoteHostDetail.tsx, apps/desktop/src/renderer/components/settings/RemoteSection.tsx, apps/desktop/src/renderer/components/settings/SessionImportSection.tsx, apps/desktop/src/renderer/components/settings/SessionRuntimeFallbackCell.tsx, apps/desktop/src/renderer/components/settings/SessionShareImportWizard.tsx, apps/desktop/src/renderer/components/settings/SettingsCatalogPanel.tsx, apps/desktop/src/renderer/components/settings/SettingsSidebarNav.tsx, apps/desktop/src/renderer/components/settings/SettingsTextInput.tsx, apps/desktop/src/renderer/components/settings/SettingsView.tsx, apps/desktop/src/renderer/components/settings/SilentEncryptedRetryCell.tsx, apps/desktop/src/renderer/components/settings/SshKeySetupDialog.tsx, apps/desktop/src/renderer/components/settings/StorageManagementCard.tsx, apps/desktop/src/renderer/components/settings/StreamFadeSection.tsx, apps/desktop/src/renderer/components/settings/SubagentModelSection.tsx, apps/desktop/src/renderer/components/settings/SwitchProGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/TelegramBehaviorSettings.tsx, apps/desktop/src/renderer/components/settings/TelegramBotSection.tsx, apps/desktop/src/renderer/components/settings/TelegramRemoteDevices.tsx, apps/desktop/src/renderer/components/settings/TerminalShellSection.tsx, apps/desktop/src/renderer/components/settings/TipsSection.tsx, apps/desktop/src/renderer/components/settings/UnifiedModelList.tsx, apps/desktop/src/renderer/components/settings/UserProfileCard.tsx, apps/desktop/src/renderer/components/settings/UserPromptSection.tsx, apps/desktop/src/renderer/components/settings/VisionBridgeSection.tsx, apps/desktop/src/renderer/components/settings/VoiceInputSection.tsx, apps/desktop/src/renderer/components/settings/WechatBotSection.tsx, apps/desktop/src/renderer/components/settings/WecomBotSection.tsx, apps/desktop/src/renderer/components/settings/WindowBehaviorSection.tsx, apps/desktop/src/renderer/components/settings/WorkLouderCodexKeyboardLayout.tsx, apps/desktop/src/renderer/components/settings/WorkLouderCodexKeycapGlyphs.tsx, apps/desktop/src/renderer/components/settings/WorkLouderCodexSettings.tsx, apps/desktop/src/renderer/components/settings/XUsageGuide.tsx, apps/desktop/src/renderer/components/settings/XboxGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/XboxGamepadSettings.tsx, apps/desktop/src/renderer/components/settings/androidStatusPresentation.ts, apps/desktop/src/renderer/components/settings/billingVisibility.ts, apps/desktop/src/renderer/components/settings/browserOpenForLoginError.ts, apps/desktop/src/renderer/components/settings/computerPermissionFlow.ts, apps/desktop/src/renderer/components/settings/contacts/ContactDetailPane.tsx, apps/desktop/src/renderer/components/settings/contacts/ContactsImportDialog.tsx, apps/desktop/src/renderer/components/settings/contacts/ContactsListPane.tsx, apps/desktop/src/renderer/components/settings/contacts/ContactsManagerDialog.tsx, apps/desktop/src/renderer/components/settings/contacts/ContactsSection.tsx, apps/desktop/src/renderer/components/settings/contacts/startContactsAiSession.ts, apps/desktop/src/renderer/components/settings/dualSenseSilhouette.ts, apps/desktop/src/renderer/components/settings/feishuBotPresentation.ts, apps/desktop/src/renderer/components/settings/fontFamilyValue.ts, apps/desktop/src/renderer/components/settings/gamepadLayoutPrimitives.tsx, apps/desktop/src/renderer/components/settings/gamepadSilhouetteGeom.ts, apps/desktop/src/renderer/components/settings/hookWorkspacePrefsLogic.ts, apps/desktop/src/renderer/components/settings/imBotVisibility.ts, apps/desktop/src/renderer/components/settings/imDefaultSettingsLogic.ts, apps/desktop/src/renderer/components/settings/joyConSilhouette.ts, apps/desktop/src/renderer/components/settings/myDevicesModel.ts, apps/desktop/src/renderer/components/settings/providerAssetModule.ts, apps/desktop/src/renderer/components/settings/realProfilePermissionGuide.ts, apps/desktop/src/renderer/components/settings/switchProSilhouette.ts, apps/desktop/src/renderer/components/settings/ultimateC1Silhouette.ts, apps/desktop/src/renderer/components/settings/usage/UsageBreakdownTables.tsx, apps/desktop/src/renderer/components/settings/usage/UsageHistorySection.tsx, apps/desktop/src/renderer/components/settings/usage/UsageStatRow.tsx, apps/desktop/src/renderer/components/settings/usage/UsageTaskTable.tsx, apps/desktop/src/renderer/components/settings/usage/UsageTokenBars.tsx, apps/desktop/src/renderer/components/settings/usage/formatUsagePercent.ts, apps/desktop/src/renderer/components/settings/usage/usageHistoryStats.ts, apps/desktop/src/renderer/components/settings/usageVisibility.ts, apps/desktop/src/renderer/components/settings/wizardRecommend.ts, apps/desktop/src/renderer/components/settings/workLouderCodexCommandCopy.ts, apps/desktop/src/renderer/components/settings/xboxSeriesSilhouette.ts, apps/desktop/src/renderer/styles/sortable.css | 143 | 121 | 731 |+| `desktop.settings` | desktop | 设置 | hash `/settings`(SettingsView;tab 含 general / personalization / providers / billing / usage / voice-input / im-bot / shortcuts / agent-island / import / remote-control / ghosts / builtin-tools / computer-use / help / about) | SettingsView | apps/desktop/src/renderer/components/settings/AboutSection.tsx, apps/desktop/src/renderer/components/settings/AccountDeletionSection.tsx, apps/desktop/src/renderer/components/settings/AddProviderWizard.tsx, apps/desktop/src/renderer/components/settings/AgentIslandSection.tsx, apps/desktop/src/renderer/components/settings/AgentResourceSection.tsx, apps/desktop/src/renderer/components/settings/AppearanceSection.tsx, apps/desktop/src/renderer/components/settings/AuxiliaryModelSection.tsx, apps/desktop/src/renderer/components/settings/BetaChannelCell.tsx, apps/desktop/src/renderer/components/settings/BrowserBackendSubsection.tsx, apps/desktop/src/renderer/components/settings/BrowserRealProfileSubsection.tsx, apps/desktop/src/renderer/components/settings/BuiltinToolsSection.tsx, apps/desktop/src/renderer/components/settings/ChatEmbeddingCell.tsx, apps/desktop/src/renderer/components/settings/ChipMetricsSection.tsx, apps/desktop/src/renderer/components/settings/CollaborationSection.tsx, apps/desktop/src/renderer/components/settings/CompactionSection.tsx, apps/desktop/src/renderer/components/settings/ComposerSendShortcutSection.tsx, apps/desktop/src/renderer/components/settings/ComputerPermissionGuideWindow.tsx, apps/desktop/src/renderer/components/settings/ComputerUseSection.tsx, apps/desktop/src/renderer/components/settings/CustomProviderDialog.tsx, apps/desktop/src/renderer/components/settings/CustomProviderRuntimeFillOverlay.tsx, apps/desktop/src/renderer/components/settings/DefaultOverrideControls.tsx, apps/desktop/src/renderer/components/settings/DingTalkBotSection.tsx, apps/desktop/src/renderer/components/settings/DiscordBotSection.tsx, apps/desktop/src/renderer/components/settings/DownloadMeter.tsx, apps/desktop/src/renderer/components/settings/ExperimentalSection.tsx, apps/desktop/src/renderer/components/settings/FeishuBotNotificationSection.tsx, apps/desktop/src/renderer/components/settings/FeishuBotSection.tsx, apps/desktop/src/renderer/components/settings/FontFamilyPicker.tsx, apps/desktop/src/renderer/components/settings/GenericGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/GitSafetySection.tsx, apps/desktop/src/renderer/components/settings/HelpAssistantPanel.tsx, apps/desktop/src/renderer/components/settings/HelpSection.tsx, apps/desktop/src/renderer/components/settings/HelpThreadView.tsx, apps/desktop/src/renderer/components/settings/HookConnectionsSection.tsx, apps/desktop/src/renderer/components/settings/HookWorkspacePrefsEditor.tsx, apps/desktop/src/renderer/components/settings/ImBotSection.tsx, apps/desktop/src/renderer/components/settings/ImChannelSettingsCard.tsx, apps/desktop/src/renderer/components/settings/ImDefaultSettingsSection.tsx, apps/desktop/src/renderer/components/settings/ImLifecycleAnnouncementSection.tsx, apps/desktop/src/renderer/components/settings/InputDeviceConnectionStatus.tsx, apps/desktop/src/renderer/components/settings/JoyConGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/KeyboardShortcutsSection.tsx, apps/desktop/src/renderer/components/settings/LanguageSection.tsx, apps/desktop/src/renderer/components/settings/LayoutResetControl.tsx, apps/desktop/src/renderer/components/settings/LinkOpenSection.tsx, apps/desktop/src/renderer/components/settings/LocalOllamaInstall.tsx, apps/desktop/src/renderer/components/settings/LocalPackagingTag.tsx, apps/desktop/src/renderer/components/settings/LogoutSection.tsx, apps/desktop/src/renderer/components/settings/LspBetaCell.tsx, apps/desktop/src/renderer/components/settings/McpServerDialog.tsx, apps/desktop/src/renderer/components/settings/McpServersSection.tsx, apps/desktop/src/renderer/components/settings/MemorySection.tsx, apps/desktop/src/renderer/components/settings/MessageNavRailCell.tsx, apps/desktop/src/renderer/components/settings/ModelPriceOverrideDialog.tsx, apps/desktop/src/renderer/components/settings/MyDevicesPanel.tsx, apps/desktop/src/renderer/components/settings/NotificationSection.tsx, apps/desktop/src/renderer/components/settings/OAuthDeviceCodeCard.tsx, apps/desktop/src/renderer/components/settings/OllamaProviderDetail.tsx, apps/desktop/src/renderer/components/settings/PiPackagesSection.tsx, apps/desktop/src/renderer/components/settings/PlayStationGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/ProfileEditDialog.tsx, apps/desktop/src/renderer/components/settings/ProvidersSection.tsx, apps/desktop/src/renderer/components/settings/RemoteControlSection.tsx, apps/desktop/src/renderer/components/settings/RemoteHostDetail.tsx, apps/desktop/src/renderer/components/settings/RemoteSection.tsx, apps/desktop/src/renderer/components/settings/SessionImportSection.tsx, apps/desktop/src/renderer/components/settings/SessionRuntimeFallbackCell.tsx, apps/desktop/src/renderer/components/settings/SessionShareImportWizard.tsx, apps/desktop/src/renderer/components/settings/SettingsCatalogPanel.tsx, apps/desktop/src/renderer/components/settings/SettingsSidebarNav.tsx, apps/desktop/src/renderer/components/settings/SettingsTextInput.tsx, apps/desktop/src/renderer/components/settings/SettingsView.tsx, apps/desktop/src/renderer/components/settings/SilentEncryptedRetryCell.tsx, apps/desktop/src/renderer/components/settings/SshKeySetupDialog.tsx, apps/desktop/src/renderer/components/settings/StorageManagementCard.tsx, apps/desktop/src/renderer/components/settings/StreamFadeSection.tsx, apps/desktop/src/renderer/components/settings/SubagentModelSection.tsx, apps/desktop/src/renderer/components/settings/SwitchProGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/TelegramBehaviorSettings.tsx, apps/desktop/src/renderer/components/settings/TelegramBotSection.tsx, apps/desktop/src/renderer/components/settings/TelegramRemoteDevices.tsx, apps/desktop/src/renderer/components/settings/TerminalShellSection.tsx, apps/desktop/src/renderer/components/settings/TipsSection.tsx, apps/desktop/src/renderer/components/settings/UnifiedModelList.tsx, apps/desktop/src/renderer/components/settings/UserProfileCard.tsx, apps/desktop/src/renderer/components/settings/UserPromptSection.tsx, apps/desktop/src/renderer/components/settings/VisionBridgeSection.tsx, apps/desktop/src/renderer/components/settings/VoiceInputSection.tsx, apps/desktop/src/renderer/components/settings/WechatBotSection.tsx, apps/desktop/src/renderer/components/settings/WecomBotSection.tsx, apps/desktop/src/renderer/components/settings/WindowBehaviorSection.tsx, apps/desktop/src/renderer/components/settings/WorkLouderCodexKeyboardLayout.tsx, apps/desktop/src/renderer/components/settings/WorkLouderCodexKeycapGlyphs.tsx, apps/desktop/src/renderer/components/settings/WorkLouderCodexSettings.tsx, apps/desktop/src/renderer/components/settings/XUsageGuide.tsx, apps/desktop/src/renderer/components/settings/XboxGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/XboxGamepadSettings.tsx, apps/desktop/src/renderer/components/settings/androidStatusPresentation.ts, apps/desktop/src/renderer/components/settings/billingVisibility.ts, apps/desktop/src/renderer/components/settings/browserOpenForLoginError.ts, apps/desktop/src/renderer/components/settings/computerPermissionFlow.ts, apps/desktop/src/renderer/components/settings/contacts/ContactDetailPane.tsx, apps/desktop/src/renderer/components/settings/contacts/ContactsImportDialog.tsx, apps/desktop/src/renderer/components/settings/contacts/ContactsListPane.tsx, apps/desktop/src/renderer/components/settings/contacts/ContactsManagerDialog.tsx, apps/desktop/src/renderer/components/settings/contacts/ContactsSection.tsx, apps/desktop/src/renderer/components/settings/contacts/startContactsAiSession.ts, apps/desktop/src/renderer/components/settings/dualSenseSilhouette.ts, apps/desktop/src/renderer/components/settings/feishuBotPresentation.ts, apps/desktop/src/renderer/components/settings/fontFamilyValue.ts, apps/desktop/src/renderer/components/settings/gamepadLayoutPrimitives.tsx, apps/desktop/src/renderer/components/settings/gamepadSilhouetteGeom.ts, apps/desktop/src/renderer/components/settings/hookWorkspacePrefsLogic.ts, apps/desktop/src/renderer/components/settings/imBotVisibility.ts, apps/desktop/src/renderer/components/settings/imDefaultSettingsLogic.ts, apps/desktop/src/renderer/components/settings/joyConSilhouette.ts, apps/desktop/src/renderer/components/settings/myDevicesModel.ts, apps/desktop/src/renderer/components/settings/providerAssetModule.ts, apps/desktop/src/renderer/components/settings/realProfilePermissionGuide.ts, apps/desktop/src/renderer/components/settings/switchProSilhouette.ts, apps/desktop/src/renderer/components/settings/ultimateC1Silhouette.ts, apps/desktop/src/renderer/components/settings/usage/UsageBreakdownTables.tsx, apps/desktop/src/renderer/components/settings/usage/UsageHistorySection.tsx, apps/desktop/src/renderer/components/settings/usage/UsageStatRow.tsx, apps/desktop/src/renderer/components/settings/usage/UsageTaskTable.tsx, apps/desktop/src/renderer/components/settings/usage/UsageTokenBars.tsx, apps/desktop/src/renderer/components/settings/usage/formatUsagePercent.ts, apps/desktop/src/renderer/components/settings/usage/usageHistoryStats.ts, apps/desktop/src/renderer/components/settings/usageVisibility.ts, apps/desktop/src/renderer/components/settings/wizardRecommend.ts, apps/desktop/src/renderer/components/settings/workLouderCodexCommandCopy.ts, apps/desktop/src/renderer/components/settings/xboxSeriesSilhouette.ts, apps/desktop/src/renderer/styles/sortable.css | 142 | 121 | 725 || `desktop.shell.main-layout` | desktop | 主窗口壳(标题栏 / 左右栏 / 内容区) | main BrowserWindow → renderer/index.tsx → main-entry.tsx → App → MainLayout (`#/` 受保护壳) | ChromeActions, FeishuConflictDialogHost, GhostMediaLightboxHost, MainLayout, RightSidebar, RightSidebarShell, SessionShareImportWizard, Sidebar, UpdateNoticeDialog, WindowControls | apps/desktop/src/renderer/cindy-brain/GhostMediaLightboxHost.tsx, apps/desktop/src/renderer/components/UpdateNoticeDialog.tsx, apps/desktop/src/renderer/components/feishuBot/FeishuConflictDialog.tsx, apps/desktop/src/renderer/components/feishuBot/FeishuConflictDialogHost.tsx, apps/desktop/src/renderer/components/layout/BrowserWebviewPool.tsx, apps/desktop/src/renderer/components/layout/ChromeActions.tsx, apps/desktop/src/renderer/components/layout/ContentHeader.tsx, apps/desktop/src/renderer/components/layout/CredentialStoreBanner.tsx, apps/desktop/src/renderer/components/layout/FadeSwitcher.tsx, apps/desktop/src/renderer/components/layout/GhostPanelWindowLayout.tsx, apps/desktop/src/renderer/components/layout/GlobalDropImportListener.tsx, apps/desktop/src/renderer/components/layout/MainLayout.tsx, apps/desktop/src/renderer/components/layout/RightSidebar.tsx, apps/desktop/src/renderer/components/layout/RightSidebarDetach.tsx, apps/desktop/src/renderer/components/layout/RightSidebarMaximize.tsx, apps/desktop/src/renderer/components/layout/RightSidebarToggle.tsx, apps/desktop/src/renderer/components/layout/SidebarWindowLayout.tsx, apps/desktop/src/renderer/components/layout/chromeActionsGeometry.ts, apps/desktop/src/renderer/components/layout/chromeActionsLayout.ts, apps/desktop/src/renderer/components/layout/railChromeActions.ts, apps/desktop/src/renderer/components/layout/windowDrag.tsx, apps/desktop/src/renderer/components/settings/SessionShareImportWizard.tsx, apps/desktop/src/renderer/components/sidebar/AccountSwitcherDialog.tsx, apps/desktop/src/renderer/components/sidebar/AttentionDot.tsx, apps/desktop/src/renderer/components/sidebar/GhostMainViewNavEntries.tsx, apps/desktop/src/renderer/components/sidebar/MobileDownloadDialog.tsx, apps/desktop/src/renderer/components/sidebar/Sidebar.tsx, apps/desktop/src/renderer/components/sidebar/SidebarIconButton.tsx, apps/desktop/src/renderer/components/sidebar/SidebarTopNav.tsx, apps/desktop/src/renderer/components/sidebar/SortableList.tsx, apps/desktop/src/renderer/components/sidebar/UpdateBanner.tsx, apps/desktop/src/renderer/components/sidebar/UserInfoSection.tsx, apps/desktop/src/renderer/components/sidebar/VendorIcon.tsx, apps/desktop/src/renderer/components/sidebar/VendorReadinessBadge.tsx, apps/desktop/src/renderer/components/sidebar/WorktreeBadge.tsx, apps/desktop/src/renderer/components/title-bar/ChromeIconButton.tsx, apps/desktop/src/renderer/components/title-bar/MenuButton.tsx, apps/desktop/src/renderer/components/title-bar/WindowControls.tsx, apps/desktop/src/renderer/features/right-sidebar/AddTabDropdown.tsx, apps/desktop/src/renderer/features/right-sidebar/EmptyState.tsx, apps/desktop/src/renderer/features/right-sidebar/RightSidebarShell.tsx, apps/desktop/src/renderer/features/right-sidebar/TabBar.tsx, apps/desktop/src/renderer/features/right-sidebar/TabBodyErrorBoundary.tsx, apps/desktop/src/renderer/features/right-sidebar/hooks/useBrowserWebview.ts, apps/desktop/src/renderer/features/right-sidebar/hooks/useNativePopupSurface.ts, apps/desktop/src/renderer/features/right-sidebar/iosSimulatorPluginAvailability.ts, apps/desktop/src/renderer/features/right-sidebar/lib/browserPartition.ts, apps/desktop/src/renderer/features/right-sidebar/lib/browserWebviewPool.ts, apps/desktop/src/renderer/features/right-sidebar/lib/detachedSidebarRouting.ts, apps/desktop/src/renderer/features/right-sidebar/lib/executeSidebarCommand.ts, apps/desktop/src/renderer/features/right-sidebar/lib/iosSimulatorFocusBridge.ts, apps/desktop/src/renderer/features/right-sidebar/lib/lastTurnChangedFiles.ts, apps/desktop/src/renderer/features/right-sidebar/lib/nativePopupTabs.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openBackgroundTasksTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openInSidebarBrowser.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openInSidebarFileBrowser.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openSubagentsTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openTerminalShortcut.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openTurnReview.ts, apps/desktop/src/renderer/features/right-sidebar/lib/popupRouter.ts, apps/desktop/src/renderer/features/right-sidebar/lib/popupTabs.ts, apps/desktop/src/renderer/features/right-sidebar/lib/rsbBrowserBridge.ts, apps/desktop/src/renderer/features/right-sidebar/lib/sidebarCommands.ts, apps/desktop/src/renderer/features/right-sidebar/lib/sidebarHostSession.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/WorkflowAgentStrip.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/WorkflowProgressTree.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/chatTaskFocusIntent.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/listSessionTasks.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/workflowProgressModel.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/FileBrowserBody.css, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/FileBrowserBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/dropExternalFile.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/fileTreeImagePreview.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/useSessionScopedTreeWidth.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/index.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/IOSSimulatorInstanceGrid.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/IOSSimulatorTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/iosSimulatorH264Decoder.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/OrcaWorkersAttentionIcon.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/OrcaWorkersTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/actions.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/closeDecision.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/ResourceUsageBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/resource-usage.css, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/subscription.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/ImageDiffPreview.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/MarkdownDiffPreview.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/PlainUnifiedDiff.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/diffRows.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/highlight.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/inlineDiff.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/useDiffHighlights.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/ReviewTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/diffExpansionPreference.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/fileTree.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/gitApplyCommand.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/markdownPreview.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useLastTurnFilter.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useReviewGitState.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useReviewSource.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/ConversationStream.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/DetailView.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/RunList.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentChrome.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentToolCard.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentsBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentChangeFence.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentConversation.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentFormat.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/TerminalTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/lib/xtermPool.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserChrome.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserCommentPopover.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/browserCommentEditorDraft.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/lib/parseOmnibox.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/useBrowserComment.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/useLocalHtmlAutoReload.ts, apps/desktop/src/renderer/features/right-sidebar/registry.ts, apps/desktop/src/renderer/features/right-sidebar/store.ts, apps/desktop/src/renderer/features/right-sidebar/types.ts, apps/desktop/src/renderer/layout/LayoutRoot.tsx, apps/desktop/src/renderer/layout/PanelDragController.tsx, apps/desktop/src/renderer/layout/PanelDragPrototype.tsx, apps/desktop/src/renderer/layout/collapsePrefs.ts, apps/desktop/src/renderer/layout/layoutDevTools.ts, apps/desktop/src/renderer/layout/panePlacement.tsx, apps/desktop/src/renderer/layout/paneWidths.tsx, apps/desktop/src/renderer/layout/panelMaximize.tsx, apps/desktop/src/renderer/styles/globals.css | 145 | 72 | 288 || `desktop.skillhub.local` | desktop | SkillHub 本地技能 | hash `/skillhub/local` 及详情 `/skillhub/local/:kind/global/:name`、`/skillhub/local/:kind/project/:projectHash/:name` | InstallTargetPicker, PluginManagementLayout, SkillhubDetailView, SkillhubFeatureLayout, SkillhubHomeView, SkillhubMarketPreviewPanel | apps/desktop/src/renderer/features/plugin/PluginManagementLayout.tsx, apps/desktop/src/renderer/features/skillhub/SkillhubDetailView.tsx, apps/desktop/src/renderer/features/skillhub/SkillhubFeatureLayout.tsx, apps/desktop/src/renderer/features/skillhub/SkillhubHomeView.tsx, apps/desktop/src/renderer/features/skillhub/SkillhubMarketPreviewPanel.tsx, apps/desktop/src/renderer/features/skillhub/components/InstallTargetPicker.tsx | 41 | 0 | 71 || `desktop.skillhub.market` | desktop | SkillHub 市场 | hash `/skillhub/market`(SkillhubMarketListView) | InstallTargetPicker, MarketCard, MarketInfoEditDialog, SkillhubMarketListView, SkillhubMarketPreviewPanel, VisibilityEditorDialog | apps/desktop/src/renderer/features/skillhub/SkillhubMarketListView.tsx, apps/desktop/src/renderer/features/skillhub/SkillhubMarketPreviewPanel.tsx, apps/desktop/src/renderer/features/skillhub/components/InstallTargetPicker.tsx, apps/desktop/src/renderer/features/skillhub/components/MarketCard.tsx, apps/desktop/src/renderer/features/skillhub/components/MarketInfoEditDialog.tsx, apps/desktop/src/renderer/features/skillhub/components/MarketPreviewTree.tsx, apps/desktop/src/renderer/features/skillhub/components/PlatformTagSelector.tsx, apps/desktop/src/renderer/features/skillhub/components/SkillCategoryFilterBar.tsx, apps/desktop/src/renderer/features/skillhub/components/SkillIcon.tsx, apps/desktop/src/renderer/features/skillhub/components/SkillTagList.tsx, apps/desktop/src/renderer/features/skillhub/components/TeamScopePicker.tsx, apps/desktop/src/renderer/features/skillhub/components/VisibilityEditorDialog.tsx | 46 | 0 | 59 |@@ -129,7 +129,7 @@ Mobile 本轮不展开顶层 screen,**待 DS-9 增量**。| `desktop.overlay.toast` | unassigned | legacy | — | 待 DS-4 标准组件落地后按 Pattern 迁 | 保持现状;发现问题记下一动作,本张不修视觉 || `desktop.plugins.app-main` | unassigned | legacy | — | 待 DS-4 标准组件落地后按 Pattern 迁 | 保持现状;发现问题记下一动作,本张不修视觉 || `desktop.plugins.installed` | unassigned | legacy | — | 待 DS-4 标准组件落地后按 Pattern 迁 | 保持现状;发现问题记下一动作,本张不修视觉 |-| `desktop.settings` | unassigned | legacy | DESIGN.md §10 语义豁免色族消费者;外部主题导入保护 token(资源用量类别色在独立窗) | 待 DS-4 标准组件落地后按 Pattern 迁 | 保持现状;发现问题记下一动作,本张不修视觉 |+| `desktop.settings` | unassigned | pilot | DESIGN.md §10 语义豁免色族消费者;外部主题导入保护 token(资源用量类别色在独立窗) | DS-4 Button / Input 已在 ProvidersSection + SettingsTextInput 六消费者落地;其余 settings 控件仍按 Pattern 迁 | **DS-5 待办:`--settings-input-*` 四个域 alias 收口**(`-border` 138 处 / `-text` 108 处 / `-border-focus` 44 处 / `-placeholder` 33 处,去重 49 个文件;32 个在本 surface,另 17 个跨 `cindy-brain` / `components/new-chat` / `features/scheduler` / `features/skillhub` / `features/cc-agent` / `components/ui/confirm-dialog`,故须整族一次收口、不按 surface 零敲)——DS-4 已把 `ui/input` 换绑 Tier-1,这批未收口的消费者在「导出型本地主题」下会与标准输入框分裂,理由见 `design-decision-log.md` 09-04 条;ivory/elevated 收口(`surface="ivory"` 登记债,独立议题);confirm-dialog 按钮族只登记不迁 || `desktop.shell.main-layout` | unassigned | legacy | DESIGN.md §15 CINDY 皮肤族(侧栏 vibrancy / 选中 pill);外部主题导入保护 token | 待 DS-4 标准组件落地后按 Pattern 迁 | 保持现状;发现问题记下一动作,本张不修视觉 || `desktop.skillhub.local` | unassigned | legacy | — | 待 DS-4 标准组件落地后按 Pattern 迁 | 保持现状;发现问题记下一动作,本张不修视觉 || `desktop.skillhub.market` | unassigned | legacy | — | 待 DS-4 标准组件落地后按 Pattern 迁 | 保持现状;发现问题记下一动作,本张不修视觉 |diff --git a/packages/design-tokens/README.md b/packages/design-tokens/README.mdindex a2d9d535e6..cf9feda68f 100644--- a/packages/design-tokens/README.md+++ b/packages/design-tokens/README.md@@ -1,6 +1,6 @@# @cindy/design-tokens-Cindy 设计 token 的 **DTCG 影子层**(reference → semantic)。+Cindy 设计 token 的 **DTCG 影子层**(reference → semantic → component)。本包只是字典,**零运行时接线**:Desktop / Mobile / 任何产品 package 都不得依赖它。生产生成切换在路线图 **DS-8**;在那之前,Desktop 颜色数值权威仍是 `apps/desktop/src/renderer/themes/colors.ts`,本包的取值必须与 DS-2b 冻结快照逐值一致。@@ -9,8 +9,8 @@ Cindy 设计 token 的 **DTCG 影子层**(reference → semantic)。治理合同 §7:影子包在约定复查期内没有真实消费者时应删除。- **复查日期:2026-11-01**-- 届时若 DS-4 仍未开工,整包删除(revert 本 PR 即可,零运行时残留)-- 等真做 DS-4 时再重建,不让没人消费的字典变成第三份漂移真相+- DS-4 已开工:component 层随 Button 消费建立。零运行时接线红线仍到 DS-8。+- 届时若仍无生产生成切换且无人维护,按治理合同 §7 评估是否删除## 数据源@@ -20,14 +20,15 @@ Cindy 设计 token 的 **DTCG 影子层**(reference → semantic)。不重新解析 `colors.ts`。重新生成:在本包目录执行 `pnpm generate`(脚本 `src/generate.ts`)。连续两次生成必须字节一致。守卫测试会核对。-## 两层+## 三层| 层 | 路径 | 内容 || --- | --- | --- |-| reference | `src/reference/color.json` | 第一批 semantic 角色实际引用的原始色值(不铺全色板) |+| reference | `src/reference/color.json` | semantic / component 角色实际引用的原始色值(不铺全色板) || semantic | `src/semantic/color.json` | DESIGN.md §10 Tier-1 的 surface / border / text / accent 四族 + status 语义;每个角色 light/dark = 冻结快照现值 |+| component | `src/component/color.json` | DS-4 起随消费组件建立。**刻意很薄**:DS-4 的 Button hover / pressed 是 `color-mix` 运行期派生值(暗色下 `--surface-hover` 与 `--surface-chip` 同值,alias 会让悬停不可见),按治理合同 §3.4 只在 `classification.json` 登记、不建模;本层只收 `button-cta-hover` 这类能落回 semantic 的纯 alias |-依赖单向:semantic → reference。不建 component 层(DS-4)。不装 Terrazzo(DS-8)。+依赖单向:component → semantic → reference。不装 Terrazzo(DS-8)。色值一律用标准 DTCG 颜色对象(`$type: "color"` + `{colorSpace, components[, alpha]}`):HSL triplet(`60 12.5% 97%`)→ `{"colorSpace":"hsl","components":[60,12.5,97]}`;diff --git a/packages/design-tokens/src/__tests__/classification.test.ts b/packages/design-tokens/src/__tests__/classification.test.tsindex 47b4922ba9..0c86c4e980 100644--- a/packages/design-tokens/src/__tests__/classification.test.ts+++ b/packages/design-tokens/src/__tests__/classification.test.ts@@ -16,8 +16,10 @@ import {assertProtectedNotSemantic,assertSemanticExemptionsRegistered,} from '../guards.ts';+import { RUNTIME_DERIVED_BUTTON_STATE_IDS } from '../component-roles.ts';import {classificationPath,+ componentPath,findRepoRoot,referencePath,semanticPath,@@ -51,6 +53,7 @@ describe('DS-3 · 分类登记', () => {{ path: classificationPath(repoRoot), body: stableStringify(generated) },{ path: referencePath(repoRoot), body: stableStringify(built.layers.reference) },{ path: semanticPath(repoRoot), body: stableStringify(built.layers.semantic) },+ { path: componentPath(repoRoot), body: stableStringify(built.layers.component) },]);for (const file of built.files) {expect(readFileSync(file.path, 'utf8')).toBe(file.body);@@ -67,6 +70,7 @@ describe('DS-3 · 分类登记', () => {'packages/design-tokens/src/classification.json','packages/design-tokens/src/reference/color.json','packages/design-tokens/src/semantic/color.json',+ 'packages/design-tokens/src/component/color.json',]) {const attrs = execFileSync('git',@@ -79,6 +83,19 @@ describe('DS-3 · 分类登记', () => {}});+ it('DS-4 运行期派生的 Button 状态值只登记不建模(治理合同 §3.4)', () => {+ // 这五个是 color-mix 派生值:暗色下 surface-hover 与 surface-chip 同值,+ // alias 会让悬停不可见,所以只能派生。派生值不进 DTCG,但必须留登记,+ // 防止日后被悄悄改成不跟主题的字面量。+ for (const id of RUNTIME_DERIVED_BUTTON_STATE_IDS) {+ const entry = generated.entries.find((item) => item.id === id);+ expect(entry, `${id} 未出现在分类登记`).toBeTruthy();+ expect(entry?.category, id).toBe('runtime-derived-or-protected');+ expect(entry?.destination, id).toBe('register-only');+ expect(entry?.modeledAsSemantic, id).toBe(false);+ }+ });+it('加严保护值标记 protected,Tier-1 照常建模、Tier-3 只登记', () => {assertProtectedNotSemantic(generated);for (const id of Object.keys(PROTECTED_IDS)) {diff --git a/packages/design-tokens/src/__tests__/fixtures/component-literal.json b/packages/design-tokens/src/__tests__/fixtures/component-literal.jsonnew file mode 100644index 0000000000..7cb278db88--- /dev/null+++ b/packages/design-tokens/src/__tests__/fixtures/component-literal.json@@ -0,0 +1,18 @@+{+ "$description": "error fixture: component writes a literal instead of aliasing semantic/reference",+ "button": {+ "button-primary-hover": {+ "light": {+ "$type": "color",+ "$value": {+ "colorSpace": "srgb",+ "components": [0.84, 0.84, 0.83]+ }+ },+ "dark": {+ "$type": "color",+ "$value": "{surface.surface-hover.dark}"+ }+ }+ }+}diff --git a/packages/design-tokens/src/__tests__/structure.test.ts b/packages/design-tokens/src/__tests__/structure.test.tsindex 6ac82dbb1b..927a55b970 100644--- a/packages/design-tokens/src/__tests__/structure.test.ts+++ b/packages/design-tokens/src/__tests__/structure.test.ts@@ -11,7 +11,7 @@ import {validateDualModes,validateStructure,} from '../guards.ts';-import { findRepoRoot, referencePath, semanticPath } from '../paths.ts';+import { componentPath, findRepoRoot, referencePath, semanticPath } from '../paths.ts';import { readSnapshot, snapshotById } from '../snapshot.ts';const fixturesDir = join(dirname(fileURLToPath(import.meta.url)), 'fixtures');@@ -32,6 +32,9 @@ describe('DS-3 · 结构守卫', () => {expect(JSON.parse(readFileSync(semanticPath(repoRoot), 'utf8'))).toEqual(layers.semantic,);+ expect(JSON.parse(readFileSync(componentPath(repoRoot), 'utf8'))).toEqual(+ layers.component,+ );});it('错误 fixture:非法 DTCG 语法被命中', () => {@@ -48,6 +51,16 @@ describe('DS-3 · 结构守卫', () => {const issues = validateAliasDirection({reference: readFixture('alias-from-reference.json'),semantic: layers.semantic,+ component: layers.component,+ });+ expect(issues.some((issue) => issue.code === 'alias-direction')).toBe(true);+ });++ it('错误 fixture:component 写字面量被命中', () => {+ const issues = validateAliasDirection({+ reference: layers.reference,+ semantic: layers.semantic,+ component: readFixture('component-literal.json'),});expect(issues.some((issue) => issue.code === 'alias-direction')).toBe(true);});diff --git a/packages/design-tokens/src/build-layers.ts b/packages/design-tokens/src/build-layers.tsindex f71d142e6d..030b93b03f 100644--- a/packages/design-tokens/src/build-layers.ts+++ b/packages/design-tokens/src/build-layers.ts@@ -6,12 +6,15 @@ import {type DtcgColorObject,type DtcgFile,} from './dtcg.ts';+import { parseAliasTarget } from './classify.ts';+import { COMPONENT_ROLES } from './component-roles.ts';import { SEMANTIC_ROLES } from './semantic-roles.ts';import type { SnapshotColor } from './snapshot.ts';export interface BuiltLayers {reference: DtcgFile;semantic: DtcgFile;+ component: DtcgFile;}function refTokenName(value: string, used: Map<string, string>): string {@@ -40,7 +43,7 @@ export function buildLayers(byId: Map<string, SnapshotColor>): BuiltLayers {const used = new Map<string, string>();const referenceTokens: DtcgFile = {$description:- 'DS-3 reference 层:仅收录第一批 semantic 角色实际引用的冻结色值。',+ 'DS-3/DS-4 reference 层:semantic 与 component 角色实际引用的冻结色值。',};const semantic: DtcgFile = {$description:@@ -87,7 +90,58 @@ export function buildLayers(byId: Map<string, SnapshotColor>): BuiltLayers {};}- return { reference: referenceTokens, semantic };+ const component: DtcgFile = {+ $description:+ 'DS-4 component 层:只收录能落回 semantic 的 Button 角色。hover / pressed 是 color-mix 运行期派生值,按治理合同 §3.4 只在 classification 登记、不建模。',+ };++ const semanticById = new Map(SEMANTIC_ROLES.map((role) => [role.id, role]));++ function componentModeAlias(value: string, mode: 'light' | 'dark'): `{${string}}` {+ const target = parseAliasTarget(value);+ if (target) {+ const semanticRole = semanticById.get(target);+ if (!semanticRole) {+ throw new Error(`component 角色 alias ${value} 不是 semantic 角色`);+ }+ return aliasValue([semanticRole.group, semanticRole.id, mode]);+ }+ const literal = toDtcgColorObject(value);+ const name = refTokenName(value, used);+ if (!referenceTokens[name]) {+ referenceTokens[name] = {+ $type: 'color',+ $value: literal,+ };+ }+ return aliasValue([name]);+ }++ for (const role of COMPONENT_ROLES) {+ const color = byId.get(role.id);+ if (!color) {+ throw new Error(`快照缺少 component 角色 ${role.id}`);+ }+ if (color.light == null || color.dark == null) {+ throw new Error(`component 角色 ${role.id} 缺少 light/dark 双模式值`);+ }+ if (!component[role.group]) {+ component[role.group] = {};+ }+ const group = component[role.group] as DtcgFile;+ group[role.id] = {+ light: {+ $type: 'color',+ $value: componentModeAlias(color.light, 'light'),+ },+ dark: {+ $type: 'color',+ $value: componentModeAlias(color.dark, 'dark'),+ },+ };+ }++ return { reference: referenceTokens, semantic, component };}export function resolvedSemanticValues(diff --git a/packages/design-tokens/src/classification.json b/packages/design-tokens/src/classification.jsonindex 618c223afe..a9bec8ae16 100644--- a/packages/design-tokens/src/classification.json+++ b/packages/design-tokens/src/classification.json@@ -1,12 +1,12 @@{"source": "apps/desktop/src/renderer/themes/colors.ts","generatedBy": "packages/design-tokens/src/classify.ts",- "snapshotCount": 514,+ "snapshotCount": 520,"categories": {"literal": 248,- "alias": 235,+ "alias": 236,"hsl-triplet": 6,- "runtime-derived-or-protected": 25+ "runtime-derived-or-protected": 30},"entries": [{@@ -5151,6 +5151,58 @@"dark": "accent-cta-bg"},"modeledAsSemantic": false+ },+ {+ "id": "button-primary-hover",+ "category": "runtime-derived-or-protected",+ "destination": "register-only",+ "lightKind": "color-mix",+ "darkKind": "color-mix",+ "modeledAsSemantic": false+ },+ {+ "id": "button-primary-pressed",+ "category": "runtime-derived-or-protected",+ "destination": "register-only",+ "lightKind": "color-mix",+ "darkKind": "color-mix",+ "modeledAsSemantic": false+ },+ {+ "id": "button-secondary-hover",+ "category": "runtime-derived-or-protected",+ "destination": "register-only",+ "lightKind": "color-mix",+ "darkKind": "color-mix",+ "modeledAsSemantic": false+ },+ {+ "id": "button-secondary-pressed",+ "category": "runtime-derived-or-protected",+ "destination": "register-only",+ "lightKind": "color-mix",+ "darkKind": "color-mix",+ "modeledAsSemantic": false+ },+ {+ "id": "button-cta-hover",+ "category": "alias",+ "destination": "semantic-or-component-candidate",+ "lightKind": "alias",+ "darkKind": "alias",+ "aliasOf": {+ "light": "accent-hover",+ "dark": "accent-hover"+ },+ "modeledAsSemantic": false+ },+ {+ "id": "button-cta-pressed",+ "category": "runtime-derived-or-protected",+ "destination": "register-only",+ "lightKind": "color-mix",+ "darkKind": "color-mix",+ "modeledAsSemantic": false}]}diff --git a/packages/design-tokens/src/component-roles.ts b/packages/design-tokens/src/component-roles.tsnew file mode 100644index 0000000000..40d607952f--- /dev/null+++ b/packages/design-tokens/src/component-roles.ts@@ -0,0 +1,38 @@+/**+ * DS-4 第一批 component 角色:只随 Button 消费建立,不预先铺设。+ * 依赖单向 component → semantic → reference。+ *+ * 本层刻意很薄:DS-4 的 hover / pressed 值是 color-mix 运行期派生+ * (见 colors.ts 的 DS-4 注释——暗色下 surface-hover 与 surface-chip 同值,+ * alias 会让悬停不可见),按治理合同 §3.4「运行时派生值不迁」只在+ * classification.json 登记为 runtime-derived-or-protected,不进 DTCG。+ * 唯一可建模的是 button-cta-hover:它是对 semantic 角色 accent-hover 的+ * 纯 alias,DS-8 生成时能落回 semantic。+ * rest 态填充按治理合同 §3.3「Primitive 默认只绑定 semantic 角色」由组件直接+ * 消费 Tier-1 slot,不再复制一层 component token。+ */+export type ComponentGroup = 'button';++export interface ComponentRole {+ id: string;+ group: ComponentGroup;+}++export const COMPONENT_ROLES: readonly ComponentRole[] = [+ { id: 'button-cta-hover', group: 'button' },+] as const;++export const COMPONENT_ROLE_IDS = new Set(COMPONENT_ROLES.map((role) => role.id));++/**+ * DS-4 的运行期派生状态值:只登记存在与去向(治理合同 §3.4),不建模。+ * 守卫测试据此断言它们确实落在 runtime-derived-or-protected 分类里,+ * 防止有人日后把它们悄悄改成字面量又不登记。+ */+export const RUNTIME_DERIVED_BUTTON_STATE_IDS = [+ 'button-primary-hover',+ 'button-primary-pressed',+ 'button-secondary-hover',+ 'button-secondary-pressed',+ 'button-cta-pressed',+] as const;diff --git a/packages/design-tokens/src/component/color.json b/packages/design-tokens/src/component/color.jsonnew file mode 100644index 0000000000..3974a274dc--- /dev/null+++ b/packages/design-tokens/src/component/color.json@@ -0,0 +1,15 @@+{+ "$description": "DS-4 component 层:只收录能落回 semantic 的 Button 角色。hover / pressed 是 color-mix 运行期派生值,按治理合同 §3.4 只在 classification 登记、不建模。",+ "button": {+ "button-cta-hover": {+ "light": {+ "$type": "color",+ "$value": "{accent.accent-hover.light}"+ },+ "dark": {+ "$type": "color",+ "$value": "{accent.accent-hover.dark}"+ }+ }+ }+}diff --git a/packages/design-tokens/src/generate.ts b/packages/design-tokens/src/generate.tsindex 53a1362f28..aff4576bcc 100644--- a/packages/design-tokens/src/generate.ts+++ b/packages/design-tokens/src/generate.ts@@ -5,6 +5,7 @@ import { buildLayers } from './build-layers.ts';import { classifySnapshot, stableStringify } from './classify.ts';import {classificationPath,+ componentPath,findRepoRoot,referencePath,semanticPath,@@ -27,6 +28,7 @@ export function buildShadowLayerFiles(repoRoot = findRepoRoot()) {{ path: classificationPath(repoRoot), body: stableStringify(classification) },{ path: referencePath(repoRoot), body: stableStringify(layers.reference) },{ path: semanticPath(repoRoot), body: stableStringify(layers.semantic) },+ { path: componentPath(repoRoot), body: stableStringify(layers.component) },],};}diff --git a/packages/design-tokens/src/guards.ts b/packages/design-tokens/src/guards.tsindex 40e49085f9..4b4d9559ae 100644--- a/packages/design-tokens/src/guards.ts+++ b/packages/design-tokens/src/guards.ts@@ -24,6 +24,7 @@ import {} from './dtcg.ts';import {CLASSIFICATION_RELATIVE_PATH,+ COMPONENT_RELATIVE_PATH,REFERENCE_RELATIVE_PATH,SEMANTIC_RELATIVE_PATH,SNAPSHOT_RELATIVE_PATH,@@ -35,7 +36,7 @@ export function snapshotMismatch(what: string): string {return [`${what} 与 DS-2b 冻结快照不一致。`,'红灯不是禁令。有意改值的合法路径 = 同一 PR 更新本快照 + 同步影子层(packages/design-tokens 的 generate 脚本)+ 按治理合同 §6 交证据 + 设计师批准。',- `更新方式:把实时提取结果写回 ${SNAPSHOT_RELATIVE_PATH},并重新生成 ${CLASSIFICATION_RELATIVE_PATH} / ${REFERENCE_RELATIVE_PATH} / ${SEMANTIC_RELATIVE_PATH}。`,+ `更新方式:把实时提取结果写回 ${SNAPSHOT_RELATIVE_PATH},并重新生成 ${CLASSIFICATION_RELATIVE_PATH} / ${REFERENCE_RELATIVE_PATH} / ${SEMANTIC_RELATIVE_PATH} / ${COMPONENT_RELATIVE_PATH}。`,'保护值(CINDY 皮肤族 DESIGN.md §15、U2 二级信息色、annotation-accent)另有比「改快照 + 设计师批准」更严的门槛,不能只更新本文件。','禁止为绿灯加豁免或绕加载路径。',].join('\n');@@ -390,6 +391,7 @@ export function validateAliasDirection(layers: BuiltLayers): StructureIssue[] {const files = {reference: layers.reference,semantic: layers.semantic,+ component: layers.component,};for (const { path, leaf } of fileLeaves(layers.reference)) {@@ -426,10 +428,10 @@ export function validateAliasDirection(layers: BuiltLayers): StructureIssue[] {});continue;}- if (resolved.file === 'semantic') {+ if (resolved.file !== 'reference') {issues.push({code: 'alias-direction',- message: `semantic.${path.join('.')} 解析回 semantic,违反单向依赖`,+ message: `semantic.${path.join('.')} 必须落在 reference,实际 ${resolved.file}`,});}if (@@ -442,6 +444,37 @@ export function validateAliasDirection(layers: BuiltLayers): StructureIssue[] {});}}++ for (const { path, leaf } of fileLeaves(layers.component)) {+ if (typeof leaf.$value !== 'string') {+ issues.push({+ code: 'alias-direction',+ message: `component.${path.join('.')} 必须 alias 到 semantic 或 reference,不能写字面量`,+ });+ continue;+ }+ if (!parseAliasPath(leaf.$value)) {+ issues.push({+ code: 'alias-direction',+ message: `component.${path.join('.')} 必须 alias 到 semantic 或 reference,不能写字面量`,+ });+ continue;+ }+ const resolved = resolveAlias(files, 'component', leaf.$value);+ if (!resolved) {+ issues.push({+ code: 'alias-unresolved',+ message: `component.${path.join('.')} 无法解析 ${leaf.$value}`,+ });+ continue;+ }+ if (resolved.file === 'component') {+ issues.push({+ code: 'alias-direction',+ message: `component.${path.join('.')} 解析回 component,违反单向依赖`,+ });+ }+ }return issues;}@@ -449,7 +482,9 @@ export function validateStructure(layers: BuiltLayers): StructureIssue[] {return [...validateDtcgSyntax(layers.reference, 'reference'),...validateDtcgSyntax(layers.semantic, 'semantic'),+ ...validateDtcgSyntax(layers.component, 'component'),...validateDualModes(layers.semantic),+ ...validateDualModes(layers.component),...validateAliasDirection(layers),];}diff --git a/packages/design-tokens/src/paths.ts b/packages/design-tokens/src/paths.tsindex 2c2a742adb..6cfdd5eb57 100644--- a/packages/design-tokens/src/paths.ts+++ b/packages/design-tokens/src/paths.ts@@ -15,6 +15,9 @@ export const REFERENCE_RELATIVE_PATH =export const SEMANTIC_RELATIVE_PATH ='packages/design-tokens/src/semantic/color.json';+export const COMPONENT_RELATIVE_PATH =+ 'packages/design-tokens/src/component/color.json';+export function findRepoRoot(startDir = dirname(fileURLToPath(import.meta.url))): string {let dir = startDir;while (true) {@@ -42,3 +45,7 @@ export function referencePath(repoRoot = findRepoRoot()): string {export function semanticPath(repoRoot = findRepoRoot()): string {return join(repoRoot, SEMANTIC_RELATIVE_PATH);}++export function componentPath(repoRoot = findRepoRoot()): string {+ return join(repoRoot, COMPONENT_RELATIVE_PATH);+}diff --git a/packages/design-tokens/src/reference/color.json b/packages/design-tokens/src/reference/color.jsonindex 273c9c442b..4f2b362ccd 100644--- a/packages/design-tokens/src/reference/color.json+++ b/packages/design-tokens/src/reference/color.json@@ -1,5 +1,5 @@{- "$description": "DS-3 reference 层:仅收录第一批 semantic 角色实际引用的冻结色值。",+ "$description": "DS-3/DS-4 reference 层:semantic 与 component 角色实际引用的冻结色值。","hex-f8f8f6": {"$type": "color","$value": {