From 28432f7c59bbea5f045385867212618f7c0cef02 Mon Sep 17 00:00:00 2001 From: Delicious233 <101502465+DeliciousBuding@users.noreply.github.com> Date: Mon, 17 Aug 2026 17:25:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(mobile):=20inkSubtle=20=E4=B8=89?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E8=BE=BE=20WCAG=20AA=20=E5=AF=B9=E6=AF=94?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dark/oled inkSubtle #666875 在 canvas 上仅 2.92:1,远低于 AA 4.5:1;light #8a8d98 也仅 3.12:1。dark/oled 提到 #8a8d98(4.90:1),light 降到 #6b6e78(4.65:1),17 处消费点(ListRow/SearchField/ChatScreen 等 meta 文本)恢复可读。新增 WCAG 对比度计算器与断言测试。 Co-authored-by: Cursor --- app/mobile-rn/src/theme/tokens.test.ts | 27 ++++++++++++++++++++++++++ app/mobile-rn/src/theme/tokens.ts | 6 +++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/app/mobile-rn/src/theme/tokens.test.ts b/app/mobile-rn/src/theme/tokens.test.ts index 51058ce5b..868a0c1cf 100644 --- a/app/mobile-rn/src/theme/tokens.test.ts +++ b/app/mobile-rn/src/theme/tokens.test.ts @@ -11,6 +11,26 @@ function resolvePath(source: unknown, path: string): unknown { ), source); } +function hexToRgb(hex: string): [number, number, number] { + const normalized = hex.replace('#', ''); + const r = parseInt(normalized.slice(0, 2), 16) / 255; + const g = parseInt(normalized.slice(2, 4), 16) / 255; + const b = parseInt(normalized.slice(4, 6), 16) / 255; + return [r, g, b]; +} + +function relativeLuminance(hex: string): number { + const [r, g, b] = hexToRgb(hex).map((c) => (c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4))); + return 0.2126 * r + 0.7152 * g + 0.0722 * b; +} + +function contrastRatio(foreground: string, background: string): number { + const l1 = relativeLuminance(foreground); + const l2 = relativeLuminance(background); + const [lighter, darker] = l1 > l2 ? [l1, l2] : [l2, l1]; + return (lighter + 0.05) / (darker + 0.05); +} + describe('AgentHub mobile tokens', () => { it('keeps light mode as the default white-first mobile surface', () => { expect(getAgentHubTheme('light', true)).toBe(agentHubThemes.light); @@ -125,4 +145,11 @@ describe('AgentHub mobile tokens', () => { expect(getAgentHubTheme('system', true).scheme).toBe('dark'); expect(getAgentHubTheme('system', false).scheme).toBe('light'); }); + + it('keeps inkSubtle at or above WCAG AA contrast (4.5:1) on canvas for every theme', () => { + for (const theme of Object.values(agentHubThemes)) { + const ratio = contrastRatio(theme.color.inkSubtle, theme.color.canvas); + expect(ratio, `${theme.scheme} inkSubtle/canvas`).toBeGreaterThanOrEqual(4.5); + } + }); }); diff --git a/app/mobile-rn/src/theme/tokens.ts b/app/mobile-rn/src/theme/tokens.ts index 9ef8d74d8..0fecb818d 100644 --- a/app/mobile-rn/src/theme/tokens.ts +++ b/app/mobile-rn/src/theme/tokens.ts @@ -196,7 +196,7 @@ export const agentHubThemes = { tint: 'rgba(41, 171, 226, 0.14)', ink: '#e3e4e6', inkMuted: '#a0a1aa', - inkSubtle: '#666875', + inkSubtle: '#8a8d98', line: 'rgba(255, 255, 255, 0.075)', focus: 'rgba(41, 171, 226, 0.42)', accent: '#29ABE2', @@ -243,7 +243,7 @@ export const agentHubThemes = { tint: 'rgba(0, 113, 188, 0.08)', ink: '#171720', inkMuted: '#525463', - inkSubtle: '#8a8d98', + inkSubtle: '#6b6e78', line: 'rgba(15, 23, 42, 0.1)', focus: 'rgba(0, 113, 188, 0.32)', accent: '#0071BC', @@ -290,7 +290,7 @@ export const agentHubThemes = { tint: 'rgba(41, 171, 226, 0.16)', ink: '#e3e4e6', inkMuted: '#a0a1aa', - inkSubtle: '#666875', + inkSubtle: '#8a8d98', line: 'rgba(255, 255, 255, 0.065)', focus: 'rgba(41, 171, 226, 0.42)', accent: '#29ABE2', From 69e9697732881bab83de6a7d335086651470afaf Mon Sep 17 00:00:00 2001 From: Delicious233 <101502465+DeliciousBuding@users.noreply.github.com> Date: Mon, 17 Aug 2026 17:32:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(mobile):=20=E4=BF=AE=E5=A4=8D=20noUnche?= =?UTF-8?q?ckedIndexedAccess=20=E5=AF=BC=E8=87=B4=E7=9A=84=20luminance=20?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- app/mobile-rn/src/theme/tokens.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/mobile-rn/src/theme/tokens.test.ts b/app/mobile-rn/src/theme/tokens.test.ts index 868a0c1cf..ada2e1483 100644 --- a/app/mobile-rn/src/theme/tokens.test.ts +++ b/app/mobile-rn/src/theme/tokens.test.ts @@ -20,8 +20,9 @@ function hexToRgb(hex: string): [number, number, number] { } function relativeLuminance(hex: string): number { - const [r, g, b] = hexToRgb(hex).map((c) => (c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4))); - return 0.2126 * r + 0.7152 * g + 0.0722 * b; + const [r, g, b] = hexToRgb(hex); + const linearize = (c: number) => (c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4)); + return 0.2126 * linearize(r) + 0.7152 * linearize(g) + 0.0722 * linearize(b); } function contrastRatio(foreground: string, background: string): number {