Skip to content

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

TypeScript

feat(control-ui): standardize agent name editing

Josué0376bc833719
diff --git a/control-ui/components/HostOverviewTab/index.tsx b/control-ui/components/HostOverviewTab/index.tsx
index 35132a620..a52a7fd3d 100644
--- a/control-ui/components/HostOverviewTab/index.tsx
+++ b/control-ui/components/HostOverviewTab/index.tsx
@@ -1,6 +1,8 @@
import React from 'react'
+import { SingleValueEditDialog } from '@clerum/frontend-components'
import { IconRobot } from '../Sidebar/icons'
-import { IconCheck, IconPencil, IconX } from '../icons'
+import { IconPencil } from '../icons'
+import { Field, TextInput } from '../ui'
import type { HostOverviewTabProps, HostTabKey } from './types'
const DESCRIPTION_MAX_LENGTH = 100
@@ -103,17 +105,25 @@ export function HostOverviewTab({
}: HostOverviewTabProps) {
const shownName = displayName.trim() || hostName
const [savingName, setSavingName] = React.useState(false)
+ const [nameError, setNameError] = React.useState('')
+ const [nameValid, setNameValid] = React.useState(true)
const hasContext = Boolean(contextRef.trim())
const trimmedDescription = description.trim()
const shownDescription = truncateDescription(trimmedDescription) || 'No description provided.'
- async function saveName() {
- const nextName = nameDraft.trim()
+ async function saveName(value: string) {
+ const nextName = value.trim()
if (!nextName || savingName) return
setSavingName(true)
+ setNameError('')
try {
- await onSaveDisplayName(nextName)
+ const saved = await onSaveDisplayName(nextName)
+ if (!saved) {
+ setNameError(
+ 'Could not save the agent name. Review the page error, reload the agent, and re-apply your change.'
+ )
+ }
} finally {
setSavingName(false)
}
@@ -123,76 +133,40 @@ export function HostOverviewTab({
<div className="cu-host-overview">
<section className="cu-host-overview-identity" aria-label="Agent identity">
<div className="cu-host-overview-identity__name-row">
- {editingName ? (
- <div className="cu-host-overview-identity__name-editor">
+ <>
+ <div className="cu-host-overview-identity__name">
<span className="cu-host-overview-identity__icon" aria-hidden="true">
<IconRobot />
</span>
- <input
- className="cu-input cu-host-overview-identity__name-input"
- value={nameDraft}
- onChange={event => onNameDraftChange(event.target.value)}
- onKeyDown={event => {
- if (event.key === 'Enter') void saveName()
- if (event.key === 'Escape') onCancelNameEdit()
- }}
- aria-label="Agent name"
- disabled={savingName}
- autoFocus
- />
- <button
- type="button"
- className="cu-btn cu-btn--icon cu-btn--toolbar"
- onClick={() => void saveName()}
- disabled={savingName || !nameDraft.trim()}
- aria-label="Save agent name"
- title="Save agent name"
- >
- <IconCheck width={16} height={16} />
- </button>
+ {/* QA: while the identity data loads the name is a skeleton —
+ * never the slug fallback (same rule as the page title). */}
+ {loadingName ? (
+ <span
+ className="cu-skeleton cu-agent-detail-title-skeleton"
+ role="progressbar"
+ aria-label="Loading agent name"
+ />
+ ) : (
+ shownName
+ )}
+ </div>
+ {loadingName ? null : (
<button
type="button"
- className="cu-btn cu-btn--icon cu-btn--ghost"
- onClick={onCancelNameEdit}
+ className="cu-btn cu-btn--icon cu-btn--ghost cu-host-overview-identity__edit"
+ onClick={() => {
+ setNameError('')
+ setNameValid(true)
+ onStartNameEdit()
+ }}
disabled={savingName}
- aria-label="Cancel editing agent name"
- title="Cancel editing agent name"
+ aria-label="Edit agent name"
+ title="Edit agent name"
>
- <IconX width={16} height={16} />
+ <IconPencil width={16} height={16} />
</button>
- </div>
- ) : (
- <>
- <div className="cu-host-overview-identity__name">
- <span className="cu-host-overview-identity__icon" aria-hidden="true">
- <IconRobot />
- </span>
- {/* QA: while the identity data loads the name is a skeleton —
- * never the slug fallback (same rule as the page title). */}
- {loadingName ? (
- <span
- className="cu-skeleton cu-agent-detail-title-skeleton"
- role="progressbar"
- aria-label="Loading agent name"
- />
- ) : (
- shownName
- )}
- </div>
- {loadingName ? null : (
- <button
- type="button"
- className="cu-btn cu-btn--icon cu-btn--ghost cu-host-overview-identity__edit"
- onClick={onStartNameEdit}
- disabled={savingName}
- aria-label="Edit agent name"
- title="Edit agent name"
- >
- <IconPencil width={16} height={16} />
- </button>
- )}
- </>
- )}
+ )}
+ </>
</div>
<div
className="cu-host-overview-identity__description"
@@ -332,6 +306,40 @@ export function HostOverviewTab({
</div>
</section>
</div>
+
+ <SingleValueEditDialog
+ open={editingName}
+ initialValue={editingName ? nameDraft : shownName}
+ title="Edit agent name"
+ description="Change the display name without changing the agent slug or route."
+ pending={savingName}
+ error={nameError || undefined}
+ isValid={nameValid}
+ isEqual={value => value === shownName}
+ discardLabel="Cancel editing agent name"
+ saveLabel="Save agent name"
+ onDismiss={() => {
+ setNameError('')
+ onCancelNameEdit()
+ }}
+ onSave={value => void saveName(value)}
+ renderEditor={({ value, onChange, disabled }) => (
+ <Field label="Agent name" htmlFor="host-display-name" required>
+ <TextInput
+ id="host-display-name"
+ aria-label="Agent name"
+ value={value}
+ onChange={event => {
+ const nextValue = event.target.value
+ setNameValid(nextValue.trim().length > 0)
+ onNameDraftChange(nextValue)
+ onChange(nextValue)
+ }}
+ disabled={disabled}
+ />
+ </Field>
+ )}
+ />
</div>
)
}
diff --git a/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsx b/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsx
index 841ac780f..171adffac 100644
--- a/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsx
+++ b/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsx
@@ -179,6 +179,9 @@ async function openOverviewEdit() {
const overviewEditButton = await screen.findByRole('button', { name: 'Edit agent name' })
await waitFor(() => expect(overviewEditButton).toBeEnabled())
fireEvent.click(overviewEditButton)
+ fireEvent.change(screen.getByLabelText('Agent name'), {
+ target: { value: 'updated-display-name' },
+ })
}
function findHostPutPayload(): Record<string, unknown> {
diff --git a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx
index 0b40bd637..f332de8ac 100644
--- a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx
+++ b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx
@@ -473,10 +473,12 @@ describe('HostDetailsPage identity integration', () => {
expect(container.querySelector('.cu-agent-detail-card')).toBeNull()
})
- it('edits the agent name inline via one PUT without changing the agent slug', async () => {
+ it('edits the agent name in a scalar dialog via one PUT without changing the agent slug', async () => {
render(<HostDetailsPage />)
+ expect(screen.queryByLabelText('Agent name')).not.toBeInTheDocument()
fireEvent.click(await screen.findByRole('button', { name: 'Edit agent name' }))
+ expect(screen.getByRole('dialog', { name: 'Edit agent name' })).toBeInTheDocument()
const nameField = screen.getByLabelText('Agent name')
expect(nameField).toHaveValue('foo-display')
fireEvent.change(nameField, { target: { value: 'Product Agents' } })
@@ -498,7 +500,7 @@ describe('HostDetailsPage identity integration', () => {
expect(pushMock).not.toHaveBeenCalledWith('/agents/Product Agents')
})
- it('cancels an inline agent name edit without persisting the draft', async () => {
+ it('discards an agent-name dialog draft without persisting it', async () => {
render(<HostDetailsPage />)
fireEvent.click(await screen.findByRole('button', { name: 'Edit agent name' }))
@@ -507,6 +509,7 @@ describe('HostDetailsPage identity integration', () => {
})
fireEvent.click(screen.getByRole('button', { name: 'Cancel editing agent name' }))
+ expect(screen.queryByRole('dialog', { name: 'Edit agent name' })).not.toBeInTheDocument()
expect(screen.getByText('foo-display')).toBeInTheDocument()
expect(screen.queryByText('Discarded Draft')).not.toBeInTheDocument()
expect(api.apiSend).not.toHaveBeenCalled()
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 2f7f229cf..d7ae0683f 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.609",
+ "version": "0.1.610",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.609",
+ "version": "0.1.610",
"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 38857b5dc..71611322d 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.609",
+ "version": "0.1.610",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",