Skip to content

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

TypeScript

fix(control-ui): wizard name-field error copy and slug-note a11y (review P2)

M396e4d65fa9a
diff --git a/control-ui/components/HostWizard/index.tsx b/control-ui/components/HostWizard/index.tsx
index b8241cb9e..5e6421210 100644
--- a/control-ui/components/HostWizard/index.tsx
+++ b/control-ui/components/HostWizard/index.tsx
@@ -1,6 +1,6 @@
'use client'
-import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
+import React, { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react'
import { validateDisplayField } from '@clerum/display-field'
import { CreateFlowPanel } from '@/components/CreateFlowPanel'
import { CreateStepFlow } from '@/components/CreateStepFlow'
@@ -176,7 +176,12 @@ 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))
+ const slug = toKebabCase(displayName)
+ // A non-empty name whose characters all strip out (e.g. "###" or a name with
+ // no Latin letters/digits) derives an empty slug — a distinct problem from a
+ // missing name, so it gets distinct copy instead of "is required".
+ if (!slug) return 'Add at least one letter or number so an identifier can be derived.'
+ return getAgentNameError(slug)
}
function isStepValid(stepIndex: number, state: HostWizardValidationState): boolean {
@@ -256,6 +261,9 @@ export function HostWizard({
// of being force-lowercased into the input while typing.
const derivedHostName = toKebabCase(hostName)
const agentNameError = agentStepError(hostName)
+ // Stable id for the slug-hint note so the input can point at it with
+ // aria-describedby (the note carries the error copy when invalid).
+ const slugNoteId = useId()
const [selectedMcp, setSelectedMcp] = useState<string[]>([])
@@ -856,6 +864,8 @@ export function HostWizard({
onChange={e => setHostName(e.target.value)}
placeholder="e.g. Support Bot"
autoFocus
+ aria-describedby={slugNoteId}
+ aria-invalid={hostName.trim() ? Boolean(agentNameError) : undefined}
/>
{hostName.trim() ? (
agentNameError ? (
@@ -879,7 +889,7 @@ export function HostWizard({
>
<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">
+ <span id={slugNoteId} className="cu-agent-slug-hint__note" aria-live="polite">
{hostName.trim() && agentNameError
? agentNameError
: 'Used in URLs, CLI, and grants. Lowercase letters, numbers, and hyphens.'}
diff --git a/control-ui/components/__tests__/HostWizard.test.tsx b/control-ui/components/__tests__/HostWizard.test.tsx
index 2dd79245c..89c4a85bd 100644
--- a/control-ui/components/__tests__/HostWizard.test.tsx
+++ b/control-ui/components/__tests__/HostWizard.test.tsx
@@ -600,21 +600,28 @@ describe('HostWizard — free-text agent name with derived identifier (TASK-230)
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: '###' },
- })
+ // No [a-z0-9] characters survive kebab-casing — the slug is empty. Review
+ // P2: a non-empty name must NOT read as "required"; it gets its own copy,
+ // surfaced through the aria-described slug note with aria-invalid set.
+ const input = screen.getByLabelText(/^Agent name/, { selector: 'input' })
+ fireEvent.change(input, { target: { value: '###' } })
expect(screen.getByRole('button', { name: 'Next' })).toBeDisabled()
+ expect(
+ screen.getByText(/add at least one letter or number so an identifier can be derived/i, {
+ selector: '.cu-agent-slug-hint__note',
+ })
+ ).toBeInTheDocument()
+ expect(input).toHaveAttribute('aria-invalid', 'true')
// A slug under the 3-character minimum is equally invalid.
- fireEvent.change(screen.getByLabelText(/^Agent name/, { selector: 'input' }), {
- target: { value: 'ab' },
- })
+ fireEvent.change(input, { target: { value: 'ab' } })
expect(screen.getByRole('button', { name: 'Next' })).toBeDisabled()
+ expect(
+ screen.getByText(/at least 3 characters/i, { selector: '.cu-agent-slug-hint__note' })
+ ).toBeInTheDocument()
- fireEvent.change(screen.getByLabelText(/^Agent name/, { selector: 'input' }), {
- target: { value: 'Support Bot' },
- })
+ fireEvent.change(input, { target: { value: 'Support Bot' } })
+ expect(input).toHaveAttribute('aria-invalid', 'false')
expect(screen.getByRole('button', { name: 'Next' })).toBeEnabled()
})
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index e87bc35a0..9877eade8 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.580",
+ "version": "0.1.581",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.580",
+ "version": "0.1.581",
"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 6c016c73b..ea964a647 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.580",
+ "version": "0.1.581",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",