Skip to content

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

TypeScript

feat(control-ui): overview — smaller count + icon, rename left Context to Connectors

Miguelon Peluchon8df140befc69
diff --git a/control-ui/app/constants/createFlowLoading.ts b/control-ui/app/constants/createFlowLoading.ts
index ded53ba87..b9e4c9e6c 100644
--- a/control-ui/app/constants/createFlowLoading.ts
+++ b/control-ui/app/constants/createFlowLoading.ts
@@ -4,9 +4,9 @@ export const CREATE_FLOW_LOADING = {
createAgent: {
iconKey: 'robot',
title: 'Create agent',
- subtitle: 'Provision a new agent with context, credentials, and access.',
+ subtitle: 'Provision a new agent with connectors, credentials, and access.',
backLabel: 'Back to agents',
- steps: ['Agent', 'Context', 'Model & Credentials', 'Access'],
+ steps: ['Agent', 'Model & Credentials', 'Access', 'Add Connectors'],
stepFlowClassName: 'cu-create-step-flow--4',
},
createCommunicationChannel: {
diff --git a/control-ui/app/globals.css b/control-ui/app/globals.css
index 3e0facd65..fe70a4ca9 100644
--- a/control-ui/app/globals.css
+++ b/control-ui/app/globals.css
@@ -7471,10 +7471,10 @@ textarea.cu-input {
display: inline-flex;
align-items: center;
justify-content: center;
- width: 1em;
- height: 1em;
- margin-right: 0.35em;
- vertical-align: -0.1em;
+ width: 0.75em;
+ height: 0.75em;
+ margin-right: 0.3em;
+ vertical-align: -0.05em;
color: var(--cu-accent);
flex-shrink: 0;
}
@@ -7593,14 +7593,14 @@ textarea.cu-input {
}
.cu-host-overview-nav-header__count {
- min-width: 1.5rem;
- padding: 0.05rem 0.45rem;
+ min-width: 1.25rem;
+ padding: 0 0.35rem;
border: 1px solid var(--cu-border-subtle);
border-radius: var(--cu-radius-pill);
background: rgba(var(--cu-panel-rgb), 0.5);
color: var(--cu-text);
font-variant-numeric: tabular-nums;
- font-size: 0.75rem;
+ font-size: 0.6875rem;
font-weight: 600;
text-align: center;
}
@@ -7774,13 +7774,15 @@ textarea.cu-input {
}
.cu-host-overview-access__head-count {
- min-width: 1.5rem;
- padding: 0.1rem 0.4rem;
+ min-width: 1.25rem;
+ padding: 0 0.35rem;
border: 1px solid var(--cu-border-subtle);
border-radius: var(--cu-radius-pill);
background: rgba(var(--cu-panel-rgb), 0.5);
color: var(--cu-text);
font-variant-numeric: tabular-nums;
+ font-size: 0.6875rem;
+ font-weight: 600;
text-align: center;
}
diff --git a/control-ui/app/hosts/new/page.tsx b/control-ui/app/hosts/new/page.tsx
index 15ac1a6ce..52755effc 100644
--- a/control-ui/app/hosts/new/page.tsx
+++ b/control-ui/app/hosts/new/page.tsx
@@ -69,7 +69,7 @@ export default function CreateHostPage() {
<CreatePageHeader
icon={<IconRobot />}
title="Create agent"
- subtitle="Provision a new agent with context, credentials, and access."
+ subtitle="Provision a new agent with connectors, credentials, and access."
backLabel="Back to agents"
onBack={backToAgents}
/>
diff --git a/control-ui/components/HostOverviewTab/index.tsx b/control-ui/components/HostOverviewTab/index.tsx
index b0921c633..3bc5313b7 100644
--- a/control-ui/components/HostOverviewTab/index.tsx
+++ b/control-ui/components/HostOverviewTab/index.tsx
@@ -140,7 +140,12 @@ export function HostOverviewTab({
<div className="cu-host-overview-identity__divider" />
- <NavHeader label="Context" tab="contexts" onNavigate={onNavigate} />
+ <NavHeader
+ label="Connectors"
+ tab="contexts"
+ count={contextMcpServers.length}
+ onNavigate={onNavigate}
+ />
{hasContext ? (
<a
href="#"
diff --git a/control-ui/components/HostWizard/constants.ts b/control-ui/components/HostWizard/constants.ts
index 94e7df63f..10b8a7c3f 100644
--- a/control-ui/components/HostWizard/constants.ts
+++ b/control-ui/components/HostWizard/constants.ts
@@ -2,7 +2,7 @@ export const HOST_SECRET_LABEL_KEY = 'clerum.io/host-secret'
export const HOST_SECRET_LABEL_VALUE = 'true'
export const HOST_NAMESPACE = 'mcp-host'
-export const STEPS = ['Agent', 'Context', 'Model & Credentials', 'Access'] as const
+export const STEPS = ['Agent', 'Model & Credentials', 'Access', 'Add Connectors'] as const
export const STEP_DETAILS = [
{
@@ -10,11 +10,6 @@ export const STEP_DETAILS = [
title: 'Agent identity',
subtitle: 'Give your agent a unique name within the selected namespace.',
},
- {
- description: 'Attach knowledge sources',
- title: 'Context',
- subtitle: 'Choose the context and MCP servers this agent can use.',
- },
{
description: 'Choose model and credentials',
title: 'Model & credentials',
@@ -25,4 +20,9 @@ export const STEP_DETAILS = [
title: 'Access',
subtitle: 'Grant members or teams permission to use this agent.',
},
+ {
+ description: 'Choose available connectors',
+ title: 'Add connectors',
+ subtitle: 'Choose the connectors this agent can use. You can leave this empty.',
+ },
] as const
diff --git a/control-ui/components/HostWizard/index.tsx b/control-ui/components/HostWizard/index.tsx
index 3812f3f7f..fffb6d5e2 100644
--- a/control-ui/components/HostWizard/index.tsx
+++ b/control-ui/components/HostWizard/index.tsx
@@ -9,8 +9,8 @@ import { SelectionDropdown } from '@/components/SelectionDropdown'
import { useToast } from '@/components/Toast'
import { IconAlertTriangle, IconCheck, IconX } from '@/components/icons'
import { Button, CheckboxField, Field, TextInput } from '@/components/ui'
+import { createAgentContextName } from '@/lib/agentContext'
import {
- apiGet,
apiSend,
getAdminTeams,
getAdminUsers,
@@ -43,7 +43,12 @@ import {
STEPS,
STEP_DETAILS,
} from './constants'
-import type { ContextOption, CreatedResource, HostWizardProps, WizardSelectProps } from './types'
+import type {
+ CreatedResource,
+ HostWizardProps,
+ HostWizardValidationState,
+ WizardSelectProps,
+} from './types'
// Stateless lifecycle support remains intact in the API and existing-agent UI;
// only creation through this wizard is temporarily unavailable.
@@ -224,33 +229,10 @@ async function createOrThrow(path: string, body: unknown, collisionMessage: stri
}
}
-function isStepValid(
- stepIndex: number,
- state: {
- hostName: string
- contextMode: 'existing' | 'new'
- contextName: string
- selectedExistingContext: string
- selectedMcp: string[]
- secretMode: 'existing' | 'new'
- existingSecret: string
- newSecretName: string
- llmKeyDraft: Record<string, string>
- llmPolicy: LlmPolicy | undefined
- provider: LlmProvider
- modelName: string
- selectedUserIds: string[]
- selectedTeamIds: string[]
- directoryLoadFailed: boolean
- }
-): boolean {
+function isStepValid(stepIndex: number, state: HostWizardValidationState): boolean {
if (stepIndex === 0)
return state.hostName.trim().length > 0 && getAgentNameError(state.hostName) === ''
if (stepIndex === 1) {
- if (state.contextMode === 'existing') return state.selectedExistingContext.trim().length > 0
- return state.contextName.trim().length > 0
- }
- if (stepIndex === 2) {
// New secret: the PRIMARY provider must be usable (asymmetric gate — a
// fallback missing its key only warns). Cross-slot mistakes (half Bedrock
// pair, malformed Vertex JSON) anywhere still block. Existing secret: the
@@ -270,7 +252,7 @@ function isStepValid(
validateLlmSecretData(projectedDraft).length === 0
return hasValidSecret && state.modelName.trim().length > 0
}
- if (stepIndex === 3) return true
+ if (stepIndex === 2 || stepIndex === 3) return true
return false
}
@@ -301,11 +283,7 @@ export function HostWizard({
const hostNamespace = HOST_NAMESPACE
const agentNameError = getAgentNameError(hostName)
- const [contextName, setContextName] = useState('')
- const [contextMode, setContextMode] = useState<'existing' | 'new'>('existing')
- const [selectedExistingContext, setSelectedExistingContext] = useState('')
const [selectedMcp, setSelectedMcp] = useState<string[]>([])
- const [existingContexts, setExistingContexts] = useState<ContextOption[]>([])
// Reuse an existing shared Secret by default. Creating an agent-specific Secret
// remains available when the operator explicitly chooses New credential.
@@ -376,12 +354,6 @@ export function HostWizard({
.sort((left, right) => left.value.localeCompare(right.value)),
[existingSecrets]
)
- const selectedContextOption = useMemo(
- () =>
- existingContexts.find(ctx => `${ctx.namespace}/${ctx.name}` === selectedExistingContext) ||
- null,
- [existingContexts, selectedExistingContext]
- )
const providerModelOptions = useMemo(
() => getModelOptions(allowedCatalog, provider),
[allowedCatalog, provider]
@@ -457,10 +429,6 @@ export function HostWizard({
const canNext = useMemo(() => {
return isStepValid(step, {
hostName,
- contextMode,
- contextName,
- selectedExistingContext,
- selectedMcp,
secretMode,
existingSecret,
newSecretName,
@@ -468,17 +436,10 @@ export function HostWizard({
llmPolicy,
provider,
modelName,
- selectedUserIds,
- selectedTeamIds,
- directoryLoadFailed: directoryLoadError.length > 0,
})
}, [
step,
hostName,
- contextMode,
- contextName,
- selectedExistingContext,
- selectedMcp,
secretMode,
existingSecret,
newSecretName,
@@ -486,9 +447,6 @@ export function HostWizard({
llmPolicy,
provider,
modelName,
- selectedUserIds,
- selectedTeamIds,
- directoryLoadError,
])
const loadDirectory = useCallback(async () => {
@@ -496,40 +454,16 @@ export function HostWizard({
setDirectoryLoadError('')
setError('')
try {
- const [usersData, teamsData, contextsData] = await Promise.all([
- getAdminUsers(''),
- getAdminTeams(),
- apiGet('/api/v1/admin/contexts') as Promise<{
- items?: Array<{
- metadata?: { name?: string; namespace?: string }
- spec?: { contextId?: string; mcpServers?: unknown[] }
- }>
- }>,
- ])
+ const [usersData, teamsData] = await Promise.all([getAdminUsers(''), getAdminTeams()])
if (!mountedRef.current) return
setUsers(Array.isArray(usersData.items) ? usersData.items : [])
setTeams(Array.isArray(teamsData.items) ? teamsData.items : [])
- const contextOptions = (contextsData.items || [])
- .map(ctx => ({
- name: String(ctx.metadata?.name || '').trim(),
- namespace: String(ctx.metadata?.namespace || 'default').trim(),
- contextId: String(ctx.spec?.contextId || ctx.metadata?.name || '').trim(),
- mcpServers: Array.isArray(ctx.spec?.mcpServers)
- ? ctx.spec?.mcpServers
- .map(String)
- .map(v => v.trim())
- .filter(Boolean)
- : [],
- }))
- .filter(ctx => ctx.name && ctx.contextId)
- .sort((a, b) => `${a.namespace}/${a.name}`.localeCompare(`${b.namespace}/${b.name}`))
- setExistingContexts(contextOptions)
} catch (e) {
if (!mountedRef.current) return
const message =
e instanceof Error
- ? `Failed to load users/teams/contexts: ${e.message}. You may not be able to grant access from this wizard — retry or check your session.`
- : 'Failed to load users/teams/contexts. You may not be able to grant access from this wizard.'
+ ? `Failed to load users/teams: ${e.message}. You may not be able to grant access from this wizard — retry or check your session.`
+ : 'Failed to load users/teams. You may not be able to grant access from this wizard.'
setDirectoryLoadError(message)
setError(message)
} finally {
@@ -548,10 +482,6 @@ export function HostWizard({
if (
!isStepValid(i, {
hostName,
- contextMode,
- contextName,
- selectedExistingContext,
- selectedMcp,
secretMode,
existingSecret,
newSecretName,
@@ -559,9 +489,6 @@ export function HostWizard({
llmPolicy,
provider,
modelName,
- selectedUserIds,
- selectedTeamIds,
- directoryLoadFailed: directoryLoadError.length > 0,
})
) {
return false
@@ -572,10 +499,6 @@ export function HostWizard({
[
step,
hostName,
- contextMode,
- contextName,
- selectedExistingContext,
- selectedMcp,
secretMode,
existingSecret,
newSecretName,
@@ -583,9 +506,6 @@ export function HostWizard({
llmPolicy,
provider,
modelName,
- selectedUserIds,
- selectedTeamIds,
- directoryLoadError,
]
)
@@ -594,20 +514,16 @@ export function HostWizard({
const agentNameError = getAgentNameError(hostName)
if (agentNameError) return agentNameError
}
- if (step === 1 && contextMode === 'existing' && !selectedExistingContext.trim())
- return 'Select an existing context.'
- if (step === 1 && contextMode === 'new' && !contextName.trim())
- return 'Context name is required.'
- if (step === 2 && !modelName.trim()) return 'Model name is required.'
- if (step === 2 && secretMode === 'existing' && !existingSecret.trim())
+ if (step === 1 && !modelName.trim()) return 'Model name is required.'
+ if (step === 1 && secretMode === 'existing' && !existingSecret.trim())
return 'Select an existing secret.'
- if (step === 2 && secretMode === 'new' && !toKebabCase(newSecretName)) {
+ if (step === 1 && secretMode === 'new' && !toKebabCase(newSecretName)) {
return 'For a new secret, set a name.'
}
- if (step === 2 && secretMode === 'new' && !primaryCredentialUsable(provider, llmKeyDraft)) {
+ if (step === 1 && secretMode === 'new' && !primaryCredentialUsable(provider, llmKeyDraft)) {
return `Add the ${getProviderLabel(provider)} credential for the primary model.`
}
- if (step === 2 && secretMode === 'new') {
+ if (step === 1 && secretMode === 'new') {
const projected = projectCredentialDraft(
llmKeyDraft,
getActiveCredentialKeys(provider, llmPolicy)
@@ -619,10 +535,6 @@ export function HostWizard({
}, [
step,
hostName,
- contextMode,
- contextName,
- selectedExistingContext,
- selectedMcp,
secretMode,
existingSecret,
newSecretName,
@@ -630,8 +542,6 @@ export function HostWizard({
llmPolicy,
provider,
modelName,
- selectedUserIds,
- selectedTeamIds,
])
function resetForm() {
@@ -639,9 +549,6 @@ export function HostWizard({
setError('')
setHostName('')
- setContextName('')
- setContextMode('existing')
- setSelectedExistingContext('')
setSelectedMcp([])
setSecretMode('existing')
setExistingSecret('')
@@ -671,10 +578,6 @@ export function HostWizard({
})
}
- function selectExistingContext(context: ContextOption) {
- setSelectedExistingContext(`${context.namespace}/${context.name}`)
- }
-
async function submitAll() {
setBusy(true)
setError('')
@@ -687,9 +590,7 @@ export function HostWizard({
let hostCreated = false
try {
const normalizedHostName = toKebabCase(hostName)
- const normalizedContextName = toKebabCase(contextName)
- const resolvedContextName =
- contextMode === 'existing' ? selectedContextOption?.contextId || '' : normalizedContextName
+ const generatedContextName = createAgentContextName(normalizedHostName)
const normalizedSecretName = toKebabCase(newSecretName)
if (secretMode === 'new') {
@@ -726,23 +627,22 @@ export function HostWizard({
created.push({ kind: 'secret', name: normalizedSecretName })
}
- if (contextMode === 'new') {
- // Create-only POST (R5-C1/R5-B1): a name collision must 409 AlreadyExists
- // server-side, never silently overwrite a foreign context via a PUT.
- await createOrThrow(
- '/api/v1/admin/contexts',
- {
- metadata: { name: normalizedContextName },
- spec: {
- contextId: normalizedContextName,
- description: `Context for agent ${normalizedHostName}`,
- mcpServers: Array.from(new Set(selectedMcp)),
- },
+ // 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)),
},
- `A context named "${normalizedContextName}" already exists — choose another name.`
- )
- created.push({ kind: 'context', name: normalizedContextName })
- }
+ },
+ 'The agent connector context could not be created — please try again.'
+ )
+ created.push({ kind: 'context', name: generatedContextName })
// Effective per-host model subset (Topic 3a): prune the draft to the
// providers actually in this host's domain (primary + fallbacks), then
@@ -758,7 +658,7 @@ export function HostWizard({
const hostSpec: Record<string, unknown> = {
host: normalizedHostName,
- contextRef: resolvedContextName,
+ contextRef: generatedContextName,
secretRef: secretMode === 'existing' ? existingSecret : normalizedSecretName,
channels: [],
model: {
@@ -938,121 +838,6 @@ export function HostWizard({
)}
{step === 1 && (
- <div className="cu-form-stack cu-agent-form-stack">
- <div className="cu-agent-radio-group">
- <label className="cu-agent-radio cu-agent-radio--card">
- <input
- type="radio"
- checked={contextMode === 'existing'}
- onChange={() => setContextMode('existing')}
- />
- <span className="cu-agent-radio__copy">
- <span className="cu-agent-radio__title">Use existing context</span>
- <span className="cu-agent-radio__description">
- Select a saved context and reuse its MCP server attachments.
- </span>
- </span>
- </label>
- <label className="cu-agent-radio cu-agent-radio--card">
- <input
- type="radio"
- checked={contextMode === 'new'}
- onChange={() => setContextMode('new')}
- />
- <span className="cu-agent-radio__copy">
- <span className="cu-agent-radio__title">Create new context</span>
- <span className="cu-agent-radio__description">
- Create a context for this agent. MCP servers can be attached now or later.
- </span>
- </span>
- </label>
- </div>
- {contextMode === 'existing' ? (
- <>
- <div className="cu-agent-access-section">
- <strong>Select Context</strong>
- <SelectionDropdown
- multiple={false}
- value={selectedExistingContext ? [selectedExistingContext] : []}
- onChange={values => {
- const next = values[0] || ''
- const context = existingContexts.find(
- ctx => `${ctx.namespace}/${ctx.name}` === next
- )
- if (context) selectExistingContext(context)
- else setSelectedExistingContext('')
- }}
- options={existingContexts.map(ctx => ({
- value: `${ctx.namespace}/${ctx.name}`,
- label: ctx.contextId,
- }))}
- placeholder="Select context..."
- searchPlaceholder="Search contexts..."
- selectionLabel="Selected context"
- emptyLabel="No contexts available."
- />
- </div>
- {selectedContextOption && (
- <section
- className="cu-agent-context-mcp-summary"
- aria-label="Attached MCP servers"
- >
- <div className="cu-agent-context-mcp-summary__head">
- <span>MCP servers</span>
- <span>{selectedContextOption.mcpServers.length}</span>
- </div>
- {selectedContextOption.mcpServers.length > 0 ? (
- <ul className="cu-agent-context-mcp-summary__list">
- {selectedContextOption.mcpServers.map(server => (
- <li key={server} title={server}>
- {server}
- </li>
- ))}
- </ul>
- ) : (
- <p className="cu-muted">No MCP servers attached.</p>
- )}
- </section>
- )}
- </>
- ) : (
- <>
- <Field
- description="Automatically formatted to lowercase with hyphens."
- label="Context name"
- >
- <TextInput
- value={contextName}
- onChange={e => setContextName(toKebabInput(e.target.value))}
- placeholder="context-name"
- />
- </Field>
- <div className="cu-agent-section-label">MCP servers (optional)</div>
- <div className="cu-agent-mcp-grid">
- {availableMcp.map(name => (
- <CheckboxField
- key={name}
- checked={selectedMcp.includes(name)}
- className="cu-agent-mcp-option"
- label={
- <span className="cu-agent-mcp-option__label">
- <span className="cu-agent-mcp-option__name">{name}</span>
- <span className="cu-agent-mcp-option__meta">MCP server</span>
- </span>
- }
- onChange={() => toggleMcp(name)}
- />
- ))}
- {availableMcp.length === 0 ? (
- <span className="cu-agent-empty-note">No MCP servers available.</span>
- ) : null}
- </div>
- </>
- )}
- </div>
- )}
-
- {step === 2 && (
<div className="cu-form-stack cu-agent-form-stack">
<div className="cu-agent-access-section">
<strong>Credentials</strong>
@@ -1158,7 +943,7 @@ export function HostWizard({
</div>
)}
- {step === 3 && (
+ {step === 2 && (
<div className="cu-form-stack cu-agent-form-stack cu-agent-form-stack--wide">
{directoryLoadError ? (
<div className="cu-workflow-access__error" role="alert">
@@ -1256,6 +1041,39 @@ export function HostWizard({
</div>
)}
+ {step === 3 && (
+ <div className="cu-form-stack cu-agent-form-stack">
+ <div className="cu-agent-access-section">
+ <strong>Connectors</strong>
+ <span className="cu-muted cu-agent-access-hint">
+ Choose the connectors this agent can use. You can leave this empty and add
+ connectors later.
+ </span>
+ </div>
+ <div className="cu-agent-section-label">Available connectors (optional)</div>
+ <div className="cu-agent-mcp-grid" role="group" aria-label="Available connectors">
+ {availableMcp.map(name => (
+ <CheckboxField
+ key={name}
+ checked={selectedMcp.includes(name)}
+ className="cu-agent-mcp-option"
+ label={
+ <span className="cu-agent-mcp-option__label">
+ <span className="cu-agent-mcp-option__name">{name}</span>
+ <span className="cu-agent-mcp-option__meta">Connector</span>
+ </span>
+ }
+ disabled={busy}
+ onChange={() => toggleMcp(name)}
+ />
+ ))}
+ {availableMcp.length === 0 ? (
+ <span className="cu-agent-empty-note">No connectors available.</span>
+ ) : null}
+ </div>
+ </div>
+ )}
+
{error ? (
<div className="cu-banner cu-banner--error cu-agent-flow-message">{error}</div>
) : null}
diff --git a/control-ui/components/HostWizard/types.ts b/control-ui/components/HostWizard/types.ts
index d3e61097c..db192b2e1 100644
--- a/control-ui/components/HostWizard/types.ts
+++ b/control-ui/components/HostWizard/types.ts
@@ -1,4 +1,5 @@
import type { ReactNode } from 'react'
+import type { LlmPolicy, LlmProvider } from '@/lib/llm'
export type McpServer = {
metadata?: { name?: string; namespace?: string }
@@ -12,13 +13,6 @@ export type SecretMeta = {
type?: string
}
-export type ContextOption = {
- contextId: string
- mcpServers: string[]
- name: string
- namespace: string
-}
-
export type ChannelOption = {
name: string
namespace: string
@@ -59,3 +53,14 @@ export type WizardSelectProps = {
placeholder: string
value: string
}
+
+export type HostWizardValidationState = {
+ hostName: string
+ secretMode: 'existing' | 'new'
+ existingSecret: string
+ newSecretName: string
+ llmKeyDraft: Record<string, string>
+ llmPolicy: LlmPolicy | undefined
+ provider: LlmProvider
+ modelName: string
+}
diff --git a/control-ui/components/__tests__/HostWizard.test.tsx b/control-ui/components/__tests__/HostWizard.test.tsx
index 3c63bbb79..6c094b9f5 100644
--- a/control-ui/components/__tests__/HostWizard.test.tsx
+++ b/control-ui/components/__tests__/HostWizard.test.tsx
@@ -2,7 +2,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 * as api from '../../lib/api'
-import { buildContextList, buildContextResource } from '../../test/fixtures/contextResource'
import { buildSecretSummary } from '../../test/fixtures/secretSummary'
import { HostWizard } from '../HostWizard'
import { ToastProvider } from '../Toast'
@@ -24,7 +23,6 @@ import { ToastProvider } from '../Toast'
// Mock lib/api BEFORE importing the component. vi.mock is hoisted.
vi.mock('../../lib/api', () => ({
- apiGet: vi.fn().mockResolvedValue({ items: [] }),
apiSend: vi.fn().mockResolvedValue({}),
getAdminUsers: vi.fn().mockResolvedValue({
items: [
@@ -125,18 +123,7 @@ async function walkToAccessStep(opts?: { agentName?: string }) {
})
fireEvent.click(screen.getByRole('button', { name: 'Next' }))
- // Step 1: Context — create a new context. MCP attachments are optional,
- // but this helper selects one to keep existing submit payload coverage.
- fireEvent.click(screen.getByLabelText(/Create new context/i))
- fireEvent.change(screen.getByPlaceholderText(/context-name/i), {
- target: { value: 'ctx1' },
- })
- // Select the first connector checkbox
- const mcpCheckbox = screen.getByRole('checkbox', { name: /mcp-a/i }) as HTMLInputElement
- fireEvent.click(mcpCheckbox)
- fireEvent.click(screen.getByRole('button', { name: 'Next' }))
-
- // Step 2: Model & Credentials — default model is valid; reuse the secret we provided.
+ // Step 1: Model & Credentials — default model is valid; reuse the secret we provided.
fireEvent.click(screen.getByLabelText(/Use an existing Secret/i))
fireEvent.click(screen.getByRole('button', { name: /Select secret/i }))
fireEvent.click(screen.getByRole('option', { name: /secret-a/i }))
@@ -155,9 +142,8 @@ function openTeamsAccessTab() {
* tests need: an already-POSTed secret that a later failure must roll back. The
* new Secret name is auto-derived from the agent name as `${slug}-llm`.
*/
-async function walkToAccessStepNewSecret(opts?: { agentName?: string; contextName?: string }) {
+async function walkToAccessStepNewSecret(opts?: { agentName?: string }) {
const name = opts?.agentName ?? 'newsecretagent'
- const ctx = opts?.contextName ?? 'ctx1'
await waitFor(() => {
expect(api.getAdminUsers).toHaveBeenCalled()
@@ -167,12 +153,7 @@ async function walkToAccessStepNewSecret(opts?: { agentName?: string; contextNam
fireEvent.change(screen.getByPlaceholderText(/agent-name/i), { target: { value: name } })
fireEvent.click(screen.getByRole('button', { name: 'Next' }))
- // Step 1: new context
- fireEvent.click(screen.getByLabelText(/Create new context/i))
- fireEvent.change(screen.getByPlaceholderText(/context-name/i), { target: { value: ctx } })
- fireEvent.click(screen.getByRole('button', { name: 'Next' }))
-
- // Step 2: New secret → make the OpenAI primary usable; secret name auto-derives.
+ // Step 1: New secret → make the OpenAI primary usable; secret name auto-derives.
// (dev's wizard renamed the "New credential" toggle to the "New secret"
// secretMode radio — the create-only seam it drives is unchanged.)
fireEvent.click(screen.getByLabelText(/New secret/i))
@@ -185,6 +166,14 @@ async function walkToAccessStepNewSecret(opts?: { agentName?: string; contextNam
// Now at the "Access" step.
}
+function continueToConnectorsStep() {
+ fireEvent.click(screen.getByRole('button', { name: 'Next' }))
+}
+
+function submitFromConnectorsStep() {
+ fireEvent.click(screen.getByRole('button', { name: /Create Agent/i }))
+}
+
/**
* Build the exact Error object the client's fetch layer would surface for a 409,
* derived from the REAL formatApiError (importActual, T1) — never hand-shaped —
@@ -217,9 +206,6 @@ describe('HostWizard — credential draft is projected onto the active provider
fireEvent.change(screen.getByPlaceholderText(/agent-name/i), { target: { value: 'testagent' } })
fireEvent.click(screen.getByRole('button', { name: 'Next' }))
- fireEvent.click(screen.getByLabelText(/Create new context/i))
- fireEvent.change(screen.getByPlaceholderText(/context-name/i), { target: { value: 'ctx1' } })
- fireEvent.click(screen.getByRole('button', { name: 'Next' }))
fireEvent.click(screen.getByLabelText(/Use an existing Secret/i))
fireEvent.click(screen.getByRole('button', { name: /Select secret/i }))
@@ -241,9 +227,6 @@ describe('HostWizard — credential draft is projected onto the active provider
fireEvent.change(screen.getByPlaceholderText(/agent-name/i), { target: { value: 'testagent' } })
fireEvent.click(screen.getByRole('button', { name: 'Next' }))
- fireEvent.click(screen.getByLabelText(/Create new context/i))
- fireEvent.change(screen.getByPlaceholderText(/context-name/i), { target: { value: 'ctx1' } })
- fireEvent.click(screen.getByRole('button', { name: 'Next' }))
fireEvent.click(screen.getByRole('button', { name: /Select secret/i }))
fireEvent.click(screen.getByRole('option', { name: /zai-only/i }))
@@ -264,9 +247,6 @@ describe('HostWizard — credential draft is projected onto the active provider
fireEvent.change(screen.getByPlaceholderText(/agent-name/i), { target: { value: 'testagent' } })
fireEvent.click(screen.getByRole('button', { name: 'Next' }))
- fireEvent.click(screen.getByLabelText(/Create new context/i))
- fireEvent.change(screen.getByPlaceholderText(/context-name/i), { target: { value: 'ctx1' } })
- fireEvent.click(screen.getByRole('button', { name: 'Next' }))
const existingCard = screen.getByLabelText(/Use an existing Secret/i).closest('label')
const newCard = screen.getByLabelText(/New secret/i).closest('label')
@@ -296,12 +276,7 @@ describe('HostWizard — credential draft is projected onto the active provider
})
fireEvent.click(screen.getByRole('button', { name: 'Next' }))
- // Step 1: a new context with just a name.
- fireEvent.click(screen.getByLabelText(/Create new context/i))
- fireEvent.change(screen.getByPlaceholderText(/context-name/i), { target: { value: 'ctx1' } })
- fireEvent.click(screen.getByRole('button', { name: 'Next' }))
-
- // Step 2: explicitly create a new Secret and make the OpenAI primary usable.
+ // Step 1: explicitly create a new Secret and make the OpenAI primary usable.
fireEvent.click(screen.getByLabelText(/New secret/i))
fireEvent.change(screen.getByLabelText(/OpenAI API key/i), { target: { value: 'sk-openai' } })
@@ -326,9 +301,10 @@ describe('HostWizard — credential draft is projected onto the active provider
expect(screen.getByRole('button', { name: 'Next' })).not.toBeDisabled()
})
- // Walk to the final Access step and create.
+ // Walk to Access, then through the final connector step and create.
fireEvent.click(screen.getByRole('button', { name: 'Next' })) // → Access
- fireEvent.click(screen.getByRole('button', { name: /Create Agent/i }))
+ continueToConnectorsStep()
+ submitFromConnectorsStep()
await waitFor(() => {
expect(api.apiSend).toHaveBeenCalledWith(
@@ -346,58 +322,93 @@ describe('HostWizard — credential draft is projected onto the active provider
})
})
-describe('HostWizard — Context creation', () => {
- it('titles the existing context selector and shows attached MCP servers as chips', async () => {
- vi.mocked(api.apiGet)
- .mockResolvedValueOnce(
- buildContextList([
- buildContextResource({
- metadata: { name: 'business', namespace: 'mcp-host' },
- spec: { mcpServers: ['mcp-a', 'mcp-b'] },
- }),
- ])
- )
- .mockResolvedValueOnce({ items: [] })
+describe('HostWizard — connector selection and automatic context creation', () => {
+ it('moves connector selection after Access and keeps the context implementation detail hidden', async () => {
await renderWizard()
+ await walkToAccessStep({ agentName: 'connector-agent' })
- fireEvent.change(screen.getByPlaceholderText(/agent-name/i), {
- target: { value: 'existing-context-agent' },
- })
- fireEvent.click(screen.getByRole('button', { name: 'Next' }))
+ expect(
+ screen.queryByText('Context', { selector: '.cu-agent-step-rail__title' })
+ ).not.toBeInTheDocument()
+ expect(screen.getByRole('button', { name: 'Next' })).toBeInTheDocument()
+ continueToConnectorsStep()
- const title = screen.getByText('Select Context', { selector: 'strong' })
- const selector = screen.getByRole('button', { name: /Select context/i })
- expect(title.compareDocumentPosition(selector)).toBe(Node.DOCUMENT_POSITION_FOLLOWING)
+ expect(screen.getByText('Connectors', { selector: 'strong' })).toBeInTheDocument()
+ expect(screen.queryByPlaceholderText(/context-name/i)).not.toBeInTheDocument()
+ expect(screen.queryByText(/Use existing context/i)).not.toBeInTheDocument()
- fireEvent.click(selector)
- fireEvent.click(screen.getByRole('option', { name: 'business' }))
- const summary = screen.getByRole('region', { name: 'Attached MCP servers' })
- expect(summary).toHaveTextContent('MCP servers')
- expect(summary).toHaveTextContent('2')
- expect(summary.querySelectorAll('li')).toHaveLength(2)
- expect(summary).toHaveTextContent('mcp-a')
- expect(summary).toHaveTextContent('mcp-b')
+ fireEvent.click(screen.getByRole('checkbox', { name: /mcp-a/i }))
+ expect(screen.getByRole('checkbox', { name: /mcp-a/i })).toBeChecked()
})
- it('allows a new context with only a name and no MCP servers selected', async () => {
+ it('writes selected connectors to the generated context before attaching it to the agent', async () => {
await renderWizard()
+ await walkToAccessStep({ agentName: 'connector-agent' })
+ continueToConnectorsStep()
+ fireEvent.click(screen.getByRole('checkbox', { name: /mcp-a/i }))
+ submitFromConnectorsStep()
await waitFor(() => {
- expect(api.getAdminUsers).toHaveBeenCalled()
+ expect(api.apiSend).toHaveBeenCalledWith(
+ 'POST',
+ '/api/v1/admin/hosts',
+ expect.objectContaining({
+ spec: expect.objectContaining({
+ contextRef: expect.stringMatching(/^connector-agent-[0-9]{5}$/),
+ }),
+ })
+ )
})
- fireEvent.change(screen.getByPlaceholderText(/agent-name/i), {
- target: { value: 'context-only-agent' },
- })
- fireEvent.click(screen.getByRole('button', { name: 'Next' }))
+ const contextCall = vi
+ .mocked(api.apiSend)
+ .mock.calls.find(call => call[0] === 'POST' && call[1] === '/api/v1/admin/contexts')
+ const hostCall = vi
+ .mocked(api.apiSend)
+ .mock.calls.find(call => call[0] === 'POST' && call[1] === '/api/v1/admin/hosts')
+ const contextPayload = contextCall![2] as {
+ metadata: { name: string }
+ spec: { mcpServers: string[] }
+ }
+ const hostPayload = hostCall![2] as { spec: { contextRef: string } }
+
+ expect(contextPayload.spec.mcpServers).toEqual(['mcp-a'])
+ expect(hostPayload.spec.contextRef).toBe(contextPayload.metadata.name)
+ })
- fireEvent.click(screen.getByLabelText(/Create new context/i))
- fireEvent.change(screen.getByPlaceholderText(/context-name/i), {
- target: { value: 'empty-context' },
+ it('creates an agent-owned context with no connectors when none are selected', async () => {
+ await renderWizard()
+ await walkToAccessStep({ agentName: 'context-free-agent' })
+ continueToConnectorsStep()
+ submitFromConnectorsStep()
+
+ await waitFor(() => {
+ expect(api.apiSend).toHaveBeenCalledWith(
+ 'POST',
+ '/api/v1/admin/contexts',
+ expect.objectContaining({
+ metadata: { name: expect.stringMatching(/^context-free-agent-[0-9]{5}$/) },
+ spec: expect.objectContaining({ mcpServers: [] }),
+ })
+ )
})
- expect(screen.getByRole('button', { name: 'Next' })).not.toBeDisabled()
- expect(screen.queryByText(/Select at least one MCP server/i)).not.toBeInTheDocument()
+ const contextCall = vi
+ .mocked(api.apiSend)
+ .mock.calls.find(call => call[0] === 'POST' && call[1] === '/api/v1/admin/contexts')
+ const contextPayload = contextCall![2] as {
+ metadata: { name: string }
+ spec: { contextId: string; mcpServers: string[] }
+ }
+ expect(contextPayload.spec.contextId).toBe(contextPayload.metadata.name)
+ expect(contextPayload.spec.mcpServers).toEqual([])
+
+ 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(
+ contextPayload.metadata.name
+ )
})
})
@@ -434,23 +445,23 @@ describe("HostWizard — 'Access' empty state", () => {
})
})
-describe('HostWizard — Access is the final step', () => {
- it("keeps 'Create Agent' enabled when selection is empty", async () => {
+describe('HostWizard — Access precedes connector selection', () => {
+ it("keeps 'Next' enabled when selection is empty", async () => {
await renderWizard()
await walkToAccessStep()
expect(screen.queryByText('Channels')).not.toBeInTheDocument()
- expect(screen.queryByRole('button', { name: 'Next' })).not.toBeInTheDocument()
- expect(screen.getByRole('button', { name: /Create Agent/i })).not.toBeDisabled()
+ expect(screen.getByRole('button', { name: 'Next' })).not.toBeDisabled()
+ expect(screen.queryByRole('button', { name: /Create Agent/i })).not.toBeInTheDocument()
})
- it("keeps 'Create Agent' enabled when a user is selected", async () => {
+ it("keeps 'Next' enabled when a user is selected", async () => {
await renderWizard()
await walkToAccessStep()
fireEvent.click(screen.getByLabelText(/alice/i))
- expect(screen.getByRole('button', { name: /Create Agent/i })).not.toBeDisabled()
+ expect(screen.getByRole('button', { name: 'Next' })).not.toBeDisabled()
})
})
@@ -459,7 +470,8 @@ describe('HostWizard — submit path uses the atomic agent-centric endpoints', (
await renderWizard()
await walkToAccessStep({ agentName: 'empty-access-test' })
- fireEvent.click(screen.getByRole('button', { name: /Create Agent/i }))
+ continueToConnectorsStep()
+ submitFromConnectorsStep()
await waitFor(() => {
expect(screen.queryByText(/Failed to create agent resources/i)).not.toBeInTheDocument()
@@ -493,7 +505,8 @@ describe('HostWizard — submit path uses the atomic agent-centric endpoints', (
fireEvent.click(screen.getByLabelText(/bob/i))
// Submit
- fireEvent.click(screen.getByRole('button', { name: /Create Agent/i }))
+ continueToConnectorsStep()
+ submitFromConnectorsStep()
// Wait for the submit pipeline to reach the agent-user association step
await waitFor(() => {
@@ -516,7 +529,8 @@ describe('HostWizard — submit path uses the atomic agent-centric endpoints', (
openTeamsAccessTab()
fireEvent.click(screen.getByLabelText(/engineering/i))
- fireEvent.click(screen.getByRole('button', { name: /Create Agent/i }))
+ continueToConnectorsStep()
+ submitFromConnectorsStep()
await waitFor(() => {
expect(vi.mocked(api.updateAgentTeams)).toHaveBeenCalled()
@@ -533,7 +547,8 @@ describe('HostWizard — submit path uses the atomic agent-centric endpoints', (
fireEvent.click(screen.getByLabelText(/alice/i))
openTeamsAccessTab()
fireEvent.click(screen.getByLabelText(/engineering/i))
- fireEvent.click(screen.getByRole('button', { name: /Create Agent/i }))
+ continueToConnectorsStep()
+ submitFromConnectorsStep()
await waitFor(() => {
expect(vi.mocked(api.updateAgentUsers)).toHaveBeenCalled()
@@ -553,7 +568,7 @@ describe('HostWizard — loadDirectory error surfacing (no more silent catch)',
// Wait for the error to surface
await waitFor(() => {
- expect(screen.getByText(/Failed to load users\/teams\/contexts/i)).toBeInTheDocument()
+ expect(screen.getByText(/Failed to load users\/teams/i)).toBeInTheDocument()
})
})
@@ -566,7 +581,7 @@ describe('HostWizard — loadDirectory error surfacing (no more silent catch)',
await waitFor(() => {
// The error banner contains the wrapped message
- expect(screen.getByText(/Failed to load users\/teams\/contexts/i)).toBeInTheDocument()
+ expect(screen.getByText(/Failed to load users\/teams/i)).toBeInTheDocument()
})
})
})
@@ -589,11 +604,6 @@ describe('HostWizard — baseline render', () => {
target: { value: 'default-model-agent' },
})
fireEvent.click(screen.getByRole('button', { name: 'Next' }))
- fireEvent.click(screen.getByLabelText(/Create new context/i))
- fireEvent.change(screen.getByPlaceholderText(/context-name/i), {
- target: { value: 'ctx1' },
- })
- fireEvent.click(screen.getByRole('button', { name: 'Next' }))
expect(
screen.getByLabelText('Default model', { selector: '#llm-primary-model' })
@@ -616,7 +626,8 @@ describe('HostWizard — Agent type (stateless lifecycle)', () => {
it('omits spec.lifecycle from the created Host when Stateful is kept (absent = disabled)', async () => {
await renderWizard()
await walkToAccessStep({ agentName: 'stateful-agent' })
- fireEvent.click(screen.getByRole('button', { name: /Create Agent/i }))
+ continueToConnectorsStep()
+ submitFromConnectorsStep()
await waitFor(() => {
// Create-only contract (R5-C1/R5-B1): POST to the collection, not PUT to a name.
@@ -633,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 context POST 409s WITHOUT a body code', async () => {
+ it('surfaces the friendly collision message and rolls back the created secret when the generated context POST 409s WITHOUT a body code', async () => {
// Code-less 409 from a create-only POST = unambiguous AlreadyExists collision.
const collision = await build409({
error: 'contexts.mcp.evenfire.io "ctx1" already exists',
@@ -644,13 +655,14 @@ describe('HostWizard — create-only seam + compensation (R5-C1/R5-B1, V-1, V-7)
})
await renderWizard()
- await walkToAccessStepNewSecret({ agentName: 'coll-agent', contextName: 'ctx1' })
- fireEvent.click(screen.getByRole('button', { name: /Create Agent/i }))
+ await walkToAccessStepNewSecret({ agentName: 'coll-agent' })
+ continueToConnectorsStep()
+ submitFromConnectorsStep()
// Observable (T4): the friendly per-resource collision message is shown —
// NOT the raw K8s AlreadyExists text.
await waitFor(() => {
- expect(screen.getByText(/A context named "ctx1" already exists/i)).toBeInTheDocument()
+ expect(screen.getByText(/agent connector context could not be created/i)).toBeInTheDocument()
})
// Observable (T4): the already-created secret is compensated with an inverse DELETE.
expect(api.apiSend).toHaveBeenCalledWith('DELETE', '/api/v1/admin/secrets/coll-agent-llm')
@@ -670,19 +682,24 @@ describe('HostWizard — create-only seam + compensation (R5-C1/R5-B1, V-1, V-7)
})
await renderWizard()
- await walkToAccessStepNewSecret({ agentName: 'hostfail', contextName: 'ctx1' })
- fireEvent.click(screen.getByRole('button', { name: /Create Agent/i }))
+ await walkToAccessStepNewSecret({ agentName: 'hostfail' })
+ continueToConnectorsStep()
+ submitFromConnectorsStep()
await waitFor(() => {
expect(screen.getByText(/That agent name is already in use/i)).toBeInTheDocument()
})
// Inverse order: created = [secret, context] → compensate context THEN secret.
+ const contextCall = vi
+ .mocked(api.apiSend)
+ .mock.calls.find(call => call[0] === 'POST' && call[1] === '/api/v1/admin/contexts')
+ const generatedContextName = (contextCall![2] as { metadata: { name: string } }).metadata.name
const deletePaths = vi
.mocked(api.apiSend)
.mock.calls.filter(c => c[0] === 'DELETE')
.map(c => c[1])
expect(deletePaths).toEqual([
- '/api/v1/admin/contexts/ctx1',
+ `/api/v1/admin/contexts/${generatedContextName}`,
'/api/v1/admin/secrets/hostfail-llm',
])
})
@@ -696,10 +713,11 @@ describe('HostWizard — create-only seam + compensation (R5-C1/R5-B1, V-1, V-7)
vi.mocked(api.updateAgentUsers).mockRejectedValueOnce(new Error('grant boom'))
await renderWizard()
- await walkToAccessStepNewSecret({ agentName: 'grantfail', contextName: 'ctx1' })
+ await walkToAccessStepNewSecret({ agentName: 'grantfail' })
// Select a user so updateAgentUsers is invoked.
fireEvent.click(screen.getByLabelText(/alice/i))
- fireEvent.click(screen.getByRole('button', { name: /Create Agent/i }))
+ continueToConnectorsStep()
+ submitFromConnectorsStep()
// The grant error is surfaced verbatim (no 409 remap at the top level).
await waitFor(() => {
@@ -726,14 +744,17 @@ describe('HostWizard — create-only seam + compensation (R5-C1/R5-B1, V-1, V-7)
})
await renderWizard()
- await walkToAccessStepNewSecret({ agentName: 'crd-agent', contextName: 'ctx1' })
- fireEvent.click(screen.getByRole('button', { name: /Create Agent/i }))
+ await walkToAccessStepNewSecret({ agentName: 'crd-agent' })
+ continueToConnectorsStep()
+ submitFromConnectorsStep()
await waitFor(() => {
expect(screen.getByText(/context CRD is outdated/i)).toBeInTheDocument()
})
// The friendly collision text must NOT appear (coded 409 is not a collision).
- expect(screen.queryByText(/A context named .* already exists/i)).not.toBeInTheDocument()
+ expect(
+ screen.queryByText(/agent connector context could not be created/i)
+ ).not.toBeInTheDocument()
// Boundary rule still applies: the secret created before the failing context
// is compensated (host never created), but nothing beyond that.
expect(api.apiSend).toHaveBeenCalledWith('DELETE', '/api/v1/admin/secrets/crd-agent-llm')
diff --git a/control-ui/e2e/qa-recorder-agent-create.spec.ts b/control-ui/e2e/qa-recorder-agent-create.spec.ts
index 112dba112..a6d825e1e 100644
--- a/control-ui/e2e/qa-recorder-agent-create.spec.ts
+++ b/control-ui/e2e/qa-recorder-agent-create.spec.ts
@@ -47,10 +47,12 @@ async function requireLlmSecret(
async function cleanupAgentFlowResources(
request: import('@playwright/test').APIRequestContext,
- names: { agentName: string; contextName: string }
+ names: { agentName: string; contextName?: string }
): Promise<void> {
await api(request, 'DELETE', `/api/v1/admin/hosts/${encodeURIComponent(names.agentName)}`)
- await api(request, 'DELETE', `/api/v1/admin/contexts/${encodeURIComponent(names.contextName)}`)
+ if (names.contextName) {
+ await api(request, 'DELETE', `/api/v1/admin/contexts/${encodeURIComponent(names.contextName)}`)
+ }
}
async function waitForAgent(
@@ -80,14 +82,14 @@ test.describe('optional QA recorder: Control UI agent creation', () => {
const credentials = adminCredentials()
const agentName = uniqueE2EName('qa-recorder-agent')
- const contextName = `${agentName}-ctx`.slice(0, 63).replace(/-$/, '')
+ let contextName = ''
const memberLabel = process.env.E2E_AGENT_ACCESS_LABEL?.trim()
try {
await loginThroughUi(page, credentials)
const sessionRequest = page.request
const secretName = await requireLlmSecret(sessionRequest)
- await cleanupAgentFlowResources(sessionRequest, { agentName, contextName })
+ await cleanupAgentFlowResources(sessionRequest, { agentName })
await page.getByRole('link', { name: 'Agents', exact: true }).click()
await expect(page).toHaveURL(/\/(?:hosts|agents)$/)
@@ -101,10 +103,6 @@ test.describe('optional QA recorder: Control UI agent creation', () => {
await page.getByPlaceholder('agent-name').fill(agentName)
await clickWizardNext(page)
- await page.getByLabel(/create new context/i).check()
- await page.getByPlaceholder('context-name').fill(contextName)
- await clickWizardNext(page)
-
await expect(page.getByText('Model & credentials', { exact: true })).toBeVisible()
await page.getByLabel(/Use an existing Secret/i).check()
await page.getByRole('button', { name: /select secret/i }).click()
@@ -120,6 +118,8 @@ test.describe('optional QA recorder: Control UI agent creation', () => {
await expect(memberOption).toBeVisible()
await memberOption.click()
}
+ await clickWizardNext(page)
+ await expect(page.getByText('Add connectors', { exact: true })).toBeVisible()
const submitAgent = page.getByRole('button', { name: 'Create Agent', exact: true })
await expect(submitAgent).toBeEnabled()
await submitAgent.click()
@@ -127,7 +127,8 @@ test.describe('optional QA recorder: Control UI agent creation', () => {
await expect(page).toHaveURL(/\/(?:hosts|agents)$/)
const created = await waitForAgent(sessionRequest, agentName)
expect((created.metadata as { name?: string } | undefined)?.name).toBe(agentName)
- expect((created.spec as { contextRef?: string } | undefined)?.contextRef).toBe(contextName)
+ contextName = String((created.spec as { contextRef?: string } | undefined)?.contextRef || '')
+ expect(contextName).toMatch(new RegExp(`^${agentName}-[0-9]{5}$`))
expect((created.spec as { secretRef?: string } | undefined)?.secretRef).toBe(secretName)
await screenshotAndLog(page, testInfo, 'control-create-agent-complete')
diff --git a/control-ui/e2e/qa-recorder-create-form-smoke.spec.ts b/control-ui/e2e/qa-recorder-create-form-smoke.spec.ts
index 9a32efe61..1972b8e02 100644
--- a/control-ui/e2e/qa-recorder-create-form-smoke.spec.ts
+++ b/control-ui/e2e/qa-recorder-create-form-smoke.spec.ts
@@ -70,12 +70,12 @@ test.describe('optional QA recorder: Control UI create-form smoke', () => {
await screenshotAndLog(page, testInfo, 'control-ui-create-connector')
})
- test('Create agent form mounts and steps to context', async ({ page }, testInfo) => {
+ test('Create agent form mounts and steps to model & credentials', async ({ page }, testInfo) => {
await openCreatePage(page, '/agents/new')
await expectShell(
page,
'Create agent',
- 'Provision a new agent with context, credentials, and access.'
+ 'Provision a new agent with connectors, credentials, and access.'
)
await expect(page.getByPlaceholder('agent-name')).toBeVisible({ timeout: 20_000 })
@@ -85,7 +85,7 @@ test.describe('optional QA recorder: Control UI create-form smoke', () => {
.getByRole('button', { name: 'Next', exact: true })
await expect(next).toBeEnabled()
await next.click()
- await expect(page.getByText('Create new context', { exact: true })).toBeVisible({
+ await expect(page.getByText('Model & credentials', { exact: true })).toBeVisible({
timeout: 20_000,
})
diff --git a/control-ui/lib/__tests__/agentContext.test.ts b/control-ui/lib/__tests__/agentContext.test.ts
new file mode 100644
index 000000000..a9ada3ff6
--- /dev/null
+++ b/control-ui/lib/__tests__/agentContext.test.ts
@@ -0,0 +1,20 @@
+import { describe, expect, it } from 'vitest'
+import { createAgentContextName } from '../agentContext'
+import { isValidK8sName } from '../k8sValidation'
+
+describe('createAgentContextName', () => {
+ it('keeps the agent name and appends a five-digit implementation suffix', () => {
+ const contextName = createAgentContextName('research-agent')
+
+ expect(contextName).toMatch(/^research-agent-[0-9]{5}$/)
+ expect(isValidK8sName(contextName)).toBe(true)
+ })
+
+ it('caps long agent names so the generated context remains a valid label', () => {
+ const contextName = createAgentContextName('a'.repeat(63))
+
+ expect(contextName).toHaveLength(63)
+ expect(contextName).toMatch(/^a{57}-[0-9]{5}$/)
+ expect(isValidK8sName(contextName)).toBe(true)
+ })
+})
diff --git a/control-ui/lib/agentContext.ts b/control-ui/lib/agentContext.ts
new file mode 100644
index 000000000..4835d2ce2
--- /dev/null
+++ b/control-ui/lib/agentContext.ts
@@ -0,0 +1,30 @@
+import { RFC1123_MAX_LENGTH } from './k8sValidation'
+import { toKebabCase } from './string'
+
+const CONTEXT_SUFFIX_LENGTH = 5
+const CONTEXT_SUFFIX_MAX = 10 ** CONTEXT_SUFFIX_LENGTH
+
+function createShortContextSuffix(): string {
+ if (typeof globalThis.crypto?.getRandomValues === 'function') {
+ const values = new Uint32Array(1)
+ globalThis.crypto.getRandomValues(values)
+ return String(values[0] % CONTEXT_SUFFIX_MAX).padStart(CONTEXT_SUFFIX_LENGTH, '0')
+ }
+
+ return String(Math.floor(Math.random() * CONTEXT_SUFFIX_MAX)).padStart(CONTEXT_SUFFIX_LENGTH, '0')
+}
+
+/**
+ * Creates the private context name used by the agent creation flow.
+ *
+ * The context is an implementation detail of an agent, so its name is not
+ * shown in the wizard. Keep the agent prefix for operational traceability and
+ * add a short suffix so deleting and recreating an agent never reuses a stale
+ * context name. The result remains a valid RFC 1123 label.
+ */
+export function createAgentContextName(agentName: string): string {
+ const normalizedAgentName = toKebabCase(agentName) || 'agent'
+ const maxPrefixLength = RFC1123_MAX_LENGTH - CONTEXT_SUFFIX_LENGTH - 1
+ const prefix = normalizedAgentName.slice(0, maxPrefixLength).replace(/-+$/g, '') || 'agent'
+ return `${prefix}-${createShortContextSuffix()}`
+}
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index e1f64bb94..5037093b5 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.448",
+ "version": "0.1.449",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.448",
+ "version": "0.1.449",
"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.json
index b9acd05fc..40c5592f7 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.448",
+ "version": "0.1.449",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",
diff --git a/tests/e2e/playwright/control-ui/hosts.spec.ts b/tests/e2e/playwright/control-ui/hosts.spec.ts
index c9adc4205..7bb929d98 100644
--- a/tests/e2e/playwright/control-ui/hosts.spec.ts
+++ b/tests/e2e/playwright/control-ui/hosts.spec.ts
@@ -220,7 +220,7 @@ test.describe('Control UI — Stateless Agents', () => {
}) => {
test.setTimeout(180_000)
const agentName = `e2e-stateless-create-${Date.now()}`
- const contextName = `${agentName}-ctx`
+ let contextName = ''
const secretName = `${agentName}-secret`
try {
// PRECONDITION (labeled setup): a managed host secret for the picker.
@@ -247,12 +247,7 @@ test.describe('Control UI — Stateless Agents', () => {
await expect(statelessRadio).toBeChecked()
await authedPage.getByRole('button', { name: 'Next', exact: true }).click()
- // Step 1 — create a new context (no MCP servers required)
- await authedPage.getByRole('radio', { name: /Create new context/ }).check()
- await authedPage.getByPlaceholder('context-name').fill(contextName)
- await authedPage.getByRole('button', { name: 'Next', exact: true }).click()
-
- // Step 2 — keep the default model, reuse the first existing secret
+ // Step 1 — keep the default model, reuse the first existing secret
await authedPage.getByRole('radio', { name: /Use existing secret/ }).check()
await authedPage.getByRole('button', { name: /Select secret/ }).click()
// Deterministic pick: the exact secret this test seeded, never .first()
@@ -261,12 +256,11 @@ test.describe('Control UI — Stateless Agents', () => {
await seededSecret.click()
await authedPage.getByRole('button', { name: 'Next', exact: true }).click()
- // Step 3 — access grants are optional
+ // Step 2 — access grants are optional
await authedPage.getByRole('button', { name: 'Next', exact: true }).click()
- // Step 4 — no channel is needed for this flag-only flow. Channel ingress
- // behavior is covered by the stateless + CommunicationChannel test below.
- await authedPage.getByRole('button', { name: /Skip channel setup/ }).click()
+ // Step 3 — no connector is needed for this flag-only flow.
+ await authedPage.getByRole('button', { name: 'Create Agent', exact: true }).click()
// Completion leaves the create page (canonical routing) — the CR poll
// below is the business signal; this asserts the UI transition.
await expect(authedPage).not.toHaveURL(/\/hosts\/new/, { timeout: 30_000 })
@@ -276,10 +270,11 @@ test.describe('Control UI — Stateless Agents', () => {
host => host.spec?.lifecycle?.stateless === true,
'spec.lifecycle.stateless=true'
)
+ contextName = String(created.spec?.contextRef || '')
expect(created.spec?.lifecycle?.stateless).toBe(true)
} finally {
await controlApi.ensureHostDeleted(agentName)
- await controlApi.ensureContextDeleted(contextName)
+ if (contextName) await controlApi.ensureContextDeleted(contextName)
await controlApi.ensureSecretDeleted(secretName)
}
})
diff --git a/tests/e2e/playwright/package-lock.json b/tests/e2e/playwright/package-lock.json
index 5a1fcd0b2..6c6c236b5 100644
--- a/tests/e2e/playwright/package-lock.json
+++ b/tests/e2e/playwright/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-playwright-tests",
- "version": "0.1.20",
+ "version": "0.1.21",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-playwright-tests",
- "version": "0.1.20",
+ "version": "0.1.21",
"devDependencies": {
"@playwright/test": "^1.50.0",
"@types/node": "^22.0.0"
diff --git a/tests/e2e/playwright/package.json b/tests/e2e/playwright/package.json
index 16f1d4e30..23fc8d8a9 100644
--- a/tests/e2e/playwright/package.json
+++ b/tests/e2e/playwright/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-playwright-tests",
- "version": "0.1.20",
+ "version": "0.1.21",
"private": true,
"description": "Playwright E2E tests for Control UI and Desktop App",
"scripts": {