Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): address agent UX review findings
Miguelon Peluchon8c9e129a7ad4
diff --git a/control-ui/app/hosts/[name]/page.tsx b/control-ui/app/hosts/[name]/page.tsxindex 0bed9a4b5..fa562d57e 100644--- a/control-ui/app/hosts/[name]/page.tsx+++ b/control-ui/app/hosts/[name]/page.tsx@@ -64,23 +64,6 @@ function parseHostTab(value: string | undefined): HostTab {return HOST_TABS.find(tab => TAB_SLUGS[tab] === value) ?? HOST_DEFAULT_TAB}-// Format an RFC3339 timestamp (or empty) to the table-style "May 21, 2024 • 10:24 AM"-// used in the Overview identity card. Empty string falls through to the same so the-// cell shows a dash and we don't render "Invalid Date".-function formatTimestamp(value: string): string {- if (!value) return ''- const date = new Date(value)- if (Number.isNaN(date.getTime())) return value- const month = date.toLocaleString('en-US', { month: 'long' })- const day = date.getDate()- const year = date.getFullYear()- let hours = date.getHours()- const minutes = date.getMinutes().toString().padStart(2, '0')- const meridiem = hours >= 12 ? 'PM' : 'AM'- hours = hours % 12 || 12- return `${month} ${day}, ${year} • ${hours}:${minutes} ${meridiem}`-}-// Cron×stateless: map the machine-readable suspend-blocked reason to// operator-friendly text. Every other reason renders verbatim.function friendlyLifecycleReason(reason: string): string {@@ -235,8 +218,6 @@ export default function HostDetailsPage() {const [hostStatusLabel, setHostStatusLabel] = useState('Unknown')const [hostStatusTone, setHostStatusTone] = useState<'active' | 'inactive' | 'unknown'>('unknown')const [hostCreatedAt, setHostCreatedAt] = useState('')- const [hostLastUpdated, setHostLastUpdated] = useState('')- const [hostUid, setHostUid] = useState('')const [accessSummary, setAccessSummary] = useState<{memberCount: numberteamCount: number@@ -249,8 +230,6 @@ export default function HostDetailsPage() {const [lifecycleReason, setLifecycleReason] = useState('')const [statelessRejectionMessage, setStatelessRejectionMessage] = useState('')- const [availableContexts, setAvailableContexts] = useState<string[]>([])-const providerModelOptions = useMemo(() => getModelOptions(allowedCatalog, providerDraft),[allowedCatalog, providerDraft]@@ -389,9 +368,7 @@ export default function HostDetailsPage() {setHostStatusTone('active')}const createdAt = String(host.metadata?.creationTimestamp || '').trim()- setHostCreatedAt(formatTimestamp(createdAt))- setHostLastUpdated(formatTimestamp(createdAt))- setHostUid(String(host.metadata?.uid || '').trim())+ setHostCreatedAt(createdAt)}const nextProvider = normalizeProvider(String((spec.model as { provider?: string } | undefined)?.provider || 'openai')@@ -436,10 +413,6 @@ export default function HostDetailsPage() {: '')- const contextIds = (contextsList || [])- .map(item => String(item.spec?.contextId || item.metadata?.name || '').trim())- .filter(Boolean)- setAvailableContexts(Array.from(new Set(contextIds)).sort((a, b) => a.localeCompare(b)))// Map each Secret to its data-key NAMES (never values), already carried by// the detail bundle. Feeds the fallback credentialSlot dropdown's extra// keys (e.g. `claude-api-key-fb1`, spec R4.5.6) without a second fetch.@@ -784,7 +757,6 @@ export default function HostDetailsPage() {return saveHost(hostDisplayDraft, nextStateless)}}createdAt={hostCreatedAt}- lastUpdated={hostLastUpdated}/>)}diff --git a/control-ui/components/HostOverviewTab/index.tsx b/control-ui/components/HostOverviewTab/index.tsxindex d902e4497..345d8ecfc 100644--- a/control-ui/components/HostOverviewTab/index.tsx+++ b/control-ui/components/HostOverviewTab/index.tsx@@ -99,8 +99,7 @@ export function HostOverviewTab({onSaveDisplayName,onSaveLifecycle,createdAt,- lastUpdated,-}: HostOverviewTabProps & { createdAt: string; lastUpdated: string }) {+}: HostOverviewTabProps) {const shownName = displayName.trim() || hostNameconst [editingName, setEditingName] = React.useState(false)const [nameDraft, setNameDraft] = React.useState(shownName)@@ -285,8 +284,6 @@ export function HostOverviewTab({<dl className="cu-host-overview-identity__meta"><dt>Created</dt><dd>{formatTimestamp(createdAt) || '—'}</dd>- <dt>Last updated</dt>- <dd>{formatTimestamp(lastUpdated) || '—'}</dd></dl></section>diff --git a/control-ui/components/HostOverviewTab/types.ts b/control-ui/components/HostOverviewTab/types.tsindex 03f4e5031..d376a7bdb 100644--- a/control-ui/components/HostOverviewTab/types.ts+++ b/control-ui/components/HostOverviewTab/types.ts@@ -27,5 +27,4 @@ export type HostOverviewTabProps = {onSaveDisplayName: (displayName: string) => Promise<boolean>onSaveLifecycle: (stateless: boolean) => Promise<boolean>createdAt: string- lastUpdated: string}diff --git a/control-ui/components/HostWizard/index.tsx b/control-ui/components/HostWizard/index.tsxindex 7bfb96d27..e3fa0a626 100644--- a/control-ui/components/HostWizard/index.tsx+++ b/control-ui/components/HostWizard/index.tsx@@ -214,6 +214,13 @@ async function compensateCreated(created: CreatedResource[]): Promise<void> {// Discriminate on `body.code` (the field INSIDE the JSON body), never on the// client's `.code` (which formatApiError sets from `body.error`, the message).// Any non-409 error is re-thrown verbatim.+class ResourceNameCollisionError extends Error {+ constructor(message: string) {+ super(message)+ this.name = 'ResourceNameCollisionError'+ }+}+async function createOrThrow(path: string, body: unknown, collisionMessage: string): Promise<void> {try {await apiSend('POST', path, body)@@ -222,13 +229,46 @@ async function createOrThrow(path: string, body: unknown, collisionMessage: striconst errBody = (e as Error & { body?: { code?: unknown } }).bodyconst hasCode = typeof errBody?.code === 'string' && errBody.code.length > 0// Code-less 409 from a create-only POST = unambiguous name collision.- if (!hasCode) throw new Error(collisionMessage)+ if (!hasCode) throw new ResourceNameCollisionError(collisionMessage)// Coded 409 (CRD-outdated) keeps the server's own message (e.message).}throw e}}+async function createPrivateContext(+ agentName: string,+ selectedMcpServers: string[],+ collisionMessage: string+): Promise<string> {+ // A generated context name is an implementation detail. Hide the rare+ // collision from the operator by trying one fresh suffix before surfacing the+ // existing friendly error. The successful name is returned to become the+ // Host's contextRef.+ for (let attempt = 0; attempt < 2; attempt += 1) {+ const contextName = createAgentContextName(agentName)+ try {+ await createOrThrow(+ '/api/v1/admin/contexts',+ {+ metadata: { name: contextName },+ spec: {+ contextId: contextName,+ description: `Connector context for agent ${agentName}`,+ mcpServers: selectedMcpServers,+ },+ },+ collisionMessage+ )+ return contextName+ } catch (error) {+ if (!(error instanceof ResourceNameCollisionError) || attempt === 1) throw error+ }+ }++ throw new Error(collisionMessage)+}+function isStepValid(stepIndex: number, state: HostWizardValidationState): boolean {if (stepIndex === 0)return state.hostName.trim().length > 0 && getAgentNameError(state.hostName) === ''@@ -590,7 +630,6 @@ export function HostWizard({let hostCreated = falsetry {const normalizedHostName = toKebabCase(hostName)- const generatedContextName = createAgentContextName(normalizedHostName)const normalizedSecretName = toKebabCase(newSecretName)if (secretMode === 'new') {@@ -630,16 +669,9 @@ export function HostWizard({// Every agent gets a private implementation context. The context name is// intentionally generated here instead of being exposed as a wizard// field; the agent still needs a contextRef for its runtime contract.- await createOrThrow(- '/api/v1/admin/contexts',- {- metadata: { name: generatedContextName },- spec: {- contextId: generatedContextName,- description: `Connector context for agent ${normalizedHostName}`,- mcpServers: Array.from(new Set(selectedMcp)),- },- },+ const generatedContextName = await createPrivateContext(+ normalizedHostName,+ Array.from(new Set(selectedMcp)),'The agent connector context could not be created — please try again.')created.push({ kind: 'context', name: generatedContextName })diff --git a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsxindex 607c37795..6ef9f3fba 100644--- a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx+++ b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx@@ -56,7 +56,7 @@ vi.mock('../../lib/api', () => ({}))const host = {- metadata: { name: 'foo' },+ metadata: { name: 'foo', creationTimestamp: '2026-08-25T12:34:56Z' },spec: {approval: { tools: { shell_exec: true } },channels: ['telegram'],@@ -219,6 +219,8 @@ describe('HostDetailsPage identity integration', () => {expect(description.textContent).toHaveLength(100)expect(description.textContent?.endsWith('…')).toBe(true)expect(screen.getByRole('button', { name: 'Edit agent name' })).toBeInTheDocument()+ expect(screen.getByText('Created').nextElementSibling).toHaveTextContent(/2026/)+ expect(screen.queryByText('Last updated')).not.toBeInTheDocument()expect(container.querySelector('.cu-host-overview-identity__slug')).toBeNull()expect(container.querySelector('.cu-agent-detail-card')).toBeNull()})diff --git a/control-ui/components/__tests__/HostWizard.test.tsx b/control-ui/components/__tests__/HostWizard.test.tsxindex ada76c39f..9aec09900 100644--- a/control-ui/components/__tests__/HostWizard.test.tsx+++ b/control-ui/components/__tests__/HostWizard.test.tsx@@ -644,7 +644,7 @@ describe('HostWizard — Agent type (stateless lifecycle)', () => {})describe('HostWizard — create-only seam + compensation (R5-C1/R5-B1, V-1, V-7)', () => {- it('surfaces the friendly collision message and rolls back the created secret when the generated context POST 409s WITHOUT a body code', async () => {+ it('surfaces the friendly collision message and rolls back the created secret when both generated context names collide', async () => {// Code-less 409 from a create-only POST = unambiguous AlreadyExists collision.const collision = await build409({error: 'contexts.mcp.evenfire.io "ctx1" already exists',@@ -664,6 +664,11 @@ describe('HostWizard — create-only seam + compensation (R5-C1/R5-B1, V-1, V-7)await waitFor(() => {expect(screen.getByText(/agent connector context could not be created/i)).toBeInTheDocument()})+ expect(+ vi+ .mocked(api.apiSend)+ .mock.calls.filter(call => call[0] === 'POST' && call[1] === '/api/v1/admin/contexts')+ ).toHaveLength(2)// Observable (T4): the already-created secret is compensated with an inverse DELETE.expect(api.apiSend).toHaveBeenCalledWith('DELETE', '/api/v1/admin/secrets/coll-agent-llm')// The Host was never POSTed (the seam aborted before the boundary).@@ -672,6 +677,42 @@ describe('HostWizard — create-only seam + compensation (R5-C1/R5-B1, V-1, V-7)).toBe(false)})+ it('retries a generated context name once after a collision and uses the fresh name on the Host', async () => {+ const collision = await build409({+ error: 'contexts.mcp.evenfire.io "ctx1" already exists',+ })+ let contextAttempts = 0+ vi.mocked(api.apiSend).mockImplementation(async (method: string, path: string) => {+ if (method === 'POST' && path === '/api/v1/admin/contexts') {+ contextAttempts += 1+ if (contextAttempts === 1) throw collision+ }+ return {}+ })++ await renderWizard()+ await walkToAccessStepNewSecret({ agentName: 'retry-context-agent' })+ continueToConnectorsStep()+ submitFromConnectorsStep()++ await waitFor(() => {+ expect(api.apiSend).toHaveBeenCalledWith('POST', '/api/v1/admin/hosts', expect.any(Object))+ })+ const contextCalls = vi+ .mocked(api.apiSend)+ .mock.calls.filter(call => call[0] === 'POST' && call[1] === '/api/v1/admin/contexts')+ expect(contextCalls).toHaveLength(2)+ const firstContextName = (contextCalls[0][2] as { metadata: { name: string } }).metadata.name+ const secondContextName = (contextCalls[1][2] as { metadata: { name: string } }).metadata.name+ const hostCall = vi+ .mocked(api.apiSend)+ .mock.calls.find(call => call[0] === 'POST' && call[1] === '/api/v1/admin/hosts')+ expect((hostCall![2] as { spec: { contextRef: string } }).spec.contextRef).toBe(+ secondContextName+ )+ expect(firstContextName).not.toBe('')+ })+it('rolls back the created secret AND context in inverse order when the HOST create fails', async () => {const hostErr = await build409({error: 'hosts.mcp.evenfire.io "hostfail" already exists',diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex 4ac83d4a1..accdf57c0 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.450",+ "version": "0.1.451","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.450",+ "version": "0.1.451","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/llm-providers": "file:../packages/llm-providers",diff --git a/control-ui/package.json b/control-ui/package.jsonindex 5fef329e3..1efd79c00 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.450",+ "version": "0.1.451","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",