Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(desktop): Switch 开关三状态视觉定稿,全皮肤开/关/不可用一眼可辨 (#1746)
Kirozengc209c2de61f0
diff --git a/apps/desktop/src/renderer/components/ui/__tests__/switch.test.tsx b/apps/desktop/src/renderer/components/ui/__tests__/switch.test.tsxindex ac2ef1115c..7546a99af3 100644--- a/apps/desktop/src/renderer/components/ui/__tests__/switch.test.tsx+++ b/apps/desktop/src/renderer/components/ui/__tests__/switch.test.tsx@@ -5,15 +5,28 @@ import { afterEach, describe, expect, it } from 'vitest';import { Switch } from '../switch';+function renderSwitch(): { track: HTMLElement; thumb: HTMLElement } {+ render(<Switch aria-label="Background updates" />);+ const track = screen.getByRole('switch', { name: 'Background updates' });+ return { track, thumb: track.firstElementChild as HTMLElement };+}+describe('Switch', () => {afterEach(cleanup);- it('uses dedicated semantic tokens for the unchecked track and thumb', () => {- render(<Switch aria-label="Background updates" />);-- const track = screen.getByRole('switch', { name: 'Background updates' });- const thumb = track.firstElementChild as HTMLElement;+ it('uses dedicated semantic tokens for both track states and the thumb', () => {+ const { track, thumb } = renderSwitch();expect(track.className).toContain('data-[state=unchecked]:bg-[var(--switch-track-off)]');expect(thumb.className).toContain('data-[state=unchecked]:bg-[var(--switch-thumb-off)]');+ expect(track.className).toContain('data-[state=checked]:bg-[var(--switch-track-on)]');+ });++ it('keeps the thumb flat and clearly mutes the disabled state', () => {+ const { track, thumb } = renderSwitch();+ // §6 零阴影哲学:滑块不得带任何投影(2026-08-05 用户裁决,试过可见投影后显式否决)+ expect(thumb.className).not.toContain('shadow');+ // 禁用态两级弱化必须走皮肤可覆盖的 token,不得回退硬编码 opacity(定值见 colors.ts)+ expect(track.className).toContain('disabled:opacity-[var(--switch-disabled-opacity)]');+ expect(thumb.className).toContain('data-[disabled]:opacity-[var(--switch-disabled-thumb-opacity)]');});});diff --git a/apps/desktop/src/renderer/components/ui/switch.tsx b/apps/desktop/src/renderer/components/ui/switch.tsxindex 30b168cc5c..261aab51b9 100644--- a/apps/desktop/src/renderer/components/ui/switch.tsx+++ b/apps/desktop/src/renderer/components/ui/switch.tsx@@ -2,8 +2,11 @@* Switch — shadcn/ui new-york 风格的 Radix Switch 包装。** 与 dropdown-menu / popover 同 Radix 包装风格:直接 forwardRef + cn() 拼样式。- * 颜色全走 token:开启 bg-primary;关闭态使用 Switch 专用 track/thumb token,- * 避免复用 input 边框色后在设置卡片上失去非文字组件所需的轮廓对比度。+ * 颜色全走 token:开启态走 --switch-track-on(默认 primary,皮肤可覆盖为主题色);+ * 关闭态使用 Switch 专用 track/thumb token,避免复用 input 边框色后在设置卡片上+ * 失去非文字组件所需的轮廓对比度。滑块无投影(DESIGN.md §6 零阴影哲学,试过可见+ * 投影后被显式否决);禁用态 = 整体 × 滑块两级不透明度 token 叠加,让「不可用」靠+ * 失去立体感区别于「关」。定值与依据见 colors.ts 注册处(用户裁决 2026-08-05)。*/import * as React from 'react';@@ -19,8 +22,8 @@ const Switch = React.forwardRef<className={cn('peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors','focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',- 'disabled:cursor-not-allowed disabled:opacity-50',- 'data-[state=checked]:bg-primary data-[state=unchecked]:bg-[var(--switch-track-off)]',+ 'disabled:cursor-not-allowed disabled:opacity-[var(--switch-disabled-opacity)]',+ 'data-[state=checked]:bg-[var(--switch-track-on)] data-[state=unchecked]:bg-[var(--switch-track-off)]',className,)}{...props}@@ -28,7 +31,8 @@ const Switch = React.forwardRef<><SwitchPrimitives.ThumbclassName={cn(- 'pointer-events-none block h-4 w-4 rounded-full shadow-lg ring-0 transition-transform',+ 'pointer-events-none block h-4 w-4 rounded-full ring-0 transition-transform',+ 'data-[disabled]:opacity-[var(--switch-disabled-thumb-opacity)]','data-[state=checked]:bg-background data-[state=unchecked]:bg-[var(--switch-thumb-off)]','data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0',)}diff --git a/apps/desktop/src/renderer/themes/__tests__/cindyDecisionData.ts b/apps/desktop/src/renderer/themes/__tests__/cindyDecisionData.tsindex 409675c436..9614fd4e65 100644--- a/apps/desktop/src/renderer/themes/__tests__/cindyDecisionData.ts+++ b/apps/desktop/src/renderer/themes/__tests__/cindyDecisionData.ts@@ -1,7 +1,10 @@-// 自动从 2026-07-17-cindy-token-decision-table.md 提取(U8 批准冻结值)。+// 初版自动从 2026-07-17-cindy-token-decision-table.md 提取(U8 批准冻结值;该表为+// 设计期工作文件,不随仓维护,生成器亦未入仓——见 DESIGN.md §15 对权威载体的说明)。// E1D 红色体系重构(用户批准 2026-07-17):B 类 11 项改反相中性,C 类按 8 项裁决。// D2T 八组断言 + 零残留脚本共享的决策基线;手改 cindy 主题值时此处不变 → 测试抓漂移。-// 不要手编此文件;改值请先过用户关卡再更新决策表 + 重生成。+// 修订契约:改值必须先过用户关卡,然后直接更新本文件对应条目,并以「用户裁决/调参/+// 改稿 + 日期」行尾注释记录依据(先例:caret-accent 2026-07-18、text-secondary+// 2026-07-20、switch-track-off 2026-08-05);没有带日期用户裁决的手编仍然禁止。export const CINDY_REQUIRED_COLOR_IDS = ['surface',@@ -34,6 +37,8 @@ export const CINDY_REQUIRED_COLOR_IDS = ['text-tertiary-hsl','text-disabled','text-disabled-tertiary',+ 'switch-track-off', // 用户裁决 2026-08-05 入表(见 CINDY_EXPECTED_VALUES 同名条目)+ 'switch-track-on', // 用户裁决 2026-08-05 入表(见 CINDY_EXPECTED_VALUES 同名条目)'caret-accent','accent-cta-bg','accent-cta-bg-pure',@@ -213,6 +218,8 @@ export const CINDY_EXPECTED_VALUES: Record<string, { light: string; dark: string'text-tertiary-hsl': { light: '222.0 4.6% 42.7%', dark: '216.0 4.1% 75.9%' },'text-disabled': { light: '#686B72', dark: '#BFC1C4' },'text-disabled-tertiary': { light: '#686B72', dark: '#BFC1C4' },+ 'switch-track-off': { light: '#888888', dark: '#787878' }, // 用户调参 2026-08-05:两端都顶到 3:1 底线内的极值拉开开/关差距——light 最亮档 #888888(×surface 3.03),dark 最深档 #787878(×elevated 3.01,等效白 36% 透明)+ 'switch-track-on': { light: '#4A4D51', dark: '#EEEEEE' }, // 用户调参 2026-08-05:light 自 primary #3C3F43 提亮一档;dark 维持 E1D 中性浅灰现状值(因 light 入表,dark 显式同冻)'caret-accent': { light: '#417CDD', dark: '#417CDD' }, // 用户改稿 2026-07-18:光标撤红改回蓝'accent-cta-bg': { light: '#3C3F43', dark: '#EEEEEE' }, // E1D'accent-cta-bg-pure': { light: '#3C3F43', dark: '#EEEEEE' }, // E1Ddiff --git a/apps/desktop/src/renderer/themes/__tests__/switchThemeContrast.test.ts b/apps/desktop/src/renderer/themes/__tests__/switchThemeContrast.test.tsindex 7f0783330c..12b09be7a2 100644--- a/apps/desktop/src/renderer/themes/__tests__/switchThemeContrast.test.ts+++ b/apps/desktop/src/renderer/themes/__tests__/switchThemeContrast.test.ts@@ -1,5 +1,6 @@import { describe, expect, it } from 'vitest';+import { contrastRatio, hslToRgb, type Rgb } from '../../../shared/theme-import/color';import { buildThemeColorsFromPalette } from '../../../shared/theme-import/palette';import { colorRegistry } from '../color-registry';import '../colors';@@ -7,19 +8,32 @@ import { builtinThemes } from '../registry';import { resolveThemeValue } from '../theme-service';import type { ColorIdentifier, Theme } from '../types';-type RGB = readonly [number, number, number];--function parseHex(value: string): RGB {+function parseHex(value: string): Rgb {if (!/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(value)) {throw new Error(`Unsupported color format in contrast test: ${value}`);}const hex = value.slice(1);const normalized = hex.length === 3 ? [...hex].map((digit) => digit.repeat(2)).join('') : hex;const number = Number.parseInt(normalized, 16);- return [(number >> 16) & 255, (number >> 8) & 255, number & 255];+ return { r: (number >> 16) & 255, g: (number >> 8) & 255, b: number & 255 };}-const UNCHECKED_SURFACES = [+/** hex 或 HSL 三元组(开启态默认链路解析到 --text-primary-hsl 用)→ RGB;其余格式 fail closed。 */+function toRgb(value: string): Rgb {+ const t = value.trim();+ if (t.startsWith('#')) return parseHex(t);+ const triplet = t.match(/^([\d.]+)\s+([\d.]+)%\s+([\d.]+)%$/);+ if (triplet) {+ return hslToRgb(parseFloat(triplet[1]), parseFloat(triplet[2]) / 100, parseFloat(triplet[3]) / 100);+ }+ throw new Error(`Unsupported color format in contrast test: ${value}`);+}++function contrast(first: string, second: string): number {+ return contrastRatio(toRgb(first), toRgb(second));+}++const SURFACES = ['surface','surface-elevated','surface-card-ivory',@@ -27,6 +41,12 @@ const UNCHECKED_SURFACES = ['surface-hover-soft',] as const;+/** 开/关两态共用一套守卫:轨道×滑块、轨道×全部表面均 ≥3:1(非文字组件底线)。 */+const CONTROL_STATES = [+ { state: 'unchecked', trackId: 'switch-track-off', thumbId: 'switch-thumb-off' },+ { state: 'checked', trackId: 'switch-track-on', thumbId: 'background' },+] as const;+const importedDarkTheme: Theme = {id: 'imported-dark-fixture',name: 'Imported Dark Fixture',@@ -48,21 +68,6 @@ const importedDarkTheme: Theme = {}, 'dark'),};-function luminance(value: string): number {- const channels = parseHex(value).map((channel) => {- const normalized = channel / 255;- return normalized <= 0.03928- ? normalized / 12.92- : ((normalized + 0.055) / 1.055) ** 2.4;- });- return 0.2126 * channels[0] + 0.7152 * channels[1] + 0.0722 * channels[2];-}--function contrast(first: string, second: string): number {- const [lighter, darker] = [luminance(first), luminance(second)].sort((a, b) => b - a);- return (lighter + 0.05) / (darker + 0.05);-}-function resolveColor(theme: Theme, id: ColorIdentifier, seen = new Set<string>()): string {if (seen.has(id)) {throw new Error(`Circular color token reference: ${[...seen, id].join(' -> ')}`);@@ -74,20 +79,33 @@ function resolveColor(theme: Theme, id: ColorIdentifier, seen = new Set<string>(throw new Error(`Theme '${theme.id}' does not resolve --${id}`);}- const reference = value.match(/^var\(--([^)]+)\)$/);+ // 认两种引用形态:var(--x) 与 hsl(var(--x))(开启态默认值 hsl(var(--primary)))。+ const reference = value.match(/^(?:hsl\()?var\(--([^)]+)\)\)?$/);return reference ? resolveColor(theme, reference[1], seen) : value;}-describe('unchecked Switch contrast', () => {+describe('Switch contrast', () => {it('registers dedicated track and thumb tokens', () => {expect(colorRegistry.resolveDefault('switch-track-off', 'light')).toBe('var(--text-secondary)');expect(colorRegistry.resolveDefault('switch-track-off', 'dark')).toBe('var(--text-secondary)');expect(colorRegistry.resolveDefault('switch-thumb-off', 'light')).toBe('var(--surface-on-card)');expect(colorRegistry.resolveDefault('switch-thumb-off', 'dark')).toBe('var(--surface-on-card)');+ // 开启态轨道默认沿用 primary:不覆盖的主题(Classic/导入)外观零变化+ expect(colorRegistry.resolveDefault('switch-track-on', 'light')).toBe('hsl(var(--primary))');+ expect(colorRegistry.resolveDefault('switch-track-on', 'dark')).toBe('hsl(var(--primary))');+ // 禁用态两级弱化的全局定稿值(用户裁决 2026-08-05):整体 0.3 × 滑块 0.5+ for (const [id, expected] of [+ ['switch-disabled-opacity', '0.3'],+ ['switch-disabled-thumb-opacity', '0.5'],+ ] as const) {+ expect(colorRegistry.resolveDefault(id, 'light'), id).toBe(expected);+ expect(colorRegistry.resolveDefault(id, 'dark'), id).toBe(expected);+ }});it('fails closed for unsupported color formats', () => {expect(() => parseHex('rgb(130, 130, 130)')).toThrow('Unsupported color format');+ expect(() => toRgb('rgba(130, 130, 130, 0.5)')).toThrow('Unsupported color format');});it('resolves unchecked colors through imported theme palette aliases', () => {@@ -98,21 +116,24 @@ describe('unchecked Switch contrast', () => {expect(thumb).toBe(importedDarkTheme.colors['surface-on-card']);expect(contrast(thumb, track), 'imported dark: thumb x track').toBeGreaterThanOrEqual(3);- for (const surface of UNCHECKED_SURFACES) {+ for (const surface of SURFACES) {const background = resolveColor(importedDarkTheme, surface);expect(contrast(track, background), `imported dark: track x ${surface}`).toBeGreaterThanOrEqual(3);}});- it.each(Object.values(builtinThemes))('$name keeps the unchecked control distinguishable', (theme) => {- const track = resolveColor(theme, 'switch-track-off');- const thumb = resolveColor(theme, 'switch-thumb-off');+ it.each(Object.values(builtinThemes))('$name keeps both switch states distinguishable', (theme) => {+ const surfaces = SURFACES.map((id) => [id, resolveColor(theme, id)] as const);++ for (const { state, trackId, thumbId } of CONTROL_STATES) {+ const track = resolveColor(theme, trackId);+ const thumb = resolveColor(theme, thumbId);- expect(contrast(thumb, track), `${theme.id}: thumb x track`).toBeGreaterThanOrEqual(3);+ expect(contrast(thumb, track), `${theme.id}: ${state} thumb x track`).toBeGreaterThanOrEqual(3);- for (const surface of UNCHECKED_SURFACES) {- const background = resolveColor(theme, surface);- expect(contrast(track, background), `${theme.id}: track x ${surface}`).toBeGreaterThanOrEqual(3);+ for (const [surfaceId, surface] of surfaces) {+ expect(contrast(track, surface), `${theme.id}: ${state} track x ${surfaceId}`).toBeGreaterThanOrEqual(3);+ }}});});diff --git a/apps/desktop/src/renderer/themes/builtin/atom-one-light.ts b/apps/desktop/src/renderer/themes/builtin/atom-one-light.tsindex ec7caae7c8..31f77a778c 100644--- a/apps/desktop/src/renderer/themes/builtin/atom-one-light.ts+++ b/apps/desktop/src/renderer/themes/builtin/atom-one-light.ts@@ -69,6 +69,7 @@ const slotOverrides = {'accent-soft': BLUE_DEEP,'accent-hover': BLUE_DEEP,'accent-pure-cta-fg': '#FFFFFF',+ 'switch-track-on': BLUE_PRIMARY,} as const;const singletonOverrides = {diff --git a/apps/desktop/src/renderer/themes/builtin/cindy-dark.ts b/apps/desktop/src/renderer/themes/builtin/cindy-dark.tsindex fa214d1dd9..afa8cf849c 100644--- a/apps/desktop/src/renderer/themes/builtin/cindy-dark.ts+++ b/apps/desktop/src/renderer/themes/builtin/cindy-dark.ts@@ -19,8 +19,8 @@ const overrides = {'surface-hover-soft': '#2B2929', // 插值: 20%'surface-hover-hsl': '0.0 2.2% 18.0%', // 插值: hover -> HSL'surface-on-card': '#2A2828', // 裁决: 中性反相前景,不作红 CTA 专用- // 有意引用决策表已冻结的 disabled 灰,与 fast-toggle-track 同源;不新增自由字面值。- 'switch-track-off': 'var(--text-disabled)',+ 'switch-track-off': '#787878', // 关闭态轨道:值与依据见决策表(用户调参 2026-08-05)+ 'switch-track-on': '#EEEEEE', // 开启态轨道:值与依据见决策表(用户调参 2026-08-05)'status-badge-fg': '#1F1F1F', // §7 必炸点:值经队列震荡后按 HEAD 冻结(#1F1F1F,5.61:1 × #FF6600 ≥4.5),批准依据:用户亲批方案 2026-07-17'border-default': '#434343', // 直映: 边框'border-default-hsl': '0.0 0.0% 26.3%', // 边框 -> HSLdiff --git a/apps/desktop/src/renderer/themes/builtin/cindy-light.ts b/apps/desktop/src/renderer/themes/builtin/cindy-light.tsindex f65aaf02e5..611e5c495a 100644--- a/apps/desktop/src/renderer/themes/builtin/cindy-light.ts+++ b/apps/desktop/src/renderer/themes/builtin/cindy-light.ts@@ -19,8 +19,8 @@ const overrides = {'surface-hover-soft': '#EFEFEF', // 插值: 20%'surface-hover-hsl': '0.0 0.0% 94.5%', // 插值: hover -> HSL'surface-on-card': '#FFFFFF', // 裁决: 中性反相前景,不作红 CTA 专用- // 有意引用决策表已冻结的 disabled 灰,与 fast-toggle-track 同源;不新增自由字面值。- 'switch-track-off': 'var(--text-disabled)',+ 'switch-track-off': '#888888', // 关闭态轨道:值与依据见决策表(用户调参 2026-08-05)+ 'switch-track-on': '#4A4D51', // 开启态轨道:值与依据见决策表(用户调参 2026-08-05)'status-badge-fg': '#1F1F1F', // §7 必炸点:值经队列震荡后按 HEAD 冻结(#1F1F1F,5.61:1 × #FF6600 ≥4.5),批准依据:用户亲批方案 2026-07-17'border-default': '#DCDFE3', // 直映: 边框'border-default-hsl': '214.3 11.1% 87.6%', // 边框 -> HSLdiff --git a/apps/desktop/src/renderer/themes/builtin/eclipse.ts b/apps/desktop/src/renderer/themes/builtin/eclipse.tsindex 7fb52fe3d1..e79fce4f37 100644--- a/apps/desktop/src/renderer/themes/builtin/eclipse.ts+++ b/apps/desktop/src/renderer/themes/builtin/eclipse.ts@@ -68,6 +68,7 @@ const slotOverrides = {'accent-soft': TEAL_SOFT,'accent-hover': TEAL_DEEP,'accent-pure-cta-fg': SURFACE_NAVY,+ 'switch-track-on': TEAL_PRIMARY,} as const;const singletonOverrides = {diff --git a/apps/desktop/src/renderer/themes/builtin/github-dark.ts b/apps/desktop/src/renderer/themes/builtin/github-dark.tsindex e84ea24207..7c8aa0ce4a 100644--- a/apps/desktop/src/renderer/themes/builtin/github-dark.ts+++ b/apps/desktop/src/renderer/themes/builtin/github-dark.ts@@ -70,6 +70,7 @@ const slotOverrides = {'accent-soft': BLUE_SOFT,'accent-hover': BLUE_DEEP,'accent-pure-cta-fg': '#ffffff',+ 'switch-track-on': BLUE_PRIMARY,'status-badge-fg': '#1F1F1F',} as const;diff --git a/apps/desktop/src/renderer/themes/builtin/material-ocean-hc.ts b/apps/desktop/src/renderer/themes/builtin/material-ocean-hc.tsindex f8a8b8efc1..7d164d4de1 100644--- a/apps/desktop/src/renderer/themes/builtin/material-ocean-hc.ts+++ b/apps/desktop/src/renderer/themes/builtin/material-ocean-hc.ts@@ -66,6 +66,7 @@ const slotOverrides = {'accent-soft': TEAL_SOFT,'accent-hover': TEAL_DEEP,'accent-pure-cta-fg': SURFACE_BG,+ 'switch-track-on': TEAL_PRIMARY,} as const;const singletonOverrides = {diff --git a/apps/desktop/src/renderer/themes/builtin/monokai-pro.ts b/apps/desktop/src/renderer/themes/builtin/monokai-pro.tsindex 5c49cae7cd..d482d7b9ae 100644--- a/apps/desktop/src/renderer/themes/builtin/monokai-pro.ts+++ b/apps/desktop/src/renderer/themes/builtin/monokai-pro.ts@@ -65,6 +65,7 @@ const slotOverrides = {'accent-soft': YELLOW_SOFT,'accent-hover': YELLOW_DEEP,'accent-pure-cta-fg': SURFACE_BG,+ 'switch-track-on': YELLOW_PRIMARY,} as const;const singletonOverrides = {diff --git a/apps/desktop/src/renderer/themes/builtin/one-dark-pro.ts b/apps/desktop/src/renderer/themes/builtin/one-dark-pro.tsindex 579c8f1df0..53a8502df9 100644--- a/apps/desktop/src/renderer/themes/builtin/one-dark-pro.ts+++ b/apps/desktop/src/renderer/themes/builtin/one-dark-pro.ts@@ -78,6 +78,7 @@ const slotOverrides = {'accent-soft': BLUE_SOFT,'accent-hover': BLUE_DEEP,'accent-pure-cta-fg': SURFACE_BG,+ 'switch-track-on': BLUE_PRIMARY,} as const;const singletonOverrides = {diff --git a/apps/desktop/src/renderer/themes/builtin/solarized-light.ts b/apps/desktop/src/renderer/themes/builtin/solarized-light.tsindex 3d95e9899a..418beaf7b9 100644--- a/apps/desktop/src/renderer/themes/builtin/solarized-light.ts+++ b/apps/desktop/src/renderer/themes/builtin/solarized-light.ts@@ -77,6 +77,7 @@ const slotOverrides = {'accent-soft': GREEN_DEEP,'accent-hover': GREEN_DEEP,'accent-pure-cta-fg': '#FFFFFF',+ 'switch-track-on': GREEN_DEEP, // 官方绿 #859900 对 thumb 2.97/对 surface 2.62 低于 3:1,取深绿变体(用户裁决 2026-08-05)} as const;const singletonOverrides = {diff --git a/apps/desktop/src/renderer/themes/colors.ts b/apps/desktop/src/renderer/themes/colors.tsindex 9049bdb384..dda3fb7994 100644--- a/apps/desktop/src/renderer/themes/colors.ts+++ b/apps/desktop/src/renderer/themes/colors.ts@@ -262,6 +262,18 @@ registerColor('switch-thumb-off', {light: 'var(--surface-on-card)',dark: 'var(--surface-on-card)',}, '共享 Switch 未选中滑块;跟随主题反相前景,与未选中轨道保持至少 3:1 非文字组件对比度');+registerColor('switch-disabled-opacity', {+ light: '0.3',+ dark: '0.3',+}, '共享 Switch 禁用态整体不透明度(纯数值 token,非颜色);全局 0.3(用户裁决 2026-08-05,自出货值 0.5 调深),各皮肤仍可覆盖');+registerColor('switch-disabled-thumb-opacity', {+ light: '0.5',+ dark: '0.5',+}, '共享 Switch 禁用态滑块自身不透明度(纯数值 token,叠加在整体不透明度之上);全局 0.5(用户裁决 2026-08-05)——禁用态滑块与轨道趋近、削掉立体感,「不可用」区别于「关」的关键');+registerColor('switch-track-on', {+ light: 'hsl(var(--primary))',+ dark: 'hsl(var(--primary))',+}, '共享 Switch 开启态轨道;默认沿用 primary(不覆盖的主题外观不变),移植主题覆盖为各自主题色、CINDY 冻结于决策表;每个覆盖值须过 switchThemeContrast 的 ≥3:1 守卫(用户裁决 2026-08-05)');registerColor('ring', {light: 'var(--text-primary-hsl)',dark: 'var(--text-primary-hsl)',diff --git a/apps/desktop/src/shared/__tests__/themeImportPalette.test.ts b/apps/desktop/src/shared/__tests__/themeImportPalette.test.tsindex 47d36a73d7..0aa218ee17 100644--- a/apps/desktop/src/shared/__tests__/themeImportPalette.test.ts+++ b/apps/desktop/src/shared/__tests__/themeImportPalette.test.ts@@ -136,7 +136,10 @@ function normalize(value: string): string {describe('theme-import 模板 · key 集合与既有 builtin 主题一致', () => {it('TEMPLATE_TOKEN_IDS 覆盖 github-dark,并仅追加导入主题专用的 Switch token', () => {- const builtinIds = Object.keys(githubDark.colors);+ // switch-track-on 是移植主题文件专属 override:模板刻意不产出,导入主题回落+ // registry 默认以保持升级前后外观不变(规则见 DESIGN.md 主题导入节,守卫见+ // switchThemeContrast.test.ts)。+ const builtinIds = Object.keys(githubDark.colors).filter((id) => id !== 'switch-track-on');expect(builtinIds.filter((id) => !TEMPLATE_TOKEN_IDS.includes(id))).toEqual([]);expect(TEMPLATE_TOKEN_IDS.filter((id) => !builtinIds.includes(id)).sort()).toEqual(['switch-thumb-off',diff --git a/docs/design-rules/DESIGN.md b/docs/design-rules/DESIGN.mdindex fd5ef0e31d..d859e330be 100644--- a/docs/design-rules/DESIGN.md+++ b/docs/design-rules/DESIGN.md@@ -255,7 +255,7 @@ Three tiers — **these three only**:| Lifted (Card) | Card fill (`#ffffff` Light / `#2c2c2a` Dark) + optional 1px Board outline | Login cards, modals, raised panels |-**Shadow Philosophy**: Cindy's base visual language uses **zero shadows**. This is not an oversight — it's a deliberate design decision. The flat, shadowless approach creates a paper-like experience where elements are distinguished purely by background color and single-pixel borders. Depth is communicated through **content hierarchy and typography weight**, not visual layering. (The only shadows in the system are the token-gated floating-layer exceptions registered in §10 — `--shadow-menu` / `--cmd-palette-shadow` / `--confirm-shadow`; never add ad-hoc shadows to in-page elements.)+**Shadow Philosophy**: Cindy's base visual language uses **zero shadows**. This is not an oversight — it's a deliberate design decision. The flat, shadowless approach creates a paper-like experience where elements are distinguished purely by background color and single-pixel borders. Depth is communicated through **content hierarchy and typography weight**, not visual layering. (The only shadows in the system are the token-gated floating-layer exceptions registered in §10 — `--shadow-menu` / `--cmd-palette-shadow` / `--confirm-shadow`; never add ad-hoc shadows to in-page elements. A Switch-knob shadow was trialed and explicitly rejected — user ruling 2026-08-05: the legacy `shadow-lg` on the 16px thumb was invisible in practice, and a visible replacement read as noise; the knob is flat by decision, don't re-add it.)## 7. Do's and Don'ts@@ -478,6 +478,7 @@ Settings → Appearance can import a VSCode color theme (`*.json` / jsonc) or an- **`-hsl` tokens are computed, not copied.** Both forms of a color must denote the same color, so the converter derives every HSL triplet from its hex via `toHslTriplet()`. (Note: a few hand-written builtin themes carry approximate HSL values — `github-dark`'s `SURFACE_BG_HSL` was copied off one-dark-pro. Those are left as-is; new imports are exact.)- **Markdown text colors go through `--md-h1-fg`…`--md-h6-fg` / `--md-strong-fg`, and default to `inherit`.** Before these tokens existed, Markdown headings and bold text inherited their color from the container (`baseComponents` sets size/weight only). Defaulting to `var(--text-primary)` would have repainted headings inside blockquotes, tool cards and secondary-text regions, so the defaults are `inherit` — every built-in theme renders exactly as before. Imported themes fill them from Obsidian `--hN-color` / `--bold-color` or VSCode `markup.heading` / `markup.bold`. Guard: `themes/__tests__/markdownColorTokens.test.ts`.- **Obsidian import is a palette import, not a theme port.** Only CSS custom properties are read; selectors, layout, radii and fonts are discarded — Cindy's layout and typography stay owned by §3/§5. Values that cannot be evaluated statically (`color-mix()`, undefined `var()`) are skipped and reported rather than guessed.+- **Checked Switch track = theme accent (ported theme files only, user ruling 2026-08-05).** The seven ported theme files each override `switch-track-on` to their own accent (solarized-light uses `GREEN_DEEP` — the official `#859900` fails the 3:1 floor). The registry default stays `hsl(var(--primary))`: Classic and imported themes keep the pre-existing neutral checked track, and CINDY carries its own frozen decision-table values (Dark keeps `#EEEEEE`; Light deliberately lightened to `#4A4D51`). Guard: `switchThemeContrast.test.ts` asserts every builtin theme's checked track ≥3:1 against the checked thumb (`background`) and all five surfaces.- **Local themes may declare an optional `family`.** Same-family light + dark variants merge into one switchable family (`themes/families.ts`); files without the field keep behaving exactly as before (family id = theme id). Obsidian's dual-mode CSS uses this to land as a single theme that follows Light/Dark mode.## 11. Voice & Content(微文案规范)