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: Constrain the Agent Selector to 480px and 10 Own Agents (#16256)

Marco Beretta764a4393f498
diff --git a/client/src/components/SidePanel/Agents/AgentSelect.tsx b/client/src/components/SidePanel/Agents/AgentSelect.tsx
index e112c12117..728180518f 100644
--- a/client/src/components/SidePanel/Agents/AgentSelect.tsx
+++ b/client/src/components/SidePanel/Agents/AgentSelect.tsx
@@ -2,17 +2,26 @@ import { memo, useCallback, useEffect, useRef } from 'react';
import { EarthIcon } from 'lucide-react';
import { ControlCombobox } from '@librechat/client';
import { useFormContext, Controller } from 'react-hook-form';
-import { AgentCapabilities, defaultAgentFormValues } from 'librechat-data-provider';
+import {
+ AgentCapabilities,
+ normalizeAgentSelectorLimit,
+ defaultAgentFormValues,
+} from 'librechat-data-provider';
import type { Agent, AgentCreateParams, StatefulCodeEnvironment } from 'librechat-data-provider';
import type { UseMutationResult, QueryObserverResult } from '@tanstack/react-query';
import type { TAgentCapabilities, AgentForm } from '~/common';
import { cn, createProviderOption, processAgentOption, getDefaultAgentFormValues } from '~/utils';
+import { useListAgentsQuery, useGetStartupConfig } from '~/data-provider';
import { useLocalize, useAgentDefaultPermissionLevel } from '~/hooks';
import { mergeDirtyToolsWithServerActions } from './agentTools';
-import { useListAgentsQuery } from '~/data-provider';
const keys = new Set(Object.keys(defaultAgentFormValues));
+/** Dropdown cap: 480px tall; the unsearched list cap comes from
+ * `interface.agentSelectorLimit` (default 10), and the search field covers
+ * agents past the cut. */
+const SELECTOR_MAX_HEIGHT = 480;
+
function AgentSelect({
agentQuery,
selectedAgentId = null,
@@ -40,6 +49,8 @@ function AgentSelect({
const dirtyFieldsRef = useRef(dirtyFields);
dirtyFieldsRef.current = dirtyFields;
const permissionLevel = useAgentDefaultPermissionLevel();
+ const { data: startupConfig } = useGetStartupConfig();
+ const selectorLimit = normalizeAgentSelectorLimit(startupConfig?.interface?.agentSelectorLimit);
const { data: agents = null } = useListAgentsQuery(
{ requiredPermission: permissionLevel },
@@ -274,6 +285,8 @@ function AgentSelect({
selectPlaceholder={field?.value?.value ?? createAgent}
iconSide="right"
searchPlaceholder={localize('com_agents_search_name')}
+ popoverMaxHeight={SELECTOR_MAX_HEIGHT}
+ unsearchedLimit={selectorLimit}
SelectIcon={field?.value?.icon}
setValue={onSelect}
items={
diff --git a/e2e/specs/mock/scenarios/agent-selector-caps.spec.ts b/e2e/specs/mock/scenarios/agent-selector-caps.spec.ts
new file mode 100644
index 0000000000..9a7db3f6df
--- /dev/null
+++ b/e2e/specs/mock/scenarios/agent-selector-caps.spec.ts
@@ -0,0 +1,149 @@
+import { expect, test } from '@playwright/test';
+import type { AgentDetail } from '../agents.helpers';
+import { cleanupAgent, openAgentBuilder, uniqueAgentName } from '../agents.helpers';
+import { MOCK_ENDPOINTS, NEW_CHAT_PATH, getAccessToken, requestJson } from '../helpers';
+
+/** Twelve own agents reproduces the design review's fixture: the cap lists ten
+ * and the cut hides two. The first-created name carries the oldest updatedAt,
+ * so it is the one that ranks past the cut. */
+const AGENT_COUNT = 12;
+
+const createAgent = async (page: Parameters<typeof getAccessToken>[0], name: string) => {
+ const token = await getAccessToken(page);
+ return requestJson<AgentDetail>(page, {
+ path: '/api/agents',
+ token,
+ method: 'POST',
+ body: {
+ name,
+ description: 'Agent selector cap acceptance fixture.',
+ instructions: 'Keep this fixture deterministic.',
+ provider: MOCK_ENDPOINTS[0].label,
+ model: MOCK_ENDPOINTS[0].model,
+ },
+ });
+};
+
+async function createCappedAgents(page: Parameters<typeof getAccessToken>[0]) {
+ const stamp = uniqueAgentName('E2E SelCap');
+ const names = Array.from(
+ { length: AGENT_COUNT },
+ (_, index) => `${stamp} ${String(index + 1).padStart(2, '0')}`,
+ );
+ const created: AgentDetail[] = [];
+ for (const name of names) {
+ created.push(await createAgent(page, name));
+ }
+ return { names, created };
+}
+
+async function openSelector(page: Parameters<typeof openAgentBuilder>[0]) {
+ const form = await openAgentBuilder(page);
+ await form.getByRole('combobox', { name: 'Agent', exact: true }).click();
+ const dialog = page.getByRole('dialog', { name: 'Agent', exact: true });
+ await expect(dialog).toBeVisible();
+ return dialog;
+}
+
+test.describe('agent selector caps', () => {
+ test('selector lists at most ten own agents unsearched @scenario:agent-selector-caps-unsearched-list', async ({
+ page,
+ }) => {
+ test.setTimeout(120000);
+ const ids: string[] = [];
+ try {
+ await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
+ const { names, created } = await createCappedAgents(page);
+ ids.push(...created.map((agent) => agent.id));
+
+ await openSelector(page);
+ await expect(page.getByRole('option').first()).toHaveAttribute('aria-setsize', '10');
+ await expect(page.getByRole('option')).toHaveCount(10);
+ await expect(page.getByRole('option', { name: names[0], exact: true })).toBeHidden();
+ } finally {
+ for (const id of ids) {
+ await cleanupAgent(page, id);
+ }
+ }
+ });
+
+ test('searching reaches an agent past the cut and selects it @scenario:agent-selector-search-reaches-agents-past-cut', async ({
+ page,
+ }) => {
+ test.setTimeout(120000);
+ const ids: string[] = [];
+ try {
+ await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
+ const { names, created } = await createCappedAgents(page);
+ ids.push(...created.map((agent) => agent.id));
+
+ const dialog = await openSelector(page);
+ await dialog.getByRole('combobox', { name: 'Search agents by name' }).fill(names[0]);
+ const pastCut = page.getByRole('option', { name: names[0], exact: true });
+ await expect(pastCut).toBeVisible();
+ await pastCut.click();
+ await expect(page.getByLabel('Agent name')).toHaveValue(names[0]);
+ } finally {
+ for (const id of ids) {
+ await cleanupAgent(page, id);
+ }
+ }
+ });
+
+ test('a selected agent past the cut stays listed and marked selected @scenario:agent-selector-keeps-selected-agent-past-cut', async ({
+ page,
+ }) => {
+ test.setTimeout(120000);
+ const ids: string[] = [];
+ try {
+ await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
+ const { names, created } = await createCappedAgents(page);
+ ids.push(...created.map((agent) => agent.id));
+
+ const dialog = await openSelector(page);
+ await dialog.getByRole('combobox', { name: 'Search agents by name' }).fill(names[0]);
+ await page.getByRole('option', { name: names[0], exact: true }).click();
+ await expect(page.getByLabel('Agent name')).toHaveValue(names[0]);
+
+ /** Reopening resets the search, so the capped list is back: the selected
+ * agent must have taken a slot instead of vanishing behind the cut. */
+ const form = page.getByRole('form', { name: 'Agent configuration form' });
+ await form.getByRole('combobox', { name: 'Agent', exact: true }).click();
+ const reopened = page.getByRole('dialog', { name: 'Agent', exact: true });
+ await expect(reopened).toBeVisible();
+ await expect(page.getByRole('option').first()).toHaveAttribute('aria-setsize', '10');
+ const selected = page.getByRole('option', { name: names[0], exact: true });
+ await expect(selected).toBeVisible();
+ await expect(selected).toHaveAttribute('aria-selected', 'true');
+ } finally {
+ for (const id of ids) {
+ await cleanupAgent(page, id);
+ }
+ }
+ });
+
+ test('popover never exceeds the viewport on a short screen @scenario:agent-selector-popover-fits-short-viewport', async ({
+ page,
+ }) => {
+ test.setTimeout(120000);
+ const ids: string[] = [];
+ try {
+ await page.setViewportSize({ width: 1280, height: 420 });
+ await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
+ const { created } = await createCappedAgents(page);
+ ids.push(...created.map((agent) => agent.id));
+
+ const dialog = await openSelector(page);
+ const box = await dialog.boundingBox();
+ expect(box).not.toBeNull();
+ /** 480px of popover cannot fit 420px of viewport; the cap must yield to
+ * the available height instead of pushing lower options offscreen. */
+ expect(box!.y + box!.height).toBeLessThanOrEqual(421);
+ await expect(page.getByRole('option').first()).toBeVisible();
+ } finally {
+ for (const id of ids) {
+ await cleanupAgent(page, id);
+ }
+ }
+ });
+});
diff --git a/packages/client/src/components/ControlCombobox.spec.tsx b/packages/client/src/components/ControlCombobox.spec.tsx
index a7c765b2f3..e772741db1 100644
--- a/packages/client/src/components/ControlCombobox.spec.tsx
+++ b/packages/client/src/components/ControlCombobox.spec.tsx
@@ -221,6 +221,82 @@ describe('ControlCombobox popover sizing', () => {
});
});
+describe('ControlCombobox dropdown caps', () => {
+ const manyItems = Array.from({ length: 15 }, (_, index) => ({
+ label: `Agent ${index + 1}`,
+ value: `agent-${index + 1}`,
+ }));
+
+ const renderCapped = (
+ overrides: { popoverMaxHeight?: number; unsearchedLimit?: number; selectedValue?: string } = {},
+ ) =>
+ render(
+ <ControlCombobox
+ selectedValue={overrides.selectedValue ?? 'agent-1'}
+ displayValue="Agent 1"
+ items={manyItems}
+ setValue={() => undefined}
+ ariaLabel="Test combobox"
+ searchPlaceholder="Search agents"
+ isCollapsed={false}
+ showCarat
+ popoverMaxHeight={480}
+ unsearchedLimit={10}
+ {...overrides}
+ />,
+ );
+
+ it('lists at most unsearchedLimit options while the search field is empty', () => {
+ renderCapped();
+ openPopover();
+ expect(screen.getAllByRole('option')[0]).toHaveAttribute('aria-setsize', '10');
+ expect(screen.queryByRole('option', { name: 'Agent 11' })).not.toBeInTheDocument();
+ });
+
+ it('lifts the cap while searching so options past the cut stay reachable', () => {
+ renderCapped();
+ openPopover();
+ fireEvent.change(screen.getByPlaceholderText('Search agents'), {
+ target: { value: 'Agent 15' },
+ });
+ expect(screen.getByRole('option', { name: 'Agent 15' })).toBeInTheDocument();
+ });
+
+ it('keeps the selected option in the capped list when it ranks past the cut', () => {
+ renderCapped({ selectedValue: 'agent-15' });
+ openPopover();
+ /** SelectRenderer windowing renders only the visible slice in jsdom, so
+ * the cap is read off aria-setsize rather than the option count. */
+ expect(screen.getAllByRole('option')[0]).toHaveAttribute('aria-setsize', '10');
+ expect(screen.getByRole('option', { name: 'Agent 15' })).toHaveAttribute(
+ 'aria-selected',
+ 'true',
+ );
+ expect(screen.queryByRole('option', { name: 'Agent 10' })).not.toBeInTheDocument();
+ });
+
+ it('caps the popover at popoverMaxHeight with the list as the scrolling region', () => {
+ renderCapped();
+ openPopover();
+ const popover = document.querySelector('.animate-popover') as HTMLElement;
+ expect(popover.style.maxHeight).toBe('min(480px, var(--popover-available-height, 480px))');
+ expect(popover.className).toContain('flex-col');
+ const scroller = popover.querySelector('div.overflow-auto');
+ expect(scroller?.className).toContain('flex-1');
+ expect(scroller?.className).toContain('min-h-0');
+ });
+
+ it('keeps the fixed 300px list cap for consumers that pass neither prop', () => {
+ renderCapped({ popoverMaxHeight: undefined, unsearchedLimit: undefined });
+ openPopover();
+ const popover = document.querySelector('.animate-popover') as HTMLElement;
+ expect(popover.style.maxHeight).toBe('');
+ const scroller = popover.querySelector('div.overflow-auto');
+ expect(scroller?.className).toContain('max-h-[300px]');
+ expect(screen.getAllByRole('option')[0]).toHaveAttribute('aria-setsize', '15');
+ });
+});
+
describe('ControlCombobox portal placement', () => {
const renderInDialog = (portal: boolean) =>
render(
diff --git a/packages/client/src/components/ControlCombobox.tsx b/packages/client/src/components/ControlCombobox.tsx
index 35008006e1..7245060f3e 100644
--- a/packages/client/src/components/ControlCombobox.tsx
+++ b/packages/client/src/components/ControlCombobox.tsx
@@ -33,6 +33,13 @@ interface ControlComboboxProps {
placement?: Ariakit.SelectStoreProps['placement'];
popoverClassName?: string;
matchTriggerWidth?: boolean;
+ /** Caps the entire popover, search field included, at this pixel height;
+ * the option list becomes the scrolling region. Unset keeps the default
+ * fixed 300px list height. */
+ popoverMaxHeight?: number;
+ /** Renders at most this many options while the search field is empty.
+ * Typing lifts the cap so search reaches every option. */
+ unsearchedLimit?: number;
/** `field` matches the `Input` primitive so this can sit in a form row. */
variant?: 'default' | 'field';
gutter?: number;
@@ -74,6 +81,8 @@ function ControlCombobox({
placement,
popoverClassName,
matchTriggerWidth = true,
+ popoverMaxHeight,
+ unsearchedLimit,
variant = 'default',
gutter = 4,
portal = true,
@@ -112,8 +121,22 @@ function ControlCombobox({
keys: ['value', 'label'],
baseSort: (a, b) => (a.index < b.index ? -1 : 1),
});
- return filteredItems.map(getItem);
- }, [searchValue, items]);
+ const mapped = filteredItems.map(getItem);
+ if (unsearchedLimit != null && searchValue.trim() === '') {
+ const capped = mapped.slice(0, unsearchedLimit);
+ /** The open list keeps offering the current selection: an option that
+ * ranks past the cut takes the last slot instead of vanishing until the
+ * user knows to search for it. */
+ if (selectedValue != null && !capped.some((item) => item.value === selectedValue)) {
+ const selected = mapped.find((item) => item.value === selectedValue);
+ if (selected != null) {
+ capped[capped.length - 1] = selected;
+ }
+ }
+ return capped;
+ }
+ return mapped;
+ }, [searchValue, items, unsearchedLimit, selectedValue]);
useEffect(() => {
const button = buttonRef.current;
@@ -205,16 +228,26 @@ function ControlCombobox({
portal={portal}
className={cn(
'overflow-hidden rounded-xl border border-border-light bg-surface-secondary shadow-lg',
+ popoverMaxHeight != null && 'flex flex-col',
popoverClassName ?? 'animate-popover',
)}
style={{
zIndex: popoverZIndex,
+ /** `--popover-available-height` is the space Ariakit measured for this
+ * placement, so a short viewport shrinks the cap instead of pushing
+ * lower options offscreen; the fallback keeps the cap when the
+ * variable is absent. */
+ ...(popoverMaxHeight != null
+ ? {
+ maxHeight: `min(${popoverMaxHeight}px, var(--popover-available-height, ${popoverMaxHeight}px))`,
+ }
+ : null),
...(matchTriggerWidth
? { width: isCollapsed ? '300px' : (buttonWidth ?? '300px') }
: { minWidth: '16rem' }),
}}
>
- <div className="py-1.5">
+ <div className="shrink-0 py-1.5">
<div className="relative">
<Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-primary" />
<Ariakit.Combobox
@@ -225,7 +258,13 @@ function ControlCombobox({
/>
</div>
</div>
- <div className="max-h-[300px] overflow-auto">
+ <div
+ className={cn(
+ popoverMaxHeight != null
+ ? 'min-h-0 flex-1 overflow-auto'
+ : 'max-h-[300px] overflow-auto',
+ )}
+ >
<Ariakit.ComboboxList store={combobox}>
<SelectRenderer store={select} items={matches} itemSize={ROW_HEIGHT} overscan={5}>
{({ value, icon, label, ...item }) => (
diff --git a/packages/data-provider/specs/config-schemas.spec.ts b/packages/data-provider/specs/config-schemas.spec.ts
index 6873eec9c4..26671c9a2f 100644
--- a/packages/data-provider/specs/config-schemas.spec.ts
+++ b/packages/data-provider/specs/config-schemas.spec.ts
@@ -8,6 +8,7 @@ import {
interfaceSchema,
fileStorageSchema,
fileStrategiesSchema,
+ normalizeAgentSelectorLimit,
SKILL_SYNC_MAX_INTERVAL_MINUTES,
summarizationTriggerSchema,
summarizationConfigSchema,
@@ -1932,3 +1933,24 @@ describe('interface.traceViewer', () => {
});
});
});
+
+describe('interfaceSchema agentSelectorLimit', () => {
+ it('defaults the unsearched agents selector list to ten entries', () => {
+ const result = interfaceSchema.parse({});
+ expect(result.agentSelectorLimit).toBe(10);
+ });
+
+ it('honors a deployment override and rejects out-of-bounds values', () => {
+ expect(interfaceSchema.parse({ agentSelectorLimit: 25 }).agentSelectorLimit).toBe(25);
+ expect(interfaceSchema.safeParse({ agentSelectorLimit: 0 }).success).toBe(false);
+ expect(interfaceSchema.safeParse({ agentSelectorLimit: 101 }).success).toBe(false);
+ });
+
+ it('normalizes runtime values that bypassed the schema back into bounds', () => {
+ expect(normalizeAgentSelectorLimit(25)).toBe(25);
+ expect(normalizeAgentSelectorLimit(undefined)).toBe(10);
+ expect(normalizeAgentSelectorLimit(0)).toBe(10);
+ expect(normalizeAgentSelectorLimit(101)).toBe(10);
+ expect(normalizeAgentSelectorLimit('10')).toBe(10);
+ });
+});
diff --git a/packages/data-provider/src/config.ts b/packages/data-provider/src/config.ts
index 6c4ba69e46..521863b2d4 100644
--- a/packages/data-provider/src/config.ts
+++ b/packages/data-provider/src/config.ts
@@ -2100,6 +2100,24 @@ export enum RetentionMode {
TEMPORARY = 'temporary',
}
+/** Single source for the agents panel selector's unsearched list cap; the
+ * schema default and the client fallback both read it. */
+export const DEFAULT_AGENT_SELECTOR_LIMIT = 10;
+export const AGENT_SELECTOR_LIMIT_MIN = 1;
+export const AGENT_SELECTOR_LIMIT_MAX = 100;
+
+/** Runtime guard for values that bypass `interfaceSchema`: raw librechat.yaml
+ * reads and principal-scoped admin overrides reach the client unparsed, so an
+ * out-of-bounds value falls back to the default instead of emptying the list. */
+export function normalizeAgentSelectorLimit(value: unknown): number {
+ return typeof value === 'number' &&
+ Number.isInteger(value) &&
+ value >= AGENT_SELECTOR_LIMIT_MIN &&
+ value <= AGENT_SELECTOR_LIMIT_MAX
+ ? value
+ : DEFAULT_AGENT_SELECTOR_LIMIT;
+}
+
export const interfaceSchema = z
.object({
privacyPolicy: z
@@ -2114,6 +2132,14 @@ export const interfaceSchema = z
modelSelect: z.boolean().optional(),
/** Milliseconds between syntax highlights while a code block streams. */
codeHighlightThrottleMs: z.number().int().min(0).max(60_000).default(300),
+ /** Most agents the agents panel selector lists before a search term is
+ * typed; typing lifts the cap so search reaches every agent. */
+ agentSelectorLimit: z
+ .number()
+ .int()
+ .min(AGENT_SELECTOR_LIMIT_MIN)
+ .max(AGENT_SELECTOR_LIMIT_MAX)
+ .default(DEFAULT_AGENT_SELECTOR_LIMIT),
parameters: z.boolean().optional(),
multiConvo: z.boolean().optional(),
bookmarks: z.boolean().optional(),
@@ -2236,6 +2262,7 @@ export const interfaceSchema = z
.default({
modelSelect: true,
codeHighlightThrottleMs: 300,
+ agentSelectorLimit: DEFAULT_AGENT_SELECTOR_LIMIT,
parameters: true,
presets: true,
multiConvo: true,
diff --git a/packages/data-schemas/src/app/interface.spec.ts b/packages/data-schemas/src/app/interface.spec.ts
index 9292db4f18..66c52ecaa8 100644
--- a/packages/data-schemas/src/app/interface.spec.ts
+++ b/packages/data-schemas/src/app/interface.spec.ts
@@ -36,6 +36,30 @@ describe('loadDefaultInterface', () => {
expect(interfaceConfig?.codeHighlightThrottleMs).toBe(100);
});
+ it('uses the schema default for the agent selector list cap when not configured', async () => {
+ const interfaceConfig = await loadDefaultInterface({
+ config: {},
+ configDefaults: getConfigDefaults(),
+ });
+
+ expect(interfaceConfig?.agentSelectorLimit).toBe(10);
+ });
+
+ it('forwards a configured agent selector list cap to the served interface', async () => {
+ const config: Partial<TCustomConfig> = {
+ interface: {
+ agentSelectorLimit: 4,
+ },
+ };
+
+ const interfaceConfig = await loadDefaultInterface({
+ config,
+ configDefaults: getConfigDefaults(),
+ });
+
+ expect(interfaceConfig?.agentSelectorLimit).toBe(4);
+ });
+
it('preserves disabled URL auto-submit config', async () => {
const config: Partial<TCustomConfig> = {
interface: {
diff --git a/packages/data-schemas/src/app/interface.ts b/packages/data-schemas/src/app/interface.ts
index 67a9303922..db451f1de1 100644
--- a/packages/data-schemas/src/app/interface.ts
+++ b/packages/data-schemas/src/app/interface.ts
@@ -34,6 +34,7 @@ export async function loadDefaultInterface({
(hasModelSpecs ? includesAddedEndpoints : defaults.modelSelect),
codeHighlightThrottleMs:
interfaceConfig?.codeHighlightThrottleMs ?? defaults.codeHighlightThrottleMs,
+ agentSelectorLimit: interfaceConfig?.agentSelectorLimit ?? defaults.agentSelectorLimit,
parameters: interfaceConfig?.parameters ?? (hasModelSpecs ? false : defaults.parameters),
presets: interfaceConfig?.presets ?? (hasModelSpecs ? false : defaults.presets),
privacyPolicy: interfaceConfig?.privacyPolicy ?? defaults.privacyPolicy,