Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
Merge origin/dev into feat/agent-rename
Diego Zacarias59afd395766f
diff --cc control-api/src/routes/admin/resources.tsindex 9a3bdc249,6c00d42d0..fcd46531b--- a/control-api/src/routes/admin/resources.ts+++ b/control-api/src/routes/admin/resources.ts@@@ -5,11 -5,8 +5,12 @@@ import { enforceNamespace } from '../..import { validateCommunicationChannelSpec } from '../../http/validateCommunicationChannelSpec.js'import { validateMcpServerSpecPreflight } from '../../http/validateMcpServerSpec.js'import { K8sGateway } from '../../k8s.js'-import { K8sConflictError } from '../../services/resourceService.js'+import {+ K8sConflictError,+ K8sNotFoundError,+ type MutableResourceSnapshot,+} from '../../services/resourceService.js'+ import { secretKeyNames } from '../../services/secretKeyNames.js'import { ClerumResourceType } from '../../types.js'import {registerCommunicationChannelCredentialsRoutes,@@@ -647,14 -603,30 +734,36 @@@ export function createAdminResourcesRou),}: body+ // A null snapshot means the channel does not exist (loadCommunicationChannelSpecSnapshot+ // returns null only on 404). Skipping the guard here is what makes the response+ // honest: with no previous spec every provider reads as newly added, so the guard+ // would answer a PUT to a missing channel with `credentials[...] is required`+ // instead of the 404 updateResource is about to produce.+ if (isCommunicationChannelUpdate && previousCommunicationChannelSpec) {+ // updateBody.spec, not body.spec: the ref the write will actually carry+ // is the preserved one, and that is the Secret whose keys decide whether+ // a newly enabled provider can work. Reuses the snapshot already loaded+ // above — no second fetch.+ const transitionError = await providerTransitionError(+ gateway,+ updateBody.spec,+ previousCommunicationChannelSpec?.spec ?? null,+ undefined,+ ns+ )+ if (transitionError) {+ res.status(400).json({ error: transitionError })+ return+ }+ }try {- const updated = await gateway.updateResource(plural, req.params.name, updateBody, ns)+ // Only the ratchet path (hosts/contexts) has a pre-read to hand off; the+ // CC/mcpservers paths call with the original 4-arg arity untouched.+ const updated = ratchetCurrent+ ? await gateway.updateResource(plural, req.params.name, updateBody, ns, {+ preReadCurrent: ratchetCurrent,+ })+ : await gateway.updateResource(plural, req.params.name, updateBody, ns)if (plural === 'communicationchannels' && body.spec) {const missingField = missingPersistedProviderSetting(updateBody.spec, updated)if (missingField) {diff --cc control-ui/app/contexts/[name]/page.tsxindex 6608d126a,11a6b3c22..9dc15e465--- a/control-ui/app/contexts/[name]/page.tsx+++ b/control-ui/app/contexts/[name]/page.tsx@@@ -177,14 -178,10 +178,15 @@@ export default function ContextDetailsPconst [contextUsers, setContextUsers] = useState<ContextUser[]>([])const [contextTeams, setContextTeams] = useState<ContextTeam[]>([])const [resolvedContextId, setResolvedContextId] = useState(isNew ? '' : routeName)+ const [contextResourceVersion, setContextResourceVersion] = useState<string | undefined>()const [contextNameDraft, setContextNameDraft] = useState(isNew ? '' : routeName)+ const [displayNameDraft, setDisplayNameDraft] = useState('')const [descriptionDraft, setDescriptionDraft] = useState('')+ // The raw spec exactly as it arrived from the server. A context PUT is a+ // full-replace: spreading this on save preserves any additive spec field the+ // form doesn't model yet (e.g. spec.gfs) instead of dropping it on a rename.+ const [loadedSpec, setLoadedSpec] = useState<Record<string, unknown>>({})const [mcpServersDraft, setMcpServersDraft] = useState<string[]>([])const [sharedFileSystemsDraft, setSharedFileSystemsDraft] = useState<ContextSharedFileSystemRef[]@@@ -417,39 -415,21 +420,46 @@@setError('')try {if (isNew) {- await createContext({- metadata: { name: contextNameDraft.trim() },- spec: payload.spec,- })- const nextName = encodeURIComponent(contextNameDraft.trim())+ // Create: no prior server spec to preserve — build a fresh spec.+ // The visible name lives in spec.displayName; omit it when empty so an+ // unset display stays absent, not "".+ const createSpec: ContextSpec = {+ contextId,+ ...(trimmedDisplay ? { displayName: trimmedDisplay } : {}),+ description: descriptionDraft.trim(),+ mcpServers: mcpServersDraft,+ sharedFileSystems: sharedFileSystemsDraft,+ }+ await createContext({ metadata: { name: contextId }, spec: createSpec })+ const nextName = encodeURIComponent(contextId)router.replace(CONTROL_ROUTES.contexts.detail(nextName))} else {+ // Full-replace PUT: spread the spec exactly as it was loaded so additive+ // fields the form doesn't model (e.g. spec.gfs) survive a rename, then+ // overwrite only the fields the form owns.+ const nextSpec: Record<string, unknown> = {+ ...loadedSpec,+ contextId,+ description: descriptionDraft.trim(),+ mcpServers: mcpServersDraft,+ sharedFileSystems: sharedFileSystemsDraft,+ }+ // Clearing the display name must REMOVE it, not leave the spread's stale+ // value — so a delete is required, the empty-omit ternary no longer suffices.+ if (trimmedDisplay) nextSpec.displayName = trimmedDisplay+ else delete nextSpec.displayName- await updateContext(routeName, { spec: nextSpec as unknown as ContextSpec })++ // Optimistic concurrency: carry the loaded resourceVersion so a stale++ // edit 409s instead of clobbering a concurrent write, and track the++ // version the server echoes back for the next save.+ const updated = await updateContext(+ routeName,- buildContextUpdatePayload(contextResourceVersion, payload.spec)++ buildContextUpdatePayload(contextResourceVersion, nextSpec as unknown as ContextSpec)+ )+ setContextResourceVersion(updated.metadata?.resourceVersion ?? contextResourceVersion)- setResolvedContextId(payload.spec.contextId)+ setResolvedContextId(contextId)setSavedDescription(descriptionDraft)setSavedContextName(contextNameDraft)+ setSavedDisplayName(trimmedDisplay)setEditing(false)}showToast('Context saved.', { tone: 'success' })@@@ -464,21 -444,16 +474,25 @@@setBusy(true)setError('')try {+ // Full-replace PUT: spread the loaded spec so additive fields the form+ // doesn't model (e.g. spec.gfs) survive a connector edit, then overwrite+ // only the fields this handler owns (all re-echoed from current state).+ const nextSpec: Record<string, unknown> = {+ ...loadedSpec,+ contextId: resolvedContextId,+ description: descriptionDraft.trim(),+ mcpServers: nextServers,+ sharedFileSystems: sharedFileSystemsDraft,+ }+ // Echo the persisted display name; a cleared name must REMOVE it, not leave+ // the spread's stale value — so a delete is required (mirrors save()).+ if (savedDisplayName.trim()) nextSpec.displayName = savedDisplayName.trim()+ else delete nextSpec.displayName- await updateContext(routeName, { spec: nextSpec as unknown as ContextSpec })+ const updated = await updateContext(+ routeName,- buildContextUpdatePayload(contextResourceVersion, {- contextId: resolvedContextId,- description: descriptionDraft.trim(),- mcpServers: nextServers,- sharedFileSystems: sharedFileSystemsDraft,- })++ buildContextUpdatePayload(contextResourceVersion, nextSpec as unknown as ContextSpec)+ )+ setContextResourceVersion(updated.metadata?.resourceVersion ?? contextResourceVersion)setMcpServersDraft(nextServers)showToast('Connectors updated.', { tone: 'success' })} catch (e) {@@@ -492,21 -467,16 +506,25 @@@setBusy(true)setError('')try {+ // Full-replace PUT: spread the loaded spec so additive fields the form+ // doesn't model (e.g. spec.gfs) survive an SFS edit, then overwrite only+ // the fields this handler owns (all re-echoed from current state).+ const nextSpec: Record<string, unknown> = {+ ...loadedSpec,+ contextId: resolvedContextId,+ description: descriptionDraft.trim(),+ mcpServers: mcpServersDraft,+ sharedFileSystems: nextRefs,+ }+ // Echo the persisted display name; a cleared name must REMOVE it, not leave+ // the spread's stale value — so a delete is required (mirrors save()).+ if (savedDisplayName.trim()) nextSpec.displayName = savedDisplayName.trim()+ else delete nextSpec.displayName- await updateContext(routeName, { spec: nextSpec as unknown as ContextSpec })+ const updated = await updateContext(+ routeName,- buildContextUpdatePayload(contextResourceVersion, {- contextId: resolvedContextId,- description: descriptionDraft.trim(),- mcpServers: mcpServersDraft,- sharedFileSystems: nextRefs,- })++ buildContextUpdatePayload(contextResourceVersion, nextSpec as unknown as ContextSpec)+ )+ setContextResourceVersion(updated.metadata?.resourceVersion ?? contextResourceVersion)setSharedFileSystemsDraft(nextRefs)showToast('Shared filesystems updated.', { tone: 'success' })} catch (e) {diff --cc control-ui/components/ContextTable.tsxindex 8633e8810,a83afd6f4..e0ad406c6--- a/control-ui/components/ContextTable.tsx+++ b/control-ui/components/ContextTable.tsx@@@ -152,25 -146,10 +151,13 @@@ export function ContextTable(aria-label={`Open context ${name}`}><td>- <button- type="button"- className="cu-link"- onClick={event => {- event.stopPropagation()- openContext(name)- }}- onKeyDown={event => event.stopPropagation()}- >- {displayName}- </button>- <span className="cu-expandable-row__name">{name}</span>++ <span className="cu-expandable-row__name">{displayName}</span>+ {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' }}>+ <div className="cu-registry-description" title={item.spec?.description || '—'}>{item.spec?.description || '—'}- </span>+ </div></td><td style={{ color: 'var(--cu-text-muted)', fontVariantNumeric: 'tabular-nums' }}>{mcpServers.length}diff --cc control-ui/components/__tests__/ContextTable.test.tsxindex 4d90c3bb9,c5d2e2bb7..af9b9566c--- a/control-ui/components/__tests__/ContextTable.test.tsx+++ b/control-ui/components/__tests__/ContextTable.test.tsx@@@ -40,37 -36,26 +36,53 @@@ describe('ContextTable', () =>expect(onView).toHaveBeenCalledWith({ name: 'business' })})+ it('stacks a non-link context name and its description in one cell', () => {+ const { container } = render(+ <ContextTable+ items={contexts}+ onView={vi.fn()}+ onEdit={vi.fn()}+ onDelete={vi.fn().mockResolvedValue(undefined)}+ deletingKey={null}+ onRefresh={vi.fn()}+ onCreate={vi.fn()}+ refreshing={false}+ />+ )++ expect(screen.getByText('business')).toHaveClass('cu-expandable-row__name')+ expect(screen.getByText('Business context')).toHaveClass('cu-registry-description')+ expect(container.querySelectorAll('thead th')).toHaveLength(3)+ expect(screen.queryByRole('button', { name: 'business' })).not.toBeInTheDocument()+ })++ it('renders the identifier (metadata.name) when displayName is blank/whitespace (R4-M1 / R1-L4)', () => {+ // A displayName written out-of-band as whitespace (' ') must fall back to- // the identifier, not render a blank label. Assert the observable rendered- // text (T4), not the intermediate spec value.++ // the identifier, not render a blank label. dev restructured the cell to a++ // non-link span (cu-expandable-row__name), so assert the observable rendered++ // name text (T4), not a button role and not the intermediate spec value.+ render(+ <ContextTable+ items={[- {++ buildContextResource({+ metadata: { name: 'business' },- spec: {- contextId: 'business',- displayName: ' ',- description: '',- mcpServers: [],- },- },++ spec: { displayName: ' ', description: '', mcpServers: [] },++ }),+ ]}+ onView={vi.fn()}+ onEdit={vi.fn()}+ onDelete={vi.fn().mockResolvedValue(undefined)}+ deletingKey={null}+ onRefresh={vi.fn()}+ onCreate={vi.fn()}+ refreshing={false}+ />+ )+- // The primary name link renders the identifier, not a blank/whitespace label.- expect(screen.getByRole('button', { name: 'business' })).toBeInTheDocument()++ // The visible name span renders the identifier, not a blank/whitespace label.++ expect(screen.getByText('business')).toHaveClass('cu-expandable-row__name')+ })+it('does not open a context from row action buttons', () => {const onView = vi.fn()const onEdit = vi.fn()diff --cc control-ui/package-lock.jsonindex b93964ed4,047434771..ed451de3d--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@@ -6,9 -6,8 +6,9 @@@"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.399",+ "version": "0.1.413","dependencies": {+ "@clerum/display-field": "file:../packages/display-field","@clerum/llm-providers": "file:../packages/llm-providers","@clerum/workflow-recipe-capability-policy": "file:../packages/workflow-recipe-capability-policy","@uiw/react-md-editor": "^4.1.0",diff --cc control-ui/test/fixtures/contextResource.tsindex 000000000,45370d46f..d8886a0ddmode 000000,100644..100644--- a/control-ui/test/fixtures/contextResource.ts+++ b/control-ui/test/fixtures/contextResource.ts@@@ -1,0 -1,50 +1,55 @@@+ import type { ContextSharedFileSystemRef, ContextSharedFileSystemStatus } from '../../lib/api'++ export type ProducerContextResource = {+ metadata: {+ name: string+ namespace: string+ resourceVersion: string+ }+ spec: {+ contextId: string++ /** Optional visible name (spec.displayName); the producer omits it when unset. */++ displayName?: string+ description: string+ mcpServers: string[]+ sharedFileSystems: ContextSharedFileSystemRef[]+ }+ status: {+ sharedFileSystems: ContextSharedFileSystemStatus[]+ }+ }++ export type ContextResourceOverrides = {+ metadata?: Partial<ProducerContextResource['metadata']>+ spec?: Partial<ProducerContextResource['spec']>+ status?: Partial<ProducerContextResource['status']>+ }++ export function buildContextResource(+ overrides: ContextResourceOverrides = {}+ ): ProducerContextResource {+ const name = overrides.metadata?.name ?? overrides.spec?.contextId ?? 'research'+ return {+ metadata: {+ name,+ namespace: overrides.metadata?.namespace ?? 'mcp-server',+ resourceVersion: overrides.metadata?.resourceVersion ?? 'rv-context-read',+ },+ spec: {+ contextId: overrides.spec?.contextId ?? name,++ ...(overrides.spec?.displayName !== undefined++ ? { displayName: overrides.spec.displayName }++ : {}),+ description: overrides.spec?.description ?? '',+ mcpServers: [...(overrides.spec?.mcpServers ?? [])],+ sharedFileSystems: [...(overrides.spec?.sharedFileSystems ?? [])],+ },+ status: {+ sharedFileSystems: [...(overrides.status?.sharedFileSystems ?? [])],+ },+ }+ }++ export function buildContextList(items: readonly ProducerContextResource[] = []) {+ return { items: [...items] }+ }diff --cc control-ui/vitest.config.tsindex 97b77f1b3,87699ccfe..31bd72363--- a/control-ui/vitest.config.ts+++ b/control-ui/vitest.config.ts@@@ -24,7 -24,7 +24,8 @@@ 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}',+ 'test/**/__tests__/**/*.{test,spec}.{ts,tsx}',],exclude: ['node_modules', '.next'],},