Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix: fall back to identifier when displayName is empty or whitespace-only (R4-M1)
Diego Zacarias0e5dc5725d93
diff --git a/control-api/package-lock.json b/control-api/package-lock.jsonindex e8203c5c1..e20f35bb9 100644--- a/control-api/package-lock.json+++ b/control-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-api",- "version": "0.1.446",+ "version": "0.1.447","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-api",- "version": "0.1.446",+ "version": "0.1.447","dependencies": {"@clerum/image-policy": "file:../packages/image-policy","@clerum/llm-providers": "file:../packages/llm-providers",diff --git a/control-api/package.json b/control-api/package.jsonindex 9cb0d76e8..7ce1538ed 100644--- a/control-api/package.json+++ b/control-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-api",- "version": "0.1.446",+ "version": "0.1.447","description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets","main": "dist/main.js","engines": {diff --git a/control-api/src/routes/admin/resourceFieldValidation.ts b/control-api/src/routes/admin/resourceFieldValidation.tsindex d108260b5..2e1cb1265 100644--- a/control-api/src/routes/admin/resourceFieldValidation.ts+++ b/control-api/src/routes/admin/resourceFieldValidation.ts@@ -79,6 +79,9 @@ export function validateDisplayField(value: unknown, field: string): FieldIssuemessage: `${field} must not contain control or bidirectional formatting characters`,}}+ if (value.trim().length === 0) {+ return { field, message: `${field} must not be empty or whitespace-only` }+ }if (value.trim().length > DISPLAY_FIELD_MAX_LENGTH) {return {field,diff --git a/control-api/test/routes.resourceFieldValidation.emptyDisplay.test.ts b/control-api/test/routes.resourceFieldValidation.emptyDisplay.test.tsnew file mode 100644index 000000000..98663e973--- /dev/null+++ b/control-api/test/routes.resourceFieldValidation.emptyDisplay.test.ts@@ -0,0 +1,27 @@+import { describe, expect, it } from 'vitest'+import { validateDisplayField } from '../src/routes/admin/resourceFieldValidation.js'++// R4-M1 (producer side): empty / whitespace-only must be rejected. The edit UI+// never sends '' (it omits the field), so rejecting does not break "clear".+describe('validateDisplayField — empty / whitespace-only (R4-M1)', () => {+ it('accepts a normal single-line label', () => {+ expect(validateDisplayField('ok', 'f')).toBeNull()+ })++ it('skips an absent (undefined) field — presence is optional', () => {+ expect(validateDisplayField(undefined, 'f')).toBeNull()+ })++ it('rejects the empty string', () => {+ const issue = validateDisplayField('', 'f')+ expect(issue).not.toBeNull()+ expect(issue?.field).toBe('f')+ expect(issue?.message).toContain('empty or whitespace-only')+ })++ it('rejects a whitespace-only string', () => {+ const issue = validateDisplayField(' ', 'f')+ expect(issue).not.toBeNull()+ expect(issue?.message).toContain('empty or whitespace-only')+ })+})diff --git a/control-ui/components/ContextTable.tsx b/control-ui/components/ContextTable.tsxindex 2211a4c63..8633e8810 100644--- a/control-ui/components/ContextTable.tsx+++ b/control-ui/components/ContextTable.tsx@@ -46,8 +46,10 @@ 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 ?? name+ // (metadata.name) when it is absent OR blank-after-trim — a displayName+ // written out-of-band (e.g. kubectl) as '' or ' ' must not render a+ // blank label. Mirrors HostTable.tsx (`.trim() || name`).+ const displayName = (item.spec?.displayName ?? '').trim() || nameconst key = nameconst mcpServers = Array.isArray(item.spec?.mcpServers) ? item.spec?.mcpServers : []return { key, name, displayName, item, mcpServers }diff --git a/control-ui/components/__tests__/ContextTable.test.tsx b/control-ui/components/__tests__/ContextTable.test.tsxindex 336e2aa1c..4d90c3bb9 100644--- a/control-ui/components/__tests__/ContextTable.test.tsx+++ b/control-ui/components/__tests__/ContextTable.test.tsx@@ -40,6 +40,37 @@ describe('ContextTable', () => {expect(onView).toHaveBeenCalledWith({ name: 'business' })})+ 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.+ render(+ <ContextTable+ items={[+ {+ metadata: { name: 'business' },+ spec: {+ contextId: 'business',+ 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()+ })+it('does not open a context from row action buttons', () => {const onView = vi.fn()const onEdit = vi.fn()diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex c555b1a8f..2dab034a7 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.392",+ "version": "0.1.393","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.392",+ "version": "0.1.393","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 3ac24d536..dd8c70fc9 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.392",+ "version": "0.1.393","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",diff --git a/desktop-app/ui/src/components/AppHeader/index.tsx b/desktop-app/ui/src/components/AppHeader/index.tsxindex b83e6c7df..1cb37ead7 100644--- a/desktop-app/ui/src/components/AppHeader/index.tsx+++ b/desktop-app/ui/src/components/AppHeader/index.tsx@@ -403,9 +403,10 @@ export const AppHeader = React.memo(function AppHeader({.map(([value, details]) => ({key: value,value,- // Visible name = context `spec.displayName`; single sanctioned fallback- // to the id (spec Decision #6). Empty today until the source lands (§8).- display: contextDisplayById[value] ?? value,+ // Visible name = context `spec.displayName`; fall back to the id (spec+ // Decision #6) when no display exists OR the display is blank/whitespace-+ // only (an out-of-band write must never render an empty context label).+ display: (contextDisplayById[value] ?? '').trim() || value,fromSelectedScope: details.fromSelectedScope,fromUserScope: false,teamNames: [...details.teamNames].sort((a, b) => a.localeCompare(b)),diff --git a/desktop-app/ui/src/components/agents/AgentWorkspace.tsx b/desktop-app/ui/src/components/agents/AgentWorkspace.tsxindex b63e24589..3383032b3 100644--- a/desktop-app/ui/src/components/agents/AgentWorkspace.tsx+++ b/desktop-app/ui/src/components/agents/AgentWorkspace.tsx@@ -394,9 +394,11 @@ export function AgentWorkspace({ mode = 'agents', scrollContainerRef }: AgentWortitle={contextId}aria-label={`Open context ${contextId}`}>- {/* Visible context name (spec.displayName); single- fallback to the id (Decision #6). */}- {contextDisplayById[contextId] ?? contextId}+ {/* Visible context name (spec.displayName); fall back+ to the id (Decision #6) when no display exists OR+ the display is blank/whitespace-only (an out-of-band+ write must never render an empty context label). */}+ {(contextDisplayById[contextId] ?? '').trim() || contextId}</ReferenceTag></td><td className="da-table__cell">diff --git a/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.displayName.test.tsx b/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.displayName.test.tsxindex 2131dc804..4d6ae3cdf 100644--- a/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.displayName.test.tsx+++ b/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.displayName.test.tsx@@ -99,6 +99,19 @@ describe('AgentWorkspace context rows — visible name (UT-11)', () => {// Branch WITHOUT display: renders the id (metadata.name) — single fallback.expect(screen.getByText('ctx-plain')).toBeTruthy()})++ it('falls back to the id when the context display is blank/whitespace-only', () => {+ // An out-of-band write (e.g. kubectl bypassing control-api validation) can+ // leave a whitespace-only spec.displayName. The row must render the stable+ // id, never a blank context label (same class as R4-M1 GfsAgentAccessSection).+ contextsMock.contextIds = ['ctx-blank']+ contextsMock.contextDisplayById = { 'ctx-blank': ' ' }++ render(<AgentWorkspace scrollContainerRef={{ current: null }} />)++ // Observable text is the id, not the whitespace-only display.+ expect(screen.getByText('ctx-blank')).toBeTruthy()+ })})// R1-M3 (desktop-app): the workspace hero title must show the agent DISPLAY namediff --git a/desktop-app/ui/src/gfs/GfsAgentAccessSection/index.tsx b/desktop-app/ui/src/gfs/GfsAgentAccessSection/index.tsxindex c7bc59ab3..e7e507396 100644--- a/desktop-app/ui/src/gfs/GfsAgentAccessSection/index.tsx+++ b/desktop-app/ui/src/gfs/GfsAgentAccessSection/index.tsx@@ -81,8 +81,10 @@ export function GfsAgentAccessSection({size="sm">{/* Visible agent name (spec.host); the id-based `name` is the- last-resort label for entries without a display source. */}- {agent.displayName ?? agent.name}+ last-resort label for entries with no display source OR a+ blank/whitespace-only displayName (an out-of-band write must+ never render a selectable option with an empty label). */}+ {(agent.displayName ?? '').trim() || agent.name}</SelectableOption>))}</div>diff --git a/desktop-app/ui/src/gfs/__tests__/GfsAgentAccessSection.test.tsx b/desktop-app/ui/src/gfs/__tests__/GfsAgentAccessSection.test.tsxindex 3744df990..e61adc36c 100644--- a/desktop-app/ui/src/gfs/__tests__/GfsAgentAccessSection.test.tsx+++ b/desktop-app/ui/src/gfs/__tests__/GfsAgentAccessSection.test.tsx@@ -106,6 +106,25 @@ describe('GfsAgentAccessSection', () => {).toBe('true')})+ it('falls back to the identifier when displayName is blank/whitespace-only', () => {+ // An out-of-band write (e.g. kubectl bypassing control-api validation) can+ // leave a whitespace-only displayName. The option must render the stable+ // identifier, never a selectable option with an empty visible label.+ render(+ <GfsAgentAccessSection+ agents={[+ { id: '1st:mcp-host/blankname', name: 'blankname', displayName: ' ' },+ { id: '1st:mcp-host/emptyname', name: 'emptyname', displayName: '' },+ ]}+ isDirectory+ onGrantAgents={vi.fn()}+ />+ )++ expect(screen.getByRole('button', { name: 'blankname' })).toBeTruthy()+ expect(screen.getByRole('button', { name: 'emptyname' })).toBeTruthy()+ })+it('renders an empty notice when the caller has no grantable agents', () => {render(<GfsAgentAccessSection agents={[]} isDirectory onGrantAgents={vi.fn()} />)