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: Use Dropdown In Code Execution Settings (#16980)

Marco Beretta1bdb8ad8113a
diff --git a/client/src/components/Nav/Settings/CodeEnvironments.tsx b/client/src/components/Nav/Settings/CodeEnvironments.tsx
index 79cad08317..9d6d1034c7 100644
--- a/client/src/components/Nav/Settings/CodeEnvironments.tsx
+++ b/client/src/components/Nav/Settings/CodeEnvironments.tsx
@@ -1,18 +1,14 @@
-import { useEffect, useState } from 'react';
+import { useEffect, useId, useState } from 'react';
import { createCodeWorkerSetupCommand, isCodeWorkerShell } from 'librechat-data-provider';
import {
Button,
Chip,
Input,
+ Dropdown,
Label,
OGDialog,
OGDialogTemplate,
OGDialogTrigger,
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
Spinner,
useToastContext,
} from '@librechat/client';
@@ -51,7 +47,7 @@ function EnvironmentStatus({ environmentId }: { environmentId: string }) {
<div className="flex min-w-0 flex-col items-end gap-1">
<Chip tone={presentation.tone}>{localize(presentation.label)}</Chip>
{query.data.sandboxProfile != null && (
- <span className="max-w-48 truncate text-xs text-text-tertiary">
+ <span className="text-text-tertiary max-w-48 truncate text-xs">
{[query.data.sandboxProfile, ...(query.data.runtimes ?? [])].join(' · ')}
</span>
)}
@@ -68,37 +64,32 @@ function WorkerCommand({ pairing }: { pairing: CodeEnvironmentPairingResponse['p
allowWorkspaceCommands: true,
});
return (
- <div className="flex flex-col gap-2 rounded-lg border border-border-medium bg-surface-secondary p-3">
+ <div className="border-border-medium bg-surface-secondary flex flex-col gap-2 rounded-lg border p-3">
<div className="flex items-center justify-between gap-3">
- <p className="text-sm font-medium text-text-primary">
+ <p className="text-text-primary text-sm font-medium">
{localize('com_ui_code_environment_pairing_ready')}
</p>
- <Select
+ <Dropdown
value={shell}
- onValueChange={(value) => {
+ options={[
+ { value: 'posix', label: localize('com_ui_code_environment_shell_posix') },
+ { value: 'powershell', label: localize('com_ui_code_environment_shell_powershell') },
+ ]}
+ onChange={(value) => {
if (isCodeWorkerShell(value)) {
setShell(value);
}
}}
- >
- <SelectTrigger
- className="w-auto min-w-36"
- aria-label={localize('com_ui_code_environment_shell')}
- >
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="posix">{localize('com_ui_code_environment_shell_posix')}</SelectItem>
- <SelectItem value="powershell">
- {localize('com_ui_code_environment_shell_powershell')}
- </SelectItem>
- </SelectContent>
- </Select>
+ ariaLabel={localize('com_ui_code_environment_shell')}
+ testId="code-environment-shell"
+ className="shrink-0"
+ sizeClasses="z-50 min-w-48"
+ />
</div>
- <p className="text-xs text-text-secondary">
+ <p className="text-text-secondary text-xs">
{localize('com_ui_code_environment_pairing_description')}
</p>
- <pre className="overflow-x-auto whitespace-pre-wrap break-all rounded-md bg-surface-tertiary p-3 text-xs text-text-primary">
+ <pre className="bg-surface-tertiary text-text-primary overflow-x-auto rounded-md p-3 text-xs break-all whitespace-pre-wrap">
{command}
</pre>
<Button
@@ -140,6 +131,7 @@ function EnvironmentPermissions({ environment }: { environment: TCodeEnvironment
const localize = useLocalize();
const { showToast } = useToastContext();
const updateMutation = useUpdateCodeEnvironmentSettingsMutation();
+ const idPrefix = useId();
const fields = environment.configSchema?.permissions;
if (fields == null || !environment.canEdit) return null;
@@ -178,31 +170,30 @@ function EnvironmentPermissions({ environment }: { environment: TCodeEnvironment
].filter((control) => control.field != null);
return (
- <div className="mt-3 grid gap-3 border-t border-border-light pt-3 sm:grid-cols-2">
+ <div className="border-border-light mt-3 grid gap-3 border-t pt-3 sm:grid-cols-2">
{controls.map(({ category, label, field }) => {
if (field == null) return null;
const value = effectivePermission(field, environment.settings?.permissions?.[category]);
return (
<div key={category} className="flex flex-col gap-1.5">
- <Label htmlFor={`${environment.id}-${category}`}>{localize(label)}</Label>
- <Select
+ <div id={`${idPrefix}-${category}`} className="text-text-primary text-sm font-medium">
+ {localize(label)}
+ </div>
+ <Dropdown
value={value}
+ options={field.allowed.map((decision) => ({
+ value: decision,
+ label: localize(permissionLabels[decision]),
+ }))}
disabled={updateMutation.isLoading}
- onValueChange={(decision) =>
+ onChange={(decision) =>
updatePermission(category, decision as CodeEnvironmentPermissionDecision)
}
- >
- <SelectTrigger id={`${environment.id}-${category}`}>
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- {field.allowed.map((decision) => (
- <SelectItem key={decision} value={decision}>
- {localize(permissionLabels[decision])}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
+ aria-labelledby={`${idPrefix}-${category}`}
+ testId={`code-environment-${category}`}
+ variant="field"
+ sizeClasses="z-50 min-w-48"
+ />
</div>
);
})}
@@ -212,6 +203,8 @@ function EnvironmentPermissions({ environment }: { environment: TCodeEnvironment
export default function CodeEnvironments() {
const localize = useLocalize();
+ const nameId = useId();
+ const planeId = useId();
const { showToast } = useToastContext();
const query = useCodeEnvironmentsQuery();
const pairMutation = usePairCodeEnvironmentMutation();
@@ -254,55 +247,71 @@ export default function CodeEnvironments() {
};
let pairingControls = (
- <p className="text-sm text-text-secondary">{localize('com_ui_code_environment_unavailable')}</p>
+ <p className="text-text-secondary text-sm">{localize('com_ui_code_environment_unavailable')}</p>
);
if (query.isLoading) {
pairingControls = (
- <div className="flex items-center gap-2 text-sm text-text-secondary">
+ <div className="text-text-secondary flex items-center gap-2 text-sm">
<Spinner />
{localize('com_ui_loading')}
</div>
);
} else if (query.isError) {
pairingControls = (
- <p className="text-sm text-text-destructive">
+ <p className="text-text-destructive text-sm">
{localize('com_ui_code_environment_load_error')}
</p>
);
} else if (controlPlanes.length > 0) {
pairingControls = (
- <div className="grid gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto]">
- <Input
- id="code-environment-name"
- value={name}
- maxLength={100}
- placeholder={localize('com_ui_code_environment_name_placeholder')}
- onChange={(event) => setName(event.target.value)}
- />
- <Select value={selectedControlPlane} onValueChange={setControlPlaneId}>
- <SelectTrigger aria-label={localize('com_ui_code_environment_control_plane')}>
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- {controlPlanes.map((controlPlane) => (
- <SelectItem key={controlPlane.id} value={controlPlane.id}>
- {controlPlane.name}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- <Button type="button" disabled={!name.trim() || pairMutation.isLoading} onClick={pair}>
+ <form
+ className="grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] sm:items-end"
+ onSubmit={(event) => {
+ event.preventDefault();
+ pair();
+ }}
+ >
+ <div className="flex min-w-0 flex-col gap-1.5">
+ <Label htmlFor={nameId}>{localize('com_ui_name')}</Label>
+ <Input
+ id={nameId}
+ value={name}
+ maxLength={100}
+ placeholder={localize('com_ui_code_environment_name_placeholder')}
+ onChange={(event) => setName(event.target.value)}
+ />
+ </div>
+ <div className="flex min-w-0 flex-col gap-1.5">
+ <div id={planeId} className="text-text-primary text-sm font-medium">
+ {localize('com_ui_code_environment_control_plane')}
+ </div>
+ <Dropdown
+ value={selectedControlPlane}
+ options={controlPlanes.map((controlPlane) => ({
+ value: controlPlane.id,
+ label: controlPlane.name,
+ }))}
+ onChange={setControlPlaneId}
+ aria-labelledby={planeId}
+ testId="code-environment-control-plane"
+ variant="field"
+ sizeClasses="z-50 min-w-48"
+ />
+ </div>
+ <Button type="submit" disabled={!name.trim() || pairMutation.isLoading}>
{pairMutation.isLoading ? <Spinner /> : localize('com_ui_code_environment_pair')}
</Button>
- </div>
+ </form>
);
}
return (
<div className="flex w-full flex-col gap-4">
<div>
- <Label htmlFor="code-environment-name">{localize('com_ui_code_environments')}</Label>
- <p className="mt-1 text-xs text-text-secondary">
+ <h3 className="text-text-primary text-sm font-medium">
+ {localize('com_ui_code_environments')}
+ </h3>
+ <p className="text-text-secondary mt-1 text-xs">
{localize('com_ui_code_environments_description')}
</p>
</div>
@@ -313,26 +322,32 @@ export default function CodeEnvironments() {
<div className="flex flex-col gap-2">
{(query.data?.environments ?? []).map((environment) => (
- <div key={environment.id} className="rounded-lg border border-border-medium p-3">
+ <div key={environment.id} className="border-border-medium rounded-lg border p-3">
<div className="flex items-center justify-between gap-3">
<div className="min-w-0">
- <p className="truncate text-sm font-medium text-text-primary">{environment.name}</p>
- <p className="truncate text-xs text-text-secondary">{environment.id}</p>
+ <p className="text-text-primary truncate text-sm font-medium">{environment.name}</p>
+ <p className="text-text-secondary truncate text-xs">{environment.id}</p>
</div>
<div className="flex shrink-0 items-center gap-2">
<EnvironmentStatus environmentId={environment.id} />
{environment.canDelete && (
<OGDialog>
<OGDialogTrigger asChild>
- <Button type="button" variant="outline" size="sm">
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ aria-label={localize('com_ui_delete_var', { 0: environment.name })}
+ >
{localize('com_ui_delete')}
</Button>
</OGDialogTrigger>
<OGDialogTemplate
+ className="max-w-md"
showCloseButton={false}
title={localize('com_ui_code_environment_remove_title')}
main={
- <p className="text-sm text-text-secondary">
+ <p className="text-text-secondary text-sm">
{localize('com_ui_code_environment_remove_description')}
</p>
}
diff --git a/client/src/components/Nav/Settings/StatefulWorkspaceDefault.tsx b/client/src/components/Nav/Settings/StatefulWorkspaceDefault.tsx
index 9de7c0d330..318b219e4d 100644
--- a/client/src/components/Nav/Settings/StatefulWorkspaceDefault.tsx
+++ b/client/src/components/Nav/Settings/StatefulWorkspaceDefault.tsx
@@ -1,12 +1,5 @@
import { useEffect, useState } from 'react';
-import {
- Select,
- SelectItem,
- SelectValue,
- SelectContent,
- SelectTrigger,
- useToastContext,
-} from '@librechat/client';
+import { Dropdown, useToastContext } from '@librechat/client';
import {
STATEFUL_CODE_ENVIRONMENTS,
resolveAllowedStatefulCodeEnvironments,
@@ -59,41 +52,36 @@ export default function StatefulWorkspaceDefault() {
mutation.mutate({ statefulCodeEnvironment });
};
+ const options = STATEFUL_CODE_ENVIRONMENTS.filter(
+ (candidate) => allowedEnvironments.includes(candidate) || candidate === savedEnvironment,
+ ).map((candidate) => ({
+ value: candidate,
+ label: localize(ENVIRONMENT_LABELS[candidate]),
+ disabled: !allowedEnvironments.includes(candidate),
+ }));
+
return (
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4">
- <div>
- <label id="default-stateful-workspace-label" htmlFor="default-stateful-workspace">
+ <div className="min-w-0">
+ <div id="default-stateful-workspace-label" className="text-text-primary text-sm">
{localize('com_ui_default_stateful_workspace')}
- </label>
+ </div>
<p id="default-stateful-workspace-description" className="text-text-secondary mt-1 text-xs">
{localize('com_ui_default_stateful_workspace_description')}
</p>
</div>
- <Select value={environment} onValueChange={handleChange} disabled={mutation.isLoading}>
- <SelectTrigger
- id="default-stateful-workspace"
- className="w-full shrink-0 sm:w-[13.75rem]"
- aria-labelledby="default-stateful-workspace-label"
- aria-describedby="default-stateful-workspace-description"
- data-testid="default-stateful-workspace"
- >
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- {STATEFUL_CODE_ENVIRONMENTS.filter(
- (candidate) =>
- allowedEnvironments.includes(candidate) || candidate === savedEnvironment,
- ).map((candidate) => (
- <SelectItem
- key={candidate}
- value={candidate}
- disabled={!allowedEnvironments.includes(candidate)}
- >
- {localize(ENVIRONMENT_LABELS[candidate])}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
+ <Dropdown
+ value={environment}
+ options={options}
+ onChange={handleChange}
+ disabled={mutation.isLoading}
+ testId="default-stateful-workspace"
+ aria-labelledby="default-stateful-workspace-label"
+ aria-describedby="default-stateful-workspace-description"
+ className="shrink-0"
+ sizeClasses="z-50 min-w-[18rem]"
+ triggerClassName="w-full sm:w-[16rem]"
+ />
</div>
);
}
diff --git a/client/src/components/Nav/Settings/__tests__/StatefulWorkspaceDefault.spec.tsx b/client/src/components/Nav/Settings/__tests__/StatefulWorkspaceDefault.spec.tsx
index 9e3773a5d3..27863239b8 100644
--- a/client/src/components/Nav/Settings/__tests__/StatefulWorkspaceDefault.spec.tsx
+++ b/client/src/components/Nav/Settings/__tests__/StatefulWorkspaceDefault.spec.tsx
@@ -1,6 +1,5 @@
import userEvent from '@testing-library/user-event';
import { render, screen } from '@testing-library/react';
-import type { ReactNode } from 'react';
import StatefulWorkspaceDefault from '../StatefulWorkspaceDefault';
const mockMutate = jest.fn();
@@ -8,42 +7,7 @@ const mockShowToast = jest.fn();
let mockAllowedEnvironments: Array<'user' | 'agent-user' | 'conversation'> | undefined;
jest.mock('@librechat/client', () => ({
- Select: ({
- value,
- onValueChange,
- disabled,
- children,
- }: {
- value: string;
- onValueChange: (value: string) => void;
- disabled?: boolean;
- children: ReactNode;
- }) => (
- <select
- aria-label="workspace-default"
- value={value}
- disabled={disabled}
- onChange={(event) => onValueChange(event.target.value)}
- >
- {children}
- </select>
- ),
- SelectTrigger: ({ children }: { children: ReactNode }) => children,
- SelectValue: () => null,
- SelectContent: ({ children }: { children: ReactNode }) => children,
- SelectItem: ({
- value,
- children,
- disabled,
- }: {
- value: string;
- children: ReactNode;
- disabled?: boolean;
- }) => (
- <option value={value} disabled={disabled}>
- {children}
- </option>
- ),
+ ...jest.requireActual('@librechat/client'),
useToastContext: () => ({ showToast: mockShowToast }),
}));
@@ -79,31 +43,42 @@ describe('StatefulWorkspaceDefault', () => {
it('shows the saved user preference', () => {
render(<StatefulWorkspaceDefault />);
- expect(screen.getByRole('combobox', { name: 'workspace-default' })).toHaveValue('agent-user');
+ expect(screen.getByTestId('default-stateful-workspace')).toHaveTextContent(
+ 'com_ui_stateful_code_environment_agent_user',
+ );
+ });
+
+ it('describes the trigger with the workspace explanation', () => {
+ render(<StatefulWorkspaceDefault />);
+
+ expect(screen.getByTestId('default-stateful-workspace')).toHaveAccessibleDescription(
+ 'com_ui_default_stateful_workspace_description',
+ );
});
it('persists a new default for future agents', async () => {
render(<StatefulWorkspaceDefault />);
- await userEvent.selectOptions(
- screen.getByRole('combobox', { name: 'workspace-default' }),
- 'conversation',
+ await userEvent.click(screen.getByTestId('default-stateful-workspace'));
+ await userEvent.click(
+ await screen.findByRole('option', { name: 'com_ui_stateful_code_environment_conversation' }),
);
expect(mockMutate).toHaveBeenCalledWith({ statefulCodeEnvironment: 'conversation' });
});
- it('only enables deployment-allowed scopes while preserving the saved value', () => {
+ it('lists the saved disallowed scope as disabled', async () => {
mockAllowedEnvironments = ['user'];
render(<StatefulWorkspaceDefault />);
+ await userEvent.click(screen.getByTestId('default-stateful-workspace'));
expect(
- screen.getByRole('option', { name: 'com_ui_stateful_code_environment_user' }),
- ).toBeEnabled();
+ await screen.findByRole('option', { name: 'com_ui_stateful_code_environment_user' }),
+ ).toBeInTheDocument();
expect(
screen.getByRole('option', { name: 'com_ui_stateful_code_environment_agent_user' }),
- ).toBeDisabled();
+ ).toHaveAttribute('aria-disabled', 'true');
expect(
screen.queryByRole('option', { name: 'com_ui_stateful_code_environment_conversation' }),
).not.toBeInTheDocument();
diff --git a/e2e/specs/mock/scenarios/nested-popovers.spec.ts b/e2e/specs/mock/scenarios/nested-popovers.spec.ts
index f7ce0c7f53..e60cfa4c27 100644
--- a/e2e/specs/mock/scenarios/nested-popovers.spec.ts
+++ b/e2e/specs/mock/scenarios/nested-popovers.spec.ts
@@ -1,7 +1,8 @@
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 { openAgentBuilder, uniqueAgentName, cleanupAgent } from '../agents.helpers';
+import { MOCK_ENDPOINTS, NEW_CHAT_PATH, getAccessToken, requestJson } from '../helpers';
import { openSidebar } from './sidebar';
/**
@@ -9,7 +10,8 @@ import { openSidebar } from './sidebar';
* `none` unless it turns pointer events back on for itself. DropdownPopup does that with a class,
* not an inline style, and its menu must still take a real mouse pick while the dialog is open.
* The Select's check indicator draws its box at the icon size role, so a theme that resizes icons
- * resizes the box with the glyph inside it.
+ * resizes the box with the glyph inside it. The Select under test is the agent code tool's execution
+ * environment picker, which renders inside the tool's modal dialog.
*/
/** Names an icon size apart from the default, so a box still drawn at a fixed size shows. */
@@ -37,8 +39,9 @@ async function useTheme(page: Page, definition?: { name: string }) {
}, definition ?? null);
}
-/** The stateful workspace Select only renders when the agents endpoint offers stateful sessions;
- * a pick's save is answered here so it stands without a configured code environment. */
+/** The stateful workspace Dropdown only renders when the agents endpoint offers stateful sessions,
+ * and the execution environment Select only when it also lists environments; a pick's save is
+ * answered here so it stands without a configured code environment. */
async function offerStatefulSessions(page: Page) {
await page.route('**/api/user/preferences', async (route) => {
if (route.request().method() === 'GET') {
@@ -50,14 +53,20 @@ async function offerStatefulSessions(page: Page) {
const response = await route.fetch();
const endpoints = await response.json();
const agents = endpoints.agents ?? {};
- agents.capabilities = [...(agents.capabilities ?? []), 'stateful_code_sessions'];
+ agents.capabilities = [
+ ...new Set([...(agents.capabilities ?? []), 'execute_code', 'stateful_code_sessions']),
+ ];
+ agents.statefulCodeSessions = {
+ ...agents.statefulCodeSessions,
+ environments: [{ id: 'e2e-managed', name: 'E2E managed runtime', type: 'managed' }],
+ };
endpoints.agents = agents;
await route.fulfill({ response, json: endpoints });
});
}
-/** Opens the stateful workspace Select's list in the Settings dialog. */
-async function openWorkspaceSelect(page: Page) {
+/** Opens the stateful workspace Dropdown's list in the Settings dialog. */
+async function openWorkspaceDropdown(page: Page) {
await page.goto(NEW_CHAT_PATH, { timeout: 15000 });
/** Mobile keeps the account menu in the drawer. */
await openSidebar(page);
@@ -71,6 +80,49 @@ async function openWorkspaceSelect(page: Page) {
const trigger = dialog.getByTestId('default-stateful-workspace');
await expect(trigger).toBeVisible();
await trigger.click();
+ await expect(page.getByRole('listbox')).toBeVisible();
+}
+
+let agentId: string | undefined;
+
+/** Opens the execution environment Select's list in the code tool's dialog of a fresh agent. */
+async function openEnvironmentSelect(page: Page) {
+ await page.goto(NEW_CHAT_PATH, { timeout: 15000 });
+ const name = uniqueAgentName('Select Fixture');
+ const token = await getAccessToken(page);
+ const agent = await requestJson<{ id: string }>(page, {
+ path: '/api/agents',
+ token,
+ method: 'POST',
+ body: {
+ name,
+ provider: MOCK_ENDPOINTS[0].label,
+ model: MOCK_ENDPOINTS[0].model,
+ tools: ['execute_code'],
+ },
+ });
+ agentId = agent.id;
+
+ const form = await openAgentBuilder(page);
+ await form.getByRole('combobox', { name: 'Agent', exact: true }).click();
+ await page.getByRole('option', { name, exact: true }).click();
+ await expect(form.getByLabel('Agent name')).toHaveValue(name);
+
+ const row = form
+ .getByText('Run Code', { exact: true })
+ .first()
+ .locator('xpath=ancestor::div[contains(@class,"group")][1]');
+ await row.hover();
+ await row.getByRole('button', { name: 'Configure' }).click();
+ const dialog = page.getByRole('dialog');
+ const stateful = dialog.getByTestId('stateful-code-sessions');
+ await expect(stateful).toBeVisible({ timeout: 15000 });
+ if ((await stateful.getAttribute('aria-checked')) !== 'true') {
+ await stateful.click();
+ }
+ const trigger = dialog.getByTestId('code-environment-id');
+ await expect(trigger).toBeVisible();
+ await trigger.click();
const listbox = page.getByRole('listbox');
await expect(listbox).toBeVisible();
/** The list zooms in, so a box read before the animation settles is scaled. */
@@ -79,6 +131,11 @@ async function openWorkspaceSelect(page: Page) {
);
}
+test.afterEach(async ({ page }) => {
+ await cleanupAgent(page, agentId);
+ agentId = undefined;
+});
+
/** The checked option's indicator box is `expected` square and its glyph fills it exactly. */
async function expectIndicator(page: Page, expected: string) {
const checked = page.getByRole('option', { selected: true });
@@ -132,7 +189,7 @@ test.describe('popovers inside a modal dialog', () => {
}) => {
await offerStatefulSessions(page);
await useTheme(page);
- await openWorkspaceSelect(page);
+ await openEnvironmentSelect(page);
await expectIndicator(page, '16px');
});
@@ -141,21 +198,21 @@ test.describe('popovers inside a modal dialog', () => {
}) => {
await offerStatefulSessions(page);
await useTheme(page, REFERENCE_ICON_THEME);
- await openWorkspaceSelect(page);
+ await openEnvironmentSelect(page);
await expectIndicator(page, '20px');
});
/** The Settings dialog is a Headless UI panel, not an OGDialog; before it declared a dialog
- * level its Select lists painted behind it (berry-13/LibreChat#249). Hit testing alone cannot
+ * level its popover lists painted behind it (berry-13/LibreChat#249). Hit testing alone cannot
* show that: the open list sets `pointer-events: none` on the body, so the panel is skipped and
* a click falls through to a list nobody can see. The probe turns pointer events back on
* everywhere so `elementFromPoint` reports what is painted on top. */
- test('a Select in the Settings dialog opens on top of it and takes a pick @scenario:settings-select-opens-on-top', async ({
+ test('a dropdown in the Settings dialog opens on top of it and takes a pick @scenario:settings-select-opens-on-top', async ({
page,
}) => {
await offerStatefulSessions(page);
await useTheme(page);
- await openWorkspaceSelect(page);
+ await openWorkspaceDropdown(page);
const option = page.getByRole('option', { name: 'Conversation workspace' });
const box = await option.boundingBox();
@@ -180,6 +237,7 @@ test.describe('popovers inside a modal dialog', () => {
await expect(page.getByTestId('default-stateful-workspace')).toHaveText(
'Conversation workspace',
);
+ await expect(page.getByRole('dialog').getByRole('heading', { name: 'Settings' })).toBeVisible();
});
});
@@ -207,7 +265,7 @@ test.describe('Select list size roles', () => {
}) => {
await offerStatefulSessions(page);
await useTheme(page);
- await openWorkspaceSelect(page);
+ await openEnvironmentSelect(page);
expect(await listBounds(page)).toEqual({ minWidth: '128px', maxHeight: '384px' });
});
@@ -216,7 +274,7 @@ test.describe('Select list size roles', () => {
}) => {
await offerStatefulSessions(page);
await useTheme(page, clickHouseTheme);
- await openWorkspaceSelect(page);
+ await openEnvironmentSelect(page);
expect(await listBounds(page)).toEqual({ minWidth: '0px', maxHeight: '384px' });
});
@@ -225,7 +283,7 @@ test.describe('Select list size roles', () => {
}) => {
await offerStatefulSessions(page);
await useTheme(page, REFERENCE_LIST_THEME);
- await openWorkspaceSelect(page);
+ await openEnvironmentSelect(page);
expect(await listBounds(page)).toEqual({ minWidth: '192px', maxHeight: '320px' });
});
});
diff --git a/packages/client/src/components/Dropdown.tsx b/packages/client/src/components/Dropdown.tsx
index 0d9ca49d06..972d91266c 100644
--- a/packages/client/src/components/Dropdown.tsx
+++ b/packages/client/src/components/Dropdown.tsx
@@ -28,6 +28,7 @@ interface DropdownProps {
renderValue?: (option: Option) => React.ReactNode;
ariaLabel?: string;
'aria-labelledby'?: string;
+ 'aria-describedby'?: string;
portal?: boolean;
/** `field` matches Input; `compact` supplies the small toolbar-control recipe. */
variant?: 'default' | 'field' | 'compact';
@@ -75,6 +76,7 @@ const Dropdown: React.FC<DropdownProps> = ({
renderValue,
ariaLabel,
'aria-labelledby': ariaLabelledBy,
+ 'aria-describedby': ariaDescribedBy,
portal = true,
variant = 'default',
shape = 'theme',
@@ -194,6 +196,7 @@ const Dropdown: React.FC<DropdownProps> = ({
aria-labelledby={
ariaLabelledBy == null || iconOnly ? ariaLabelledBy : `${ariaLabelledBy} ${valueId}`
}
+ aria-describedby={ariaDescribedBy}
>
<div className={cn('flex min-w-0 items-center gap-2', iconOnly ? 'shrink-0' : 'w-full')}>
{icon}
@@ -288,6 +291,7 @@ const Dropdown: React.FC<DropdownProps> = ({
<Select.SelectItem
key={`option-${index}`}
value={String(option.value)}
+ disabled={option.disabled === true}
className="select-item"
data-theme={option.value}
>