Skip to content

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

TypeScript

fix(desktop-app): show agent display names in chat notifications

M460fe86158bd
diff --git a/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx b/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx
index 0212ebfa3..e395a4207 100644
--- a/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx
+++ b/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx
@@ -14,8 +14,18 @@ const notificationMocks = vi.hoisted(() => ({
refresh: vi.fn(async () => undefined),
}))
+// Rename propagation tests swap this catalog in; default null keeps the
+// identifier-fallback path (no catalog) that the legacy assertions rely on.
+type AgentsCatalogStub = null | {
+ agentNames: string[]
+ userAgentNames: string[]
+ teamAgentNames: string[]
+ agentDisplayByName: Record<string, string>
+}
+const agentsCatalogMock = vi.hoisted(() => ({ catalog: null as AgentsCatalogStub }))
+
vi.mock('@hooks/domain/useAgentsDataController', () => ({
- useAgentsDataController: () => ({ accessCatalog: null }),
+ useAgentsDataController: () => ({ accessCatalog: agentsCatalogMock.catalog }),
}))
vi.mock('@hooks/domain/useContextsDataController', () => ({
@@ -80,10 +90,51 @@ describe('AppHeader notification tray presentation', () => {
afterEach(() => {
cleanup()
notificationMocks.notifications.length = 0
+ agentsCatalogMock.catalog = null
vi.clearAllMocks()
vi.unstubAllGlobals()
})
+ // Rename propagation: the tray header shows the catalog display name
+ // (spec.host); pseudo-agents absent from the catalog pass through as-is.
+ it('shows the agent display name from the access catalog in the tray', () => {
+ agentsCatalogMock.catalog = {
+ agentNames: ['research-agent'],
+ userAgentNames: ['research-agent'],
+ teamAgentNames: [],
+ agentDisplayByName: { 'research-agent': 'Research agent' },
+ }
+ notificationMocks.notifications.push(
+ {
+ id: 'notification-1',
+ kind: 'assistant_reply' as const,
+ agentName: 'research-agent',
+ text: 'Your answer is ready.',
+ timestamp: Date.now(),
+ read: true,
+ },
+ {
+ id: 'notification-2',
+ kind: 'assistant_reply' as const,
+ agentName: 'Workflows',
+ text: 'Workflow finished.',
+ timestamp: Date.now(),
+ read: true,
+ }
+ )
+
+ render(<AppHeader />)
+ fireEvent.click(screen.getByRole('button', { name: 'Notifications and approvals' }))
+
+ expect(
+ screen.getByText('Research agent', { selector: '.notification-menu-agent' })
+ ).toBeTruthy()
+ expect(screen.getByText('Workflows', { selector: '.notification-menu-agent' })).toBeTruthy()
+ expect(
+ screen.queryByText('research-agent', { selector: '.notification-menu-agent' })
+ ).toBeNull()
+ })
+
it('opens a notification when its card surface is clicked', () => {
const notification = {
id: 'notification-1',
diff --git a/desktop-app/ui/src/components/HeaderActions/index.tsx b/desktop-app/ui/src/components/HeaderActions/index.tsx
index d35ffcf33..053167bd0 100644
--- a/desktop-app/ui/src/components/HeaderActions/index.tsx
+++ b/desktop-app/ui/src/components/HeaderActions/index.tsx
@@ -1,4 +1,4 @@
-import React, { useEffect, useMemo, useRef, useState } from 'react'
+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useNavigationContext } from '@contexts/NavigationContext'
import { useNotificationsContext } from '@contexts/NotificationsContext'
import ReactMarkdown from 'react-markdown'
@@ -323,6 +323,17 @@ export const HeaderActions = React.memo(function HeaderActions({
}))
}, [accessCatalog, currentTeamId, currentTeamName, teamDirectory, teams])
+ // Visible name for a notification's agent: the catalog display name
+ // (spec.host) with the raw identifier as fallback. Pseudo-agents that are
+ // not catalog agents ('Workflows', recipe names) pass through untouched.
+ const notificationAgentDisplay = useCallback(
+ (agentName: string): string => {
+ const map = accessCatalog?.agentDisplayByName
+ return (map && map[agentName]) || agentName
+ },
+ [accessCatalog]
+ )
+
const filteredAgents = useMemo(
() =>
hasSearch
@@ -837,7 +848,9 @@ export const HeaderActions = React.memo(function HeaderActions({
tabIndex={notification.kind === 'approval_required' ? undefined : 0}
>
<div className="notification-menu-item-header">
- <p className="notification-menu-agent">{notification.agentName}</p>
+ <p className="notification-menu-agent">
+ {notificationAgentDisplay(notification.agentName)}
+ </p>
<span className="notification-menu-time">
{formatNotificationTime(notification.timestamp)}
</span>
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/controllerHarness.tsx b/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/controllerHarness.tsx
index cb8bfdd3d..56ec8e565 100644
--- a/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/controllerHarness.tsx
+++ b/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/controllerHarness.tsx
@@ -53,6 +53,8 @@ export function renderController(
navItem: 'agents',
pushToast: spies.pushToast,
pushNotification: spies.pushNotification,
+ // Identity resolver by default (no catalog display layer in the harness).
+ agentDisplayName: (agentName: string) => agentName,
canDeliverChatResponseNotification: spies.canDeliverChatResponseNotification,
showDesktopNotification: spies.showDesktopNotification,
openAgentConversationFromNotification: spies.openAgentConversationFromNotification,
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/useAgentChatController.crossChat.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/useAgentChatController.crossChat.test.tsx
index 6c827f126..563745c9a 100644
--- a/desktop-app/ui/src/hooks/domain/__tests__/useAgentChatController.crossChat.test.tsx
+++ b/desktop-app/ui/src/hooks/domain/__tests__/useAgentChatController.crossChat.test.tsx
@@ -108,6 +108,7 @@ function AgentChatHarness() {
navItem: 'chat',
pushToast: vi.fn(),
pushNotification: vi.fn(),
+ agentDisplayName: (agentName: string) => agentName,
canDeliverChatResponseNotification: vi.fn(() => false),
showDesktopNotification: vi.fn(async () => 'unsupported' as const),
openAgentConversationFromNotification: vi.fn(async () => undefined),
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/useAgentChatController.pendingModel.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/useAgentChatController.pendingModel.test.tsx
index 2d02d58b1..8bab5bb52 100644
--- a/desktop-app/ui/src/hooks/domain/__tests__/useAgentChatController.pendingModel.test.tsx
+++ b/desktop-app/ui/src/hooks/domain/__tests__/useAgentChatController.pendingModel.test.tsx
@@ -100,6 +100,7 @@ function AgentChatHarness() {
navItem: 'chat',
pushToast: vi.fn(),
pushNotification: vi.fn(),
+ agentDisplayName: (agentName: string) => agentName,
canDeliverChatResponseNotification: vi.fn(() => false),
showDesktopNotification: vi.fn(async () => 'unsupported' as const),
openAgentConversationFromNotification: vi.fn(async () => undefined),
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/useChatNotifications.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/useChatNotifications.test.tsx
index bbdbdca20..5ed49bcf0 100644
--- a/desktop-app/ui/src/hooks/domain/__tests__/useChatNotifications.test.tsx
+++ b/desktop-app/ui/src/hooks/domain/__tests__/useChatNotifications.test.tsx
@@ -30,6 +30,9 @@ function makeParams(overrides?: Partial<Parameters<typeof useChatNotifications>[
activeChatVisibilityRef,
currentTeamId: 'team-1',
currentTeamName: 'Team One',
+ // Display-name resolver: catalog display (spec.host) with identifier
+ // fallback — mirrors the real resolver from useAgentsDataController.
+ agentDisplayName: (agentName: string) => (agentName === 'agent-x' ? 'Agent X' : agentName),
pushNotification,
// Deliver to both channels (chat not visible): the dedupe, not the gating, is
// what suppresses the second call.
@@ -87,4 +90,21 @@ describe('useChatNotifications — reply first-materialization dedupe (§4.7.2)'
expect(params.pushNotification).toHaveBeenCalledTimes(2)
})
+
+ // Rename propagation: the desktop toast TITLE uses the agent's display name
+ // (spec.host), while the in-app notification payload stays keyed by the
+ // immutable identifier (matching + dedupe survive a rename).
+ it('titles desktop toasts with the display name but keys in-app notifications by the identifier', () => {
+ const params = makeParams()
+ const { result } = renderHook(() => useChatNotifications(params))
+
+ result.current.pushAssistantReplyNotification('agent-x', reply('msg-A', 'task-1'), 'chat-1')
+
+ expect(params.showDesktopNotification).toHaveBeenCalledWith(
+ expect.objectContaining({ title: 'Agent X replied' })
+ )
+ expect(params.pushNotification).toHaveBeenCalledWith(
+ expect.objectContaining({ kind: 'assistant_reply', agentName: 'agent-x' })
+ )
+ })
})
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/useHostPrewarmController.chatIntegration.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/useHostPrewarmController.chatIntegration.test.tsx
index b7a4f5829..9c323fbd2 100644
--- a/desktop-app/ui/src/hooks/domain/__tests__/useHostPrewarmController.chatIntegration.test.tsx
+++ b/desktop-app/ui/src/hooks/domain/__tests__/useHostPrewarmController.chatIntegration.test.tsx
@@ -53,6 +53,7 @@ function installBridge() {
const stableCallbacks = {
pushToast: vi.fn(),
pushNotification: vi.fn(),
+ agentDisplayName: (agentName: string) => agentName,
canDeliverChatResponseNotification: vi.fn(() => true),
showDesktopNotification: vi.fn(async () => 'granted' as const),
openAgentConversationFromNotification: vi.fn(async () => undefined),
diff --git a/desktop-app/ui/src/hooks/domain/useAgentChatController.ts b/desktop-app/ui/src/hooks/domain/useAgentChatController.ts
index b34db491f..540e6212f 100644
--- a/desktop-app/ui/src/hooks/domain/useAgentChatController.ts
+++ b/desktop-app/ui/src/hooks/domain/useAgentChatController.ts
@@ -322,6 +322,13 @@ interface UseAgentChatControllerParams {
navItem: NavItem
pushToast: (msg: string, tone: Tone) => void
pushNotification: (n: PushNotificationInput) => void
+ /**
+ * Human-visible name for an agent identifier (catalog `spec.host` display
+ * name, identifier fallback). Used for desktop toast titles only — supplied
+ * by the host (useAppController) so this controller keeps zero TanStack
+ * Query coupling.
+ */
+ agentDisplayName: (agentName: string) => string
canDeliverChatResponseNotification: (
channel: 'inApp' | 'desktop',
context: { activeChatVisible: boolean }
@@ -346,6 +353,7 @@ export function useAgentChatController({
navItem,
pushToast,
pushNotification,
+ agentDisplayName,
canDeliverChatResponseNotification,
showDesktopNotification,
openAgentConversationFromNotification,
@@ -593,6 +601,10 @@ export function useAgentChatController({
activeChatVisibilityRef,
currentTeamId,
currentTeamName,
+ // Catalog display-name resolver (spec.host) for desktop toast titles.
+ // Reads the shared cache-backed catalog query — no new fetch. The
+ // notification payloads themselves stay keyed by the identifier.
+ agentDisplayName,
pushNotification,
canDeliverChatResponseNotification,
showDesktopNotification,
diff --git a/desktop-app/ui/src/hooks/domain/useChatNotifications.ts b/desktop-app/ui/src/hooks/domain/useChatNotifications.ts
index 036840a0f..3d7bf496c 100644
--- a/desktop-app/ui/src/hooks/domain/useChatNotifications.ts
+++ b/desktop-app/ui/src/hooks/domain/useChatNotifications.ts
@@ -32,6 +32,13 @@ interface UseChatNotificationsParams {
activeChatVisibilityRef: MutableRefObject<ActiveChatVisibility>
currentTeamId: string
currentTeamName: string
+ /**
+ * Human-visible name for an agent identifier (catalog `spec.host` display
+ * name, identifier fallback). Used ONLY in desktop toast titles — the
+ * notification objects stay keyed by the immutable identifier so matching
+ * (`resolveApprovalNotification`) and dedupe keep working after a rename.
+ */
+ agentDisplayName: (agentName: string) => string
pushNotification: (n: PushNotificationInput) => void
canDeliverChatResponseNotification: (
channel: 'inApp' | 'desktop',
@@ -66,6 +73,7 @@ export function useChatNotifications({
activeChatVisibilityRef,
currentTeamId,
currentTeamName,
+ agentDisplayName,
pushNotification,
canDeliverChatResponseNotification,
showDesktopNotification,
@@ -75,6 +83,7 @@ export function useChatNotifications({
const liveDepsRef = useRef({
currentTeamId,
currentTeamName,
+ agentDisplayName,
pushNotification,
openAgentConversationFromNotification,
decideApprovalFromNotification,
@@ -83,6 +92,7 @@ export function useChatNotifications({
liveDepsRef.current = {
currentTeamId,
currentTeamName,
+ agentDisplayName,
pushNotification,
openAgentConversationFromNotification,
decideApprovalFromNotification,
@@ -90,6 +100,7 @@ export function useChatNotifications({
}, [
currentTeamId,
currentTeamName,
+ agentDisplayName,
pushNotification,
openAgentConversationFromNotification,
decideApprovalFromNotification,
@@ -165,7 +176,7 @@ export function useChatNotifications({
}
if (canDeliver('desktop', { activeChatVisible })) {
void showDesktopNotification({
- title: `${agentName} replied`,
+ title: `${deps.agentDisplayName(agentName)} replied`,
body: text,
tag: `assistant-reply:${agentName}:${chatId || 'no-chat'}:${message.id}`,
onClick: () =>
@@ -215,7 +226,7 @@ export function useChatNotifications({
notificationDeliveryRef.current
if (!canDeliver('desktop', { activeChatVisible })) return
void showDesktopNotification({
- title: `${agentName} needs authorization`,
+ title: `${deps.agentDisplayName(agentName)} needs authorization`,
body: desktopText,
tag: dedupeKey,
actions: [
diff --git a/desktop-app/ui/src/hooks/useAppController.ts b/desktop-app/ui/src/hooks/useAppController.ts
index f8c31d9f9..4c666e375 100644
--- a/desktop-app/ui/src/hooks/useAppController.ts
+++ b/desktop-app/ui/src/hooks/useAppController.ts
@@ -299,6 +299,13 @@ export function useAppController() {
})
// ─── Agent Chat ───
+ // Human-visible agent name (spec.host display name) for chat notification
+ // titles. Total over catalog agents at the producer; the identifier is the
+ // sanctioned fallback (Decision #6).
+ const agentDisplayName = useCallback(
+ (agentName: string) => agentsData.agentDisplayByName[agentName] ?? agentName,
+ [agentsData.agentDisplayByName]
+ )
const chat = useAgentChatController({
selectedAgent: nav.selectedAgent,
agentNames: agentsData.agentNames,
@@ -310,6 +317,7 @@ export function useAppController() {
navItem: nav.navItem,
pushToast,
pushNotification: notif.pushNotification,
+ agentDisplayName,
canDeliverChatResponseNotification: notificationSettings.canDeliverChatResponseNotification,
showDesktopNotification: notificationSettings.showDesktopNotification,
openAgentConversationFromNotification,