Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
adapt(control-ui): align the Add provider picker with dev's SelectionDropdown pattern
Diego Zacariasc4f0a8fd49bc
diff --git a/control-ui/app/globals.css b/control-ui/app/globals.cssindex 57fb06168..dfe8eb39b 100644--- a/control-ui/app/globals.css+++ b/control-ui/app/globals.css@@ -6852,9 +6852,26 @@ textarea.cu-input {margin: 0;}-/* The "+ Add provider" picker of the additive editor. */-select.cu-input.cu-llm-cred-add {- max-width: 14rem;+/* The "Add provider" picker of the additive editor (a SelectionDropdown, so+ the width cap lands on its root element, not on a native <select>). The cap+ also bounds the popover menu, so it stays wide enough for the longest+ provider labels; inline mode (update modal) keeps the surface's full width. */+.cu-selection-dropdown.cu-llm-cred-add:not(.cu-selection-dropdown--inline) {+ max-width: 16rem;+}++/* The picker is a MENU (value is always empty): entries mount a provider+ section and vanish from the list, so the never-filled selection squares+ would read as 21 uncheckable checkboxes. */+.cu-llm-cred-add .cu-selection-dropdown__check {+ display: none;+}++/* The picker's Field is the last child of the editor's flex column, which+ already spaces children with its gap — drop the Field's own trailing+ margin so the editor doesn't end in dead space (visible in the modal). */+.cu-llm-cred-groups > .cu-field:last-child {+ margin-bottom: 0;}/* ── Host LLM config surface (spec Topic 1b, jury design C) ───────────────── */@@ -6951,8 +6968,13 @@ select.cu-input.cu-llm-cred-add {filter: brightness(0);}+/* OpenAI ships a white-on-transparent mark, so on light surfaces it needs to be+ knocked back to black. Scoped to the PROVIDER pickers only (the agents LLM+ provider select and the secrets "+ Add provider" picker) — the model+ dropdown reuses the same icon on a different treatment and must not inherit+ this. */:root[data-theme='light']- .cu-llm-config__provider-select+ :is(.cu-llm-config__provider-select, .cu-llm-cred-add).cu-llm-provider-icon[data-provider='openai']img {filter: brightness(0);diff --git a/control-ui/components/LlmCredentialFields/index.tsx b/control-ui/components/LlmCredentialFields/index.tsxindex 84105c7f6..56421a39a 100644--- a/control-ui/components/LlmCredentialFields/index.tsx+++ b/control-ui/components/LlmCredentialFields/index.tsx@@ -3,8 +3,11 @@import React, { useMemo, useRef, useState } from 'react'import Link from 'next/link'import { CONTROL_ROUTES } from '@constants/routes'+import { LlmProviderIcon } from '@/components/LlmProviderIcon'+import { SelectionDropdown } from '@/components/SelectionDropdown'+import type { SelectionDropdownOption } from '@/components/SelectionDropdown/types'import { IconX } from '@/components/icons'-import { Button, Field, SelectInput, TextAreaInput, TextInput } from '@/components/ui'+import { Button, Field, TextAreaInput, TextInput } from '@/components/ui'import { cn } from '@/lib/cn'import {LLM_CREDENTIAL_GROUPS,@@ -32,6 +35,10 @@ const DATA_KEY_PATTERN = /^[a-zA-Z0-9]([a-zA-Z0-9._-]*[a-zA-Z0-9])?$/// id already ends in a unique dataKey/slot id, so this is a fixed constant.const ID_PREFIX = 'llm-secret'+// Stable id for the "+ Add provider" picker so its <Field> label points at the+// dropdown's trigger button.+const ADD_PROVIDER_ID = `${ID_PREFIX}-add-provider`+// Every canonical (registry) slot dataKey across providers. An existing Secret// key outside this set is an operator-minted extra slot (`claude-api-key-fb1`).const CANONICAL_SLOT_KEYS: ReadonlySet<string> = new Set(@@ -85,6 +92,7 @@ export function LlmCredentialFields({onChange,disabled = false,existingKeys,+ pickerInline = false,}: LlmCredentialFieldsProps) {const [extraSlots, setExtraSlots] = useState<ExtraSlot[]>(() =>seedExistingExtraSlots(existingKeys)@@ -126,6 +134,15 @@ export function LlmCredentialFields({const visibleGroups = LLM_CREDENTIAL_GROUPS.filter(group => visibleProviders.has(group.provider))const addableGroups = LLM_CREDENTIAL_GROUPS.filter(group => !visibleProviders.has(group.provider))+ // The picker is a MENU, not a selection: it never holds a value (see the+ // `value={[]}` below), so each addable provider is just an entry with its+ // brand mark, mirroring the agents LLM provider selector.+ const addProviderOptions: SelectionDropdownOption[] = addableGroups.map(group => ({+ value: group.provider,+ label: group.label,+ icon: <LlmProviderIcon provider={group.provider} label={group.label} />,+ }))+// The full set of keys the form already knows (package slots + created extra// slots) — used to flag duplicate extra-slot names.const knownKeys = useMemo(() => {@@ -391,20 +408,27 @@ export function LlmCredentialFields({})}{addableGroups.length > 0 ? (- <SelectInput- className="cu-llm-cred-add"- value=""- onChange={event => addProvider(event.target.value)}- disabled={disabled}- aria-label="Add provider"- >- <option value="">+ Add provider…</option>- {addableGroups.map(group => (- <option key={group.provider} value={group.provider}>- {group.label}- </option>- ))}- </SelectInput>+ <Field htmlFor={ADD_PROVIDER_ID} label="Add provider">+ <SelectionDropdown+ id={ADD_PROVIDER_ID}+ className="cu-llm-cred-add"+ inline={pickerInline}+ // Always empty: picking a provider MOUNTS its section, it does not+ // leave the picker "holding" that provider — the entry disappears+ // from the options instead. Single-select closes the menu itself.+ value={[]}+ options={addProviderOptions}+ placeholder="Select a provider…"+ searchPlaceholder="Search providers…"+ selectionLabel="provider"+ multiple={false}+ showSelectedChips={false}+ disabled={disabled}+ onChange={next => {+ if (next[0]) addProvider(next[0])+ }}+ />+ </Field>) : null}</div>)diff --git a/control-ui/components/LlmCredentialFields/types.ts b/control-ui/components/LlmCredentialFields/types.tsindex 61284bf98..163f89e4d 100644--- a/control-ui/components/LlmCredentialFields/types.ts+++ b/control-ui/components/LlmCredentialFields/types.ts@@ -27,4 +27,8 @@ export type LlmCredentialFieldsProps = {// Keys already stored in the Secret (edit mode) — light up the present chips// without ever exposing a value. Create flows omit it.existingKeys?: string[]+ // Render the "Add provider" picker as an always-open inline list instead of a+ // popover. Scroll-clipped surfaces (the update modal) must set it — an+ // absolute-positioned menu would open below the modal's visible fold.+ pickerInline?: boolean}diff --git a/control-ui/components/LlmProviderConfig/index.tsx b/control-ui/components/LlmProviderConfig/index.tsxindex f62735a87..b3ee8122a 100644--- a/control-ui/components/LlmProviderConfig/index.tsx+++ b/control-ui/components/LlmProviderConfig/index.tsx@@ -1,9 +1,10 @@'use client'-import React, { useMemo } from 'react'+import { useMemo } from 'react'import Link from 'next/link'import { CONTROL_ROUTES } from '@constants/routes'import { LlmPolicyEditor } from '@/components/LlmPolicyEditor'+import { LlmProviderIcon } from '@/components/LlmProviderIcon'import { SelectionDropdown } from '@/components/SelectionDropdown'import type { SelectionDropdownOption } from '@/components/SelectionDropdown/types'import { Button, Field, TextAreaInput, TextInput } from '@/components/ui'@@ -34,22 +35,6 @@ import type { LlmCredentialWiring, LlmProviderConfigProps } from './types'// links to it, it never duplicates that editor (spec R4.5.4).const HOST_ENV_HREF = CONTROL_ROUTES.agents.root-function LlmProviderIcon({ provider, label }: { provider: LlmProvider; label: string }) {- const [failed, setFailed] = React.useState(false)-- React.useEffect(() => setFailed(false), [provider])-- return (- <span className="cu-llm-provider-icon" aria-hidden="true" data-provider={provider}>- {failed ? (- <span>{label.slice(0, 1).toUpperCase()}</span>- ) : (- <img src={`/provider-icons/${provider}.svg`} alt="" onError={() => setFailed(true)} />- )}- </span>- )-}-// A synthetic slot definition for a fallback's chosen extra credentialSlot when// that key is NOT one of the provider's canonical registry slots (e.g.// `claude-api-key-fb1`). Extra slots are always a single api-key-style value.diff --git a/control-ui/components/LlmProviderIcon/index.tsx b/control-ui/components/LlmProviderIcon/index.tsxnew file mode 100644index 000000000..35ed13ee2--- /dev/null+++ b/control-ui/components/LlmProviderIcon/index.tsx@@ -0,0 +1,30 @@+'use client'++import React from 'react'+import type { LlmProviderIconProps } from './types'++export type { LlmProviderIconProps } from './types'++/**+ * The provider brand mark used by every LLM provider picker (agents LLM config,+ * the additive secrets editor). Purely decorative — the option/button label+ * carries the accessible name — so the wrapper stays `aria-hidden`. When the SVG+ * under `/provider-icons/` is missing or fails to load it degrades to the+ * provider label's initial; the failure flag resets whenever the provider+ * changes so a recycled icon slot retries the new asset.+ */+export function LlmProviderIcon({ provider, label }: LlmProviderIconProps) {+ const [failed, setFailed] = React.useState(false)++ React.useEffect(() => setFailed(false), [provider])++ return (+ <span className="cu-llm-provider-icon" aria-hidden="true" data-provider={provider}>+ {failed ? (+ <span>{label.slice(0, 1).toUpperCase()}</span>+ ) : (+ <img src={`/provider-icons/${provider}.svg`} alt="" onError={() => setFailed(true)} />+ )}+ </span>+ )+}diff --git a/control-ui/components/LlmProviderIcon/types.ts b/control-ui/components/LlmProviderIcon/types.tsnew file mode 100644index 000000000..8d2e710be--- /dev/null+++ b/control-ui/components/LlmProviderIcon/types.ts@@ -0,0 +1,7 @@+import type { LlmProvider } from '@/lib/llm'++export type LlmProviderIconProps = {+ provider: LlmProvider+ // Rendered as the single-letter fallback when the provider SVG fails to load.+ label: string+}diff --git a/control-ui/components/SecretsTable.tsx b/control-ui/components/SecretsTable.tsxindex b7ac4bb8a..8e765802b 100644--- a/control-ui/components/SecretsTable.tsx+++ b/control-ui/components/SecretsTable.tsx@@ -920,6 +920,7 @@ export function SecretsTable({onChange={(dataKey, value) => setKeyDraft(prev => ({ ...prev, [dataKey]: value }))}existingKeys={editingKeys}disabled={saving}+ pickerInline/></div>diff --git a/control-ui/components/__tests__/LlmCredentialFields.test.tsx b/control-ui/components/__tests__/LlmCredentialFields.test.tsxindex 9a67141eb..d2677ada8 100644--- a/control-ui/components/__tests__/LlmCredentialFields.test.tsx+++ b/control-ui/components/__tests__/LlmCredentialFields.test.tsx@@ -29,10 +29,24 @@ function Harness({)}-const addProviderSelect = () => screen.getByLabelText('Add provider') as HTMLSelectElement+// The "+ Add provider" picker is a SelectionDropdown: its <Field> label names+// the trigger button, and the options only exist in the DOM while the menu is+// open (single-select closes it again as soon as one is picked).+const addProviderTrigger = () => screen.getByLabelText('Add provider')++function openAddProvider() {+ fireEvent.click(addProviderTrigger())+}++function providerLabel(provider: string): string {+ const group = LLM_CREDENTIAL_GROUPS.find(item => item.provider === provider)+ if (!group) throw new Error(`unknown provider in test: ${provider}`)+ return group.label+}function addProvider(provider: string) {- fireEvent.change(addProviderSelect(), { target: { value: provider } })+ openAddProvider()+ fireEvent.click(screen.getByRole('option', { name: providerLabel(provider) }))}// Provider sections are the only elements using this title class; option@@ -48,9 +62,18 @@ describe('LlmCredentialFields (additive provider editor)', () => {const { container } = render(<Harness />)expect(container.querySelectorAll('.cu-llm-cred-group')).toHaveLength(0)expect(screen.getByText(/No providers added yet/i)).toBeInTheDocument()- // Placeholder option + one option per provider in the shared package.- const options = within(addProviderSelect()).getAllByRole('option')- expect(options).toHaveLength(LLM_CREDENTIAL_GROUPS.length + 1)+ // One option per provider in the shared package (the dropdown has no+ // placeholder entry — the placeholder lives on the trigger button).+ openAddProvider()+ const options = screen.getAllByRole('option')+ expect(options).toHaveLength(LLM_CREDENTIAL_GROUPS.length)+ // Every entry carries its provider brand mark, keyed to the provider id.+ for (const group of LLM_CREDENTIAL_GROUPS) {+ const option = screen.getByRole('option', { name: group.label })+ expect(+ option.querySelector(`.cu-llm-provider-icon[data-provider="${group.provider}"]`)+ ).not.toBeNull()+ }})it('edit mode renders only the providers that already have a stored key', () => {@@ -65,7 +88,9 @@ describe('LlmCredentialFields (additive provider editor)', () => {render(<Harness />)addProvider('openai')expect(sectionTitle('OpenAI')).toBeInTheDocument()- expect(within(addProviderSelect()).queryByRole('option', { name: 'OpenAI' })).toBeNull()+ openAddProvider()+ expect(screen.queryByRole('option', { name: 'OpenAI' })).toBeNull()+ expect(screen.getByRole('option', { name: 'Anthropic' })).toBeInTheDocument()// The rest stays hidden.expect(sectionTitle('Anthropic')).toBeNull()})@@ -153,7 +178,8 @@ describe('LlmCredentialFields (additive provider editor)', () => {addProvider('openai')fireEvent.click(screen.getByRole('button', { name: 'Remove OpenAI provider' }))expect(sectionTitle('OpenAI')).toBeNull()- expect(within(addProviderSelect()).getByRole('option', { name: 'OpenAI' })).toBeInTheDocument()+ openAddProvider()+ expect(screen.getByRole('option', { name: 'OpenAI' })).toBeInTheDocument()})it('offers no remove control for a stored provider or one holding a typed value', () => {