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: Cap the Select List at the Popover's Available Height (#16938)
Marco Berettad738fa43b4c9
diff --git a/client/src/Providers/__tests__/themeCache.spec.ts b/client/src/Providers/__tests__/themeCache.spec.tsindex bae575caed..93e2df5c8b 100644--- a/client/src/Providers/__tests__/themeCache.spec.ts+++ b/client/src/Providers/__tests__/themeCache.spec.ts@@ -224,7 +224,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.4.dxwdxg', digest: '39up6s' };+const PIN = { fingerprint: '1.5.dxwdxg', digest: '1n3ywnj' };const digestOf = (text: string): string => {let hash = 5381;diff --git a/e2e/specs/mock/scenarios/nested-popovers.spec.ts b/e2e/specs/mock/scenarios/nested-popovers.spec.tsindex e60cfa4c27..a9c63018db 100644--- a/e2e/specs/mock/scenarios/nested-popovers.spec.ts+++ b/e2e/specs/mock/scenarios/nested-popovers.spec.ts@@ -251,31 +251,66 @@ const REFERENCE_LIST_THEME = {},} as const;-/** The open list's width floor and scroll cap, as the browser computed them. */+/** The open list's width floor and scroll cap, as the browser computed them, with the room the+ * popper leaves between its trigger and the viewport's edge, and the list's drawn box. */async function listBounds(page: Page) {return page.getByRole('listbox').evaluate((element) => {const style = getComputedStyle(element);- return { minWidth: style.minWidth, maxHeight: style.maxHeight };+ const { top, bottom } = element.getBoundingClientRect();+ return {+ minWidth: style.minWidth,+ maxHeight: style.maxHeight,+ available: parseFloat(style.getPropertyValue('--radix-select-content-available-height')),+ top,+ bottom,+ };});}+/** Tall enough that the list's own cap, not the viewport, decides its height. */+async function useTallWindow(page: Page) {+ const { width } = page.viewportSize() ?? { width: 1280 };+ await page.setViewportSize({ width, height: 1100 });+}++const SHORT_PHONE = { width: 375, height: 480 };+const SHORT_WINDOW = { width: 1024, height: 420 };++/** In a viewport too short for the list's own cap, the list scrolls inside the room the popper+ * leaves rather than running past the viewport's edge. */+async function expectListFits(page: Page, viewport: { width: number; height: number }) {+ await page.setViewportSize(viewport);+ await openEnvironmentSelect(page);+ const bounds = await listBounds(page);+ expect(bounds.available).toBeLessThan(384);+ expect(parseFloat(bounds.maxHeight)).toBeLessThanOrEqual(bounds.available);+ expect(bounds.top).toBeGreaterThanOrEqual(0);+ expect(bounds.bottom).toBeLessThanOrEqual(viewport.height);+}+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 useTallWindow(page);await openEnvironmentSelect(page);- expect(await listBounds(page)).toEqual({ minWidth: '128px', maxHeight: '384px' });+ const bounds = await listBounds(page);+ expect(bounds.available).toBeGreaterThan(384);+ expect(bounds).toMatchObject({ minWidth: '128px', maxHeight: '384px' });});- test('the ClickHouse theme sizes the list by its trigger @scenario:select-list-size-clickhouse', async ({+ test('the ClickHouse theme sizes the list by its trigger and caps it at the available height @scenario:select-list-size-clickhouse', async ({page,}) => {await offerStatefulSessions(page);await useTheme(page, clickHouseTheme);+ await useTallWindow(page);await openEnvironmentSelect(page);- expect(await listBounds(page)).toEqual({ minWidth: '0px', maxHeight: '384px' });+ const bounds = await listBounds(page);+ expect(bounds.available).toBeGreaterThan(384);+ expect(bounds).toMatchObject({ minWidth: '0px', maxHeight: `${bounds.available}px` });});test('a theme that sets both list roles resizes the list @scenario:select-list-size-reference', async ({@@ -283,7 +318,40 @@ test.describe('Select list size roles', () => {}) => {await offerStatefulSessions(page);await useTheme(page, REFERENCE_LIST_THEME);+ await useTallWindow(page);await openEnvironmentSelect(page);- expect(await listBounds(page)).toEqual({ minWidth: '192px', maxHeight: '320px' });+ expect(await listBounds(page)).toMatchObject({ minWidth: '192px', maxHeight: '320px' });+ });++ test('the default list never grows past a short phone screen @scenario:select-list-fits-short-phone', async ({+ page,+ }) => {+ await offerStatefulSessions(page);+ await useTheme(page);+ await expectListFits(page, SHORT_PHONE);+ });++ test('the ClickHouse list never grows past a short phone screen @scenario:select-list-fits-short-phone-clickhouse', async ({+ page,+ }) => {+ await offerStatefulSessions(page);+ await useTheme(page, clickHouseTheme);+ await expectListFits(page, SHORT_PHONE);+ });++ test('the default list never grows past a small desktop window @scenario:select-list-fits-short-window', async ({+ page,+ }) => {+ await offerStatefulSessions(page);+ await useTheme(page);+ await expectListFits(page, SHORT_WINDOW);+ });++ test('the ClickHouse list never grows past a small desktop window @scenario:select-list-fits-short-window-clickhouse', async ({+ page,+ }) => {+ await offerStatefulSessions(page);+ await useTheme(page, clickHouseTheme);+ await expectListFits(page, SHORT_WINDOW);});});diff --git a/e2e/specs/mock/scenarios/primitive-sizes.spec.ts b/e2e/specs/mock/scenarios/primitive-sizes.spec.tsindex 6ddbbf0f89..ab2af0a709 100644--- a/e2e/specs/mock/scenarios/primitive-sizes.spec.ts+++ b/e2e/specs/mock/scenarios/primitive-sizes.spec.ts@@ -126,6 +126,8 @@ test.describe('primitive size roles', () => {'select-item': '4px','min-w-theme-tab': '0px','min-w-theme-list': '0px',+ /** `none`: no cap of its own, so outside a Select's popper only the viewport bounds it. */+ 'max-h-theme-list': `${modePage.viewportSize()?.height}px`,'h-theme-field': '32px',/** 3.6876rem: the 3rem title line, field.space.y twice and a 1px stroke each side (Click UI field metrics). */'h-theme-field-lg': '59px',diff --git a/packages/client/src/theme/README.md b/packages/client/src/theme/README.mdindex 7f9c784d21..0648e5537d 100644--- a/packages/client/src/theme/README.md+++ b/packages/client/src/theme/README.md@@ -391,7 +391,9 @@ Each status family has a foreground, a `-subtle` background, a `-border`, and athe 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 tabtrigger. `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+ its trigger, and `listMaxHeight`, 8 to 40rem or `none`) bound the Select's list, which never+ grows past the room the popper leaves between its trigger and the viewport's edge, so `none`+ drops the fixed cap and keeps only that one. Every default is the size the primitive drew before. The icon and checkbox rolesare bounded to the room their layouts leave: `iconSize` 0.75 to 1.25rem, `iconSizeMd` (theexported Dialog's close glyph) 1.25 to 1.5rem, `iconSizeLg` 1 to 2rem, `checkboxSize` 1 to1.5rem. The target floor (`h-theme-target`, `min-h-theme-target`, `min-w-theme-target`) isdiff --git a/packages/client/src/theme/registry.spec.ts b/packages/client/src/theme/registry.spec.tsindex 0e2179093e..97b5b44964 100644--- a/packages/client/src/theme/registry.spec.ts+++ b/packages/client/src/theme/registry.spec.ts@@ -1561,8 +1561,10 @@ describe('theme registry', () => {expect(issues({ listMinWidth: '0', listMaxHeight: '8rem' })).toEqual([]);expect(issues({ listMinWidth: '12rem', listMaxHeight: '640px' })).toEqual([]);+ expect(issues({ listMaxHeight: 'none' })).toEqual([]);[{ listMinWidth: 'auto' },+ { listMaxHeight: 'auto' },{ listMinWidth: '-1rem' },{ listMaxHeight: '0' },{ listMaxHeight: '7rem' },@@ -2408,4 +2410,14 @@ describe('appearance families substitute through the emitted variables', () => {expect(themed.get(property)).not.toBe(base.get(property));},);++ it('writes a `none` list height as the viewport height its available-height cap undercuts', () => {+ const uncapped = emitted({+ ...reference,+ modes: { light: { appearance: { listMaxHeight: 'none' } } },+ });++ expect(emitted(libreChatTheme).get('--theme-list-max-height')).toBe('24rem');+ expect(uncapped.get('--theme-list-max-height')).toBe('100dvh');+ });});diff --git a/packages/client/src/theme/tailwind.spec.js b/packages/client/src/theme/tailwind.spec.jsindex 497ec135e4..0d3f681ac1 100644--- a/packages/client/src/theme/tailwind.spec.js+++ b/packages/client/src/theme/tailwind.spec.js@@ -221,6 +221,10 @@ describe('LibreChat Tailwind preset', () => {expect(css).toContain(`var(${property}, ${fallback})`);});+ expect(rule(css, 'max-h-theme-list')).toContain(+ 'var(--radix-select-content-available-height, 100dvh)',+ );+/** The tap-target floor is the role's reason to exist, so the floor itself is asserted* rather than only the control-height variable it is built from. */expect(css).toContain(diff --git a/packages/client/src/theme/themes/clickhouse.ts b/packages/client/src/theme/themes/clickhouse.tsindex 0231518f9c..2946af3748 100644--- a/packages/client/src/theme/themes/clickhouse.ts+++ b/packages/client/src/theme/themes/clickhouse.ts@@ -470,10 +470,10 @@ const clickHouseShape = {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. */+ * floor of its own. Its height is capped only by the popover's available height+ * (`--radix-popover-content-available-height`). */listMinWidth: '0',- listMaxHeight: '24rem',+ listMaxHeight: 'none',radiusSm: '0.25rem', // border.radii.1radiusMd: '0.25rem', // border.radii.1radiusLg: '0.25rem', // border.radii.1diff --git a/packages/client/src/theme/themes/clickui.spec.ts b/packages/client/src/theme/themes/clickui.spec.tsindex a1056826ae..8a5995b6ea 100644--- a/packages/client/src/theme/themes/clickui.spec.ts+++ b/packages/client/src/theme/themes/clickui.spec.ts@@ -505,10 +505,10 @@ const appearanceDecisions: Partial<Record<keyof IThemeAppearance, AppearanceDeci'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',+ value: 'none',+ status: 'match',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; tracked under the not-expressible list",+ 'none: Click UI caps its select list only at var(--radix-popover-content-available-height), the cap the Select list keeps under every value',},iconButtonSizeSm: {value: '1.5rem',@@ -1429,15 +1429,7 @@ interface NotExpressible {* close it. Remove an entry when the change that closes it lands, and pin its decisions to what* they then measure.*/-const notExpressible: Record<string, NotExpressible> = {- 'Select list height': {- decisions: {},- appearance: ['listMaxHeight'],- reason:- "Click UI caps its select list only at var(--radix-popover-content-available-height), which a length role cannot express, so listMaxHeight keeps LibreChat's 24rem",- issue: 'https://github.com/berry-13/LibreChat/issues/282',- },-};+const notExpressible: Record<string, NotExpressible> = {};type Verdict = 'match' | 'near' | 'deviation' | 'not expressible';diff --git a/packages/client/src/theme/utils/applyTheme.ts b/packages/client/src/theme/utils/applyTheme.tsindex 20e237f365..af66da33b0 100644--- a/packages/client/src/theme/utils/applyTheme.ts+++ b/packages/client/src/theme/utils/applyTheme.ts@@ -187,8 +187,15 @@ function mapColors(input: RenamedThemeRGB, base?: IThemeRGB): Array<[string, strreturn variables;}-/** The `theme-chrome-quiet:` variant matches the literal `0`, so every spelling of zero is written as it. */+/**+ * The `theme-chrome-quiet:` variant matches the literal `0`, so every spelling of zero is written as+ * it. A `none` list height is written as the viewport's, which the list's available-height cap+ * always undercuts; `none` itself would void the `min()` that applies that cap.+ */function canonicalAppearance(key: keyof IThemeAppearance, value: string): string {+ if (key === 'listMaxHeight' && value === 'none') {+ return '100dvh';+ }return key === 'chromeBorderAlpha' && Number(value) === 0 ? '0' : value;}diff --git a/packages/client/tailwind.preset.cjs b/packages/client/tailwind.preset.cjsindex 4afd5fecae..6546f03244 100644--- a/packages/client/tailwind.preset.cjs+++ b/packages/client/tailwind.preset.cjs@@ -57,8 +57,10 @@ module.exports = {'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)',+ /** The tallest a Select's list draws before it scrolls, never past the room the popper+ * leaves between its trigger and the viewport's edge. */+ 'theme-list':+ 'min(var(--theme-list-max-height, 24rem), var(--radix-select-content-available-height, 100dvh))',},inset: {/** Where a sign-in label rests in its field: centered 2px low, as on the stock 44px field,diff --git a/packages/data-provider/src/theme.ts b/packages/data-provider/src/theme.tsindex 69acd4a389..1146f0823c 100644--- a/packages/data-provider/src/theme.ts+++ b/packages/data-provider/src/theme.ts@@ -307,6 +307,10 @@ const lengthWithin =const px = parseFloat(value) * (value.endsWith('rem') ? 16 : 1);return px >= minPx && px <= maxPx;};+/** A Select list's scroll height, or `none` for no cap of its own, so it fills the room the popper+ * leaves. */+const isListMaxHeight = (value: unknown): value is string =>+ value === 'none' || lengthWithin(128, 640)(value);/** A pointer target never drops under WCAG 2.5.8's 24px minimum, written in px or rem. */const isTargetSize = (value: unknown): value is string =>isSwitchLength(value) && parseFloat(value) >= (value.endsWith('rem') ? 1.5 : 24);@@ -433,9 +437,10 @@ const appearanceValidators = {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. */+ * past: never under 8rem, so a few options always show, nor over 40rem, or `none` to scroll+ * only past the room the popper leaves, which also caps every other value. */listMinWidth: isTableLength,- listMaxHeight: lengthWithin(128, 640),+ listMaxHeight: isListMaxHeight,radiusSm: isLength,radiusMd: isLength,radiusLg: isLength,@@ -596,7 +601,7 @@ export function parseSessionHint(value: string): SessionHint | undefined {* 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 = 4 as const;+export const THEME_CACHE_EPOCH = 5 as const;/*** Names the role set a stored resolved theme was built against: any color, brand or appearance