Skip to content

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

TypeScript

feat(control-ui): derive the agent identifier from a free-text name in the create wizard (TASK-230)

M983721085b29
diff --git a/control-ui/app/globals.css b/control-ui/app/globals.css
index 3b55fa072..12aaa1644 100644
--- a/control-ui/app/globals.css
+++ b/control-ui/app/globals.css
@@ -6199,6 +6199,45 @@ td.cu-registry-description {
font-size: 0.8125rem;
}
+/* TASK-230: live preview of the identifier derived from the free-text agent
+ * name. Sits directly under the Agent name field in the create wizard. */
+.cu-agent-slug-hint {
+ display: grid;
+ grid-template-columns: auto 1fr;
+ gap: 0.15rem var(--cu-space-2);
+ align-items: baseline;
+ padding: var(--cu-space-2) var(--cu-space-3);
+ border: 1px solid var(--cu-border-subtle);
+ border-radius: var(--cu-radius-sm);
+ background: var(--cu-bg-elevated);
+}
+
+.cu-agent-slug-hint__label {
+ color: var(--cu-text-muted);
+ font-size: var(--cu-font-size-2xs);
+ font-weight: var(--cu-font-weight-semibold);
+ letter-spacing: 0.05em;
+ text-transform: uppercase;
+}
+
+.cu-agent-slug-hint__value {
+ color: var(--cu-text);
+ font-family: var(--cu-font-mono);
+ font-size: var(--cu-font-size-xs);
+ overflow-wrap: anywhere;
+}
+
+.cu-agent-slug-hint__note {
+ grid-column: 1 / -1;
+ color: var(--cu-text-soft);
+ font-size: var(--cu-font-size-xs);
+ line-height: var(--cu-line-height-normal);
+}
+
+.cu-agent-slug-hint[data-state='invalid'] .cu-agent-slug-hint__note {
+ color: var(--cu-warning);
+}
+
.cu-agent-section-label {
color: var(--cu-text-muted);
font-size: 0.8125rem;
diff --git a/control-ui/components/HostWizard/index.tsx b/control-ui/components/HostWizard/index.tsx
index 8932db25c..370f0d36b 100644
--- a/control-ui/components/HostWizard/index.tsx
+++ b/control-ui/components/HostWizard/index.tsx
@@ -1,6 +1,7 @@
'use client'
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
+import { validateDisplayField } from '@clerum/display-field'
import { CreateFlowPanel } from '@/components/CreateFlowPanel'
import { CreateStepFlow } from '@/components/CreateStepFlow'
import { LlmProviderConfig } from '@/components/LlmProviderConfig'
@@ -149,9 +150,23 @@ async function createOrThrow(path: string, body: unknown, collisionMessage: stri
}
}
+// Step 0 collects a free-text display name (`spec.host`) and derives the
+// immutable identifier (`metadata.name`) from it. Two validations apply:
+// - the DISPLAY name passes the shared display-field rule (control chars +
+// trimmed length, D4: same validator as control-api's write gate — the field
+// label is passed in so the issue text reads as wizard copy);
+// - the DERIVED slug passes the RFC1123 agent-name rule (3–63 chars, lowercase
+// alphanumerics + hyphens), because the slug is what reaches metadata.name.
+function agentStepError(displayName: string): string {
+ if (!displayName.trim()) return 'Agent name is required.'
+ const displayIssue = validateDisplayField(displayName, 'Agent name')
+ if (displayIssue) return displayIssue.message
+ return getAgentNameError(toKebabCase(displayName))
+}
+
function isStepValid(stepIndex: number, state: HostWizardValidationState): boolean {
if (stepIndex === 0)
- return state.hostName.trim().length > 0 && getAgentNameError(state.hostName) === ''
+ return state.hostName.trim().length > 0 && agentStepError(state.hostName) === ''
if (stepIndex === 1) {
if (!state.modelName.trim()) return false
if (
@@ -221,7 +236,11 @@ export function HostWizard({
const [hostName, setHostName] = useState('')
const hostNamespace = HOST_NAMESPACE
- const agentNameError = getAgentNameError(hostName)
+ // TASK-230: the operator types a free-text display name; the immutable
+ // metadata.name slug is derived from it (shown live under the field) instead
+ // of being force-lowercased into the input while typing.
+ const derivedHostName = toKebabCase(hostName)
+ const agentNameError = agentStepError(hostName)
const [selectedMcp, setSelectedMcp] = useState<string[]>([])
@@ -530,7 +549,7 @@ export function HostWizard({
const validationMessage = useMemo(() => {
if (step === 0) {
- const agentNameError = getAgentNameError(hostName)
+ const agentNameError = agentStepError(hostName)
if (agentNameError) return agentNameError
}
if (step === 1 && !modelName.trim()) return 'Model name is required.'
@@ -695,7 +714,10 @@ export function HostWizard({
: ''
const hostSpec: Record<string, unknown> = {
- host: normalizedHostName,
+ // Display name: the free text the operator typed (falls back to the
+ // slug only when the trimmed name is somehow empty). The slug lives in
+ // metadata.name below — the two are intentionally distinct now.
+ host: hostName.trim() || normalizedHostName,
contextRef: generatedContextName,
...(resolvedSecretRef ? { secretRef: resolvedSecretRef } : {}),
channels: [],
@@ -801,15 +823,17 @@ export function HostWizard({
{step === 0 && (
<div className="cu-form-stack cu-agent-form-stack">
<Field
- description="Automatically formatted to lowercase with hyphens."
- label="Agent metadata name"
+ description="The name members see. The identifier used in URLs is derived automatically."
+ htmlFor="wizard-agent-name"
+ label="Agent name"
required
>
<span className="cu-agent-input-shell">
<TextInput
+ id="wizard-agent-name"
value={hostName}
- onChange={e => setHostName(toKebabInput(e.target.value))}
- placeholder="agent-name"
+ onChange={e => setHostName(e.target.value)}
+ placeholder="e.g. Support Bot"
autoFocus
/>
{hostName.trim() ? (
@@ -828,6 +852,18 @@ export function HostWizard({
) : null}
</span>
</Field>
+ <div
+ className="cu-agent-slug-hint"
+ data-state={hostName.trim() ? (agentNameError ? 'invalid' : 'ready') : 'empty'}
+ >
+ <span className="cu-agent-slug-hint__label">Identifier</span>
+ <span className="cu-agent-slug-hint__value">{derivedHostName || 'agent-name'}</span>
+ <span className="cu-agent-slug-hint__note">
+ {hostName.trim() && agentNameError
+ ? agentNameError
+ : 'Used in URLs, CLI, and grants. Lowercase letters, numbers, and hyphens.'}
+ </span>
+ </div>
<div className="cu-agent-namespace">Namespace: {HOST_NAMESPACE}</div>
{SHOW_STATELESS_AGENT_SELECTOR ? (
<div className="cu-agent-access-section">
diff --git a/control-ui/components/__tests__/HostWizard.test.tsx b/control-ui/components/__tests__/HostWizard.test.tsx
index 763f14a4d..fdbf0b83d 100644
--- a/control-ui/components/__tests__/HostWizard.test.tsx
+++ b/control-ui/components/__tests__/HostWizard.test.tsx
@@ -1,6 +1,6 @@
import React from 'react'
import { afterEach, describe, expect, it, vi } from 'vitest'
-import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
+import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'
import * as api from '../../lib/api'
import {
buildHostReferencesForContext,
@@ -173,7 +173,7 @@ async function walkToAccessStep(opts?: { agentName?: string }) {
})
// Step 0: Agent name
- fireEvent.change(screen.getByPlaceholderText(/agent-name/i), {
+ fireEvent.change(screen.getByLabelText(/^Agent name/, { selector: 'input' }), {
target: { value: name },
})
fireEvent.click(screen.getByRole('button', { name: 'Next' }))
@@ -207,7 +207,9 @@ async function walkToAccessStepNewSecret(opts?: { agentName?: string }) {
})
// Step 0: Agent name
- fireEvent.change(screen.getByPlaceholderText(/agent-name/i), { target: { value: name } })
+ fireEvent.change(screen.getByLabelText(/^Agent name/, { selector: 'input' }), {
+ target: { value: name },
+ })
fireEvent.click(screen.getByRole('button', { name: 'Next' }))
// Step 1: New LLM Secret → make the OpenAI primary usable; its internal name auto-derives.
@@ -263,7 +265,9 @@ describe('HostWizard — credential draft is projected onto the active provider
})
await waitFor(() => expect(api.getAdminUsers).toHaveBeenCalled())
- fireEvent.change(screen.getByPlaceholderText(/agent-name/i), { target: { value: 'testagent' } })
+ fireEvent.change(screen.getByLabelText(/^Agent name/, { selector: 'input' }), {
+ target: { value: 'testagent' },
+ })
fireEvent.click(screen.getByRole('button', { name: 'Next' }))
fireEvent.click(screen.getByLabelText(/Use an existing LLM Secret/i))
fireEvent.click(screen.getByRole('button', { name: /Select LLM Secret/i }))
@@ -284,7 +288,9 @@ describe('HostWizard — credential draft is projected onto the active provider
})
await waitFor(() => expect(api.getAdminUsers).toHaveBeenCalled())
- fireEvent.change(screen.getByPlaceholderText(/agent-name/i), { target: { value: 'testagent' } })
+ fireEvent.change(screen.getByLabelText(/^Agent name/, { selector: 'input' }), {
+ target: { value: 'testagent' },
+ })
fireEvent.click(screen.getByRole('button', { name: 'Next' }))
fireEvent.click(screen.getByRole('button', { name: /Select LLM Secret/i }))
@@ -304,7 +310,9 @@ describe('HostWizard — credential draft is projected onto the active provider
await renderWizard()
await waitFor(() => expect(api.getAdminUsers).toHaveBeenCalled())
- fireEvent.change(screen.getByPlaceholderText(/agent-name/i), { target: { value: 'testagent' } })
+ fireEvent.change(screen.getByLabelText(/^Agent name/, { selector: 'input' }), {
+ target: { value: 'testagent' },
+ })
fireEvent.click(screen.getByRole('button', { name: 'Next' }))
const existingCard = screen.getByLabelText(/Use an existing LLM Secret/i).closest('label')
@@ -330,7 +338,7 @@ describe('HostWizard — credential draft is projected onto the active provider
await waitFor(() => expect(api.getAdminUsers).toHaveBeenCalled())
// Step 0: name.
- fireEvent.change(screen.getByPlaceholderText(/agent-name/i), {
+ fireEvent.change(screen.getByLabelText(/^Agent name/, { selector: 'input' }), {
target: { value: 'bedrock-orphan' },
})
fireEvent.click(screen.getByRole('button', { name: 'Next' }))
@@ -574,6 +582,61 @@ describe('HostWizard — Access precedes connector selection', () => {
})
})
+describe('HostWizard — free-text agent name with derived identifier (TASK-230)', () => {
+ it('preserves mixed case while typing and derives the RFC1123 identifier live', async () => {
+ await renderWizard()
+ await waitFor(() => expect(api.getAdminUsers).toHaveBeenCalled())
+
+ const input = screen.getByLabelText(/^Agent name/, { selector: 'input' })
+ fireEvent.change(input, { target: { value: 'Support Bot' } })
+
+ expect(input).toHaveValue('Support Bot')
+ expect(
+ screen.getByText('support-bot', { selector: '.cu-agent-slug-hint__value' })
+ ).toBeInTheDocument()
+ })
+
+ it('blocks Next when the derived identifier is not a valid RFC1123 slug', async () => {
+ await renderWizard()
+ await waitFor(() => expect(api.getAdminUsers).toHaveBeenCalled())
+
+ // No [a-z0-9] characters survive kebab-casing — the slug is empty.
+ fireEvent.change(screen.getByLabelText(/^Agent name/, { selector: 'input' }), {
+ target: { value: '###' },
+ })
+ expect(screen.getByRole('button', { name: 'Next' })).toBeDisabled()
+
+ // A slug under the 3-character minimum is equally invalid.
+ fireEvent.change(screen.getByLabelText(/^Agent name/, { selector: 'input' }), {
+ target: { value: 'ab' },
+ })
+ expect(screen.getByRole('button', { name: 'Next' })).toBeDisabled()
+
+ fireEvent.change(screen.getByLabelText(/^Agent name/, { selector: 'input' }), {
+ target: { value: 'Support Bot' },
+ })
+ expect(screen.getByRole('button', { name: 'Next' })).toBeEnabled()
+ })
+
+ it('writes the display name to spec.host and the derived slug to metadata.name', async () => {
+ await renderWizard()
+ await walkToAccessStep({ agentName: 'Support Bot' })
+ continueToConnectorsStep()
+ submitFromConnectorsStep()
+
+ await waitFor(() => {
+ expect(api.apiSend).toHaveBeenCalledWith(
+ 'POST',
+ '/api/v1/admin/hosts',
+ expect.objectContaining({
+ metadata: { name: 'support-bot' },
+ spec: expect.objectContaining({ host: 'Support Bot' }),
+ })
+ )
+ })
+ })
+})
+
describe('HostWizard — submit path uses the atomic agent-centric endpoints', () => {
it('creates an agent without access grants when no users or teams are selected', async () => {
await renderWizard()
@@ -701,15 +764,15 @@ describe('HostWizard — baseline render', () => {
expect(screen.getByText(/Create Agent/i)).toBeInTheDocument()
})
- it('starts on Step 0 (Agent metadata name)', async () => {
+ it('starts on Step 0 (Agent name)', async () => {
await renderWizard()
- expect(screen.getByPlaceholderText(/agent-name/i)).toBeInTheDocument()
+ expect(screen.getByLabelText(/^Agent name/, { selector: 'input' })).toBeInTheDocument()
})
it('shows Default model without Allowed models in Model & Credentials', async () => {
await renderWizard()
- fireEvent.change(screen.getByPlaceholderText(/agent-name/i), {
+ fireEvent.change(screen.getByLabelText(/^Agent name/, { selector: 'input' }), {
target: { value: 'default-model-agent' },
})
fireEvent.click(screen.getByRole('button', { name: 'Next' }))
@@ -918,7 +981,9 @@ async function walkToModelStep(opts?: { agentName?: string }) {
await waitFor(() => {
expect(api.getAdminUsers).toHaveBeenCalled()
})
- fireEvent.change(screen.getByPlaceholderText(/agent-name/i), { target: { value: name } })
+ fireEvent.change(screen.getByLabelText(/^Agent name/, { selector: 'input' }), {
+ target: { value: name },
+ })
fireEvent.click(screen.getByRole('button', { name: 'Next' }))
await waitFor(() => {
expect(
diff --git a/control-ui/e2e/qa-recorder-agent-create.spec.ts b/control-ui/e2e/qa-recorder-agent-create.spec.ts
index a6d825e1e..437e064f1 100644
--- a/control-ui/e2e/qa-recorder-agent-create.spec.ts
+++ b/control-ui/e2e/qa-recorder-agent-create.spec.ts
@@ -100,7 +100,7 @@ test.describe('optional QA recorder: Control UI agent creation', () => {
await expect(page).toHaveURL(/\/(?:hosts|agents)\/new$/)
await expect(page.getByRole('heading', { name: 'Create agent', exact: true })).toBeVisible()
- await page.getByPlaceholder('agent-name').fill(agentName)
+ await page.getByLabel('Agent name', { exact: true }).fill(agentName)
await clickWizardNext(page)
await expect(page.getByText('Model & credentials', { exact: true })).toBeVisible()
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index e13cd85d9..6e19a7ac7 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.575",
+ "version": "0.1.576",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.575",
+ "version": "0.1.576",
"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 80993b694..3d70dd5e1 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.575",
+ "version": "0.1.576",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",