Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🌗 a11y: Ink the Dark Default Avatar Glyph at 3:1 on Its Fill (#16931)
Marco Berettaa0de8bbba735
diff --git a/client/src/Providers/__tests__/themeCache.spec.ts b/client/src/Providers/__tests__/themeCache.spec.tsindex 3bbe882899..8ffcf094ee 100644--- a/client/src/Providers/__tests__/themeCache.spec.ts+++ b/client/src/Providers/__tests__/themeCache.spec.ts@@ -182,7 +182,7 @@ describe('theme cache storage', () => {* - definitions with one or both mode blocks absent.* A new role, or a new fallback, joins by construction.*/-const PIN = { fingerprint: '1.2.leqd1k', digest: '1fm6x5m' };+const PIN = { fingerprint: '1.3.leqd1k', digest: '1js4qi' };const digestOf = (text: string): string => {let hash = 5381;diff --git a/e2e/specs/mock/scenarios/avatar-glyph-contrast.spec.ts b/e2e/specs/mock/scenarios/avatar-glyph-contrast.spec.tsnew file mode 100644index 0000000000..692e20cbf1--- /dev/null+++ b/e2e/specs/mock/scenarios/avatar-glyph-contrast.spec.ts@@ -0,0 +1,109 @@+import { expect, test } from '@playwright/test';+import type { Page } from '@playwright/test';+import { NEW_CHAT_PATH } from '../helpers';++/**+ * The default user avatar's glyph is a graphical object under WCAG 1.4.11 (Non-text Contrast), so+ * it owes 3:1 against the `avatar-fill` behind it. Light mode keeps its #212121 ink; dark mode+ * inks it white, since the #ececec primary text held only 2.6:1 on the #7989ff fill.+ */++type Mode = 'light' | 'dark';++const THEME_PARAM = 'e2eThemeMode';+const MISSING_AVATAR = 'https://avatar.e2e.invalid/missing.png';+const WCAG_NON_TEXT_MIN = 3;+const EXPECTED: Record<Mode, { fill: string; glyph: string }> = {+ light: { fill: 'rgb(121, 137, 255)', glyph: 'rgb(33, 33, 33)' },+ dark: { fill: 'rgb(121, 137, 255)', glyph: 'rgb(255, 255, 255)' },+};++test.use({ viewport: { width: 1280, height: 800 } });++async function installThemeBridge(page: Page) {+ await page.addInitScript(() => {+ const mode = new URL(location.href).searchParams.get('e2eThemeMode');+ if (mode) {+ localStorage.setItem('color-theme', mode);+ }+ localStorage.setItem('navVisible', 'true');+ localStorage.removeItem('theme-colors');+ localStorage.removeItem('theme-name');+ localStorage.removeItem('theme-definition');+ localStorage.removeItem('theme-source');+ });+}++/** The default avatar only draws once the user's image fails to load. */+async function failUserAvatar(page: Page) {+ await page.route(`${MISSING_AVATAR}*`, (route) => route.abort());+ await page.route('**/api/user', async (route) => {+ const response = await route.fetch();+ const user = await response.json();+ await route.fulfill({ response, json: { ...user, avatar: MISSING_AVATAR } });+ });+}++const channels = (color: string): number[] =>+ (color.match(/\d+(\.\d+)?/g) ?? []).slice(0, 3).map(Number);++/** WCAG 2 relative luminance of an sRGB colour. */+function luminance(color: string): number {+ const [r, g, b] = channels(color).map((value) => {+ const unit = value / 255;+ return unit <= 0.04045 ? unit / 12.92 : ((unit + 0.055) / 1.055) ** 2.4;+ });+ return 0.2126 * r + 0.7152 * g + 0.0722 * b;+}++function contrast(foreground: string, background: string): number {+ const [lighter, darker] = [luminance(foreground), luminance(background)].sort((a, b) => b - a);+ return (lighter + 0.05) / (darker + 0.05);+}++/** Renders the default avatar in `mode` and reads the glyph's stroke and the fill behind it. */+async function defaultAvatarPaint(page: Page, mode: Mode) {+ await installThemeBridge(page);+ await failUserAvatar(page);+ await page.goto(`${NEW_CHAT_PATH}?${THEME_PARAM}=${mode}`);+ await expect+ .poll(() => page.evaluate(() => document.documentElement.classList.contains('dark')))+ .toBe(mode === 'dark');++ const avatar = page.getByTestId('nav-user').locator('div[aria-hidden="true"]').first();+ await expect(avatar).toBeVisible({ timeout: 20000 });+ const paint = await avatar.evaluate((node) => {+ const mark = node.querySelector('svg');+ return {+ fill: getComputedStyle(node).backgroundColor,+ glyph: mark ? getComputedStyle(mark).stroke : '',+ };+ });+ await test.info().attach(`default-avatar-${mode}`, {+ body: await avatar.screenshot(),+ contentType: 'image/png',+ });+ return paint;+}++test.describe('default avatar glyph contrast', () => {+ test.describe.configure({ timeout: 60000 });++ test('the default avatar glyph keeps its light ink at 3:1 or more @scenario:default-avatar-glyph-contrast-light', async ({+ page,+ }) => {+ const { fill, glyph } = await defaultAvatarPaint(page, 'light');++ expect({ fill, glyph }).toEqual(EXPECTED.light);+ expect(contrast(glyph, fill)).toBeGreaterThanOrEqual(WCAG_NON_TEXT_MIN);+ });++ test('the default avatar glyph clears 3:1 on its fill in dark mode @scenario:default-avatar-glyph-contrast-dark', async ({+ page,+ }) => {+ const { fill, glyph } = await defaultAvatarPaint(page, 'dark');++ expect({ fill, glyph }).toEqual(EXPECTED.dark);+ expect(contrast(glyph, fill)).toBeGreaterThanOrEqual(WCAG_NON_TEXT_MIN);+ });+});diff --git a/e2e/specs/mock/scenarios/clickhouse-theme.spec.ts b/e2e/specs/mock/scenarios/clickhouse-theme.spec.tsindex cb9b5c0c64..101dbd8ceb 100644--- a/e2e/specs/mock/scenarios/clickhouse-theme.spec.ts+++ b/e2e/specs/mock/scenarios/clickhouse-theme.spec.ts@@ -270,7 +270,7 @@ test.describe('clickhouse reference theme', () => {try {for (const [mode, placeholder, ink] of [['light', defaultTheme['rgb-surface-secondary'], 'rgb(33, 33, 33)'],- ['dark', darkTheme['rgb-surface-tertiary'], 'rgb(236, 236, 236)'],+ ['dark', darkTheme['rgb-surface-tertiary'], 'rgb(255, 255, 255)'],] as const) {await page.goto(`/c/${conversationId}?${THEME_PARAM}=${mode}`);await expect(page.getByText(REPLY_TEXT, { exact: true }).first()).toBeVisible({diff --git a/packages/client/src/theme/README.md b/packages/client/src/theme/README.mdindex f889bdfd1c..f0459c8d1f 100644--- a/packages/client/src/theme/README.md+++ b/packages/client/src/theme/README.md@@ -343,6 +343,8 @@ Each status family has a foreground, a `-subtle` background, a `-border`, and a- `bg-avatar-fill` / `text-avatar-text` - The default user avatar drawn when auser has no image, and its glyph. A theme that sets `rgb-text-primary` but not`rgb-avatar-text` inks the glyph in its primary text, as it did before the role.+ The bundled dark theme inks it white, which clears the 3:1 WCAG 1.4.11 sets for+ the glyph on the fill where its #ececec primary text does not.- `bg-avatar-placeholder` - Behind an agent or assistant avatar while its imageloads or where it is transparent. A theme that sets only its surfaces keeps iton `surface-secondary` in light and `surface-tertiary` in dark, where it satdiff --git a/packages/client/src/theme/defaults.css b/packages/client/src/theme/defaults.cssindex e730e862f7..8ed2b65632 100644--- a/packages/client/src/theme/defaults.css+++ b/packages/client/src/theme/defaults.css@@ -377,7 +377,7 @@ html {.dark {--brand-purple: 171 104 255;--avatar-fill: 121 137 255;- --avatar-text: var(--text-primary);+ --avatar-text: 255 255 255;--avatar-placeholder: var(--surface-tertiary);--avatar-edge: 240 246 252;--illustration-subtle: 175 193 255;diff --git a/packages/client/src/theme/semanticTokens.spec.ts b/packages/client/src/theme/semanticTokens.spec.tsindex b4e8949cd4..536cd2c45a 100644--- a/packages/client/src/theme/semanticTokens.spec.ts+++ b/packages/client/src/theme/semanticTokens.spec.ts@@ -566,19 +566,10 @@ describe('verified fill defaults', () => {});});-/**- * The default avatar's glyph is a graphical object under WCAG 1.4.11, so it needs 3:1 on its fill.- * The bundled dark theme keeps the 2.6:1 its avatar painted before the role existed: the glyph is- * decorative (aria-hidden beside the account name), and raising it is tracked on its own.- */-it('keeps the bundled dark avatar glyph no fainter than it painted before its role', () => {- expect(- contrast(toRgb(darkTheme, 'rgb-avatar-text'), toRgb(darkTheme, 'rgb-avatar-fill')),- ).toBeGreaterThanOrEqual(2.6);-});-+/** The default avatar's glyph is a graphical object under WCAG 1.4.11, so it needs 3:1 on its fill. */describe.each([['default', defaultTheme],+ ['dark', darkTheme],['high contrast light', highContrastLightTheme],['high contrast dark', highContrastDarkTheme],['clickhouse light', clickHouseLightTheme],diff --git a/packages/client/src/theme/themes/dark.ts b/packages/client/src/theme/themes/dark.tsindex 3f802d2b9a..c4bd6f74a6 100644--- a/packages/client/src/theme/themes/dark.ts+++ b/packages/client/src/theme/themes/dark.ts@@ -150,7 +150,9 @@ export const darkTheme: IThemeRGB = {// Brand colors'rgb-brand-purple': '171 104 255', // #ab68ff'rgb-avatar-fill': '121 137 255', // #7989ff (the default avatar fill in every bundled theme)- 'rgb-avatar-text': '236 236 236', // #ececec (gray-100, matching text-primary)+ /** White, not the #ececec primary text: the glyph is a graphical object (WCAG 1.4.11) and+ * #ececec held only 2.6:1 on the #7989ff fill, where white reaches 3.07:1. */+ 'rgb-avatar-text': '255 255 255', // #ffffff'rgb-avatar-placeholder': '47 47 47', // #2f2f2f (gray-700, matching surface-tertiary)'rgb-avatar-edge': '240 246 252', // #f0f6fc at 10%, a hairline that only shows against a dark page'rgb-illustration-subtle': '175 193 255', // #afc1ffdiff --git a/packages/data-provider/src/theme.ts b/packages/data-provider/src/theme.tsindex ab31d708fe..44e044b1b0 100644--- a/packages/data-provider/src/theme.ts+++ b/packages/data-provider/src/theme.ts@@ -543,7 +543,7 @@ export const themeAppearanceTokens = Object.freeze(* Bumped by hand when a release changes what resolving a theme emits without changing its roles* (a palette value, a fallback derivation, an emitted attribute), so cached entries are rebuilt.*/-export const THEME_CACHE_EPOCH = 2 as const;+export const THEME_CACHE_EPOCH = 3 as const;/*** Names the role set a stored resolved theme was built against: any color, brand or appearance