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
📐 feat: Menu, tooltip and tab corner theme roles (#16599)
Marco Berettaf83c502c16ca
diff --git a/client/src/style.css b/client/src/style.cssindex 005649365f..296bd6cc0f 100644--- a/client/src/style.css+++ b/client/src/style.css@@ -1973,7 +1973,7 @@ html {.tooltip {z-index: 150;cursor: pointer;- border-radius: 0.275rem;+ border-radius: var(--theme-tooltip-radius, 0.275rem);background-color: rgb(var(--surface-primary));padding-top: 0.25rem;padding-bottom: 0.25rem;@@ -2064,7 +2064,7 @@ html[data-input-modality='keyboard']flex-direction: column;overflow: auto;overscroll-behavior: contain;- border-radius: 0.7rem;+ border-radius: var(--theme-menu-radius, 0.7rem);border-width: 1px;border-style: solid;border-color: rgb(var(--border-light) / var(--border-light-alpha, 1));diff --git a/e2e/specs/mock/scenarios/corner-roles.spec.ts b/e2e/specs/mock/scenarios/corner-roles.spec.tsnew file mode 100644index 0000000000..5bc957463a--- /dev/null+++ b/e2e/specs/mock/scenarios/corner-roles.spec.ts@@ -0,0 +1,74 @@+import { expect, test } from '@playwright/test';+import type { Page } from '@playwright/test';+import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';+import { NEW_CHAT_PATH } from '../helpers';+import { probeStyle } from './style.helpers';++/**+ * The menu panel (`.popover-ui`), the tooltip (`.tooltip`) and the tab trigger (`rounded-theme-tab`)+ * take their corners from the `menuRadius`, `tooltipRadius` and `tabRadius` roles. Their defaults+ * are the literals they drew before, so the default theme is unchanged in both modes, and the+ * ClickHouse theme rounds all three at Click UI's 0.25rem.+ */++type Mode = 'light' | 'dark';++const PROBES = ['popover-ui', 'tooltip', 'rounded-theme-tab'] 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 corners(page: Page): Promise<string[]> {+ const values: string[] = [];+ for (const classes of PROBES) {+ values.push(await probeStyle(page, classes, 'border-top-left-radius'));+ }+ return values;+}++test.describe('menu, tooltip and tab corners', () => {+ test('the default theme keeps its menu, tooltip and tab corners in both modes @scenario:corner-roles-default-unchanged', 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 corners(modePage)).toEqual(['11.2px', '4.4px', '2.96px']);+ }+ });++ test('the ClickHouse theme rounds menus, tooltips and tabs at Click UI corners in both modes @scenario:corner-roles-clickhouse', async ({+ page,+ }) => {+ for (const mode of ['light', 'dark'] as const) {+ const modePage = mode === 'light' ? page : await page.context().newPage();+ await openChat(modePage, mode, clickHouseTheme);++ expect(await corners(modePage)).toEqual(['4px', '4px', '4px']);+ }+ });+});diff --git a/packages/client/src/components/Dropdown.css b/packages/client/src/components/Dropdown.cssindex 4bee1fd751..3d140f89ec 100644--- a/packages/client/src/components/Dropdown.css+++ b/packages/client/src/components/Dropdown.css@@ -4,7 +4,7 @@flex-direction: column;overflow: auto;overscroll-behavior: contain;- border-radius: 0.7rem;+ border-radius: var(--theme-menu-radius, 0.7rem);border-width: 1px;border-style: solid;border-color: rgb(var(--border-light) / var(--border-light-alpha, 1));diff --git a/packages/client/src/components/Tabs.tsx b/packages/client/src/components/Tabs.tsxindex cf6a59e21b..651308702b 100644--- a/packages/client/src/components/Tabs.tsx+++ b/packages/client/src/components/Tabs.tsx@@ -33,7 +33,7 @@ const TabsTrigger: React.ForwardRefExoticComponent<>(({ className = '', ...props }, ref) => (<TabsPrimitive.TriggerclassName={cn(- 'text-text-secondary data-[state=active]:bg-surface-primary data-[state=active]:text-text-primary inline-flex min-w-[100px] items-center justify-center rounded-[0.185rem] px-3 py-1.5 text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50',+ 'text-text-secondary data-[state=active]:bg-surface-primary data-[state=active]:text-text-primary rounded-theme-tab inline-flex min-w-[100px] items-center justify-center px-3 py-1.5 text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50',disabledInkClasses,className,)}diff --git a/packages/client/src/components/Tooltip.css b/packages/client/src/components/Tooltip.cssindex adf350ff7a..89a71d95cc 100644--- a/packages/client/src/components/Tooltip.css+++ b/packages/client/src/components/Tooltip.css@@ -2,7 +2,7 @@z-index: 150;cursor: pointer;pointer-events: auto;- border-radius: 0.275rem;+ border-radius: var(--theme-tooltip-radius, 0.275rem);background-color: rgb(var(--surface-primary));padding-top: 0.25rem;padding-bottom: 0.25rem;diff --git a/packages/client/src/theme/README.md b/packages/client/src/theme/README.mdindex 702c0a11db..83d5bbb5b0 100644--- a/packages/client/src/theme/README.md+++ b/packages/client/src/theme/README.md@@ -59,6 +59,10 @@ them.> `calc(0.5rem - 4px)` and `--radius` no longer retunes them. Set the `radiusSm` through> `radius3xl` appearance roles, or the properties behind them, to reshape the scale.+Three primitives keep corners of their own outside that scale: the menu panel (`.popover-ui`) reads+`menuRadius` (0.7rem), the tooltip reads `tooltipRadius` (0.275rem) and the tab trigger reads+`tabRadius` (0.185rem, through `rounded-theme-tab`). The defaults are the corners they always drew.+The bundled ClickHouse theme (`themes/clickhouse.ts`) is the reference for a theme that changesshape as well as color: it tightens the radius scale to Click UI's `border.radii` steps, sets themono family to Inconsolata over a real fallback stack, and raises every surface with Click UI'sdiff --git a/packages/client/src/theme/defaults.css b/packages/client/src/theme/defaults.cssindex 5a7d806cd3..ccdc465903 100644--- a/packages/client/src/theme/defaults.css+++ b/packages/client/src/theme/defaults.css@@ -198,6 +198,9 @@ html {--theme-round-control-radius: 9999px;--theme-surface-radius: 1rem;--theme-large-surface-radius: 1.5rem;+ --theme-menu-radius: 0.7rem;+ --theme-tooltip-radius: 0.275rem;+ --theme-tab-radius: 0.185rem;--theme-radius-sm: calc(0.5rem - 4px);--theme-radius-md: calc(0.5rem - 2px);--theme-radius-lg: 0.5rem;diff --git a/packages/client/src/theme/registry.spec.ts b/packages/client/src/theme/registry.spec.tsindex d552d54aa7..89bcad928f 100644--- a/packages/client/src/theme/registry.spec.ts+++ b/packages/client/src/theme/registry.spec.ts@@ -948,6 +948,27 @@ describe('theme registry', () => {].forEach((appearance) => expect(issues(appearance)).toHaveLength(1));});+ it('keeps the menu, tooltip and tab corners on their old literals unless a theme names its own', () => {+ expect(defaultAppearance).toMatchObject({+ menuRadius: '0.7rem',+ tooltipRadius: '0.275rem',+ tabRadius: '0.185rem',+ });+ const corners = { menuRadius: '4px', tooltipRadius: '0.25rem', tabRadius: '0' };+ const { appearance } = resolveTheme(+ { version: 1, name: 'corner-reference', modes: { light: { appearance: corners } } },+ 'light',+ );+ expect(appearance).toMatchObject(corners);+ expect(+ validateThemeDefinition({+ version: 1,+ name: 'corner-values',+ modes: { light: { appearance: { menuRadius: 'round' } } },+ }),+ ).toHaveLength(1);+ });+it('keeps a 2px focus outline 2px off the edge unless a theme names its own', () => {expect(defaultAppearance).toMatchObject({ focusRingWidth: '2px', focusRingOffset: '2px' });const { appearance } = resolveTheme(diff --git a/packages/client/src/theme/registry.ts b/packages/client/src/theme/registry.tsindex d8282b6f8a..367c28672b 100644--- a/packages/client/src/theme/registry.ts+++ b/packages/client/src/theme/registry.ts@@ -162,6 +162,9 @@ export const themeAppearanceProperties: Readonly<roundControlRadius: '--theme-round-control-radius',surfaceRadius: '--theme-surface-radius',largeSurfaceRadius: '--theme-large-surface-radius',+ menuRadius: '--theme-menu-radius',+ tooltipRadius: '--theme-tooltip-radius',+ tabRadius: '--theme-tab-radius',radiusSm: '--theme-radius-sm',radiusMd: '--theme-radius-md',radiusLg: '--theme-radius-lg',@@ -231,6 +234,9 @@ export const defaultAppearance: IThemeAppearance = Object.freeze({roundControlRadius: '9999px',surfaceRadius: '1rem',largeSurfaceRadius: '1.5rem',+ menuRadius: '0.7rem',+ tooltipRadius: '0.275rem',+ tabRadius: '0.185rem',radiusSm: 'calc(0.5rem - 4px)',radiusMd: 'calc(0.5rem - 2px)',radiusLg: '0.5rem',diff --git a/packages/client/src/theme/tailwind.spec.js b/packages/client/src/theme/tailwind.spec.jsindex 1aee39c4bf..6bafd0caa1 100644--- a/packages/client/src/theme/tailwind.spec.js+++ b/packages/client/src/theme/tailwind.spec.js@@ -157,6 +157,7 @@ describe('LibreChat Tailwind preset', () => {'--theme-large-surface-radius',defaultAppearance.largeSurfaceRadius,],+ ['rounded-theme-tab', '--theme-tab-radius', defaultAppearance.tabRadius],['shadow-theme-surface', '--theme-elevation-surface', defaultAppearance.elevationSurface],['duration-theme-fast', '--theme-motion-fast', defaultAppearance.motionFast],['duration-theme-normal', '--theme-motion-normal', defaultAppearance.motionNormal],diff --git a/packages/client/src/theme/themes/clickhouse.ts b/packages/client/src/theme/themes/clickhouse.tsindex 9dedaa143a..010fafe50e 100644--- a/packages/client/src/theme/themes/clickhouse.ts+++ b/packages/client/src/theme/themes/clickhouse.ts@@ -347,6 +347,9 @@ const clickHouseShape = {surfaceRadius: '0.5rem',largeSurfaceRadius: '0.75rem',roundControlRadius: '9999px',+ menuRadius: '0.25rem', // genericMenu.panel.radii.all+ tooltipRadius: '0.25rem', // tooltip.radii.all+ tabRadius: '0.25rem', // tabs.radii.allradiusSm: '0.25rem', // border.radii.1radiusMd: '0.25rem', // border.radii.1radiusLg: '0.25rem', // border.radii.1diff --git a/packages/client/src/theme/themes/clickui.json b/packages/client/src/theme/themes/clickui.jsonindex 67af0ef3a7..d992e31d8e 100644--- a/packages/client/src/theme/themes/clickui.json+++ b/packages/client/src/theme/themes/clickui.json@@ -44,6 +44,7 @@"click.field.color.text.default": "#302e32","click.field.space.y": "0.2813rem","click.field.typography.label.default": "500 0.75rem/1.5 \"Inter\", \"SF Pro Display\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif;",+ "click.genericMenu.panel.radii.all": "0.25rem","click.genericMenu.panel.shadow.default": "0 4px 6px -1px lch(6.7738 0 none / 0.15), 0 2px 4px -1px lch(6.7738 0 none / 0.15)","click.genericMenu.panel.size.height": "2rem","click.global.color.text.danger": "#c10000",@@ -172,6 +173,7 @@"click.field.color.text.default": "#e6e7e9","click.field.space.y": "0.2813rem","click.field.typography.label.default": "500 0.75rem/1.5 \"Inter\", \"SF Pro Display\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif;",+ "click.genericMenu.panel.radii.all": "0.25rem","click.genericMenu.panel.shadow.default": "0 4px 6px -1px rgb(8.2353% 8.2353% 8.2353% / 0.6), 0 2px 4px -1px rgb(8.2353% 8.2353% 8.2353% / 0.6)","click.genericMenu.panel.size.height": "2rem","click.global.color.text.danger": "#ffbaba",diff --git a/packages/client/src/theme/themes/clickui.spec.ts b/packages/client/src/theme/themes/clickui.spec.tsindex 68ab8ddd1a..fd02d3bbc4 100644--- a/packages/client/src/theme/themes/clickui.spec.ts+++ b/packages/client/src/theme/themes/clickui.spec.ts@@ -487,6 +487,9 @@ const appearanceSources: Partial<Record<keyof IThemeAppearance, string>> = {largeSurfaceRadius: 'border.radii.3',radius3xl: 'border.radii.3',roundControlRadius: 'border.radii.full',+ menuRadius: 'click.genericMenu.panel.radii.all',+ tooltipRadius: 'click.tooltip.radii.all',+ tabRadius: 'click.tabs.radii.all',fontFamily: 'typography.font.families.regular',monoFontFamily: 'typography.font.families.mono',displayFontFamily: 'typography.font.families.display',@@ -837,10 +840,6 @@ const cssValue = (path: string, selector: string, property: string) => {return value.replace(/\s+/g, ' ').trim();};-/** The value of `property` in the first `selector` rule of a primitive's stylesheet. */-const stylesheetValue = (file: string, selector: string, property: string) => () =>- cssValue(`components/${file}`, selector, property);-/** The app stylesheet, which repaints some primitive rules after the package's own. */const APP_STYLESHEET = '../../../client/src/style.css';@@ -859,12 +858,27 @@ function resolveRoleVar(value: string, mode: ThemeMode): string {return resolveTheme(clickHouseTheme, mode).appearance[role];}+/**+ * A primitive rule's value with the theme role it reads resolved, after checking that the app+ * stylesheet, which loads after the package's and repeats the rule, still draws the same value.+ */+function appCopyResolved(file: string, selector: string, property: string, mode: ThemeMode) {+ const own = cssValue(`components/${file}`, selector, property);+ const app = cssValue(APP_STYLESHEET, selector, property);+ if (app !== own) {+ throw new Error(+ `The app's ${selector} ${property} (${app}) no longer repeats ${file} (${own})`,+ );+ }+ return resolveRoleVar(own, mode);+}+/*** The open Dropdown menu's corner. jsdom loads no stylesheet, so the rendered popover is checked* to take its corner from `.popover-ui` alone (no radius utility or inline radius overrides it)* before the rule's value is read.*/-const popoverCorner = () => {+const popoverCorner = (mode: ThemeMode) => {try {fireEvent.click(dropdownProbe());const popover = document.querySelector<HTMLElement>('[role="listbox"]');@@ -875,7 +889,7 @@ const popoverCorner = () => {if (override !== undefined || popover.style.borderRadius !== '') {throw new Error(`The open Dropdown menu sets its own corner (${override ?? 'inline'})`);}- return stylesheetValue('Dropdown.css', '.popover-ui', 'border-radius')();+ return appCopyResolved('Dropdown.css', '.popover-ui', 'border-radius', mode);} finally {cleanup();}@@ -908,26 +922,16 @@ const tooltipShadow = (mode: ThemeMode) =>'box-shadow',);-/** The Tabs trigger's corner, an arbitrary `rounded-[...]` value on the rendered trigger. */-const tabsCorner = () => {- try {- const trigger = mount(- createElement(- Tabs,- { defaultValue: 'a' },- createElement(TabsList, null, createElement(TabsTrigger, { value: 'a' }, 'A')),- ),- '[role="tab"]',- );- const corner = /(?:^|\s)rounded-\[([^\]]+)\]/.exec(trigger.getAttribute('class') ?? '')?.[1];- if (corner === undefined) {- throw new Error('The Tabs trigger no longer draws a literal corner; probe its role instead');- }- return corner;- } finally {- cleanup();- }-};+/** The Tabs trigger, which takes its corner from a radius utility. */+const tabsProbe = () =>+ mount(+ createElement(+ Tabs,+ { defaultValue: 'a' },+ createElement(TabsList, null, createElement(TabsTrigger, { value: 'a' }, 'A')),+ ),+ '[role="tab"]',+ );const bothModes = (reason: string): Partial<Record<ThemeMode, string>> => ({light: reason,@@ -1028,7 +1032,7 @@ const parityProbes: Record<string, ParityProbe> = {element: dropdownProbe,},'Dropdown menu corner': {- token: 'border.radii.1',+ token: 'click.genericMenu.panel.radii.all',kind: 'shape',utility: 'rounded',literal: popoverCorner,@@ -1043,7 +1047,7 @@ const parityProbes: Record<string, ParityProbe> = {token: 'click.tooltip.radii.all',kind: 'shape',utility: 'rounded',- literal: stylesheetValue('Tooltip.css', '.tooltip', 'border-radius'),+ literal: (mode) => appCopyResolved('Tooltip.css', '.tooltip', 'border-radius', mode),},'Tooltip shadow': {untokened: { value: 'none', source: 'Tooltip.module.css .content sets no box-shadow' },@@ -1055,7 +1059,7 @@ const parityProbes: Record<string, ParityProbe> = {token: 'click.tabs.radii.all',kind: 'shape',utility: 'rounded',- literal: tabsCorner,+ element: tabsProbe,},'Dialog surface': {token: 'click.dialog.color.background.default',@@ -1240,32 +1244,17 @@ const notExpressible: Record<string, NotExpressible> = {issue: 'https://github.com/berry-13/LibreChat/issues/206',},- 'Dropdown menu corner': {- decisions: { light: ['Dropdown menu corner'], dark: ['Dropdown menu corner'] },- reason:- 'the popover corner is a 0.7rem literal in Dropdown.css, and no radius role defaults to 0.7rem',- issue: 'https://github.com/berry-13/LibreChat/issues/196',- },'Dropdown menu shadow': {decisions: { dark: ['Dropdown menu shadow'] },reason:"light reads shadowLg, but the app's dark .popover-ui rule repaints the shadow with a 0.25-alpha literal that no shadow role defaults to",issue: 'https://github.com/berry-13/LibreChat/issues/217',},- 'Tooltip corner and shadow': {- decisions: {- light: ['Tooltip corner', 'Tooltip shadow'],- dark: ['Tooltip corner', 'Tooltip shadow'],- },- reason:- 'Tooltip.css draws a 0.275rem corner and a black drop shadow as literals; no radius role defaults to 0.275rem and no shadow role to either shadow, where Click UI draws 0.25rem and no shadow',- issue: 'https://github.com/berry-13/LibreChat/issues/215',- },- 'Tabs corner': {- decisions: { light: ['Tabs corner'], dark: ['Tabs corner'] },+ 'Tooltip shadow': {+ decisions: { light: ['Tooltip shadow'], dark: ['Tooltip shadow'] },reason:- 'the Tabs trigger corner is a rounded-[0.185rem] literal, and no radius role defaults to 0.185rem',- issue: 'https://github.com/berry-13/LibreChat/issues/216',+ 'Tooltip.css draws a black drop shadow, a different one in each mode, and no shadow role defaults to either, where Click UI draws none',+ issue: 'https://github.com/berry-13/LibreChat/issues/220',},};@@ -1296,6 +1285,7 @@ const radiusRoles: Record<string, keyof IThemeAppearance> = {'theme-control-round': 'roundControlRadius','theme-surface': 'surfaceRadius','theme-surface-lg': 'largeSurfaceRadius',+ 'theme-tab': 'tabRadius',};const fixedRadii: Record<string, string> = { full: '9999px', none: '0px' };diff --git a/packages/client/src/theme/types/index.ts b/packages/client/src/theme/types/index.tsindex 865b66d67f..ead46a0ee4 100644--- a/packages/client/src/theme/types/index.ts+++ b/packages/client/src/theme/types/index.ts@@ -449,6 +449,11 @@ export interface IThemeAppearance {roundControlRadius: string;surfaceRadius: string;largeSurfaceRadius: string;+ /** The corners of a menu panel (`.popover-ui`), a tooltip and a tab trigger, apart from the+ * control and surface radii; their defaults are the literals those primitives drew. */+ menuRadius: string;+ tooltipRadius: string;+ tabRadius: string;radiusSm: string;radiusMd: string;radiusLg: string;diff --git a/packages/client/tailwind.preset.cjs b/packages/client/tailwind.preset.cjsindex 5c57621483..1215c48a21 100644--- a/packages/client/tailwind.preset.cjs+++ b/packages/client/tailwind.preset.cjs@@ -102,6 +102,7 @@ module.exports = {'theme-control-round': 'var(--theme-round-control-radius, 9999px)','theme-surface': 'var(--theme-surface-radius, 1rem)','theme-surface-lg': 'var(--theme-large-surface-radius, 1.5rem)',+ 'theme-tab': 'var(--theme-tab-radius, 0.185rem)',},boxShadow: {'theme-surface':diff --git a/packages/data-provider/src/theme.ts b/packages/data-provider/src/theme.tsindex 329dfb0a5d..c8489e7306 100644--- a/packages/data-provider/src/theme.ts+++ b/packages/data-provider/src/theme.ts@@ -322,6 +322,10 @@ const appearanceValidators = {roundControlRadius: isLength,surfaceRadius: isLength,largeSurfaceRadius: isLength,+ /** A menu panel's, a tooltip's and a tab trigger's corner. */+ menuRadius: isLength,+ tooltipRadius: isLength,+ tabRadius: isLength,radiusSm: isLength,radiusMd: isLength,radiusLg: isLength,