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

📏 feat: Size Roles for the Select List (#16714)

Marco Berettaf156160c99f8
diff --git a/e2e/specs/mock/scenarios/nested-popovers.spec.ts b/e2e/specs/mock/scenarios/nested-popovers.spec.ts
index 2b4e0db761..88c35eecf8 100644
--- a/e2e/specs/mock/scenarios/nested-popovers.spec.ts
+++ b/e2e/specs/mock/scenarios/nested-popovers.spec.ts
@@ -1,5 +1,6 @@
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 { openSidebar } from './sidebar';
@@ -138,3 +139,50 @@ test.describe('popovers inside a modal dialog', () => {
await expectIndicator(page, '20px');
});
});
+
+/** Sets both list roles apart from their defaults, so a list still drawing a fixed size shows. */
+const REFERENCE_LIST_THEME = {
+ version: 1,
+ name: 'e2e-list-reference',
+ modes: {
+ light: { appearance: { listMinWidth: '12rem', listMaxHeight: '20rem' } },
+ dark: { appearance: { listMinWidth: '12rem', listMaxHeight: '20rem' } },
+ },
+} as const;
+
+/** The open list's width floor and scroll cap, as the browser computed them. */
+async function listBounds(page: Page) {
+ return page.getByRole('listbox').evaluate((element) => {
+ const style = getComputedStyle(element);
+ return { minWidth: style.minWidth, maxHeight: style.maxHeight };
+ });
+}
+
+test.describe('Select list size roles', () => {
+ test('the default theme keeps the list at 8rem wide and 24rem tall at most @scenario:select-list-size-default', async ({
+ page,
+ }) => {
+ await offerStatefulSessions(page);
+ await useTheme(page);
+ await openWorkspaceSelect(page);
+ expect(await listBounds(page)).toEqual({ minWidth: '128px', maxHeight: '384px' });
+ });
+
+ test('the ClickHouse theme sizes the list by its trigger @scenario:select-list-size-clickhouse', async ({
+ page,
+ }) => {
+ await offerStatefulSessions(page);
+ await useTheme(page, clickHouseTheme);
+ await openWorkspaceSelect(page);
+ expect(await listBounds(page)).toEqual({ minWidth: '0px', maxHeight: '384px' });
+ });
+
+ test('a theme that sets both list roles resizes the list @scenario:select-list-size-reference', async ({
+ page,
+ }) => {
+ await offerStatefulSessions(page);
+ await useTheme(page, REFERENCE_LIST_THEME);
+ await openWorkspaceSelect(page);
+ expect(await listBounds(page)).toEqual({ minWidth: '192px', maxHeight: '320px' });
+ });
+});
diff --git a/e2e/specs/mock/scenarios/primitive-sizes.spec.ts b/e2e/specs/mock/scenarios/primitive-sizes.spec.ts
index f7b8819412..0527df301b 100644
--- a/e2e/specs/mock/scenarios/primitive-sizes.spec.ts
+++ b/e2e/specs/mock/scenarios/primitive-sizes.spec.ts
@@ -53,6 +53,8 @@ async function sizes(page: Page): Promise<Record<string, string>> {
['h-theme-target', 'height'],
['min-w-theme-target', 'min-width'],
['min-w-theme-tab', 'min-width'],
+ ['min-w-theme-list', 'min-width'],
+ ['max-h-theme-list', 'max-height'],
['select-item', 'border-top-left-radius'],
];
const result: Record<string, string> = {};
@@ -87,6 +89,8 @@ const DEFAULT_SIZES = {
'h-theme-target': '24px',
'min-w-theme-target': '24px',
'min-w-theme-tab': '100px',
+ 'min-w-theme-list': '128px',
+ 'max-h-theme-list': '384px',
'select-item': '8px',
};
@@ -121,6 +125,7 @@ test.describe('primitive size roles', () => {
'size-theme-icon-button-sm': '24px',
'select-item': '4px',
'min-w-theme-tab': '0px',
+ 'min-w-theme-list': '0px',
'h-theme-field': '32px',
});
}
diff --git a/packages/client/src/components/Select.spec.tsx b/packages/client/src/components/Select.spec.tsx
index 734b546041..230360d313 100644
--- a/packages/client/src/components/Select.spec.tsx
+++ b/packages/client/src/components/Select.spec.tsx
@@ -1,6 +1,6 @@
import '@testing-library/jest-dom';
import { render, screen } from '@testing-library/react';
-import { Select, SelectTrigger, SelectValue } from './Select';
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './Select';
describe('SelectTrigger', () => {
/** The trigger hid the outline on every focus and drew nothing in its place, so a keyboard
@@ -23,3 +23,21 @@ describe('SelectTrigger', () => {
expect(trigger).not.toHaveClass('focus:outline-hidden');
});
});
+
+describe('SelectContent', () => {
+ /** The list's width floor and scroll cap are theme roles, so a theme can retune both. */
+ it('bounds the list with the list size roles', () => {
+ render(
+ <Select open value="one">
+ <SelectTrigger aria-label="Model">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="one">One</SelectItem>
+ </SelectContent>
+ </Select>,
+ );
+
+ expect(screen.getByRole('listbox')).toHaveClass('min-w-theme-list', 'max-h-theme-list');
+ });
+});
diff --git a/packages/client/src/components/Select.tsx b/packages/client/src/components/Select.tsx
index 4f120a5cfc..edb656ffee 100644
--- a/packages/client/src/components/Select.tsx
+++ b/packages/client/src/components/Select.tsx
@@ -93,7 +93,7 @@ const SelectContent: React.ForwardRefExoticComponent<
(see `useNestedPopoverStyle`); elsewhere `z-40` applies. */
style={{ zIndex: nested ? zIndex : undefined, ...style }}
className={cn(
- 'border-border-light bg-surface-secondary text-text-primary data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-40 max-h-96 min-w-[8rem] overflow-hidden rounded-md border shadow-md',
+ 'border-border-light bg-surface-secondary text-text-primary data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 max-h-theme-list min-w-theme-list relative z-40 overflow-hidden rounded-md border shadow-md',
position === 'popper'
? 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1'
: '',
diff --git a/packages/client/src/theme/README.md b/packages/client/src/theme/README.md
index 64643c51af..3b75b84f7f 100644
--- a/packages/client/src/theme/README.md
+++ b/packages/client/src/theme/README.md
@@ -367,7 +367,8 @@ Each status family has a foreground, a `-subtle` background, a `-border`, and a
`size-theme-icon-lg` (`iconSize`, `iconSizeLg`) the icons in menus and selects and
the dialog's close icon, `h-theme-field-lg` (`fieldHeightLg`) the large `title`
input, and `h-theme-target` the switch's hit area, and `min-w-theme-tab` (`tabMinWidth`, `0` to size a tab by its label) the tab
- trigger. Every default is the size the primitive drew before. The icon and checkbox roles
+ trigger. `min-w-theme-list` and `max-h-theme-list` (`listMinWidth`, `0` to size the list by
+ its trigger, and `listMaxHeight`, 8 to 40rem) bound the Select's list. Every default is the size the primitive drew before. The icon and checkbox roles
are bounded to the room their layouts leave: `iconSize` 0.75 to 1.25rem, `iconSizeMd` (the
exported Dialog's close glyph) 1.25 to 1.5rem, `iconSizeLg` 1 to 2rem, `checkboxSize` 1 to
1.5rem. The target floor (`h-theme-target`, `min-h-theme-target`, `min-w-theme-target`) is
diff --git a/packages/client/src/theme/defaults.css b/packages/client/src/theme/defaults.css
index 4ea0ead542..a6482e4083 100644
--- a/packages/client/src/theme/defaults.css
+++ b/packages/client/src/theme/defaults.css
@@ -221,6 +221,8 @@ html {
--theme-tooltip-radius: 0.275rem;
--theme-tab-radius: 0.185rem;
--theme-tab-min-width: 100px;
+ --theme-list-min-width: 8rem;
+ --theme-list-max-height: 24rem;
--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/primitives.spec.ts b/packages/client/src/theme/primitives.spec.ts
index d55f753c7b..bd7b89d14d 100644
--- a/packages/client/src/theme/primitives.spec.ts
+++ b/packages/client/src/theme/primitives.spec.ts
@@ -7,9 +7,8 @@ import { readFileSync } from 'fs';
* raw palette utilities, hex/rgb/hsl literals, arbitrary corners and shadows, fixed size
* utilities (`h-4`, `size-10`, `min-w-[8rem]`; a fraction such as `w-11/12`, a viewport unit or a
* value read from the component library is relative, and a `0` is a reset, not a size), literal
- * corners and shadows in its stylesheet, and design-rule suppressions. Move a primitive into
- * `themeDriven` when a change clears it; the remaining values of the others are pinned so a new
- * literal fails by name.
+ * corners and shadows in its stylesheet, and design-rule suppressions. All ten are theme-driven,
+ * so a new literal in any of them fails by name.
*/
const components = join(__dirname, '../components');
@@ -28,24 +27,6 @@ const primitives: Record<string, string[]> = {
Tooltip: ['Tooltip.tsx', 'Tooltip.css'],
};
-const themeDriven = [
- 'Button',
- 'Input',
- 'Dialog',
- 'Menu',
- 'Tabs',
- 'Switch',
- 'Checkbox',
- 'Table',
- 'Tooltip',
-];
-
-/** What the other still hard-codes, and why it stays. */
-const remaining: Record<string, string[]> = {
- /** The list's scroll cap and its minimum width have no role. */
- Select: ['Select.tsx: arbitrary size min-w-[8rem]', 'Select.tsx: fixed size h-96'],
-};
-
const suppressions: Record<string, Record<string, { count: number }>> = JSON.parse(
readFileSync(join(repoRoot, 'eslint-suppressions.json'), 'utf8'),
);
@@ -158,11 +139,8 @@ const values = Object.fromEntries(
);
describe('the ten named primitives', () => {
- it('draws at least eight of them from theme roles alone', () => {
- const driven = Object.keys(primitives).filter((name) => values[name].length === 0);
-
- expect(driven).toEqual(themeDriven);
- expect(driven.length).toBeGreaterThanOrEqual(8);
+ it.each(Object.keys(primitives))('draws %s from theme roles alone', (name) => {
+ expect(values[name]).toEqual([]);
});
it('reads any raw palette hue under any color utility', () => {
@@ -184,8 +162,4 @@ describe('the ten named primitives', () => {
'.a { box-shadow: var(--local-shadow, 0 1px #000); }',
);
});
-
- it.each(Object.keys(remaining))('pins what %s still hard-codes', (name) => {
- expect(values[name]).toEqual(remaining[name]);
- });
});
diff --git a/packages/client/src/theme/registry.spec.ts b/packages/client/src/theme/registry.spec.ts
index dde227fb90..65c15cefea 100644
--- a/packages/client/src/theme/registry.spec.ts
+++ b/packages/client/src/theme/registry.spec.ts
@@ -1141,9 +1141,31 @@ describe('theme registry', () => {
iconButtonSizeSm: '2rem',
fieldHeightLg: '3rem',
checkboxSize: '1rem',
+ listMinWidth: '8rem',
+ listMaxHeight: '24rem',
});
});
+ it("bounds a Select list's width and scroll height", () => {
+ const issues = (appearance: Record<string, string>) =>
+ validateThemeDefinition({
+ version: 1,
+ name: 'list-values',
+ modes: { light: { appearance } },
+ });
+
+ expect(issues({ listMinWidth: '0', listMaxHeight: '8rem' })).toEqual([]);
+ expect(issues({ listMinWidth: '12rem', listMaxHeight: '640px' })).toEqual([]);
+ [
+ { listMinWidth: 'auto' },
+ { listMinWidth: '-1rem' },
+ { listMaxHeight: '0' },
+ { listMaxHeight: '7rem' },
+ { listMaxHeight: '41rem' },
+ { listMaxHeight: '50vh' },
+ ].forEach((appearance) => expect(issues(appearance)).toHaveLength(1));
+ });
+
it('rejects a pointer target under 24px and a size that is not a positive length', () => {
const issues = (appearance: Record<string, string>) =>
validateThemeDefinition({
diff --git a/packages/client/src/theme/registry.ts b/packages/client/src/theme/registry.ts
index 7b4a624ad2..c19704d9b3 100644
--- a/packages/client/src/theme/registry.ts
+++ b/packages/client/src/theme/registry.ts
@@ -167,6 +167,8 @@ export const themeAppearanceProperties: Readonly<
tooltipRadius: '--theme-tooltip-radius',
tabRadius: '--theme-tab-radius',
tabMinWidth: '--theme-tab-min-width',
+ listMinWidth: '--theme-list-min-width',
+ listMaxHeight: '--theme-list-max-height',
radiusSm: '--theme-radius-sm',
radiusMd: '--theme-radius-md',
radiusLg: '--theme-radius-lg',
@@ -253,6 +255,8 @@ export const defaultAppearance: IThemeAppearance = Object.freeze({
tooltipRadius: '0.275rem',
tabRadius: '0.185rem',
tabMinWidth: '100px',
+ listMinWidth: '8rem',
+ listMaxHeight: '24rem',
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.js
index 696348e9a9..c046e57cd4 100644
--- a/packages/client/src/theme/tailwind.spec.js
+++ b/packages/client/src/theme/tailwind.spec.js
@@ -159,6 +159,8 @@ describe('LibreChat Tailwind preset', () => {
],
['rounded-theme-tab', '--theme-tab-radius', defaultAppearance.tabRadius],
['min-w-theme-tab', '--theme-tab-min-width', defaultAppearance.tabMinWidth],
+ ['min-w-theme-list', '--theme-list-min-width', defaultAppearance.listMinWidth],
+ ['max-h-theme-list', '--theme-list-max-height', defaultAppearance.listMaxHeight],
['h-theme-button-xs', '--theme-button-height-xs', defaultAppearance.buttonHeightXs],
['h-theme-button-lg', '--theme-button-height-lg', defaultAppearance.buttonHeightLg],
[
diff --git a/packages/client/src/theme/themes/clickhouse.ts b/packages/client/src/theme/themes/clickhouse.ts
index f7aeda3e60..8b6d3669dc 100644
--- a/packages/client/src/theme/themes/clickhouse.ts
+++ b/packages/client/src/theme/themes/clickhouse.ts
@@ -386,6 +386,12 @@ const clickHouseShape = {
tabRadius: '0.25rem', // tabs.radii.all
/** Click UI sizes a tab trigger by its label, in `tabs.space.x` on each side. */
tabMinWidth: '0',
+ /** Click UI's select list is as wide as its trigger (`select-popover-content` in
+ * SelectComponents.module.css), which the list's viewport already enforces, so it takes no
+ * floor of its own. Its height is capped only by the viewport's available height, which a
+ * length role cannot express, so the cap keeps LibreChat's. */
+ listMinWidth: '0',
+ listMaxHeight: '24rem',
radiusSm: '0.25rem', // border.radii.1
radiusMd: '0.25rem', // border.radii.1
radiusLg: '0.25rem', // border.radii.1
diff --git a/packages/client/src/theme/themes/clickui.spec.ts b/packages/client/src/theme/themes/clickui.spec.ts
index b1dc8db5d1..0e9f62dfed 100644
--- a/packages/client/src/theme/themes/clickui.spec.ts
+++ b/packages/client/src/theme/themes/clickui.spec.ts
@@ -529,6 +529,18 @@ const appearanceDecisions: Partial<Record<keyof IThemeAppearance, AppearanceDeci
status: 'match',
reason: '0: Click UI sizes tab triggers by their label in tabs.space.x, with no minimum width',
},
+ listMinWidth: {
+ value: '0',
+ status: 'match',
+ reason:
+ '0: Click UI draws its select list at var(--radix-popover-trigger-width) (select-popover-content), with no minimum of its own',
+ },
+ listMaxHeight: {
+ value: '24rem',
+ status: 'mismatch',
+ reason:
+ "24rem: Click UI caps its select list only at var(--radix-popover-content-available-height), which a length role cannot express, so the cap keeps LibreChat's",
+ },
iconButtonSizeSm: {
value: '1.5rem',
status: 'match',
@@ -1859,6 +1871,7 @@ describe('ClickHouse primitive parity against Click UI components', () => {
expect(moved).toEqual([]);
expect(statuses.filter(([, status]) => status === 'mismatch').map(([key]) => key)).toEqual([
+ 'listMaxHeight',
'text2xl',
]);
expect(statuses.filter(([, status]) => status === 'near').map(([key]) => key)).toEqual([]);
diff --git a/packages/client/src/theme/types/index.ts b/packages/client/src/theme/types/index.ts
index 238e5a2818..c114097b76 100644
--- a/packages/client/src/theme/types/index.ts
+++ b/packages/client/src/theme/types/index.ts
@@ -520,6 +520,10 @@ export interface IThemeAppearance {
tabRadius: string;
/** The narrowest a tab trigger draws; `0` sizes it by its label. */
tabMinWidth: string;
+ /** The narrowest a Select's list draws; `0` sizes it by its trigger and options. */
+ listMinWidth: string;
+ /** The tallest a Select's list draws before it scrolls, 8 to 40rem. */
+ listMaxHeight: string;
radiusSm: string;
radiusMd: string;
radiusLg: string;
diff --git a/packages/client/src/utils/utils.spec.ts b/packages/client/src/utils/utils.spec.ts
index 2fa4810419..72d9da0b65 100644
--- a/packages/client/src/utils/utils.spec.ts
+++ b/packages/client/src/utils/utils.spec.ts
@@ -10,6 +10,8 @@ describe('cn', () => {
['h-theme-control', 'size-theme-control'],
['min-w-theme-target', 'min-w-0'],
['min-h-theme-target', 'min-h-0'],
+ ['min-w-theme-list', 'min-w-48'],
+ ['max-h-theme-list', 'max-h-60'],
])('lets a caller size replace %s', (role, caller) => {
expect(cn(role, caller)).toBe(caller);
});
diff --git a/packages/client/src/utils/utils.ts b/packages/client/src/utils/utils.ts
index e87a8ff700..486081019c 100644
--- a/packages/client/src/utils/utils.ts
+++ b/packages/client/src/utils/utils.ts
@@ -37,7 +37,8 @@ const twMerge = extendTailwindMerge({
],
},
],
- 'min-w': [{ 'min-w': ['theme-tab', 'theme-target'] }],
+ 'min-w': [{ 'min-w': ['theme-tab', 'theme-list', 'theme-target'] }],
+ 'max-h': [{ 'max-h': ['theme-list'] }],
'min-h': [{ 'min-h': ['theme-target'] }],
size: [
{
diff --git a/packages/client/tailwind.preset.cjs b/packages/client/tailwind.preset.cjs
index 852f98717a..fb00352ab2 100644
--- a/packages/client/tailwind.preset.cjs
+++ b/packages/client/tailwind.preset.cjs
@@ -48,6 +48,12 @@ module.exports = {
'theme-target': '24px',
/** The narrowest a tab trigger draws. */
'theme-tab': 'var(--theme-tab-min-width, 100px)',
+ /** The narrowest a Select's list draws. */
+ 'theme-list': 'var(--theme-list-min-width, 8rem)',
+ },
+ maxHeight: {
+ /** The tallest a Select's list draws before it scrolls. */
+ 'theme-list': 'var(--theme-list-max-height, 24rem)',
},
width: {
/** Never narrower than the track is tall, so the knob always has somewhere to travel. */
diff --git a/packages/data-provider/src/theme.ts b/packages/data-provider/src/theme.ts
index 050c1d4180..5ee8e9605f 100644
--- a/packages/data-provider/src/theme.ts
+++ b/packages/data-provider/src/theme.ts
@@ -361,6 +361,10 @@ const appearanceValidators = {
tooltipRadius: isLength,
tabRadius: isLength,
tabMinWidth: isTableLength,
+ /** A Select list's narrowest width (`0` to size it by its trigger), and the height it scrolls
+ * past: never under 8rem, so a few options always show, nor over 40rem. */
+ listMinWidth: isTableLength,
+ listMaxHeight: lengthWithin(128, 640),
radiusSm: isLength,
radiusMd: isLength,
radiusLg: isLength,