Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(control-ui): r1-m1 dedupe selection option names

Josué14fdd60af3bf
diff --git a/control-ui/components/SelectionDropdown/index.tsx b/control-ui/components/SelectionDropdown/index.tsx
index 6756f2731..2bd6994ef 100644
--- a/control-ui/components/SelectionDropdown/index.tsx
+++ b/control-ui/components/SelectionDropdown/index.tsx
@@ -193,13 +193,19 @@ export function SelectionDropdown({
) : (
filteredOptions.map(option => {
const selected = selectedSet.has(option.value)
+ const normalizedLabel = option.label.trim().replace(/\s+/g, ' ').toLowerCase()
+ const normalizedBadge = option.badge?.trim().replace(/\s+/g, ' ').toLowerCase()
+ const accessibleName =
+ option.badge && normalizedBadge !== normalizedLabel
+ ? `${option.label}, ${option.badge}`
+ : option.label
return (
<button
key={option.value}
type="button"
className="cu-selection-dropdown__option"
role="option"
- aria-label={option.badge ? `${option.label}, ${option.badge}` : option.label}
+ aria-label={accessibleName}
aria-selected={selected}
data-selected={selected ? 'true' : undefined}
onClick={() => toggleOption(option.value)}
diff --git a/control-ui/components/__tests__/GovernedTraceExploration.test.tsx b/control-ui/components/__tests__/GovernedTraceExploration.test.tsx
index dc4cc46d5..3c21e0858 100644
--- a/control-ui/components/__tests__/GovernedTraceExploration.test.tsx
+++ b/control-ui/components/__tests__/GovernedTraceExploration.test.tsx
@@ -191,7 +191,7 @@ describe('GovernedEventExplorer', () => {
await screen.findByText('Permission grant')
fireEvent.click(screen.getByRole('button', { name: 'Filter Operator' }))
- fireEvent.click(await screen.findByRole('option', { name: 'admin' }))
+ fireEvent.click(await screen.findByRole('option', { name: 'admin, control-admin-1' }))
await waitFor(() =>
expect(navigation.replace).toHaveBeenCalledWith(
diff --git a/control-ui/components/__tests__/LlmProviderConfig.test.tsx b/control-ui/components/__tests__/LlmProviderConfig.test.tsx
index 545947ab1..903159bfb 100644
--- a/control-ui/components/__tests__/LlmProviderConfig.test.tsx
+++ b/control-ui/components/__tests__/LlmProviderConfig.test.tsx
@@ -280,7 +280,9 @@ describe('LlmProviderConfig (spec Topic 3a — per-host allowed-models subset)',
// The saved model stays selectable but the operator is warned it won't be offered.
expect(screen.getByText(/gpt-5\.4 isn.t in the models offered for OpenAI/i)).toBeInTheDocument()
fireEvent.click(screen.getByLabelText('Model', { selector: '#llm-primary-model' }))
- expect(screen.getByRole('option', { name: 'gpt-5.4' })).toHaveTextContent('out of allowlist')
+ expect(screen.getByRole('option', { name: 'gpt-5.4, out of allowlist' })).toHaveTextContent(
+ 'out of allowlist'
+ )
})
it('shows an allowed-models control for a fallback provider on a different provider', () => {
diff --git a/control-ui/components/__tests__/SelectionDropdown.accessible-name.test.tsx b/control-ui/components/__tests__/SelectionDropdown.accessible-name.test.tsx
new file mode 100644
index 000000000..0697943bc
--- /dev/null
+++ b/control-ui/components/__tests__/SelectionDropdown.accessible-name.test.tsx
@@ -0,0 +1,81 @@
+import { describe, expect, it, vi } from 'vitest'
+import { render, screen } from '@testing-library/react'
+import { SelectionDropdown } from '../SelectionDropdown'
+
+describe('SelectionDropdown accessible option names', () => {
+ it('uses the label when no badge is present', () => {
+ render(
+ <SelectionDropdown
+ inline
+ multiple={false}
+ onChange={vi.fn()}
+ options={[{ label: 'Alpha', value: 'alpha' }]}
+ placeholder="Choose"
+ searchable={false}
+ value={[]}
+ />
+ )
+
+ expect(screen.getByRole('option', { name: 'Alpha', exact: true })).toBeInTheDocument()
+ })
+
+ it('includes a distinct identifier badge in the accessible name', () => {
+ render(
+ <SelectionDropdown
+ inline
+ multiple={false}
+ onChange={vi.fn()}
+ options={[{ label: 'admin', badge: 'control-admin-1', value: 'admin' }]}
+ placeholder="Choose"
+ searchable={false}
+ value={[]}
+ />
+ )
+
+ expect(
+ screen.getByRole('option', { name: 'admin, control-admin-1', exact: true })
+ ).toBeInTheDocument()
+ })
+
+ it('includes a distinct status badge in the accessible name', () => {
+ render(
+ <SelectionDropdown
+ inline
+ multiple={false}
+ onChange={vi.fn()}
+ options={[{ label: 'gpt-5.4', badge: 'out of allowlist', value: 'gpt-5.4' }]}
+ placeholder="Choose"
+ searchable={false}
+ value={[]}
+ />
+ )
+
+ expect(
+ screen.getByRole('option', { name: 'gpt-5.4, out of allowlist', exact: true })
+ ).toBeInTheDocument()
+ })
+
+ it('does not repeat a badge that matches the label', () => {
+ render(
+ <SelectionDropdown
+ inline
+ multiple={false}
+ onChange={vi.fn()}
+ options={[
+ {
+ label: 'user-from-shared-url',
+ badge: 'user-from-shared-url',
+ value: 'user-from-shared-url',
+ },
+ ]}
+ placeholder="Choose"
+ searchable={false}
+ value={[]}
+ />
+ )
+
+ expect(
+ screen.getByRole('option', { name: 'user-from-shared-url', exact: true })
+ ).toBeInTheDocument()
+ })
+})
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 6211ee690..38b006aee 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.637",
+ "version": "0.1.638",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.637",
+ "version": "0.1.638",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/frontend-components": "file:../packages/frontend-components",
diff --git a/control-ui/package.json b/control-ui/package.json
index c76b4062b..894107594 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.637",
+ "version": "0.1.638",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",