Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
feat(desktop-app): render editable display name for agents and contexts
Diego Zacarias6ac847a79854
diff --git a/desktop-app/src/appService.ts b/desktop-app/src/appService.tsindex f3c2539c6..2d94de386 100644--- a/desktop-app/src/appService.ts+++ b/desktop-app/src/appService.ts@@ -1613,6 +1613,14 @@ export class AppService {const contextMcpServers: Record<string, Array<{ name: string }>> = {}const agentContextByName: Record<string, string | null> = {}const agentProviderByName: Record<string, string | null> = {}+ // Visible agent name (Agent CRD `spec.host`, arriving as the wire+ // `displayName`) keyed by `metadata.name`. This is the single producer+ // boundary for the desktop catalog: the `|| name` guard lives here only+ // (mirroring control-api's accessReconciliation `configuredDisplayName ||+ // name`), so renderer consumers read `agentDisplayByName[name]` directly+ // without sprinkling `|| name` (spec Decision #6). Filled total over+ // `agentNames` below so a lookup is never undefined.+ const agentDisplayByName: Record<string, string> = {}const upsertScopedServers = (target: Record<string, Array<{ name: string }>>,key: string,@@ -1628,6 +1636,7 @@ export class AppService {const collectAgents = (agents?: Array<{name: string+ displayName?: string | nullcontextRef?: string | nullprovider?: string | nullmodel?: { provider?: string | null } | null@@ -1638,6 +1647,13 @@ export class AppService {for (const a of agents) {const agentName = String(a?.name || '').trim()if (!agentName) continue+ const displayNameCandidate = typeof a?.displayName === 'string' ? a.displayName.trim() : ''+ if (+ displayNameCandidate &&+ !Object.prototype.hasOwnProperty.call(agentDisplayByName, agentName)+ ) {+ agentDisplayByName[agentName] = displayNameCandidate+ }const contextRef =typeof a?.contextRef === 'string' && a.contextRef.trim().length > 0? a.contextRef.trim()@@ -1677,6 +1693,7 @@ export class AppService {const filterAgentDetails = (agents?: Array<{name: string+ displayName?: string | nullcontextRef?: string | nullprovider?: string | nullmodel?: { provider?: string | null } | null@@ -1696,6 +1713,12 @@ export class AppService {if (!Object.prototype.hasOwnProperty.call(agentProviderByName, agentName)) {agentProviderByName[agentName] = null}+ // Producer-side `|| name` guard (the only one — see Decision #6): an agent+ // whose wire entry carried no `displayName` (pre-display API build) falls+ // back to its identifier here so consumers never render an empty label.+ if (!Object.prototype.hasOwnProperty.call(agentDisplayByName, agentName)) {+ agentDisplayByName[agentName] = agentName+ }}const hasAgentScopedMcp = Object.keys(agentMcpServers).length > 0@@ -1715,6 +1738,7 @@ export class AppService {...(hasContextScopedMcp ? { contextMcpServers } : {}),agentContextByName,agentProviderByName,+ agentDisplayByName,}return this.accessCatalog}diff --git a/desktop-app/src/types.ts b/desktop-app/src/types.tsindex 7b3570468..3973bd78a 100644--- a/desktop-app/src/types.ts+++ b/desktop-app/src/types.ts@@ -374,6 +374,14 @@ export type UserContexts = {*/export type AgentWithMcpServers = {name: string+ /**+ * Human-visible name for the agent (Agent CRD `spec.host`), surfaced by+ * control-api's agent directory (accessReconciliation.buildAgentDirectoryEntry)+ * and threaded through external-rest-api. `spec.host` is required in the CRD,+ * so this is expected to always be present for a real agent; it is optional on+ * the wire only to stay compatible with pre-display API builds.+ */+ displayName?: stringcontextRef: string | nullprovider?: string | nullmcpServers: Array<{ name: string }>@@ -447,6 +455,22 @@ export type AccessCatalog = {* as unknown.*/agentProviderByName?: Record<string, string | null>+ /**+ * Visible name (Agent CRD `spec.host`) keyed by agent `metadata.name`. Built+ * once at this producer boundary from the wire `displayName` (mirroring+ * control-api's `configuredDisplayName || name` guard), so renderer consumers+ * read `agentDisplayByName[name]` directly WITHOUT re-adding a `|| name`+ * fallback (spec Decision #6: the guard lives at the producer, not sprinkled+ * across consumers). Present when the catalog carried any agent display.+ */+ agentDisplayByName?: Record<string, string>+ /**+ * Visible name (Context CRD `spec.displayName`) keyed by context id. Optional+ * field with no dedicated producer on the session path yet (external context+ * display endpoint undecided — spec §8 / UT-7b), so consumers apply the single+ * sanctioned fallback `contextDisplayById[id] ?? id`.+ */+ contextDisplayById?: Record<string, string>}export type RpcMcpServer = {diff --git a/desktop-app/ui/src/components/AppHeader/__tests__/displayName.test.tsx b/desktop-app/ui/src/components/AppHeader/__tests__/displayName.test.tsxnew file mode 100644index 000000000..ad574530c--- /dev/null+++ b/desktop-app/ui/src/components/AppHeader/__tests__/displayName.test.tsx@@ -0,0 +1,106 @@+// @vitest-environment jsdom+import { afterEach, describe, expect, it, vi } from 'vitest'+import { cleanup, fireEvent, render, screen } from '@testing-library/react'+import type { AccessCatalog } from '../../../../../src/types'+import { AppHeader } from '../index'++// UT-11 (spec §5, F3 desktop-app) — Agent WITHOUT fallback.+// The agents menu must render the visible name (spec.host, surfaced as the+// catalog's agentDisplayByName) and NOT the identifier (metadata.name). The+// fixture makes the display ("Product Agents") differ from the name+// ("product-agent") so rendering the name instead of the display fails.++const catalogMock = vi.hoisted(() => ({ current: null as AccessCatalog | null }))++vi.mock('@hooks/domain/useAgentsDataController', () => ({+ useAgentsDataController: () => ({ accessCatalog: catalogMock.current }),+}))++vi.mock('@hooks/domain/useContextsDataController', () => ({+ useContextsDataController: () => ({ contextIds: [] }),+}))++vi.mock('@hooks/domain/useMcpServersDataController', () => ({+ useMcpServersDataController: () => ({ globalMcpServers: [], mcpServersByAgent: {} }),+}))++vi.mock('@hooks/domain/useTeamsDataController', () => ({+ useTeamsDataController: () => ({+ teams: [],+ teamMembers: [],+ teamDirectory: {},+ loading: false,+ teamDirectoryHydrated: true,+ currentTeamId: '',+ ensureHydrated: vi.fn(async () => undefined),+ }),+}))++vi.mock('@contexts/NavigationContext', () => ({+ useNavigationContext: () => ({+ navItem: 'apps',+ handleNavSelect: vi.fn(),+ handleOpenContextDetails: vi.fn(),+ handleOpenTeamDetails: vi.fn(),+ }),+}))++vi.mock('@contexts/NotificationsContext', () => ({+ useNotificationsContext: () => ({+ notifications: [],+ unreadNotificationCount: 0,+ notificationActionById: {},+ pendingApprovals: [],+ pendingApprovalsLoading: false,+ pendingApprovalActionId: null,+ markNotificationsRead: vi.fn(),+ clearNotifications: vi.fn(),+ removeNotification: vi.fn(),+ handleOpenNotification: vi.fn(),+ handleApproveNotification: vi.fn(),+ handleDenyNotification: vi.fn(),+ handleRefreshPendingApprovals: vi.fn(async () => undefined),+ handleDecidePendingApproval: vi.fn(),+ }),+}))++vi.mock('@hooks/useClickOutside', () => ({ useClickOutside: vi.fn() }))++function catalogWithAgentDisplay(): AccessCatalog {+ return {+ userId: 'user-1',+ teamId: null,+ userContextIds: [],+ userAgentNames: ['product-agent'],+ teamContextIds: [],+ teamAgentNames: [],+ contextIds: [],+ agentNames: ['product-agent'],+ mcpServersByAgent: {},+ agentContextByName: { 'product-agent': null },+ agentProviderByName: {},+ agentDisplayByName: { 'product-agent': 'Product Agents' },+ }+}++describe('AppHeader agents menu — visible name (UT-11)', () => {+ afterEach(() => {+ cleanup()+ catalogMock.current = null+ vi.clearAllMocks()+ })++ it('renders the agent display (spec.host) not the identifier', () => {+ catalogMock.current = catalogWithAgentDisplay()+ render(<AppHeader />)++ fireEvent.change(screen.getByLabelText('Search'), { target: { value: 'Product' } })++ // The search matched an agent (the "Agents" group heading is present).+ expect(screen.getByText('Agents')).toBeTruthy()+ // Reads the display directly — an implementation rendering the name would+ // show "product-agent" here and fail.+ expect(screen.getByText('Product Agents')).toBeTruthy()+ expect(screen.queryByText('product-agent')).toBeNull()+ })+})diff --git a/desktop-app/ui/src/components/AppHeader/index.tsx b/desktop-app/ui/src/components/AppHeader/index.tsxindex 856379a01..b83e6c7df 100644--- a/desktop-app/ui/src/components/AppHeader/index.tsx+++ b/desktop-app/ui/src/components/AppHeader/index.tsx@@ -85,7 +85,7 @@ export const AppHeader = React.memo(function AppHeader({onShellOverlayOpenChange,}: AppHeaderProps) {const { accessCatalog: agentsAccessCatalog } = useAgentsDataController()- const { contextIds } = useContextsDataController()+ const { contextIds, contextDisplayById } = useContextsDataController()const { globalMcpServers, mcpServersByAgent } = useMcpServersDataController()const {teams,@@ -307,11 +307,17 @@ export const AppHeader = React.memo(function AppHeader({}}+ // Visible name = agent `spec.host` (catalog `agentDisplayByName`, total over+ // catalog agents at the producer). The `?? value` covers cross-team agents+ // added from the team directory (no catalog display source), not a defensive+ // guard on catalog agents — see spec Decision #6.+ const agentDisplayByName = accessCatalog?.agentDisplayByNamereturn [...byName.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([value, details]) => ({key: value,value,+ display: agentDisplayByName?.[value] ?? value,fromSelectedScope: details.fromSelectedScope,fromUserScope: details.fromUserScope,teamNames: [...details.teamNames].sort((a, b) => a.localeCompare(b)),@@ -359,6 +365,7 @@ export const AppHeader = React.memo(function AppHeader({? aggregatedAgents.filter(agent =>agent.value.toLowerCase().includes(normalizedSearch) ||+ agent.display.toLowerCase().includes(normalizedSearch) ||agent.teamNames.some(teamName => teamName.toLowerCase().includes(normalizedSearch))): [],@@ -396,17 +403,21 @@ 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,fromSelectedScope: details.fromSelectedScope,fromUserScope: false,teamNames: [...details.teamNames].sort((a, b) => a.localeCompare(b)),}))- }, [contextIds, teamDirectory, teams])+ }, [contextDisplayById, contextIds, teamDirectory, teams])const filteredContexts = useMemo(() =>hasSearch? aggregatedContexts.filter(context =>context.value.toLowerCase().includes(normalizedSearch) ||+ context.display.toLowerCase().includes(normalizedSearch) ||context.teamNames.some(teamName => teamName.toLowerCase().includes(normalizedSearch))): [],@@ -438,6 +449,8 @@ export const AppHeader = React.memo(function AppHeader({.map(([value, agentNames]) => ({key: value,value,+ // Connectors have no separate display name; the server name is the label.+ display: value,fromSelectedScope: true,fromUserScope: false,teamNames: [...agentNames].sort((a, b) => a.localeCompare(b)),@@ -592,7 +605,7 @@ export const AppHeader = React.memo(function AppHeader({size="sm"><div className="search-result-main">- <strong>{context.value}</strong>+ <strong>{context.display}</strong><span className="search-result-subline">{context.teamNames.length? `Teams: ${context.teamNames.join(', ')}`@@ -652,7 +665,7 @@ export const AppHeader = React.memo(function AppHeader({size="sm"><div className="search-result-main">- <strong>{agent.value}</strong>+ <strong>{agent.display}</strong><span className="search-result-subline">{agent.teamNames.length? `Teams: ${agent.teamNames.join(', ')}`diff --git a/desktop-app/ui/src/components/AppHeader/types.ts b/desktop-app/ui/src/components/AppHeader/types.tsindex fc7fcb49b..6935045bb 100644--- a/desktop-app/ui/src/components/AppHeader/types.ts+++ b/desktop-app/ui/src/components/AppHeader/types.ts@@ -20,7 +20,10 @@ export type SearchEntityResult = {fromUserScope: booleankey: stringteamNames: string[]+ /** Stable identifier (agent `metadata.name` / context id) — used for keys, navigation and filtering. */value: string+ /** Human-visible label rendered to the user (agent `spec.host` / context `spec.displayName`). */+ display: string}export type SearchTeamResult = {diff --git a/desktop-app/ui/src/components/agents/AgentWorkspace.tsx b/desktop-app/ui/src/components/agents/AgentWorkspace.tsxindex b1937ea9b..888fd4703 100644--- a/desktop-app/ui/src/components/agents/AgentWorkspace.tsx+++ b/desktop-app/ui/src/components/agents/AgentWorkspace.tsx@@ -69,7 +69,12 @@ export function AgentWorkspace({ mode = 'agents', scrollContainerRef }: AgentWorhandleOpenContextDetails,} = useNavigationContext()const { agentNames } = useAgentsDataController()- const { contextIds, loading: contextsLoading, error: contextsError } = useContextsDataController()+ const {+ contextIds,+ contextDisplayById,+ loading: contextsLoading,+ error: contextsError,+ } = useContextsDataController()const { agentContextByName, selectedAgentMcpServers } = useMcpServersDataController({selectedAgent,})@@ -375,7 +380,9 @@ export function AgentWorkspace({ mode = 'agents', scrollContainerRef }: AgentWortitle={contextId}aria-label={`Open context ${contextId}`}>- {contextId}+ {/* Visible context name (spec.displayName); single+ fallback to the id (Decision #6). */}+ {contextDisplayById[contextId] ?? 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.tsxnew file mode 100644index 000000000..f03f92a28--- /dev/null+++ b/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.displayName.test.tsx@@ -0,0 +1,79 @@+// @vitest-environment jsdom+import { afterEach, describe, expect, it, vi } from 'vitest'+import { cleanup, render, screen } from '@testing-library/react'+import { AgentWorkspace } from '../AgentWorkspace'++// UT-11 (spec §5, F3 desktop-app) — Context display with the single sanctioned+// fallback `contextDisplayById[id] ?? id`:+// - WITH display: a context whose displayName ("Prod Ctx") differs from its id+// renders the display.+// - WITHOUT display: a context with no displayName renders its id+// (metadata.name) — the only fallback.++const contextsMock = vi.hoisted(() => ({+ contextIds: [] as string[],+ contextDisplayById: {} as Record<string, string>,+}))++vi.mock('@hooks/domain/useAgentsDataController', () => ({+ useAgentsDataController: () => ({ agentNames: ['product-agent'] }),+}))++vi.mock('@hooks/domain/useContextsDataController', () => ({+ useContextsDataController: () => ({+ contextIds: contextsMock.contextIds,+ contextDisplayById: contextsMock.contextDisplayById,+ loading: false,+ error: null,+ }),+}))++vi.mock('@hooks/domain/useMcpServersDataController', () => ({+ useMcpServersDataController: () => ({+ agentContextByName: {},+ selectedAgentMcpServers: [],+ }),+}))++vi.mock('@contexts/NavigationContext', () => ({+ useNavigationContext: () => ({+ selectedAgent: 'product-agent',+ selectedAgentRoute: 'contexts',+ handleBackToAgents: vi.fn(),+ handleOpenAgentWorkspace: vi.fn(),+ handleSelectChatAgent: vi.fn(),+ handleOpenContextDetails: vi.fn(),+ }),+}))++vi.mock('@contexts/ChatListContext', () => ({+ useChatListContext: () => ({ sessionStateByChatId: {}, activeChatId: null }),+}))++vi.mock('@contexts/McpRuntimeContext', () => ({+ useMcpRuntimeContext: () => ({ hostRuntimeStatus: null }),+}))++vi.mock('@hooks/useClickOutside', () => ({ useClickOutside: vi.fn() }))++describe('AgentWorkspace context rows — visible name (UT-11)', () => {+ afterEach(() => {+ cleanup()+ contextsMock.contextIds = []+ contextsMock.contextDisplayById = {}+ vi.clearAllMocks()+ })++ it('renders the context display when present and the id when absent', () => {+ contextsMock.contextIds = ['ctx-with', 'ctx-plain']+ contextsMock.contextDisplayById = { 'ctx-with': 'Prod Ctx' }++ render(<AgentWorkspace scrollContainerRef={{ current: null }} />)++ // Branch WITH display: renders "Prod Ctx", not the id.+ expect(screen.getByText('Prod Ctx')).toBeTruthy()+ expect(screen.queryByText('ctx-with')).toBeNull()+ // Branch WITHOUT display: renders the id (metadata.name) — single fallback.+ expect(screen.getByText('ctx-plain')).toBeTruthy()+ })+})diff --git a/desktop-app/ui/src/gfs/GfsAgentAccessSection/index.tsx b/desktop-app/ui/src/gfs/GfsAgentAccessSection/index.tsxindex 6d4e56248..c7bc59ab3 100644--- a/desktop-app/ui/src/gfs/GfsAgentAccessSection/index.tsx+++ b/desktop-app/ui/src/gfs/GfsAgentAccessSection/index.tsx@@ -80,7 +80,9 @@ export function GfsAgentAccessSection({selected={selectedIds.includes(agent.id)}size="sm">- {agent.name}+ {/* Visible agent name (spec.host); the id-based `name` is the+ last-resort label for entries without a display source. */}+ {agent.displayName ?? agent.name}</SelectableOption>))}</div>diff --git a/desktop-app/ui/src/gfs/delegation.types.ts b/desktop-app/ui/src/gfs/delegation.types.tsindex a0aef21b2..3a308b5a1 100644--- a/desktop-app/ui/src/gfs/delegation.types.ts+++ b/desktop-app/ui/src/gfs/delegation.types.ts@@ -29,7 +29,10 @@ export interface GfsDelegationPanelProps {*/export interface GfsAgentSubjectOption {id: string+ /** Agent identifier (`metadata.name`) — used for keys and stable sorting. */name: string+ /** Visible name (Agent CRD `spec.host`); rendered to the user when present. */+ displayName?: string}/**diff --git a/desktop-app/ui/src/hooks/domain/useAgentsDataController.ts b/desktop-app/ui/src/hooks/domain/useAgentsDataController.tsindex 62218fc9e..045af3168 100644--- a/desktop-app/ui/src/hooks/domain/useAgentsDataController.ts+++ b/desktop-app/ui/src/hooks/domain/useAgentsDataController.ts@@ -6,6 +6,7 @@ import { desktopQueryKeys } from './queryKeys'const EMPTY_STRING_LIST: string[] = []const EMPTY_AGENT_CONTEXT_BY_NAME: Record<string, string | null> = {}const EMPTY_AGENT_PROVIDER_BY_NAME: Record<string, string | null> = {}+const EMPTY_AGENT_DISPLAY_BY_NAME: Record<string, string> = {}const EMPTY_MCP_SERVERS_BY_AGENT: Record<string, string[]> = {}function toErrorMessage(error: unknown): string {@@ -64,6 +65,7 @@ export function useAgentsDataController() {mcpServersByAgent: catalogQuery.data?.mcpServersByAgent ?? EMPTY_MCP_SERVERS_BY_AGENT,agentContextByName: catalogQuery.data?.agentContextByName ?? EMPTY_AGENT_CONTEXT_BY_NAME,agentProviderByName: catalogQuery.data?.agentProviderByName ?? EMPTY_AGENT_PROVIDER_BY_NAME,+ agentDisplayByName: catalogQuery.data?.agentDisplayByName ?? EMPTY_AGENT_DISPLAY_BY_NAME,refresh,refreshWithCatalog,reset,diff --git a/desktop-app/ui/src/hooks/domain/useContextsDataController.ts b/desktop-app/ui/src/hooks/domain/useContextsDataController.tsindex 28dceae11..d6ea7a4e4 100644--- a/desktop-app/ui/src/hooks/domain/useContextsDataController.ts+++ b/desktop-app/ui/src/hooks/domain/useContextsDataController.ts@@ -11,6 +11,7 @@ import type {} from './useContextsDataController.types'const EMPTY_STRING_LIST: string[] = []+const EMPTY_CONTEXT_DISPLAY_BY_ID: Record<string, string> = {}type SharedFileDirectorySpec = {contextId: string@@ -241,6 +242,10 @@ export function useContextsDataController() {contextIds: catalogQuery.data?.contextIds ?? EMPTY_STRING_LIST,userContextIds: catalogQuery.data?.userContextIds ?? EMPTY_STRING_LIST,teamContextIds: catalogQuery.data?.teamContextIds ?? EMPTY_STRING_LIST,+ // Visible context name (Context CRD `spec.displayName`) keyed by id. No+ // producer on the session path yet (spec §8 / UT-7b), so this is empty+ // today and consumers apply the single fallback `contextDisplayById[id] ?? id`.+ contextDisplayById: catalogQuery.data?.contextDisplayById ?? EMPTY_CONTEXT_DISPLAY_BY_ID,sharedFilesByContext,sharedFileDirectoriesByContext,refresh,diff --git a/desktop-app/ui/src/hooks/domain/useMcpServersDataController.ts b/desktop-app/ui/src/hooks/domain/useMcpServersDataController.tsindex 525da2c9a..abdf5e1a1 100644--- a/desktop-app/ui/src/hooks/domain/useMcpServersDataController.ts+++ b/desktop-app/ui/src/hooks/domain/useMcpServersDataController.ts@@ -7,6 +7,7 @@ import { getMcpServerDerivedData } from './mcpServerDerivedData'import { desktopQueryKeys } from './queryKeys'const EMPTY_STRING_LIST: string[] = []+const EMPTY_AGENT_DISPLAY_BY_NAME: Record<string, string> = {}const EMPTY_AGENT_CONTEXT_BY_NAME: Record<string, string | null> = {}const EMPTY_MCP_SERVERS_BY_AGENT: Record<string, string[]> = {}const EMPTY_GLOBAL_MCP_SERVERS: ScopedMcpServer[] = []@@ -261,6 +262,7 @@ export function useMcpServersDataController(params: UseMcpServersDataControllerPerror,accessCatalog: catalogQuery.data ?? null,agentNames: catalogQuery.data?.agentNames ?? EMPTY_STRING_LIST,+ agentDisplayByName: catalogQuery.data?.agentDisplayByName ?? EMPTY_AGENT_DISPLAY_BY_NAME,agentContextByName: catalogQuery.data?.agentContextByName ?? EMPTY_AGENT_CONTEXT_BY_NAME,mcpServersByAgent: catalogQuery.data?.mcpServersByAgent ?? EMPTY_MCP_SERVERS_BY_AGENT,agentMcpServersByAgent,diff --git a/desktop-app/ui/src/pages/ContextDetailsPage.tsx b/desktop-app/ui/src/pages/ContextDetailsPage.tsxindex 292d851a2..74a5fe39d 100644--- a/desktop-app/ui/src/pages/ContextDetailsPage.tsx+++ b/desktop-app/ui/src/pages/ContextDetailsPage.tsx@@ -23,6 +23,7 @@ export function ContextDetailsPage() {} = useNavigationContext()const {agentNames,+ agentDisplayByName,agentContextByName,mcpServersByAgent,accessCatalog: mcpAccessCatalog,@@ -459,7 +460,13 @@ export function ContextDetailsPage() {><td className="da-table__cell"><span className="context-id-cell">- <strong>{agent.name}</strong>+ {/* Visible agent name (spec.host). The catalog map is+ total only over catalog agents; scopedAgents also+ carries cross-team agents added from the team+ directory (no catalog display source), so fall back+ to the identifier for those — not the Decision #6+ `|| name` guard. */}+ <strong>{agentDisplayByName[agent.name] ?? agent.name}</strong></span></td><td className="da-table__cell">@@ -577,7 +584,13 @@ export function ContextDetailsPage() {title={agentName}aria-label={`Open connectors for agent ${agentName}`}>- {agentName}+ {/* Visible agent name (spec.host). mappedAgents+ can include cross-team agents (from scoped+ context detail sources) absent from the+ catalog map, so fall back to the identifier+ for those — not the Decision #6 `|| name`+ guard. */}+ {agentDisplayByName[agentName] ?? agentName}</ReferenceTag>))}</span>diff --git a/desktop-app/ui/src/pages/FilesPage.tsx b/desktop-app/ui/src/pages/FilesPage.tsxindex 8c9ed6df9..dad109114 100644--- a/desktop-app/ui/src/pages/FilesPage.tsx+++ b/desktop-app/ui/src/pages/FilesPage.tsx@@ -100,7 +100,11 @@ function agentSubjectOptions(agents: MyAgentEntry[] | undefined): GfsAgentSubjecfor (const agent of agents) {// Only agents with a canonical host gfsSubject are grantable targets.if (agent.gfsSubject?.type !== 'host' || !agent.gfsSubject.id) continue- options.set(agent.gfsSubject.id, { id: agent.gfsSubject.id, name: agent.name })+ options.set(agent.gfsSubject.id, {+ id: agent.gfsSubject.id,+ name: agent.name,+ displayName: agent.displayName,+ })}return [...options.values()].sort((left, right) => left.name.localeCompare(right.name))}diff --git a/desktop-app/ui/src/pages/FilesPage.types.ts b/desktop-app/ui/src/pages/FilesPage.types.tsindex 60ae0fdb5..deb37589d 100644--- a/desktop-app/ui/src/pages/FilesPage.types.ts+++ b/desktop-app/ui/src/pages/FilesPage.types.ts@@ -22,5 +22,7 @@ export interface FilesPageProps {*/export interface MyAgentEntry {name: string+ /** Visible name (Agent CRD `spec.host`) surfaced on the wire; may be absent on older builds. */+ displayName?: stringgfsSubject?: { type: string; id: string }}diff --git a/desktop-app/ui/src/pages/McpServersPage.tsx b/desktop-app/ui/src/pages/McpServersPage.tsxindex d2816393b..50822ec61 100644--- a/desktop-app/ui/src/pages/McpServersPage.tsx+++ b/desktop-app/ui/src/pages/McpServersPage.tsx@@ -8,6 +8,7 @@ import { useMcpServersDataController } from '../hooks/domain/useMcpServersDataCoexport function McpServersPage() {const {agentNames,+ agentDisplayByName,mcpServersByAgent,agentContextByName,globalMcpServers,@@ -154,7 +155,9 @@ export function McpServersPage() {title={agentName}aria-label={`Open agent ${agentName}`}>- {agentName}+ {/* Visible agent name (spec.host) read directly from+ the producer-total map — no fallback (Decision #6). */}+ {agentDisplayByName[agentName]}</ReferenceTag>))}</span>diff --git a/desktop-app/ui/src/pages/TeamsPage.tsx b/desktop-app/ui/src/pages/TeamsPage.tsxindex f2dc3ee83..1bc9b4740 100644--- a/desktop-app/ui/src/pages/TeamsPage.tsx+++ b/desktop-app/ui/src/pages/TeamsPage.tsx@@ -4,6 +4,7 @@ import { Button, DataTable, EmptyState, ReferenceTag } from '@components/Common'import type { TeamMember } from '../../../src/types'import { useAuthContext } from '../contexts/AuthContext'import { useNavigationContext } from '../contexts/NavigationContext'+import { useAgentsDataController } from '../hooks/domain/useAgentsDataController'import { useTeamsDataController } from '../hooks/domain/useTeamsDataController'import { clickableRowProps } from '../lib/clickableRowProps'@@ -32,6 +33,7 @@ export function TeamsPage() {const { teams, loading, error, teamDirectory, teamDirectoryHydrated, truncated, refresh } =useTeamsDataController()const { selectedTeam, handleOpenContextDetails, handleOpenTeamDetails } = useNavigationContext()+ const { agentDisplayByName } = useAgentsDataController()const [floatingTooltip, setFloatingTooltip] = useState<TeamFloatingTooltip | null>(null)const setFloatingTooltipNode = useCallback(@@ -95,7 +97,10 @@ export function TeamsPage() {kind: 'agent',...position,title: `Active agents (${agentNames.length})`,- items: visibleItems,+ // Visible agent name (spec.host). The catalog map only covers the current+ // user's accessible agents; other teams' agents have no display source here,+ // so fall back to the identifier for those (not the Decision #6 `|| name`).+ items: visibleItems.map(agentName => agentDisplayByName[agentName] ?? agentName),overflowCount,})}diff --git a/desktop-app/ui/src/pages/__tests__/ContextDetailsPage.test.tsx b/desktop-app/ui/src/pages/__tests__/ContextDetailsPage.test.tsxindex a505941c3..cd985898d 100644--- a/desktop-app/ui/src/pages/__tests__/ContextDetailsPage.test.tsx+++ b/desktop-app/ui/src/pages/__tests__/ContextDetailsPage.test.tsx@@ -1,8 +1,15 @@// @vitest-environment jsdomimport React from 'react'-import { afterEach, describe, expect, it, vi } from 'vitest'-import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'-import type { AccessCatalog, SessionMe, TeamMember, TeamSummary } from '../../../../src/types'+import { afterEach, beforeAll, describe, expect, it, vi } from 'vitest'+import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'+import { AppService } from '../../../../src/appService'+import type {+ AccessCatalog,+ SessionMe,+ TeamDirectoryEntry,+ TeamMember,+ TeamSummary,+} from '../../../../src/types'import { AuthContext } from '../../contexts/AuthContext'import type { AuthContextValue } from '../../contexts/AuthContext'import { NavigationContext } from '../../contexts/NavigationContext'@@ -24,6 +31,24 @@ vi.mock('../../hooks/domain/useTeamsDataController', () => ({useTeamsDataController: vi.fn(),}))+// AppService (imported only to derive a real AccessCatalog fixture from the+// producer — see deriveAccessCatalog) transitively imports electron at module+// load; stub it so the import resolves under jsdom.+vi.mock('electron', () => ({+ app: {+ isReady: () => false,+ getPath: () => '/tmp/clerum-desktop-test',+ getName: () => 'test',+ on: () => {},+ },+ safeStorage: {+ isEncryptionAvailable: () => false,+ encryptString: () => Buffer.from(''),+ decryptString: () => '',+ },+ shell: { openExternal: () => {} },+}))+const useContextsDataControllerMock = vi.mocked(useContextsDataController)const useMcpServersDataControllerMock = vi.mocked(useMcpServersDataController)const useTeamsDataControllerMock = vi.mocked(useTeamsDataController)@@ -129,6 +154,7 @@ const makeContextsDataValue = (contextIds: accessCatalog?.contextIds ?? [],userContextIds: accessCatalog?.userContextIds ?? [],teamContextIds: accessCatalog?.teamContextIds ?? [],+ contextDisplayById: accessCatalog?.contextDisplayById ?? {},sharedFilesByContext: {},sharedFileDirectoriesByContext: {},refresh: vi.fn(),@@ -147,6 +173,7 @@ const makeMcpServersDataValue = (error: null,accessCatalog,agentNames: accessCatalog?.agentNames ?? [],+ agentDisplayByName: accessCatalog?.agentDisplayByName ?? {},agentContextByName: accessCatalog?.agentContextByName ?? {},mcpServersByAgent: accessCatalog?.mcpServersByAgent ?? {},globalMcpServers: [],@@ -317,3 +344,133 @@ describe('ContextDetailsPage', () => {expect(screen.queryByRole('button', { name: 'Open agent delta' })).toBeNull()})})++// Regression: cross-team agents (H1). scopedAgents / mappedAgents can include+// agents that live only in another team's directory entry — never in the+// current team's catalog — so `agentDisplayByName` (total ONLY over+// catalog.agentNames) has no entry for them. Rendering the map lookup without a+// fallback leaves an empty cell; the fix falls back to the identifier.+describe('ContextDetailsPage — cross-team agent display (H1)', () => {+ // T1: derive the catalog from the real producer (AppService.refreshAccessCatalog)+ // instead of hand-tabulating it, so agentDisplayByName is genuinely total only+ // over the catalog's own agents and genuinely omits the cross-team agent.+ let derivedCatalog: AccessCatalog++ const CROSS_TEAM_AGENT = 'crossteam-agent'+ const OTHER_TEAM: TeamSummary = { id: 'team-2', name: 'Other Team', role: 'member' }+ const OTHER_TEAM_DIRECTORY: Record<string, TeamDirectoryEntry> = {+ 'team-2': {+ team: OTHER_TEAM,+ members: [],+ contextIds: ['ctx-alpha'],+ agentNames: [CROSS_TEAM_AGENT],+ },+ }++ async function deriveAccessCatalog(): Promise<AccessCatalog> {+ const service = new AppService() as unknown as {+ sessionToken: string+ me: SessionMe+ bindCurrentChatStore: (id: string) => Promise<void>+ rpcTokenManager: { getOrIssue: () => unknown; clear: () => void }+ authClient: Record<string, unknown>+ refreshAccessCatalog: () => Promise<AccessCatalog>+ }+ service.sessionToken = 'session-token'+ service.me = ME+ // Catalog construction does not need the chat store; keep it out of the fixture.+ service.bindCurrentChatStore = async () => {}+ service.rpcTokenManager = { getOrIssue: vi.fn(), clear: vi.fn() }+ const currentTeamAgents = {+ agentNames: ['alpha', 'gamma'],+ agents: [+ { name: 'alpha', displayName: 'Alpha Host', contextRef: 'ctx-alpha', mcpServers: [] },+ { name: 'gamma', displayName: 'Gamma Host', contextRef: 'ctx-alpha', mcpServers: [] },+ ],+ }+ service.authClient = {+ getMe: vi.fn().mockResolvedValue(ME),+ getMyContexts: vi.fn().mockResolvedValue({ contextIds: ['ctx-alpha'] }),+ getMyAgents: vi.fn().mockResolvedValue(currentTeamAgents),+ getTeamContexts: vi.fn().mockResolvedValue({ contextIds: ['ctx-alpha'] }),+ getTeamAgents: vi.fn().mockResolvedValue(currentTeamAgents),+ }+ return service.refreshAccessCatalog()+ }++ beforeAll(async () => {+ derivedCatalog = await deriveAccessCatalog()+ })++ afterEach(() => {+ cleanup()+ vi.clearAllMocks()+ })++ it('producer catalog is total over its own agents and omits the cross-team agent', () => {+ // Guards the fixture's realism (T1): if the producer ever started emitting a+ // display entry for non-catalog agents, this test would no longer cover H1.+ expect(Object.keys(derivedCatalog.agentDisplayByName ?? {}).sort()).toEqual(['alpha', 'gamma'])+ expect(derivedCatalog.agentDisplayByName?.[CROSS_TEAM_AGENT]).toBeUndefined()+ expect(derivedCatalog.agentNames).not.toContain(CROSS_TEAM_AGENT)+ })++ it('shows the identifier for a cross-team agent in the agents tab (no empty cell)', () => {+ renderWithContexts(+ { selectedContext: 'ctx-alpha' },+ {+ accessCatalog: derivedCatalog,+ teams: {+ teams: [{ id: 'team-1', name: 'Core Team', role: 'admin' }, OTHER_TEAM],+ currentTeamId: 'team-1',+ teamDirectory: OTHER_TEAM_DIRECTORY,+ },+ }+ )++ // Catalog agents still render their spec.host display name.+ expect(screen.getByText('Alpha Host')).toBeTruthy()++ // T4: assert the visible cell of the cross-team row, not an intermediate. The+ // row exists (aria-label uses the id), but before the fix its display cell is+ // empty because agentDisplayByName has no entry for the cross-team agent.+ const crossTeamRow = screen.getByRole('button', {+ name: `Open agent ${CROSS_TEAM_AGENT}`,+ })+ expect(within(crossTeamRow).getByText(CROSS_TEAM_AGENT)).toBeTruthy()+ })++ it('shows the identifier for a cross-team mapped agent in the connectors tab', () => {+ renderWithContexts(+ { selectedContext: 'ctx-alpha' },+ {+ accessCatalog: derivedCatalog,+ teams: {+ teams: [{ id: 'team-1', name: 'Core Team', role: 'admin' }, OTHER_TEAM],+ currentTeamId: 'team-1',+ teamDirectory: OTHER_TEAM_DIRECTORY,+ },+ mcpServers: {+ selectedContextMcpServerMappingAvailable: true,+ selectedContextMcpServerDetails: [+ {+ name: 'srv-1',+ mappedAgentCount: 1,+ mappedAgents: [CROSS_TEAM_AGENT],+ mappingSource: 'context-map',+ },+ ],+ },+ }+ )++ fireEvent.click(screen.getByRole('button', { name: 'Connectors' }))++ // T4: the mapped-agent reference tag renders the identifier (aria-label uses+ // the id; the visible label was empty before the fix).+ const mappedTag = screen.getByRole('button', {+ name: `Open connectors for agent ${CROSS_TEAM_AGENT}`,+ })+ expect(within(mappedTag).getByText(CROSS_TEAM_AGENT)).toBeTruthy()+ })+})diff --git a/desktop-app/ui/src/pages/__tests__/TeamsPage.test.tsx b/desktop-app/ui/src/pages/__tests__/TeamsPage.test.tsxindex c58de0619..16242d905 100644--- a/desktop-app/ui/src/pages/__tests__/TeamsPage.test.tsx+++ b/desktop-app/ui/src/pages/__tests__/TeamsPage.test.tsx@@ -20,6 +20,10 @@ vi.mock('../../hooks/domain/useTeamsDataController', () => ({useTeamsDataController: vi.fn(),}))+vi.mock('../../hooks/domain/useAgentsDataController', () => ({+ useAgentsDataController: () => ({ agentDisplayByName: {} }),+}))+const useTeamsDataControllerMock = vi.mocked(useTeamsDataController)const ME: SessionMe = {