Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
feat(control-ui): editable display name for agents and contexts
Diego Zacarias280ea264ae4d
diff --git a/control-ui/app/contexts/[name]/page.tsx b/control-ui/app/contexts/[name]/page.tsxindex ed60c1555..374c8b198 100644--- a/control-ui/app/contexts/[name]/page.tsx+++ b/control-ui/app/contexts/[name]/page.tsx@@ -179,6 +179,7 @@ export default function ContextDetailsPage() {const [resolvedContextId, setResolvedContextId] = useState(isNew ? '' : routeName)const [contextNameDraft, setContextNameDraft] = useState(isNew ? '' : routeName)+ const [displayNameDraft, setDisplayNameDraft] = useState('')const [descriptionDraft, setDescriptionDraft] = useState('')const [mcpServersDraft, setMcpServersDraft] = useState<string[]>([])const [sharedFileSystemsDraft, setSharedFileSystemsDraft] = useState<@@ -191,6 +192,7 @@ export default function ContextDetailsPage() {const [editing, setEditing] = useState(isNew)const [savedDescription, setSavedDescription] = useState('')const [savedContextName, setSavedContextName] = useState('')+ const [savedDisplayName, setSavedDisplayName] = useState('')const [activeTab, setActiveTab] = useState<ContextTab>(() => parseContextTab(params.tab))@@ -271,6 +273,8 @@ export default function ContextDetailsPage() {setContextNameDraft(resolvedName)setSavedContextName(resolvedName)setResolvedContextId(resolvedContext)+ setDisplayNameDraft(spec.displayName || '')+ setSavedDisplayName(spec.displayName || '')setDescriptionDraft(spec.description || '')setSavedDescription(spec.description || '')const servers = Array.isArray(spec.mcpServers)@@ -366,7 +370,7 @@ export default function ContextDetailsPage() {.map(host => ({name: String(host.metadata?.name || '').trim(),contextRef: String(host.spec?.contextRef || '').trim(),- displayName: getAgentDisplayName(String(host.metadata?.name || '')),+ displayName: getAgentDisplayName(String(host.metadata?.name || ''), allHosts),})).filter(agent => agent.name && agent.contextRef !== resolvedContextId).sort((a, b) => a.displayName.localeCompare(b.displayName) || a.name.localeCompare(b.name)),@@ -387,21 +391,28 @@ export default function ContextDetailsPage() {function startEditing() {setSavedDescription(descriptionDraft)setSavedContextName(contextNameDraft)+ setSavedDisplayName(displayNameDraft)setEditing(true)}function cancelEditing() {setDescriptionDraft(savedDescription)setContextNameDraft(savedContextName)+ setDisplayNameDraft(savedDisplayName)setEditing(false)setError('')}async function save() {if (!canSave) return+ const trimmedDisplay = displayNameDraft.trim()+ // Full-replace safety: echo every spec field the form knows about+ // (identifier + all editables). The visible name lives in spec.displayName;+ // omit it when empty so an unset display stays absent, not "".const payload = {spec: {contextId: contextNameDraft.trim(),+ ...(trimmedDisplay ? { displayName: trimmedDisplay } : {}),description: descriptionDraft.trim(),mcpServers: mcpServersDraft,sharedFileSystems: sharedFileSystemsDraft,@@ -423,6 +434,7 @@ export default function ContextDetailsPage() {setResolvedContextId(payload.spec.contextId)setSavedDescription(descriptionDraft)setSavedContextName(contextNameDraft)+ setSavedDisplayName(trimmedDisplay)setEditing(false)}showToast('Context saved.', { tone: 'success' })@@ -440,6 +452,8 @@ export default function ContextDetailsPage() {await updateContext(routeName, {spec: {contextId: resolvedContextId,+ // Echo the persisted display name so a connector edit never drops it.+ ...(savedDisplayName.trim() ? { displayName: savedDisplayName.trim() } : {}),description: descriptionDraft.trim(),mcpServers: nextServers,sharedFileSystems: sharedFileSystemsDraft,@@ -461,6 +475,8 @@ export default function ContextDetailsPage() {await updateContext(routeName, {spec: {contextId: resolvedContextId,+ // Echo the persisted display name so an SFS edit never drops it.+ ...(savedDisplayName.trim() ? { displayName: savedDisplayName.trim() } : {}),description: descriptionDraft.trim(),mcpServers: mcpServersDraft,sharedFileSystems: nextRefs,@@ -789,7 +805,7 @@ export default function ContextDetailsPage() {header={<CreatePageHeadericon={<IconGroupWork />}- title={routeName}+ title={savedDisplayName.trim() || routeName}subtitle="Review details, manage connectors, agents, teams, and members."backLabel="Back to contexts"onBack={() => router.push(CONTROL_ROUTES.contexts.root)}@@ -1241,12 +1257,21 @@ export default function ContextDetailsPage() {<div className="cu-modal-panel__body"><div className="cu-field" style={{ marginBottom: 0 }}><label htmlFor="ctx-name">Name</label>+ <input id="ctx-name" className="cu-input" value={contextNameDraft} readOnly />+ <span className="cu-field__hint">+ This is the context identifier, not editable.+ </span>+ </div>+ <div className="cu-field" style={{ marginBottom: 0 }}>+ <label htmlFor="ctx-display">Display name</label><input- id="ctx-name"+ id="ctx-display"className="cu-input"- value={contextNameDraft}- disabled- style={{ opacity: 0.6 }}+ value={displayNameDraft}+ onChange={event => setDisplayNameDraft(event.target.value)}+ disabled={busy}+ placeholder="Human-readable name"+ autoFocus/></div><div className="cu-field" style={{ marginBottom: 0 }}>@@ -1259,7 +1284,6 @@ export default function ContextDetailsPage() {disabled={busy}rows={3}placeholder="Human-readable context description"- autoFocus/></div></div>diff --git a/control-ui/app/contexts/__tests__/ContextDetail.name.test.tsx b/control-ui/app/contexts/__tests__/ContextDetail.name.test.tsxnew file mode 100644index 000000000..30883217c--- /dev/null+++ b/control-ui/app/contexts/__tests__/ContextDetail.name.test.tsx@@ -0,0 +1,169 @@+import React from 'react'+import type { ReactNode } from 'react'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { cleanup, fireEvent, render as rtlRender, screen, waitFor } from '@testing-library/react'+import { ToastProvider } from '../../../components/Toast'+import * as api from '../../../lib/api'+import ContextDetailsPage from '../[name]/page'++const replaceMock = vi.fn()+const pushMock = vi.fn()+let mockParams: { name: string; tab?: string } = { name: 'prod-ctx' }++vi.mock('next/navigation', () => ({+ useParams: () => mockParams,+ usePathname: () => '/contexts/prod-ctx',+ useRouter: () => ({ push: pushMock, replace: replaceMock }),+ useSearchParams: () => new URLSearchParams(),+}))++// Render the frame as a passthrough so the form is the unit under test.+vi.mock('../../../components/DashboardLayout', () => ({+ DashboardLayout: ({ children }: { children: ReactNode }) => <div>{children}</div>,+}))++vi.mock('../../../lib/api', () => ({+ apiSend: vi.fn().mockResolvedValue({}),+ createContext: vi.fn().mockResolvedValue({}),+ deleteContext: vi.fn().mockResolvedValue({}),+ getAdminTeamContexts: vi.fn().mockResolvedValue({ contextIds: [] }),+ getAdminTeams: vi.fn().mockResolvedValue({ items: [] }),+ getAdminUserContexts: vi.fn().mockResolvedValue({ contextIds: [] }),+ getAdminUsers: vi.fn().mockResolvedValue({ items: [] }),+ getContext: vi.fn(),+ getContextTeams: vi.fn().mockResolvedValue({ items: [] }),+ getContextUsers: vi.fn().mockResolvedValue({ items: [] }),+ getHosts: vi.fn().mockResolvedValue({ items: [] }),+ getMcpServers: vi.fn().mockResolvedValue({ items: [] }),+ getSharedFileSystems: vi.fn().mockResolvedValue({ items: [] }),+ updateAdminTeamContexts: vi.fn().mockResolvedValue({}),+ updateAdminUserContexts: vi.fn().mockResolvedValue({}),+ updateContext: vi.fn().mockResolvedValue({}),+}))++type TestContext = {+ metadata: { name: string }+ spec: Record<string, unknown>+}++function mockContext(ctx: TestContext) {+ ;(api.getContext as unknown as ReturnType<typeof vi.fn>).mockResolvedValue(ctx)+}++function render(children: ReactNode) {+ return rtlRender(<ToastProvider>{children}</ToastProvider>)+}++async function openEditModal() {+ fireEvent.click(await screen.findByRole('button', { name: 'Context actions' }))+ fireEvent.click(screen.getByRole('menuitem', { name: 'Edit context' }))+}++afterEach(() => {+ cleanup()+})++describe('ContextDetailsPage display name (UT-10)', () => {+ beforeEach(() => {+ vi.clearAllMocks()+ mockParams = { name: 'prod-ctx' }+ })++ it('shows a readonly identifier and edits the display name via a single PUT (no cascade)', async () => {+ mockContext({+ metadata: { name: 'prod-ctx' },+ spec: {+ contextId: 'prod-ctx',+ description: 'Original description',+ mcpServers: ['srv-a'],+ displayName: 'Prod Ctx',+ },+ })++ render(<ContextDetailsPage />)++ // The visible name (display) is shown in the header.+ expect(await screen.findByText('Prod Ctx')).toBeInTheDocument()++ await openEditModal()++ // Identifier is present but readonly, with a hint.+ const nameField = screen.getByLabelText('Name')+ expect(nameField).toHaveAttribute('readonly')+ expect(nameField).toHaveValue('prod-ctx')+ expect(screen.getByText(/identifier, not editable/i)).toBeInTheDocument()++ // The display name is the editable field, seeded from spec.displayName.+ const displayField = screen.getByLabelText('Display name')+ expect(displayField).toHaveValue('Prod Ctx')+ fireEvent.change(displayField, { target: { value: 'Prod Ctx 2' } })++ fireEvent.click(screen.getByRole('button', { name: 'Save' }))++ await waitFor(() => expect(api.updateContext).toHaveBeenCalled())+ const [name, payload] = (api.updateContext as unknown as ReturnType<typeof vi.fn>).mock+ .calls[0] as [string, { spec: Record<string, unknown> }]+ // Identifier / contextId untouched; the PUT targets the same slug.+ expect(name).toBe('prod-ctx')+ expect(payload.spec.contextId).toBe('prod-ctx')+ // Full-replace safety: the spec echoes its other fields, not just displayName.+ expect(payload.spec.displayName).toBe('Prod Ctx 2')+ expect(payload.spec.mcpServers).toEqual(['srv-a'])++ // No cascade: hosts are never re-written to chase a rename.+ expect(api.apiSend).not.toHaveBeenCalledWith(+ 'PUT',+ expect.stringContaining('/api/v1/admin/hosts/'),+ expect.anything()+ )+ expect(await screen.findByText('Context saved.')).toBeInTheDocument()+ })++ it('still saves the description through the same PUT', async () => {+ mockContext({+ metadata: { name: 'prod-ctx' },+ spec: {+ contextId: 'prod-ctx',+ description: 'Original description',+ mcpServers: [],+ displayName: 'Prod Ctx',+ },+ })++ render(<ContextDetailsPage />)+ await screen.findByText('Prod Ctx')+ await openEditModal()++ fireEvent.change(screen.getByLabelText('Description'), {+ target: { value: 'Updated description' },+ })+ fireEvent.click(screen.getByRole('button', { name: 'Save' }))++ await waitFor(() => expect(api.updateContext).toHaveBeenCalled())+ const [, payload] = (api.updateContext as unknown as ReturnType<typeof vi.fn>).mock+ .calls[0] as [string, { spec: Record<string, unknown> }]+ expect(payload.spec.description).toBe('Updated description')+ expect(payload.spec.contextId).toBe('prod-ctx')+ })++ it('falls back to metadata.name when spec.displayName is absent (the only fallback)', async () => {+ mockContext({+ metadata: { name: 'prod-ctx' },+ spec: {+ contextId: 'prod-ctx',+ description: '',+ mcpServers: [],+ // no displayName+ },+ })++ render(<ContextDetailsPage />)++ // With no display name, the identifier is shown as the visible name.+ expect(await screen.findByText('prod-ctx')).toBeInTheDocument()++ await openEditModal()+ // The display name field is empty (ready to be filled), not the slug.+ expect(screen.getByLabelText('Display name')).toHaveValue('')+ })+})diff --git a/control-ui/app/contexts/new/page.tsx b/control-ui/app/contexts/new/page.tsxindex 6d47b9a5b..c45915190 100644--- a/control-ui/app/contexts/new/page.tsx+++ b/control-ui/app/contexts/new/page.tsx@@ -12,7 +12,7 @@ import { IconGroupWork } from '@components/Sidebar/icons'import { Button, Field, TextAreaInput, TextInput } from '@components/ui'import { CONTROL_ROUTES } from '@constants/routes'import { createContext, getMcpServers } from '@lib/api'-import { toKebabCase, toKebabInput } from '@lib/string'+import { toKebabCase } from '@lib/string'const STEPS = ['Context', 'Connectors'] as const@@ -85,10 +85,14 @@ export default function CreateContextPage() {setError('')try {const nextName = toKebabCase(contextName)+ const trimmedDisplay = contextName.trim()await createContext({metadata: { name: nextName },spec: {contextId: nextName,+ // Store the free-text name the user typed as the visible display name;+ // metadata.name/contextId stay the derived RFC1123 slug.+ ...(trimmedDisplay ? { displayName: trimmedDisplay } : {}),description: description.trim(),mcpServers: selectedServers,},@@ -131,11 +135,16 @@ export default function CreateContextPage() {<TextInputid="ctx-name"value={contextName}- onChange={event => setContextName(toKebabInput(event.target.value))}+ onChange={event => setContextName(event.target.value)}disabled={busy}- placeholder="context1"+ placeholder="Context 1"autoFocus/>+ {toKebabCase(contextName) ? (+ <span className="cu-field__hint">+ Identifier: <code>{toKebabCase(contextName)}</code>+ </span>+ ) : null}</Field><Field label="Description" htmlFor="ctx-description">diff --git a/control-ui/app/globals.css b/control-ui/app/globals.cssindex 013e7dda3..83bc9ab72 100644--- a/control-ui/app/globals.css+++ b/control-ui/app/globals.css@@ -7944,6 +7944,14 @@ textarea.cu-input {font-size: 0.8125rem;}+/* Secondary identity line under a primary display name (e.g. the immutable+ slug shown beneath an agent's editable display name). */+.cu-table__cell-subtle {+ color: var(--cu-text-muted);+ font-size: 0.75rem;+ margin-top: 0.125rem;+}+.cu-table__cell-numeric {color: var(--cu-text-muted);font-variant-numeric: tabular-nums;diff --git a/control-ui/app/hosts/[name]/page.tsx b/control-ui/app/hosts/[name]/page.tsxindex 6729e08c6..39ec085dd 100644--- a/control-ui/app/hosts/[name]/page.tsx+++ b/control-ui/app/hosts/[name]/page.tsx@@ -15,7 +15,6 @@ import { LlmProviderConfig } from '../../../components/LlmProviderConfig'import { IconRobot } from '../../../components/Sidebar/icons'import { IconCheck, IconPencil, IconX } from '../../../components/icons'import {- apiGet,apiSend,getAdminTeamAgents,getAdminUserAgents,@@ -46,7 +45,7 @@ import {validateLlmPolicy,validateLlmSecretData,} from '../../../lib/llm'-import type { ChannelResource, HostTab } from './types'+import type { HostTab } from './types'const TAB_LABELS: Record<HostTab, string> = {details: 'Overview',@@ -200,7 +199,6 @@ export default function HostDetailsPage() {})),[allTeams, teamIdsWithAccess])- const hasPendingRename = hostNameDraft.trim() && hostNameDraft.trim() !== routeNameconst providerModelOptions = useMemo(() => getModelOptions(allowedCatalog, providerDraft),[allowedCatalog, providerDraft]@@ -426,142 +424,6 @@ export default function HostDetailsPage() {: {}),}- if (nextHostName !== routeName) {- let createdNewHost = false- const updatedChannels: Array<{ name: string; previousSpec: ChannelResource['spec'] }> = []- const previousUserAgentNamesById = new Map<string, string[]>()- const previousTeamAgentNamesById = new Map<string, string[]>()- try {- await apiSend('POST', '/api/v1/admin/hosts', {- metadata: { name: nextHostName },- spec: nextSpec,- })- createdNewHost = true-- const channels = (await apiGet('/api/v1/admin/communication-channels')) as {- items?: ChannelResource[]- }- for (const channel of channels.items || []) {- if (String(channel.spec?.hostRef || '').trim() !== routeName) continue- const channelName = String(channel.metadata?.name || '').trim()- if (!channelName) continue- await apiSend(- 'PUT',- `/api/v1/admin/communication-channels/${encodeURIComponent(channelName)}`,- {- spec: {- ...(channel.spec || {}),- hostRef: nextHostName,- },- }- )- updatedChannels.push({ name: channelName, previousSpec: channel.spec })- }-- for (const user of usersWithAccess) {- const userAccess = await getAdminUserAgents(user.id)- const previousAgentNames = (userAccess.agentNames || [])- .map(String)- .map(v => v.trim())- .filter(Boolean)- previousUserAgentNamesById.set(user.id, previousAgentNames)- const nextAgentNames = Array.from(- new Set(previousAgentNames.map(name => (name === routeName ? nextHostName : name)))- )- await updateAdminUserAgents(user.id, nextAgentNames, [- ...(userAccess.agentNames || []),- ...(userAccess.deletedAgentNames || []),- ])- }-- for (const team of teamsWithAccess) {- const teamAccess = await getAdminTeamAgents(team.id)- const previousAgentNames = (teamAccess.agentNames || [])- .map(String)- .map(v => v.trim())- .filter(Boolean)- previousTeamAgentNamesById.set(team.id, previousAgentNames)- const nextAgentNames = Array.from(- new Set(previousAgentNames.map(name => (name === routeName ? nextHostName : name)))- )- await updateAdminTeamAgents(team.id, nextAgentNames, [- ...(teamAccess.agentNames || []),- ...(teamAccess.deletedAgentNames || []),- ])- }-- await apiSend('DELETE', `/api/v1/admin/hosts/${encodeURIComponent(routeName)}`)- showToast('Agent renamed and updated.', { tone: 'success' })- router.replace(CONTROL_ROUTES.agents.detail(nextHostName))- return true- } catch (renameError) {- const rollbackErrors: string[] = []- if (createdNewHost) {- for (const [teamId, previousAgentNames] of Array.from(- previousTeamAgentNamesById.entries()- ).reverse()) {- try {- const current = await getAdminTeamAgents(teamId)- await updateAdminTeamAgents(teamId, previousAgentNames, [- ...(current.agentNames || []),- ...(current.deletedAgentNames || []),- ])- } catch (rollbackError) {- const rollbackMessage =- rollbackError instanceof Error ? rollbackError.message : 'unknown rollback error'- rollbackErrors.push(`team ${teamId}: ${rollbackMessage}`)- }- }- for (const [userId, previousAgentNames] of Array.from(- previousUserAgentNamesById.entries()- ).reverse()) {- try {- const current = await getAdminUserAgents(userId)- await updateAdminUserAgents(userId, previousAgentNames, [- ...(current.agentNames || []),- ...(current.deletedAgentNames || []),- ])- } catch (rollbackError) {- const rollbackMessage =- rollbackError instanceof Error ? rollbackError.message : 'unknown rollback error'- rollbackErrors.push(`member ${userId}: ${rollbackMessage}`)- }- }- for (const channel of [...updatedChannels].reverse()) {- try {- await apiSend(- 'PUT',- `/api/v1/admin/communication-channels/${encodeURIComponent(channel.name)}`,- {- spec: {- ...(channel.previousSpec || {}),- hostRef: routeName,- },- }- )- } catch (rollbackError) {- const rollbackMessage =- rollbackError instanceof Error ? rollbackError.message : 'unknown rollback error'- rollbackErrors.push(`channel ${channel.name}: ${rollbackMessage}`)- }- }- try {- await apiSend('DELETE', `/api/v1/admin/hosts/${encodeURIComponent(nextHostName)}`)- } catch (rollbackError) {- const rollbackMessage =- rollbackError instanceof Error ? rollbackError.message : 'unknown rollback error'- rollbackErrors.push(`agent ${nextHostName}: ${rollbackMessage}`)- }- }- if (rollbackErrors.length > 0) {- const renameMessage =- renameError instanceof Error ? renameError.message : 'Failed to rename agent'- throw new Error(`${renameMessage} (rollback issues: ${rollbackErrors.join('; ')})`)- }- throw renameError- }- }-const formResourceVersion = formResourceVersionRef.currentawait apiSend('PUT', `/api/v1/admin/hosts/${encodeURIComponent(routeName)}`, {// AP-6: carry the resourceVersion captured at form load so the API@@ -776,7 +638,7 @@ export default function HostDetailsPage() {)async function grantUserAccess() {- if (selectedUserIdsToGrant.length === 0 || hasPendingRename) return+ if (selectedUserIdsToGrant.length === 0) returnsetBusy(true)setError('')try {@@ -809,7 +671,6 @@ export default function HostDetailsPage() {}async function revokeUserAccess(userId: string) {- if (hasPendingRename) returnconst user = usersWithAccess.find(item => item.id === userId)const shouldRevoke = await confirm({title: 'Revoke Member Access',@@ -842,7 +703,7 @@ export default function HostDetailsPage() {}async function grantTeamAccess() {- if (selectedTeamIdsToGrant.length === 0 || hasPendingRename) return+ if (selectedTeamIdsToGrant.length === 0) returnsetBusy(true)setError('')try {@@ -875,7 +736,6 @@ export default function HostDetailsPage() {}async function revokeTeamAccess(teamId: string) {- if (hasPendingRename) returnconst team = teamsWithAccess.find(item => item.id === teamId)const shouldRevoke = await confirm({title: 'Revoke Team Access',@@ -928,13 +788,6 @@ export default function HostDetailsPage() {backLabel="Back to agents"error={error}icon={<IconRobot />}- notice={- hasPendingRename ? (- <div className="cu-banner cu-banner--warning">- Save agent rename before changing user or team access.- </div>- ) : null- }onBack={() => router.push(CONTROL_ROUTES.agents.root)}onTabChange={selectTab}subtitle="Configuration and access for this agent."@@ -1016,16 +869,29 @@ export default function HostDetailsPage() {<div className="cu-form-stack"><div className="cu-field"><label htmlFor="host-name">Name</label>+ {editingOverview ? (+ <>+ <input id="host-name" value={hostNameDraft} readOnly />+ <span className="cu-field__hint">+ This is the agent identifier, not editable.+ </span>+ </>+ ) : (+ <div className="cu-field__readonly">{hostNameDraft}</div>+ )}+ </div>+ <div className="cu-field">+ <label htmlFor="host-display">Display name</label>{editingOverview ? (<input- id="host-name"- value={hostNameDraft}- onChange={e => setHostNameDraft(e.target.value)}+ id="host-display"+ value={hostDisplayDraft}+ onChange={e => setHostDisplayDraft(e.target.value)}disabled={busy}autoFocus/>) : (- <div className="cu-field__readonly">{hostNameDraft}</div>+ <div className="cu-field__readonly">{hostDisplayDraft}</div>)}</div><div className="cu-field" style={{ marginBottom: 0 }}>@@ -1375,7 +1241,7 @@ export default function HostDetailsPage() {type="button"className="cu-btn cu-btn--primary cu-btn--sm"onClick={() => setShowAddUser(true)}- disabled={busy || hasPendingRename}+ disabled={busy}>Add member</button>@@ -1425,7 +1291,7 @@ export default function HostDetailsPage() {type="button"className="cu-btn cu-btn--icon cu-btn--danger-icon"onClick={() => void revokeUserAccess(user.id)}- disabled={busy || hasPendingRename}+ disabled={busy}title="Revoke"aria-label="Revoke member access">@@ -1461,7 +1327,7 @@ export default function HostDetailsPage() {type="button"className="cu-btn cu-btn--primary cu-btn--sm"onClick={() => setShowAddTeam(true)}- disabled={busy || hasPendingRename}+ disabled={busy}>Add team</button>@@ -1511,7 +1377,7 @@ export default function HostDetailsPage() {type="button"className="cu-btn cu-btn--icon cu-btn--danger-icon"onClick={() => void revokeTeamAccess(team.id)}- disabled={busy || hasPendingRename}+ disabled={busy}title="Revoke"aria-label="Revoke team access">@@ -1578,7 +1444,7 @@ export default function HostDetailsPage() {searchPlaceholder="Search members..."selectionLabel="Selected members"emptyLabel="No available members."- disabled={busy || hasPendingRename}+ disabled={busy}/></div>@@ -1598,7 +1464,7 @@ export default function HostDetailsPage() {await grantUserAccess()setShowAddUser(false)}}- disabled={busy || selectedUserIdsToGrant.length === 0 || hasPendingRename}+ disabled={busy || selectedUserIdsToGrant.length === 0}>{selectedUserIdsToGrant.length > 1 ? 'Add members' : 'Add member'}</button>@@ -1657,7 +1523,7 @@ export default function HostDetailsPage() {searchPlaceholder="Search teams..."selectionLabel="Selected teams"emptyLabel="No available teams."- disabled={busy || hasPendingRename}+ disabled={busy}/></div>@@ -1677,7 +1543,7 @@ export default function HostDetailsPage() {await grantTeamAccess()setShowAddTeam(false)}}- disabled={busy || selectedTeamIdsToGrant.length === 0 || hasPendingRename}+ disabled={busy || selectedTeamIdsToGrant.length === 0}>{selectedTeamIdsToGrant.length > 1 ? 'Add teams' : 'Add team'}</button>diff --git a/control-ui/app/profile-admin/teams/[teamId]/page.tsx b/control-ui/app/profile-admin/teams/[teamId]/page.tsxindex 693588f56..812092999 100644--- a/control-ui/app/profile-admin/teams/[teamId]/page.tsx+++ b/control-ui/app/profile-admin/teams/[teamId]/page.tsx@@ -580,10 +580,10 @@ export default function TeamDetailsPage() {.filter(agentName => !assignedAgentNames.includes(agentName)).map(agentName => ({value: agentName,- label: getAgentDisplayName(agentName),+ label: getAgentDisplayName(agentName, hosts),description: agentName,})),- [assignedAgentNames, hostNameOptions]+ [assignedAgentNames, hostNameOptions, hosts])useEffect(() => {diff --git a/control-ui/app/profile-admin/teams/new/page.tsx b/control-ui/app/profile-admin/teams/new/page.tsxindex 5c93f139f..590fa0f2b 100644--- a/control-ui/app/profile-admin/teams/new/page.tsx+++ b/control-ui/app/profile-admin/teams/new/page.tsx@@ -140,7 +140,7 @@ export default function CreateTeamPage() {.sort((a, b) => a.localeCompare(b)).map(agentName => ({value: agentName,- label: getAgentDisplayName(agentName),+ label: getAgentDisplayName(agentName, hosts),description: agentName,})),[hosts]diff --git a/control-ui/app/profile-admin/users/[userId]/page.tsx b/control-ui/app/profile-admin/users/[userId]/page.tsxindex 0e4017a0f..e894c1f85 100644--- a/control-ui/app/profile-admin/users/[userId]/page.tsx+++ b/control-ui/app/profile-admin/users/[userId]/page.tsx@@ -166,10 +166,10 @@ export default function UserDetailsPage() {.filter(agentName => !assignedAgentNames.includes(agentName)).map(agentName => ({value: agentName,- label: getAgentDisplayName(agentName),+ label: getAgentDisplayName(agentName, hosts),description: agentName,})),- [assignedAgentNames, hostNameOptions]+ [assignedAgentNames, hostNameOptions, hosts])const userCommunicationConversations = useMemo(() =>diff --git a/control-ui/components/ContextTable.tsx b/control-ui/components/ContextTable.tsxindex 7bece2246..2211a4c63 100644--- a/control-ui/components/ContextTable.tsx+++ b/control-ui/components/ContextTable.tsx@@ -45,18 +45,21 @@ export function ContextTable({() =>items.map(item => {const name = item.metadata?.name || 'unknown'+ // Visible name is the optional spec.displayName; fall back to the slug+ // (metadata.name) when it is absent — the single justified fallback.+ const displayName = item.spec?.displayName ?? nameconst key = nameconst mcpServers = Array.isArray(item.spec?.mcpServers) ? item.spec?.mcpServers : []- return { key, name, item, mcpServers }+ return { key, name, displayName, item, mcpServers }}),[items])const normalizedSearch = searchQuery.trim().toLowerCase()const filteredRows = useMemo(() => {if (!normalizedSearch) return rows- return rows.filter(({ name, item, mcpServers }) => {+ return rows.filter(({ name, displayName, item, mcpServers }) => {const description = String(item.spec?.description || '').trim()- return [name, description, String(mcpServers.length), ...mcpServers.map(String)]+ return [name, displayName, description, String(mcpServers.length), ...mcpServers.map(String)].join(' ').toLowerCase().includes(normalizedSearch)@@ -137,7 +140,7 @@ export function ContextTable({<TableHeaderRow columns={CONTEXT_COLUMNS} /></thead><tbody>- {filteredRows.map(({ key, name, item, mcpServers }) => (+ {filteredRows.map(({ key, name, displayName, item, mcpServers }) => (<trkey={key}className="cu-table__row cu-table__row--clickable"@@ -156,8 +159,11 @@ export function ContextTable({}}onKeyDown={event => event.stopPropagation()}>- {name}+ {displayName}</button>+ {displayName !== name ? (+ <div className="cu-table__cell-subtle">{name}</div>+ ) : null}</td><td style={{ color: 'var(--cu-text-soft)', maxWidth: '28rem' }}><span style={{ display: 'inline-block', verticalAlign: 'top' }}>diff --git a/control-ui/components/HostTable.tsx b/control-ui/components/HostTable.tsxindex 706c4808e..f89b10672 100644--- a/control-ui/components/HostTable.tsx+++ b/control-ui/components/HostTable.tsx@@ -90,15 +90,20 @@ export function HostTable({items.map(i => {const namespace = i.metadata?.namespace || 'default'const name = i.metadata?.name || 'unknown'+ // The visible name is the editable spec.host; the slug (metadata.name)+ // stays as secondary identity. Empty-after-trim falls back to the slug+ // (legacy Hosts, mirrors accessReconciliation), never a blank label.+ const displayName =+ String((i.spec as { host?: string } | undefined)?.host || '').trim() || nameconst key = `${namespace}/${name}`- return { key, namespace, name, item: i }+ return { key, namespace, name, displayName, item: i }}),[items])const normalizedSearch = searchQuery.trim().toLowerCase()const filteredRows = useMemo(() => {if (!normalizedSearch) return rows- return rows.filter(({ name, namespace, item }) => {+ return rows.filter(({ name, displayName, namespace, item }) => {const spec = item.spec || {}const lifecycle = getHostLifecycleInfo(item)const contextRef = String(spec.contextRef || '').trim()@@ -109,6 +114,7 @@ export function HostTable({const modelProviderLabel = modelProvider ? getProviderLabel(modelProvider) : ''return [name,+ displayName,namespace,lifecycle.label,lifecycle.state,@@ -186,7 +192,7 @@ export function HostTable({<TableHeaderRow columns={HOST_COLUMNS} /></thead><tbody>- {filteredRows.map(({ key, namespace, name, item }) => {+ {filteredRows.map(({ key, namespace, name, displayName, item }) => {const rawContext = String(item.spec?.contextRef || '').trim()const contextRef = rawContext || '-'const contextClickable = Boolean(rawContext)@@ -227,8 +233,11 @@ export function HostTable({}}onKeyDown={e => e.stopPropagation()}>- {name}+ {displayName}</button>+ {displayName !== name ? (+ <div className="cu-table__cell-subtle">{name}</div>+ ) : null}</td><td><HostLifecycleBadge lifecycle={lifecycle} />diff --git a/control-ui/components/HostWizard/index.tsx b/control-ui/components/HostWizard/index.tsxindex 4a2864523..a1b1ab923 100644--- a/control-ui/components/HostWizard/index.tsx+++ b/control-ui/components/HostWizard/index.tsx@@ -895,7 +895,9 @@ export function HostWizard({)const hostSpec: Record<string, unknown> = {- host: normalizedHostName,+ // Visible name is the free text the operator typed; metadata.name and+ // every reference (channels.hostRef, access grants) use the derived slug.+ host: hostName.trim() || normalizedHostName,contextRef: resolvedContextName,secretRef: secretMode === 'existing' ? existingSecret : normalizedSecretName,channels: channelRefs,@@ -984,14 +986,14 @@ 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="Type any name — the identifier is derived automatically."+ label="Agent name"required><span className="cu-agent-input-shell"><TextInputvalue={hostName}- onChange={e => setHostName(toKebabInput(e.target.value))}+ onChange={e => setHostName(e.target.value)}placeholder="agent-name"autoFocus/>@@ -1001,6 +1003,11 @@ export function HostWizard({</span>) : null}</span>+ {toKebabCase(hostName) ? (+ <span className="cu-field__hint">+ Identifier: <code>{toKebabCase(hostName)}</code>+ </span>+ ) : null}</Field><div className="cu-agent-namespace">Namespace: {HOST_NAMESPACE}</div>{SHOW_STATELESS_AGENT_SELECTOR ? (@@ -1052,8 +1059,8 @@ export function HostWizard({<div><strong>Naming conventions</strong><p>- Use lowercase letters, numbers, and hyphens only. Must start with a letter and be- 3-63 characters long.+ The display name can be anything. Its identifier is derived automatically as a+ lowercase, hyphenated slug and cannot be changed later.</p></div></div>diff --git a/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsx b/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsxindex 61e8f2dc9..8425699bf 100644--- a/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsx+++ b/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsx@@ -236,7 +236,7 @@ describe('HostDetailsPage cross-tab draft preservation', () => {it('preserves an open Overview draft when Model & credentials is saved', async () => {const view = render(<HostDetailsPage />)await openOverviewEdit()- fireEvent.change(screen.getByLabelText('Name'), {+ fireEvent.change(screen.getByLabelText('Display name'), {target: { value: 'unsaved-overview-name' },})diff --git a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsxindex 0935a0898..df70fa7e7 100644--- a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx+++ b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx@@ -155,7 +155,7 @@ describe('HostDetailsPage identity integration', () => {expect(container.querySelector('.cu-host-approval-section .cu-section-title')).toBeNull()})- it('shows editable Name and Type in Overview without Display ID and preserves personalization', async () => {+ it('shows editable Type in Overview without Display ID and preserves personalization', async () => {const { container } = render(<HostDetailsPage />)expect(await screen.findByText('Name')).toBeInTheDocument()expect(await screen.findByText('Type')).toBeInTheDocument()@@ -167,17 +167,62 @@ describe('HostDetailsPage identity integration', () => {const [overviewEditButton] = await screen.findAllByRole('button', { name: 'Edit' })await waitFor(() => expect(overviewEditButton).toBeEnabled())fireEvent.click(overviewEditButton)- expect(screen.getByLabelText('Name')).toHaveValue('foo')- fireEvent.change(screen.getByLabelText('Name'), { target: { value: 'foo' } })fireEvent.change(screen.getByLabelText('Type'), { target: { value: 'stateless' } })fireEvent.click(screen.getByRole('button', { name: 'Save' }))await waitFor(() =>expect(api.apiSend).toHaveBeenCalledWith('PUT', '/api/v1/admin/hosts/foo', expect.any(Object)))- const payload = (api.apiSend as unknown as ReturnType<typeof vi.fn>).mock.calls[0][2]+ const putCall = (api.apiSend as unknown as ReturnType<typeof vi.fn>).mock.calls.find(+ c => c[0] === 'PUT' && c[1] === '/api/v1/admin/hosts/foo'+ )+ const payload = putCall![2]expect(payload.spec.lifecycle).toEqual({ stateless: true })expect(payload.spec.personalization).toEqual(host.spec.personalization)expect(payload.spec.approval).toEqual(host.spec.approval)})++ // UT-3 — the identifier is readonly and only the display name (spec.host) is+ // editable. Saving is a SINGLE PUT that updates spec.host and leaves+ // metadata.name intact, with ZERO create (POST) / delete (DELETE) calls: the+ // behavioral proof that the create+migrate+delete rename dance is gone.+ it('makes the identifier readonly and saves the display name via one PUT (no rename dance)', async () => {+ render(<HostDetailsPage />)++ const [overviewEditButton] = await screen.findAllByRole('button', { name: 'Edit' })+ await waitFor(() => expect(overviewEditButton).toBeEnabled())+ fireEvent.click(overviewEditButton)++ // Identifier ("Name") is present but not editable.+ const nameField = screen.getByLabelText('Name')+ expect(nameField).toHaveAttribute('readonly')+ expect(nameField).toHaveValue('foo')++ // The display name (spec.host) is the editable field.+ const displayField = screen.getByLabelText('Display name')+ expect(displayField).toHaveValue('foo-display')+ fireEvent.change(displayField, { target: { value: 'Product Agents' } })++ fireEvent.click(screen.getByRole('button', { name: 'Save' }))++ await waitFor(() =>+ expect(api.apiSend).toHaveBeenCalledWith('PUT', '/api/v1/admin/hosts/foo', expect.any(Object))+ )++ const calls = (api.apiSend as unknown as ReturnType<typeof vi.fn>).mock.calls+ const puts = calls.filter(c => c[0] === 'PUT' && c[1] === '/api/v1/admin/hosts/foo')+ expect(puts).toHaveLength(1)+ const payload = puts[0][2]+ expect(payload.spec.host).toBe('Product Agents')+ // The identifier is untouched: the PUT targets the same slug and never sets+ // a different metadata.name.+ expect(payload.metadata?.name).toBeUndefined()++ // The dance is gone: no create of a new host and no delete of the old one.+ expect(calls.some(c => c[0] === 'POST')).toBe(false)+ expect(calls.some(c => c[0] === 'DELETE')).toBe(false)+ // And the route was never re-navigated to a renamed slug.+ expect(replaceMock).not.toHaveBeenCalledWith('/agents/Product Agents')+ expect(pushMock).not.toHaveBeenCalledWith('/agents/Product Agents')+ })})diff --git a/control-ui/components/__tests__/HostTable.test.tsx b/control-ui/components/__tests__/HostTable.test.tsxindex d345294af..65249ea51 100644--- a/control-ui/components/__tests__/HostTable.test.tsx+++ b/control-ui/components/__tests__/HostTable.test.tsx@@ -88,3 +88,55 @@ describe('HostTable lifecycle column', () => {expect(screen.getByLabelText('Open agent chatllm-stateless')).toBeInTheDocument()})})++// UT-9 — the row shows the editable display name (spec.host) as the primary+// label, with the immutable identifier (metadata.name / slug) as visible+// secondary text; the search haystack matches BOTH.+describe('HostTable display name column (UT-9)', () => {+ function makeDisplayHost(name: string, displayName: string): HostItem {+ return {+ metadata: { name, namespace: 'mcp-host' },+ spec: {+ host: displayName,+ contextRef: 'context1',+ model: { provider: 'zai', name: 'glm-5.1' },+ },+ }+ }++ it('renders the display name as primary and the slug as secondary', () => {+ renderHostTable([makeDisplayHost('prod-x', 'Prod X')])++ const row = screen.getByLabelText('Open agent prod-x')+ expect(within(row).getByText('Prod X')).toBeInTheDocument()+ expect(within(row).getByText('prod-x')).toBeInTheDocument()+ })++ it('filters rows by the display name', () => {+ renderHostTable([+ makeDisplayHost('prod-x', 'Prod X'),+ makeDisplayHost('sales-agent', 'Sales Agent'),+ ])++ fireEvent.change(screen.getByRole('searchbox', { name: 'Search agents' }), {+ target: { value: 'Prod' },+ })++ expect(screen.getByText('Prod X')).toBeInTheDocument()+ expect(screen.queryByText('Sales Agent')).not.toBeInTheDocument()+ })++ it('filters rows by the slug identifier', () => {+ renderHostTable([+ makeDisplayHost('prod-x', 'Prod X'),+ makeDisplayHost('sales-agent', 'Sales Agent'),+ ])++ fireEvent.change(screen.getByRole('searchbox', { name: 'Search agents' }), {+ target: { value: 'sales-agent' },+ })++ expect(screen.getByText('Sales Agent')).toBeInTheDocument()+ expect(screen.queryByText('Prod X')).not.toBeInTheDocument()+ })+})diff --git a/control-ui/lib/__tests__/agentName.test.ts b/control-ui/lib/__tests__/agentName.test.tsnew file mode 100644index 000000000..4bda0603e--- /dev/null+++ b/control-ui/lib/__tests__/agentName.test.ts@@ -0,0 +1,25 @@+import { describe, expect, it } from 'vitest'+import { getAgentDisplayName } from '../agentName'++const directory = [+ { metadata: { name: 'prod-x' }, spec: { host: 'Prod X' } },+ { metadata: { name: 'sales-agent' }, spec: { host: 'Sales Agent' } },+ { metadata: { name: 'no-display' }, spec: {} },+]++describe('getAgentDisplayName', () => {+ it('returns the directory display name (spec.host) when a match exists', () => {+ expect(getAgentDisplayName('prod-x', directory)).toBe('Prod X')+ expect(getAgentDisplayName('sales-agent', directory)).toBe('Sales Agent')+ })++ it('falls back to the slug when the directory entry has no display name', () => {+ expect(getAgentDisplayName('no-display', directory)).toBe('no-display')+ })++ it('falls back to the slug when there is no directory or no match', () => {+ expect(getAgentDisplayName('unknown-agent', directory)).toBe('unknown-agent')+ expect(getAgentDisplayName('mcp-host/prod-x')).toBe('prod-x')+ expect(getAgentDisplayName('')).toBe('')+ })+})diff --git a/control-ui/lib/__tests__/string.test.ts b/control-ui/lib/__tests__/string.test.tsindex 18d880ce2..68e56cc0e 100644--- a/control-ui/lib/__tests__/string.test.ts+++ b/control-ui/lib/__tests__/string.test.ts@@ -15,3 +15,42 @@ describe('string formatters', () => {expect(toKebabInput('_Telegram')).toBe('telegram')})})++// UT-4 — slug contract that shields the wizard auto-slug. Free display text (with+// spaces, capitals, underscores, punctuation) must always derive to a valid+// RFC1123 metadata.name via toKebabCase; and toKebabInput normalizes spaces and+// underscores to hyphens as the user types.+describe('slug contract (UT-4)', () => {+ // RFC1123 DNS label: lowercase alphanumeric + hyphens, start/end alphanumeric,+ // 1-63 chars. Mirrors control-api/src/http/rfc1123.ts.+ const RFC1123_RE = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/++ it('derives a hyphenated slug from free display text', () => {+ expect(toKebabInput('Sales Agent')).toBe('sales-agent')+ expect(toKebabCase('Sales Agent')).toBe('sales-agent')+ })++ it('normalizes underscores to hyphens', () => {+ expect(toKebabInput('sales_agent')).toBe('sales-agent')+ expect(toKebabCase('sales_agent')).toBe('sales-agent')+ })++ it('always produces a valid RFC1123 metadata.name from content-bearing display names', () => {+ const displayNames = [+ 'Sales Agent',+ 'Ventas & Más',+ 'Product Agents',+ 'Prod X',+ 'My_Cool_Agent 42',+ ' Leading and trailing ',+ 'UPPER lower 99',+ 'a',+ 'agent---name',+ ]+ for (const name of displayNames) {+ const slug = toKebabCase(name)+ expect(slug.length, `slug for "${name}" must be non-empty`).toBeGreaterThan(0)+ expect(RFC1123_RE.test(slug), `"${name}" -> "${slug}" must be RFC1123`).toBe(true)+ }+ })+})diff --git a/control-ui/lib/agentName.ts b/control-ui/lib/agentName.tsindex 667af5fba..3cc737abc 100644--- a/control-ui/lib/agentName.ts+++ b/control-ui/lib/agentName.ts@@ -1,6 +1,26 @@-export function getAgentDisplayName(agentName: string): string {+// A minimal shape of an agent (Host) directory entry: the immutable identifier+// (`metadata.name`) mapped to the editable visible name (`spec.host`). `spec` is+// intentionally a loose record so a full HostResource is assignable here.+type AgentDirectoryHost = {+ metadata?: { name?: string }+ spec?: Record<string, unknown>+}++// Resolve the human-visible name for an agent identifier. When a directory of+// Hosts is provided, the agent's editable display name (`spec.host`) wins;+// otherwise (or when the entry has no display name) it falls back to the slug+// identifier — never a silent empty label.+export function getAgentDisplayName(+ agentName: string,+ directory?: readonly AgentDirectoryHost[]+): string {const trimmed = String(agentName || '').trim()if (!trimmed) return ''+ if (directory) {+ const match = directory.find(host => String(host?.metadata?.name || '').trim() === trimmed)+ const display = String((match?.spec as { host?: string } | undefined)?.host || '').trim()+ if (display) return display+ }const segments = trimmed.split('/').filter(Boolean)if (segments.length === 0) return trimmedreturn segments[segments.length - 1]diff --git a/control-ui/lib/api.ts b/control-ui/lib/api.tsindex cc61cf0da..a2acee34f 100644--- a/control-ui/lib/api.ts+++ b/control-ui/lib/api.ts@@ -783,6 +783,9 @@ export type ContextSharedFileSystemStatus = {}export type ContextSpec = {contextId: string+ // Editable, human-visible name (free text). Optional/new: existing contexts+ // won't have it, so consumers fall back to `metadata.name`.+ displayName?: stringdescription?: stringmcpServers: string[]sharedFileSystems?: ContextSharedFileSystemRef[]diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex dcca8f277..4d312c178 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.389",+ "version": "0.1.390","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.389",+ "version": "0.1.390","dependencies": {"@clerum/llm-providers": "file:../packages/llm-providers","@clerum/workflow-recipe-capability-policy": "file:../packages/workflow-recipe-capability-policy",diff --git a/control-ui/package.json b/control-ui/package.jsonindex d71b5a910..7467c2e7c 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.389",+ "version": "0.1.390","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",diff --git a/control-ui/vitest.config.ts b/control-ui/vitest.config.tsindex 6f274125b..97b77f1b3 100644--- a/control-ui/vitest.config.ts+++ b/control-ui/vitest.config.ts@@ -24,6 +24,7 @@ export default defineConfig({'lib/**/__tests__/**/*.{test,spec}.{ts,tsx}','lib/__tests__/**/*.{test,spec}.{ts,tsx}','components/__tests__/**/*.{test,spec}.{ts,tsx}',+ 'app/**/__tests__/**/*.{test,spec}.{ts,tsx}',],exclude: ['node_modules', '.next'],},