Skip to content

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

🎯 fix: Hold Default Button Heights and the Dialog Close Button at the 24px Target (#16928)

Marco Beretta74e682b7a3c5
diff --git a/client/src/Providers/__tests__/themeCache.spec.ts b/client/src/Providers/__tests__/themeCache.spec.ts
index 14387ce1a8..602749f66a 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.3.dxwdxg', digest: 'aepelz' };
+const PIN = { fingerprint: '1.4.dxwdxg', digest: 'aepelz' };
const digestOf = (text: string): string => {
let hash = 5381;
diff --git a/e2e/specs/mock/scenarios/target-floor.spec.ts b/e2e/specs/mock/scenarios/target-floor.spec.ts
new file mode 100644
index 0000000000..75ba9d5261
--- /dev/null
+++ b/e2e/specs/mock/scenarios/target-floor.spec.ts
@@ -0,0 +1,172 @@
+import { expect, test } from '@playwright/test';
+import type { Page } from '@playwright/test';
+import { NEW_CHAT_PATH, getAccessToken, requestJson } from '../helpers';
+import { probeStyle } from './style.helpers';
+import { openSidebar } from './sidebar';
+
+/**
+ * WCAG 2.5.8's 24px target minimum reaches the Button's default and `sm` heights and the exported
+ * Dialog's close button. The default theme keeps every size it drew; a stored theme naming a
+ * smaller Button height still loads, and draws its Buttons at the floor.
+ */
+
+type Mode = 'light' | 'dark';
+type CreatedAssistant = { id: string };
+
+const ASSISTANT_NAME = 'E2E dialog close target assistant';
+
+/** Button heights under the floor, which the theme validator has always accepted. */
+const SMALL_BUTTON_THEME = {
+ version: 1,
+ name: 'e2e-small-buttons',
+ modes: {
+ light: { appearance: { buttonHeight: '0', buttonHeightSm: '1rem' } },
+ dark: { appearance: { buttonHeight: '0', buttonHeightSm: '1rem' } },
+ },
+} as const;
+
+async function openChat(page: Page, mode: Mode, definition?: { name: string }) {
+ await page.addInitScript(
+ ([colorTheme, stored]) => {
+ localStorage.setItem('color-theme', colorTheme as string);
+ localStorage.removeItem('theme-colors');
+ localStorage.removeItem('theme-name');
+ if (stored) {
+ localStorage.setItem('theme-definition', JSON.stringify(stored));
+ localStorage.setItem('theme-source', 'definition');
+ } else {
+ localStorage.removeItem('theme-definition');
+ localStorage.removeItem('theme-source');
+ }
+ },
+ [mode, definition ?? null] as [string, unknown],
+ );
+ await page.goto(NEW_CHAT_PATH, { timeout: 15000 });
+ await expect(page.getByRole('textbox', { name: 'Message input' })).toBeVisible({
+ timeout: 30000,
+ });
+ await expect(page.locator('html')).toHaveClass(mode === 'dark' ? /\bdark\b/ : /\blight\b/);
+ if (definition) {
+ await expect(page.locator('html')).toHaveAttribute('data-theme', definition.name);
+ }
+}
+
+async function buttonSizes(page: Page): Promise<Record<string, string>> {
+ return {
+ 'h-theme-button': await probeStyle(page, 'h-theme-button', 'height'),
+ 'h-theme-button-sm': await probeStyle(page, 'h-theme-button-sm', 'height'),
+ 'size-theme-button': await probeStyle(page, 'size-theme-button', 'width'),
+ };
+}
+
+test.describe('target floor', () => {
+ test('the default theme keeps the default and sm Button heights in both modes @scenario:button-height-floor-default', async ({
+ page,
+ }) => {
+ for (const mode of ['light', 'dark'] as const) {
+ const modePage = mode === 'light' ? page : await page.context().newPage();
+ await openChat(modePage, mode);
+ expect(await buttonSizes(modePage)).toEqual({
+ 'h-theme-button': '40px',
+ 'h-theme-button-sm': '36px',
+ 'size-theme-button': '40px',
+ });
+ }
+ });
+
+ test('a stored theme with Button heights under 24px loads and draws them at 24px @scenario:button-height-floor-theme', async ({
+ page,
+ }) => {
+ for (const mode of ['light', 'dark'] as const) {
+ const modePage = mode === 'light' ? page : await page.context().newPage();
+ await openChat(modePage, mode, SMALL_BUTTON_THEME);
+ expect(await buttonSizes(modePage)).toEqual({
+ 'h-theme-button': '24px',
+ 'h-theme-button-sm': '24px',
+ 'size-theme-button': '24px',
+ });
+ }
+ });
+
+ test('the exported Dialog close button is a 24px target with its glyph in place @scenario:dialog-close-target', async ({
+ page,
+ }) => {
+ test.setTimeout(90000);
+ await page.goto('/c/new', { timeout: 10000 });
+ const token = await getAccessToken(page);
+ const assistant = await requestJson<CreatedAssistant>(page, {
+ path: '/api/assistants/v2',
+ token,
+ method: 'POST',
+ body: { endpoint: 'assistants', model: 'gpt-4o-mini', name: ASSISTANT_NAME },
+ });
+
+ try {
+ for (const mode of ['light', 'dark'] as const) {
+ await page.addInitScript((selected) => {
+ localStorage.setItem('color-theme', selected);
+ localStorage.setItem('navVisible', 'true');
+ }, mode);
+ await page.goto('/c/new?endpoint=assistants&model=gpt-4o-mini', { timeout: 10000 });
+ await expect(page.locator('html')).toHaveClass(mode === 'dark' ? /\bdark\b/ : /\blight\b/);
+ await openSidebar(page);
+ const controlPanel = page.getByRole('button', { name: 'Control Panel' });
+ if (await controlPanel.isVisible()) {
+ await controlPanel.click();
+ await page.getByRole('menuitemcheckbox', { name: 'Assistant Builder' }).click();
+ } else {
+ /** The panel choice persists, so the second mode finds the builder already open and a
+ * click would close it. */
+ const builder = page.getByRole('button', { name: 'Assistant Builder' }).first();
+ if ((await builder.getAttribute('aria-pressed')) !== 'true') {
+ await builder.click();
+ }
+ }
+ const picker = page.getByTestId('select-dropdown-button').first();
+ await expect(picker.getByText(ASSISTANT_NAME, { exact: true })).toBeVisible();
+
+ /** The delete control is the builder's only neutral button holding a destructive icon. */
+ await page
+ .locator('button.btn-neutral')
+ .filter({ has: page.locator('.text-text-destructive') })
+ .click();
+ const dialog = page.getByRole('dialog', { name: 'Delete Assistant' });
+ await expect(dialog).toBeVisible();
+ /** The dialog slides in, so its frame and glyph are only comparable once it settles. */
+ await dialog.evaluate((element) =>
+ Promise.all(
+ element.getAnimations({ subtree: true }).map((animation) => animation.finished),
+ ),
+ );
+
+ const close = dialog.getByRole('button', { name: 'Close' });
+ const [box, glyph, frame] = await Promise.all([
+ close.boundingBox(),
+ close.locator('svg').boundingBox(),
+ dialog.boundingBox(),
+ ]);
+ expect(box && glyph && frame).toBeTruthy();
+ if (!box || !glyph || !frame) {
+ return;
+ }
+ expect(box.width).toBeGreaterThanOrEqual(24);
+ expect(box.height).toBeGreaterThanOrEqual(24);
+ /** The 20px glyph stays where it drew before the floor: 1.6rem down, 1.5rem in. */
+ expect(glyph.width).toBeCloseTo(20, 0);
+ expect(glyph.y - frame.y).toBeCloseTo(25.6, 0);
+ expect(frame.x + frame.width - (glyph.x + glyph.width)).toBeCloseTo(24, 0);
+
+ await close.focus();
+ await page.keyboard.press('Enter');
+ await expect(dialog).toBeHidden();
+ }
+ } finally {
+ await requestJson(page, {
+ path: `/api/assistants/v2/${encodeURIComponent(assistant.id)}?endpoint=assistants&model=gpt-4o-mini`,
+ token,
+ method: 'DELETE',
+ body: { endpoint: 'assistants' },
+ });
+ }
+ });
+});
diff --git a/packages/client/src/components/Dialog.tsx b/packages/client/src/components/Dialog.tsx
index d3c30df2ea..ab9b95a6a7 100644
--- a/packages/client/src/components/Dialog.tsx
+++ b/packages/client/src/components/Dialog.tsx
@@ -73,7 +73,7 @@ const DialogContent: React.ForwardRefExoticComponent<
>
{children}
{showCloseButton && (
- <DialogPrimitive.Close className="focus:ring-focus-control data-[state=open]:bg-surface-hover absolute top-[1.6rem] right-6 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">
+ <DialogPrimitive.Close className="focus:ring-focus-control data-[state=open]:bg-surface-hover min-h-theme-target min-w-theme-target absolute top-[1.6rem] right-6 -mt-0.5 -mr-0.5 inline-flex items-center justify-center rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">
<X className="text-text-primary size-theme-icon-md" aria-hidden="true" />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
diff --git a/packages/client/src/theme/README.md b/packages/client/src/theme/README.md
index 98d3d62766..7f9c784d21 100644
--- a/packages/client/src/theme/README.md
+++ b/packages/client/src/theme/README.md
@@ -397,8 +397,11 @@ Each status family has a foreground, a `-subtle` background, a `-border`, and a
1.5rem. The target floor (`h-theme-target`, `min-h-theme-target`, `min-w-theme-target`) is
a fixed 24px, WCAG 2.5.8's minimum, not a role, so a theme cannot lower it. The Button's
`xs`, `lg`, `compact` and `icon-sm` heights and `fieldHeightLg` reject a value under 24px;
- `controlHeight`, `buttonHeight`, `buttonHeightSm` and `fieldHeight` predate the floor and
- keep their earlier validation.
+ `buttonHeight` and `buttonHeightSm` predate the floor, so they keep their earlier validation
+ and are floored where they are drawn instead: `h-theme-button`, `h-theme-button-sm` and
+ `size-theme-button` never draw under 24px, so a stored theme naming less still loads.
+ `controlHeight` and `fieldHeight` keep their earlier validation. The exported Dialog's close
+ button takes the same 24px floor around its `iconSizeMd` glyph.
- `bg-field-fill` / `text-field-text` - A form field's fill and typed value. The
ink follows `text-primary` and the fill follows `surface-primary` when a theme
names those and not these. Fields stay clear unless the theme's
diff --git a/packages/client/src/theme/registry.spec.ts b/packages/client/src/theme/registry.spec.ts
index e60031332d..0e2179093e 100644
--- a/packages/client/src/theme/registry.spec.ts
+++ b/packages/client/src/theme/registry.spec.ts
@@ -1004,6 +1004,19 @@ describe('theme registry', () => {
});
});
+ it('writes a zero Button height as a length the 24px floor can compare', () => {
+ const { appearance } = resolveTheme(
+ {
+ version: 1,
+ name: 'zero-buttons',
+ modes: { light: { appearance: { buttonHeight: '0', buttonHeightSm: '0' } } },
+ },
+ 'light',
+ );
+
+ expect(appearance).toMatchObject({ buttonHeight: '0px', buttonHeightSm: '0px' });
+ });
+
it('keeps LibreChat’s button weight and heights by default', () => {
expect(defaultAppearance).toMatchObject({
controlFontWeight: '500',
diff --git a/packages/client/src/theme/registry.ts b/packages/client/src/theme/registry.ts
index 6cbb24d1c1..199a966de8 100644
--- a/packages/client/src/theme/registry.ts
+++ b/packages/client/src/theme/registry.ts
@@ -607,6 +607,20 @@ function withComposableShadows(appearance: IThemeAppearance): IThemeAppearance {
);
}
+/** The Button heights are drawn inside `max()` to hold the 24px target floor, where a unitless
+ * `0` is a number and would void the declaration, so it is written as the length it means. */
+const flooredAppearanceKeys: ReadonlyArray<keyof IThemeAppearance> = [
+ 'buttonHeight',
+ 'buttonHeightSm',
+];
+
+function withFloorableLengths(appearance: IThemeAppearance): IThemeAppearance {
+ return flooredAppearanceKeys.reduce<IThemeAppearance>(
+ (result, key) => (result[key].trim() === '0' ? { ...result, [key]: '0px' } : result),
+ appearance,
+ );
+}
+
/**
* Roles split out of a broader one, each paired with the role it read before. Headings drew the UI
* family before the display role existed, theme-sized controls were padded by the shared spacing,
@@ -923,7 +937,9 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedT
...seriesEightFallback,
...verifiedFallback,
} as Required<IThemeRGB>,
- appearance: withComposableShadows(withInheritedRoles(mode, definition?.appearance)),
+ appearance: withFloorableLengths(
+ withComposableShadows(withInheritedRoles(mode, definition?.appearance)),
+ ),
/** Mode last: a mode override is more specific than the theme-wide set. */
brands: {
...defaultBrands,
diff --git a/packages/client/src/theme/tailwind.spec.js b/packages/client/src/theme/tailwind.spec.js
index 1b7532222f..497ec135e4 100644
--- a/packages/client/src/theme/tailwind.spec.js
+++ b/packages/client/src/theme/tailwind.spec.js
@@ -234,6 +234,19 @@ describe('LibreChat Tailwind preset', () => {
);
expect(target).not.toContain('--theme-min-target-size');
+ /** The default and `sm` Button heights predate the target validator, so the floor is drawn
+ * rather than validated: a stored theme naming less still loads. */
+ const buttons = await generate(['h-theme-button', 'h-theme-button-sm', 'size-theme-button']);
+ expect(buttons).toContain(
+ `height: max(var(--theme-button-height, ${defaultAppearance.buttonHeight}), 24px)`,
+ );
+ expect(buttons).toContain(
+ `height: max(var(--theme-button-height-sm, ${defaultAppearance.buttonHeightSm}), 24px)`,
+ );
+ expect(buttons).toContain(
+ `width: max(var(--theme-button-height, ${defaultAppearance.buttonHeight}), 24px)`,
+ );
+
/** A stylesheet that predates the control spacing roles pads controls with the shared
* spacing they read before. */
expect(rule(css, 'px-theme-control-x')).toContain(
diff --git a/packages/client/tailwind.preset.cjs b/packages/client/tailwind.preset.cjs
index e416994d58..4afd5fecae 100644
--- a/packages/client/tailwind.preset.cjs
+++ b/packages/client/tailwind.preset.cjs
@@ -20,9 +20,10 @@ module.exports = {
height: {
'theme-control': 'var(--theme-control-height, 2.25rem)',
'theme-switch': 'var(--theme-switch-height, 1.5rem)',
- /** The Button's default and `sm` heights. */
- 'theme-button': 'var(--theme-button-height, 2.5rem)',
- 'theme-button-sm': 'var(--theme-button-height-sm, 2.25rem)',
+ /** The Button's default and `sm` heights, held at WCAG 2.5.8's 24px target minimum with
+ * `max()` so a stored theme that names less still loads and draws a reachable control. */
+ 'theme-button': 'max(var(--theme-button-height, 2.5rem), 24px)',
+ 'theme-button-sm': 'max(var(--theme-button-height-sm, 2.25rem), 24px)',
'theme-button-xs': 'var(--theme-button-height-xs, 1.75rem)',
'theme-button-lg': 'var(--theme-button-height-lg, 2.75rem)',
'theme-button-compact': 'var(--theme-button-height-compact, 2rem)',
@@ -74,8 +75,9 @@ module.exports = {
'theme-compact': 'var(--theme-space-compact, 0.375rem)',
'theme-normal': 'var(--theme-space-normal, 0.75rem)',
'theme-control': 'var(--theme-control-height, 2.25rem)',
- /** Square sizes: icon buttons as wide as their row is tall, the checkbox, and icons. */
- 'theme-button': 'var(--theme-button-height, 2.5rem)',
+ /** Square sizes: icon buttons as wide as their row is tall (never under the 24px target
+ * floor, like the height they follow), the checkbox, and icons. */
+ 'theme-button': 'max(var(--theme-button-height, 2.5rem), 24px)',
'theme-button-xs': 'var(--theme-button-height-xs, 1.75rem)',
'theme-icon-button-sm': 'var(--theme-icon-button-size-sm, 2rem)',
'theme-checkbox': 'var(--theme-checkbox-size, 1rem)',
diff --git a/packages/data-provider/src/theme.ts b/packages/data-provider/src/theme.ts
index 334130bf18..5a194fdeb2 100644
--- a/packages/data-provider/src/theme.ts
+++ b/packages/data-provider/src/theme.ts
@@ -569,7 +569,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 = 3 as const;
+export const THEME_CACHE_EPOCH = 4 as const;
/**
* Names the role set a stored resolved theme was built against: any color, brand or appearance