Skip to content

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

TypeScript

fix: render chat controls above the titlebar surface

Josué27aee6fd46ff
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsx
index 928478782..31e190427 100644
--- a/desktop-app/ui/src/App.tsx
+++ b/desktop-app/ui/src/App.tsx
@@ -22,7 +22,7 @@ import { GfsImagePreview } from '@components/GfsImagePreview'
import { PluginConsentModal } from '@components/PluginConsentModal'
import type { PluginConsentRequest } from '@components/PluginConsentModal/types'
import { SidebarNav } from '@components/SidebarNav'
-import { WindowTitleBar } from '@components/WindowTitleBar'
+import { TitlebarActionsPortal, WindowTitleBar } from '@components/WindowTitleBar'
import { DESKTOP_ROUTES, SIDEBAR_COLLAPSED_KEY } from '@constants/navigation'
import { THEME_STORAGE_KEY } from '@constants/theme'
import { useAgentChatActionsValue } from '@hooks/useAgentChatActionsValue'
@@ -311,6 +311,7 @@ export function App() {
const [composerFocusRequestId, setComposerFocusRequestId] = React.useState(0)
const [globalSearchFocusRequestId, setGlobalSearchFocusRequestId] = React.useState(0)
const [notificationOpenRequestId, setNotificationOpenRequestId] = React.useState(0)
+ const [titlebarActionsRoot, setTitlebarActionsRoot] = React.useState<HTMLDivElement | null>(null)
const [sidebarToggleRequestId, setSidebarToggleRequestId] = React.useState(0)
const [chatLocalSearchOpen, setChatLocalSearchOpen] = React.useState(false)
const [chatLocalSearchState, setChatLocalSearchState] = React.useState<{
@@ -2033,7 +2034,7 @@ export function App() {
return (
<AuthContext.Provider value={authValue}>
<div className="app-frame">
- <WindowTitleBar />
+ <WindowTitleBar actionsRef={setTitlebarActionsRoot} />
<div className="app-root" inert={bootSplashLoading || undefined}>
{vm.isAuthenticated ? (
<NavigationContext.Provider value={navValue}>
@@ -2073,6 +2074,10 @@ export function App() {
className={`content-panel glass-card${
isAgentChatView ? ' content-panel--agent-chat' : ''
}${vm.navItem === DESKTOP_ROUTES.settings ? ' content-panel--settings' : ''}${
+ vm.navItem === DESKTOP_ROUTES.chat
+ ? ' content-panel--titlebar-actions'
+ : ''
+ }${
appNotificationDrawerOpen
? ' content-panel--app-notification-drawer-open'
: ''
@@ -2092,16 +2097,32 @@ export function App() {
: undefined
}
>
- <AppHeader
- searchFocusRequestId={globalSearchFocusRequestId}
- notificationOpenRequestId={notificationOpenRequestId}
- notificationTrayMode={
- notificationTrayUsesDrawer ? 'drawer' : 'overlay'
- }
- notificationTrayReady={notificationDrawerReady}
- onNotificationTrayOpenChange={setHeaderNotificationTrayOpen}
- onShellOverlayOpenChange={setHeaderShellOverlayOpen}
- />
+ {vm.navItem === DESKTOP_ROUTES.chat ? (
+ <TitlebarActionsPortal container={titlebarActionsRoot}>
+ <AppHeader
+ placement="titlebar"
+ searchFocusRequestId={globalSearchFocusRequestId}
+ notificationOpenRequestId={notificationOpenRequestId}
+ notificationTrayMode={
+ notificationTrayUsesDrawer ? 'drawer' : 'overlay'
+ }
+ notificationTrayReady={notificationDrawerReady}
+ onNotificationTrayOpenChange={setHeaderNotificationTrayOpen}
+ onShellOverlayOpenChange={setHeaderShellOverlayOpen}
+ />
+ </TitlebarActionsPortal>
+ ) : (
+ <AppHeader
+ searchFocusRequestId={globalSearchFocusRequestId}
+ notificationOpenRequestId={notificationOpenRequestId}
+ notificationTrayMode={
+ notificationTrayUsesDrawer ? 'drawer' : 'overlay'
+ }
+ notificationTrayReady={notificationDrawerReady}
+ onNotificationTrayOpenChange={setHeaderNotificationTrayOpen}
+ onShellOverlayOpenChange={setHeaderShellOverlayOpen}
+ />
+ )}
<ToastStack items={vm.toasts} />
{vm.navItem === DESKTOP_ROUTES.chat && (
<ChatViewWorkspace
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 efa91c5e4..e1ec335aa 100644
--- a/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx
+++ b/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx
@@ -236,30 +236,24 @@ describe('AppHeader notification tray presentation', () => {
).toBe(false)
})
- it('uses a compact search label at constrained widths while retaining the full hover text', () => {
+ it('uses the shared search label at constrained widths', () => {
vi.stubGlobal('innerWidth', 1200)
render(<AppHeader />)
const search = screen.getByRole('textbox', { name: 'Search' })
- expect(search.getAttribute('placeholder')).toBe('Search workspace...')
- expect(search.getAttribute('title')).toBe(
- 'Search teams, contexts, members, agents or connectors...'
- )
+ expect(search.getAttribute('placeholder')).toBe('Search')
+ expect(search.getAttribute('title')).toBe('Search')
})
- it('uses the full search label above the constrained-width breakpoint', () => {
+ it('uses the shared search label above the constrained-width breakpoint', () => {
vi.stubGlobal('innerWidth', 1400)
render(<AppHeader />)
const search = screen.getByRole('textbox', { name: 'Search' })
- expect(search.getAttribute('placeholder')).toBe(
- 'Search teams, contexts, members, agents or connectors...'
- )
- expect(search.getAttribute('title')).toBe(
- 'Search teams, contexts, members, agents or connectors...'
- )
+ expect(search.getAttribute('placeholder')).toBe('Search')
+ expect(search.getAttribute('title')).toBe('Search')
})
it('opens and focuses the existing global search for a command request', () => {
diff --git a/desktop-app/ui/src/components/AppHeader/__tests__/searchCollapse.test.tsx b/desktop-app/ui/src/components/AppHeader/__tests__/searchCollapse.test.tsx
index f942704d8..685b5eb3f 100644
--- a/desktop-app/ui/src/components/AppHeader/__tests__/searchCollapse.test.tsx
+++ b/desktop-app/ui/src/components/AppHeader/__tests__/searchCollapse.test.tsx
@@ -85,13 +85,15 @@ describe('AppHeader global search idle collapse', () => {
const user = userEvent.setup()
const { container } = render(<AppHeader />)
const search = container.querySelector('.global-search')
+ const input = screen.getByRole('textbox', { name: 'Search' })
expect(search).not.toBeNull()
+ expect(input.getAttribute('placeholder')).toBe('Search')
- await user.click(screen.getByRole('textbox', { name: 'Search' }))
+ await user.click(input)
expect(search?.classList.contains('is-open')).toBe(false)
await user.tab()
- expect(document.activeElement).not.toBe(screen.getByRole('textbox', { name: 'Search' }))
+ expect(document.activeElement).not.toBe(input)
expect(search?.classList.contains('is-open')).toBe(false)
})
@@ -107,4 +109,20 @@ describe('AppHeader global search idle collapse', () => {
await user.clear(input)
expect(search?.classList.contains('is-open')).toBe(false)
})
+
+ it('renders explicit titlebar search chrome for contrast', () => {
+ const { container } = render(<AppHeader placement="titlebar" />)
+
+ expect(container.querySelector('.global-search--titlebar')).toBeTruthy()
+ expect(container.querySelector('.search-input--titlebar')).toBeTruthy()
+ const icon = container.querySelector<HTMLElement>('.global-search__titlebar-icon')
+ const placeholder = container.querySelector<HTMLElement>('.search-input__titlebar-placeholder')
+ const bell = container.querySelector<HTMLElement>('.notification-bell--titlebar')
+
+ expect(icon?.textContent).toBe('⌕')
+ expect(icon?.style.color).toBe('var(--titlebar-action-ink)')
+ expect(placeholder?.textContent).toBe('Search')
+ expect(placeholder?.style.color).toBe('var(--titlebar-action-ink)')
+ expect(bell?.style.color).toBe('var(--titlebar-action-ink)')
+ })
})
diff --git a/desktop-app/ui/src/components/AppHeader/index.tsx b/desktop-app/ui/src/components/AppHeader/index.tsx
index 73edc4e53..52f903885 100644
--- a/desktop-app/ui/src/components/AppHeader/index.tsx
+++ b/desktop-app/ui/src/components/AppHeader/index.tsx
@@ -1,1186 +1,5 @@
-import React, { useEffect, useMemo, useRef, useState } from 'react'
-import { useNavigationContext } from '@contexts/NavigationContext'
-import { useNotificationsContext } from '@contexts/NotificationsContext'
-import ReactMarkdown from 'react-markdown'
-import remarkGfm from 'remark-gfm'
-import { Button, IconButton, Pill, SelectableOption, TextInput } from '@components/Common'
-import { DESKTOP_ROUTES } from '@constants/navigation'
-import { useAgentsDataController } from '@hooks/domain/useAgentsDataController'
-import { useContextsDataController } from '@hooks/domain/useContextsDataController'
-import { useMcpServersDataController } from '@hooks/domain/useMcpServersDataController'
-import { useSearchPluginsAppsController } from '@hooks/domain/useSearchPluginsAppsController'
-import { useTeamsDataController } from '@hooks/domain/useTeamsDataController'
-import { useClickOutside } from '@hooks/useClickOutside'
-import { notificationKindLabel, notificationPreviewText } from '@/lib/notifications'
-import type { AppNotificationKind } from '@/uiTypes'
-import type {
- AppHeaderProps,
- SearchAppResult,
- SearchEntityResult,
- SearchMemberResult,
- SearchPluginResult,
- SearchTeamResult,
-} from './types'
+import { HeaderActions } from '@components/HeaderActions'
-const FULL_SEARCH_PLACEHOLDER = 'Search teams, contexts, members, agents or connectors...'
-const COMPACT_SEARCH_PLACEHOLDER = 'Search workspace...'
-const COMPACT_SEARCH_BREAKPOINT = 1220
+export const AppHeader = HeaderActions
-function formatApprovalTimestamp(value: string, mode: 'relative' | 'absolute'): string {
- const date = new Date(value)
- if (Number.isNaN(date.getTime())) {
- return mode === 'relative' ? 'unknown time' : 'unknown deadline'
- }
-
- if (mode === 'absolute') {
- return new Intl.DateTimeFormat(undefined, {
- month: 'short',
- day: 'numeric',
- hour: '2-digit',
- minute: '2-digit',
- }).format(date)
- }
-
- const deltaMs = date.getTime() - Date.now()
- const deltaMinutes = Math.round(deltaMs / 60_000)
- const absMinutes = Math.abs(deltaMinutes)
-
- if (absMinutes < 1) return 'just now'
- if (absMinutes < 60) return `${absMinutes}m ${deltaMinutes >= 0 ? 'from now' : 'ago'}`
- const absHours = Math.round(absMinutes / 60)
- if (absHours < 24) return `${absHours}h ${deltaMinutes >= 0 ? 'from now' : 'ago'}`
- const absDays = Math.round(absHours / 24)
- return `${absDays}d ${deltaMinutes >= 0 ? 'from now' : 'ago'}`
-}
-
-function resolveNotificationActionText(
- notification: ReturnType<typeof useNotificationsContext>['notifications'][number]
-): string {
- const explicit = String(notification.approval?.displayName || '').trim()
- if (explicit) return explicit
- const raw = String(notification.text || '').trim()
- if (!raw) return 'Approval required'
- const sanitized = raw
- .replace(/needs your approval\.?$/i, '')
- .replace(/^approval required for /i, '')
- .trim()
- return sanitized || raw
-}
-
-function notificationPillClass(kind: AppNotificationKind): string {
- if (kind === 'approval_required') return 'approval'
- if (kind === 'workflow_completed') return 'workflow'
- if (kind === 'sdk_notification') return 'workflow'
- return 'reply'
-}
-
-function notificationPillTone(kind: AppNotificationKind): 'warning' | 'accent' | 'success' {
- if (kind === 'approval_required') return 'warning'
- if (kind === 'workflow_completed') return 'success'
- if (kind === 'sdk_notification') return 'accent'
- return 'accent'
-}
-
-function notificationPillLabel(kind: AppNotificationKind): string {
- return notificationKindLabel(kind)
-}
-
-export const AppHeader = React.memo(function AppHeader({
- searchFocusRequestId = 0,
- notificationOpenRequestId = 0,
- notificationTrayMode = 'overlay',
- notificationTrayReady = true,
- onNotificationTrayOpenChange,
- onShellOverlayOpenChange,
-}: AppHeaderProps) {
- const { accessCatalog: agentsAccessCatalog } = useAgentsDataController()
- const { contextIds, contextDisplayById } = useContextsDataController()
- const { globalMcpServers, mcpServersByAgent } = useMcpServersDataController()
- const {
- teams,
- teamMembers,
- teamDirectory,
- loading: teamDirectoryLoading,
- teamDirectoryHydrated,
- currentTeamId,
- ensureHydrated: onEnsureTeamDirectory,
- } = useTeamsDataController()
- const {
- plugins: searchPlugins,
- apps: searchApps,
- loading: pluginsAppsLoading,
- ensureLoaded: ensurePluginsAppsLoaded,
- } = useSearchPluginsAppsController()
- const { navItem, handleNavSelect, handleOpenContextDetails, handleOpenTeamDetails } =
- useNavigationContext()
- const {
- notifications,
- unreadNotificationCount,
- notificationActionById,
- pendingApprovals,
- pendingApprovalsLoading,
- pendingApprovalActionId,
- markNotificationsRead: onMarkNotificationsRead,
- clearNotifications: onClearNotifications,
- removeNotification: onRemoveNotification,
- handleOpenNotification: onOpenNotification,
- handleApproveNotification: onApproveNotification,
- handleDenyNotification: onDenyNotification,
- handleRefreshPendingApprovals: onRefreshPendingApprovals,
- handleDecidePendingApproval: onDecidePendingApproval,
- } = useNotificationsContext()
-
- const onOpenAgents = () => handleNavSelect(DESKTOP_ROUTES.agents)
- const onOpenConnectors = () => handleNavSelect(DESKTOP_ROUTES.connectors)
- const [now, setNow] = useState(Date.now())
- const [searchQuery, setSearchQuery] = useState('')
- const [searchOpen, setSearchOpen] = useState(false)
- const [notificationsOpen, setNotificationsOpen] = useState(false)
- const [compactSearch, setCompactSearch] = useState(
- () => window.innerWidth <= COMPACT_SEARCH_BREAKPOINT
- )
- const searchRef = useRef<HTMLDivElement | null>(null)
- const searchInputRef = useRef<HTMLInputElement | null>(null)
- const notificationsRef = useRef<HTMLDivElement | null>(null)
- const searchDirectoryInFlightRef = useRef(false)
- const searchDirectoryRefreshQueryRef = useRef('')
- const accessCatalog = agentsAccessCatalog
- const notificationTrayUsesDrawer = notificationTrayMode === 'drawer'
- const notificationTrayVisible =
- notificationsOpen && (!notificationTrayUsesDrawer || notificationTrayReady)
-
- useEffect(() => {
- const timer = window.setInterval(() => setNow(Date.now()), 30_000)
- return () => window.clearInterval(timer)
- }, [])
-
- useEffect(() => {
- const updateCompactSearch = () =>
- setCompactSearch(window.innerWidth <= COMPACT_SEARCH_BREAKPOINT)
- window.addEventListener('resize', updateCompactSearch)
- return () => window.removeEventListener('resize', updateCompactSearch)
- }, [])
-
- useClickOutside(searchRef, searchOpen, () => setSearchOpen(false))
- useClickOutside(notificationsRef, notificationsOpen, () => setNotificationsOpen(false))
-
- useEffect(() => {
- if (searchFocusRequestId <= 0) return
- setNotificationsOpen(false)
- // Open based on query presence rather than delegating to the input's
- // onFocus: when the field is already focused (e.g. Escape then re-triggering
- // the shortcut) focus() is a no-op and onFocus would not re-fire. Read the
- // live input value so this stays keyed only on the request id.
- setSearchOpen((searchInputRef.current?.value ?? '').trim().length > 0)
- searchInputRef.current?.focus()
- }, [searchFocusRequestId])
-
- useEffect(() => {
- if (notificationOpenRequestId <= 0) return
- setSearchOpen(false)
- setNotificationsOpen(true)
- }, [notificationOpenRequestId])
-
- React.useLayoutEffect(() => {
- onShellOverlayOpenChange?.(searchOpen || (notificationsOpen && !notificationTrayUsesDrawer))
- onNotificationTrayOpenChange?.(notificationsOpen)
- }, [
- notificationTrayUsesDrawer,
- notificationsOpen,
- onNotificationTrayOpenChange,
- onShellOverlayOpenChange,
- searchOpen,
- ])
-
- useEffect(() => {
- return () => {
- onShellOverlayOpenChange?.(false)
- onNotificationTrayOpenChange?.(false)
- }
- }, [onNotificationTrayOpenChange, onShellOverlayOpenChange])
-
- useEffect(() => {
- if (!notificationsOpen) return
- void onRefreshPendingApprovals()
- }, [notificationsOpen, onRefreshPendingApprovals])
-
- useEffect(() => {
- if (!notificationsOpen || unreadNotificationCount === 0) return
- onMarkNotificationsRead()
- }, [notificationsOpen, onMarkNotificationsRead, unreadNotificationCount])
-
- const normalizedSearch = searchQuery.trim().toLowerCase()
- const hasSearch = normalizedSearch.length > 0
-
- const teamNameById = useMemo(() => {
- const mapping: Record<string, string> = {}
- for (const team of teams) {
- mapping[team.id] = team.name
- }
- return mapping
- }, [teams])
-
- const currentTeamName = teamNameById[currentTeamId] || currentTeamId || 'Workspace team'
-
- const memberInitial = (member: { label: string; email: string }) => {
- const source = member.label || member.email
- return source ? source.charAt(0).toUpperCase() : '?'
- }
-
- const formatNotificationTime = (timestamp: number) => {
- const elapsedMs = Math.max(0, now - timestamp)
- if (elapsedMs < 60_000) return 'just now'
- if (elapsedMs < 3_600_000) return `${Math.floor(elapsedMs / 60_000)}m ago`
- if (elapsedMs < 86_400_000) return `${Math.floor(elapsedMs / 3_600_000)}h ago`
- return `${Math.floor(elapsedMs / 86_400_000)}d ago`
- }
-
- const openNotification = (notification: (typeof notifications)[number]) => {
- setNotificationsOpen(false)
- void onOpenNotification(notification)
- }
-
- const isNestedNotificationAction = (event: React.SyntheticEvent<HTMLDivElement>) => {
- const target = event.target
- if (!(target instanceof Element)) return false
- const interactiveTarget = target.closest(
- 'button, a, input, select, textarea, [role="button"], [role="link"]'
- )
- return interactiveTarget !== null && interactiveTarget !== event.currentTarget
- }
-
- const handleNotificationCardClick = (
- event: React.MouseEvent<HTMLDivElement>,
- notification: (typeof notifications)[number]
- ) => {
- if (notification.kind === 'approval_required') return
- if (isNestedNotificationAction(event)) return
- openNotification(notification)
- }
-
- const handleNotificationCardKeyDown = (
- event: React.KeyboardEvent<HTMLDivElement>,
- notification: (typeof notifications)[number]
- ) => {
- if (notification.kind === 'approval_required') return
- if (event.key !== 'Enter' && event.key !== ' ') return
- if (isNestedNotificationAction(event)) return
- event.preventDefault()
- openNotification(notification)
- }
-
- const selectedTeamMembers = useMemo<SearchMemberResult[]>(() => {
- return teamMembers.map(member => ({
- key: `${currentTeamId}:${member.id}`,
- id: member.id,
- label: (member.name || member.email).trim(),
- email: member.email,
- role: member.role,
- teamId: currentTeamId,
- teamName: currentTeamName,
- }))
- }, [currentTeamId, currentTeamName, teamMembers])
-
- const otherTeamMembers = useMemo<SearchMemberResult[]>(() => {
- const rows: SearchMemberResult[] = []
- for (const team of teams) {
- if (team.id === currentTeamId) continue
- const members = teamDirectory[team.id]?.members || []
- for (const member of members) {
- rows.push({
- key: `${team.id}:${member.id}`,
- id: member.id,
- label: (member.name || member.email).trim(),
- email: member.email,
- role: member.role,
- teamId: team.id,
- teamName: team.name,
- })
- }
- }
- return rows
- }, [currentTeamId, teamDirectory, teams])
-
- const aggregatedAgents = useMemo<SearchEntityResult[]>(() => {
- const byName = new Map<
- string,
- { fromSelectedScope: boolean; fromUserScope: boolean; teamNames: Set<string> }
- >()
- const add = (
- value: string,
- options: { selectedScope?: boolean; userScope?: boolean; teamName?: string } = {}
- ) => {
- const normalized = value.trim()
- if (!normalized) return
- const current = byName.get(normalized) || {
- fromSelectedScope: false,
- fromUserScope: false,
- teamNames: new Set<string>(),
- }
- if (options.selectedScope) current.fromSelectedScope = true
- if (options.userScope) current.fromUserScope = true
- if (options.teamName) current.teamNames.add(options.teamName)
- byName.set(normalized, current)
- }
-
- if (accessCatalog) {
- for (const agentName of accessCatalog.agentNames) {
- add(agentName, { selectedScope: true })
- }
- for (const agentName of accessCatalog.userAgentNames) {
- add(agentName, { selectedScope: true, userScope: true })
- }
- for (const agentName of accessCatalog.teamAgentNames) {
- add(agentName, { selectedScope: true, teamName: currentTeamName })
- }
- } else {
- const currentTeamAgents = teamDirectory[currentTeamId]?.agentNames || []
- for (const agentName of currentTeamAgents) {
- add(agentName, { selectedScope: true, teamName: currentTeamName })
- }
- }
-
- if (!accessCatalog) {
- for (const team of teams) {
- if (team.id === currentTeamId) continue
- const names = teamDirectory[team.id]?.agentNames || []
- for (const agentName of names) {
- add(agentName, { teamName: team.name })
- }
- }
- }
-
- // 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?.agentDisplayByName
- return [...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)),
- }))
- }, [accessCatalog, currentTeamId, currentTeamName, teamDirectory, teams])
-
- const filteredSelectedMembers = useMemo(
- () =>
- hasSearch
- ? selectedTeamMembers.filter(
- member =>
- member.label.toLowerCase().includes(normalizedSearch) ||
- member.email.toLowerCase().includes(normalizedSearch) ||
- member.role.toLowerCase().includes(normalizedSearch) ||
- member.teamName.toLowerCase().includes(normalizedSearch)
- )
- : [],
- [hasSearch, selectedTeamMembers, normalizedSearch]
- )
- const filteredOtherMembers = useMemo(
- () =>
- hasSearch
- ? otherTeamMembers.filter(
- member =>
- member.label.toLowerCase().includes(normalizedSearch) ||
- member.email.toLowerCase().includes(normalizedSearch) ||
- member.role.toLowerCase().includes(normalizedSearch) ||
- member.teamName.toLowerCase().includes(normalizedSearch)
- )
- : [],
- [hasSearch, otherTeamMembers, normalizedSearch]
- )
- const filteredMembers = useMemo(
- () =>
- [...filteredSelectedMembers, ...filteredOtherMembers].sort((left, right) => {
- const labelCompare = left.label.localeCompare(right.label)
- if (labelCompare !== 0) return labelCompare
- return left.teamName.localeCompare(right.teamName)
- }),
- [filteredOtherMembers, filteredSelectedMembers]
- )
- const filteredAgents = useMemo(
- () =>
- hasSearch
- ? aggregatedAgents.filter(
- agent =>
- agent.value.toLowerCase().includes(normalizedSearch) ||
- agent.display.toLowerCase().includes(normalizedSearch) ||
- agent.teamNames.some(teamName => teamName.toLowerCase().includes(normalizedSearch))
- )
- : [],
- [aggregatedAgents, hasSearch, normalizedSearch]
- )
- const aggregatedContexts = useMemo<SearchEntityResult[]>(() => {
- const byId = new Map<string, { fromSelectedScope: boolean; teamNames: Set<string> }>()
- const add = (contextId: string, options: { selectedScope?: boolean; teamName?: string }) => {
- const normalized = contextId.trim()
- if (!normalized) return
- const current = byId.get(normalized) || {
- fromSelectedScope: false,
- teamNames: new Set<string>(),
- }
- if (options.selectedScope) current.fromSelectedScope = true
- if (options.teamName) current.teamNames.add(options.teamName)
- byId.set(normalized, current)
- }
-
- for (const contextId of contextIds) {
- add(contextId, { selectedScope: true })
- }
-
- if (!contextIds.length) {
- for (const team of teams) {
- const ids = teamDirectory[team.id]?.contextIds || []
- for (const contextId of ids) {
- add(contextId, { teamName: team.name })
- }
- }
- }
-
- return [...byId.entries()]
- .sort(([a], [b]) => a.localeCompare(b))
- .map(([value, details]) => ({
- key: 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)),
- }))
- }, [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))
- )
- : [],
- [aggregatedContexts, hasSearch, normalizedSearch]
- )
- const filteredConnectors = useMemo<SearchEntityResult[]>(() => {
- if (!hasSearch) return []
- const connectorsByName = new Map<string, Set<string>>()
- const add = (serverName: string, agentName?: string) => {
- const normalized = serverName.trim()
- if (!normalized) return
- const agents = connectorsByName.get(normalized) || new Set<string>()
- if (agentName) agents.add(agentName)
- connectorsByName.set(normalized, agents)
- }
-
- for (const server of globalMcpServers) add(server.name)
- for (const [agentName, serverNames] of Object.entries(mcpServersByAgent)) {
- for (const serverName of serverNames) add(String(serverName), agentName)
- }
-
- return [...connectorsByName.entries()]
- .filter(
- ([serverName, agentNames]) =>
- serverName.toLowerCase().includes(normalizedSearch) ||
- [...agentNames].some(agentName => agentName.toLowerCase().includes(normalizedSearch))
- )
- .sort(([a], [b]) => a.localeCompare(b))
- .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)),
- }))
- }, [globalMcpServers, hasSearch, mcpServersByAgent, normalizedSearch])
- const filteredTeams = useMemo<SearchTeamResult[]>(
- () =>
- hasSearch
- ? teams
- .filter(team => {
- const members =
- team.id === currentTeamId
- ? teamMembers.length
- : (teamDirectory[team.id]?.members || []).length
- return (
- team.name.toLowerCase().includes(normalizedSearch) ||
- String(members).includes(normalizedSearch)
- )
- })
- .map(team => ({
- id: team.id,
- name: team.name,
- memberCount:
- team.id === currentTeamId
- ? teamMembers.length
- : (teamDirectory[team.id]?.members || []).length,
- }))
- : [],
- [currentTeamId, hasSearch, normalizedSearch, teamDirectory, teamMembers.length, teams]
- )
- const filteredPlugins = useMemo<SearchPluginResult[]>(
- () =>
- hasSearch
- ? searchPlugins
- .filter(
- plugin =>
- plugin.name.toLowerCase().includes(normalizedSearch) ||
- plugin.namespace.toLowerCase().includes(normalizedSearch)
- )
- .sort((left, right) => left.name.localeCompare(right.name))
- .map(plugin => ({
- key: `${plugin.namespace}/${plugin.name}`,
- name: plugin.name,
- namespace: plugin.namespace,
- status: plugin.status ?? null,
- }))
- : [],
- [hasSearch, normalizedSearch, searchPlugins]
- )
- const filteredApps = useMemo<SearchAppResult[]>(() => {
- if (!hasSearch) return []
- return searchApps
- .map(app => ({
- key: app.appRef,
- appRef: app.appRef,
- label: (app.title ?? '').trim() || app.appRef,
- description: (app.description ?? '').trim() || null,
- ready: app.ready,
- }))
- .filter(
- app =>
- app.label.toLowerCase().includes(normalizedSearch) ||
- app.appRef.toLowerCase().includes(normalizedSearch) ||
- (app.description?.toLowerCase().includes(normalizedSearch) ?? false)
- )
- .sort((left, right) => left.label.localeCompare(right.label))
- }, [hasSearch, normalizedSearch, searchApps])
-
- const totalMatches =
- filteredTeams.length +
- filteredMembers.length +
- filteredAgents.length +
- filteredContexts.length +
- filteredConnectors.length +
- filteredPlugins.length +
- filteredApps.length
- const pendingApprovalsCount = pendingApprovals.length
- const inboxNotificationCount = notifications.length
- const totalAttentionCount = pendingApprovalsCount + unreadNotificationCount
- const notificationButtonLabel =
- totalAttentionCount === 0
- ? 'Inbox'
- : `${totalAttentionCount} item${totalAttentionCount === 1 ? '' : 's'} in inbox`
-
- const navigateToSection = (target: 'agents' | 'connectors' | 'plugins' | 'apps') => {
- setSearchOpen(false)
- if (target === 'agents') {
- onOpenAgents()
- return
- }
- if (target === 'connectors') {
- onOpenConnectors()
- return
- }
- handleNavSelect(target === 'plugins' ? DESKTOP_ROUTES.plugins : DESKTOP_ROUTES.apps)
- }
-
- const navigateToTeam = (teamId: string) => {
- setSearchOpen(false)
- handleOpenTeamDetails(teamId)
- }
-
- const navigateToContext = (contextId: string) => {
- setSearchOpen(false)
- handleOpenContextDetails(contextId)
- }
-
- useEffect(() => {
- if (!searchOpen || !hasSearch) {
- searchDirectoryRefreshQueryRef.current = ''
- return
- }
- if (teamDirectoryLoading) return
- if (searchDirectoryInFlightRef.current) return
- if (searchDirectoryRefreshQueryRef.current === normalizedSearch) return
- searchDirectoryRefreshQueryRef.current = normalizedSearch
- searchDirectoryInFlightRef.current = true
- void Promise.resolve(onEnsureTeamDirectory())
- .catch(() => undefined)
- .finally(() => {
- searchDirectoryInFlightRef.current = false
- })
- }, [hasSearch, normalizedSearch, onEnsureTeamDirectory, searchOpen, teamDirectoryLoading])
-
- useEffect(() => {
- if (!searchOpen || !hasSearch) return
- void ensurePluginsAppsLoaded()
- }, [ensurePluginsAppsLoaded, hasSearch, searchOpen])
-
- return (
- <header className="top-bar">
- <div className="header-left">
- <div className={`global-search${searchOpen ? ' is-open' : ''}`} ref={searchRef}>
- <TextInput
- ref={searchInputRef}
- type="text"
- placeholder={compactSearch ? COMPACT_SEARCH_PLACEHOLDER : FULL_SEARCH_PLACEHOLDER}
- className="search-input"
- aria-label="Search"
- title={FULL_SEARCH_PLACEHOLDER}
- value={searchQuery}
- onChange={event => {
- setSearchQuery(event.target.value)
- setSearchOpen(event.target.value.trim().length > 0)
- }}
- onFocus={() => setSearchOpen(searchQuery.trim().length > 0)}
- onKeyDown={event => {
- if (event.key === 'Escape') {
- setSearchOpen(false)
- }
- }}
- />
- {searchOpen && hasSearch && (
- <div className="global-search-results">
- <div className="search-results-card">
- <div className="search-results-header-row">
- <strong>Search Results</strong>
- <span className="search-results-meta">
- {totalMatches} match{totalMatches === 1 ? '' : 'es'}
- </span>
- </div>
-
- {teamDirectoryLoading && !teamDirectoryHydrated && (
- <p className="search-results-loading">
- Loading members and agents from your other teams...
- </p>
- )}
-
- {pluginsAppsLoading && !searchPlugins.length && !searchApps.length && (
- <p className="search-results-loading">Loading plugins and apps...</p>
- )}
-
- {Boolean(filteredTeams.length) && (
- <section className="search-results-group">
- <header className="search-results-group-title">Teams</header>
- <div className="search-results-list">
- {filteredTeams.map(team => (
- <SelectableOption
- key={team.id}
- className="search-result-item search-result-item-button"
- onClick={() => navigateToTeam(team.id)}
- size="sm"
- >
- <div className="search-result-main">
- <strong>{team.name}</strong>
- <span className="search-result-subline">
- {team.memberCount} member{team.memberCount === 1 ? '' : 's'}
- </span>
- </div>
- <span className="search-result-tag">Team</span>
- </SelectableOption>
- ))}
- </div>
- </section>
- )}
-
- {Boolean(filteredContexts.length) && (
- <section className="search-results-group">
- <header className="search-results-group-title">Contexts</header>
- <div className="search-results-list">
- {filteredContexts.map(context => (
- <SelectableOption
- key={context.key}
- className="search-result-item search-result-item-button"
- onClick={() => navigateToContext(context.value)}
- size="sm"
- >
- <div className="search-result-main">
- <strong>{context.display}</strong>
- <span className="search-result-subline">
- {context.teamNames.length
- ? `Teams: ${context.teamNames.join(', ')}`
- : 'Access scope'}
- </span>
- </div>
- <span className="search-result-tag">Context</span>
- </SelectableOption>
- ))}
- </div>
- </section>
- )}
-
- {Boolean(filteredMembers.length) && (
- <section className="search-results-group">
- <header className="search-results-group-title">Members</header>
- <div className="search-results-list">
- {filteredMembers.map(member => (
- <SelectableOption
- key={member.key}
- className="search-result-item search-result-item-button"
- onClick={() => navigateToTeam(member.teamId)}
- size="sm"
- >
- <span className="team-member-initial-avatar">
- {memberInitial(member)}
- </span>
- <div className="search-result-main">
- <strong>{member.label}</strong>
- <span className="search-result-subline">
- {member.email}
- {member.role && (
- <>
- {' '}
- {' · '}
- {member.role}
- </>
- )}
- </span>
- </div>
- <span className="search-result-tag">{member.teamName}</span>
- </SelectableOption>
- ))}
- </div>
- </section>
- )}
-
- {Boolean(filteredAgents.length) && (
- <section className="search-results-group">
- <header className="search-results-group-title">Agents</header>
- <div className="search-results-list">
- {filteredAgents.map(agent => (
- <SelectableOption
- key={agent.key}
- className="search-result-item search-result-item-button"
- onClick={() => navigateToSection('agents')}
- size="sm"
- >
- <div className="search-result-main">
- <strong>{agent.display}</strong>
- <span className="search-result-subline">
- {agent.teamNames.length
- ? `Teams: ${agent.teamNames.join(', ')}`
- : 'No team mapping'}
- </span>
- </div>
- </SelectableOption>
- ))}
- </div>
- </section>
- )}
-
- {Boolean(filteredConnectors.length) && (
- <section className="search-results-group">
- <header className="search-results-group-title">Connectors</header>
- <div className="search-results-list">
- {filteredConnectors.map(connector => (
- <SelectableOption
- key={connector.key}
- className="search-result-item search-result-item-button"
- onClick={() => navigateToSection('connectors')}
- size="sm"
- >
- <div className="search-result-main">
- <strong>{connector.value}</strong>
- <span className="search-result-subline">
- {connector.teamNames.length
- ? `Agents: ${connector.teamNames.join(', ')}`
- : 'Available connector'}
- </span>
- </div>
- </SelectableOption>
- ))}
- </div>
- </section>
- )}
-
- {Boolean(filteredPlugins.length) && (
- <section className="search-results-group">
- <header className="search-results-group-title">Plugins</header>
- <div className="search-results-list">
- {filteredPlugins.map(plugin => (
- <SelectableOption
- key={plugin.key}
- className="search-result-item search-result-item-button"
- onClick={() => navigateToSection('plugins')}
- size="sm"
- >
- <div className="search-result-main">
- <strong>{plugin.name}</strong>
- <span className="search-result-subline">
- {plugin.namespace} · {plugin.status ?? 'Status unknown'}
- </span>
- </div>
- <span className="search-result-tag">Plugin</span>
- </SelectableOption>
- ))}
- </div>
- </section>
- )}
-
- {Boolean(filteredApps.length) && (
- <section className="search-results-group">
- <header className="search-results-group-title">Apps</header>
- <div className="search-results-list">
- {filteredApps.map(app => (
- <SelectableOption
- key={app.key}
- className="search-result-item search-result-item-button"
- onClick={() => navigateToSection('apps')}
- size="sm"
- >
- <div className="search-result-main">
- <strong>{app.label}</strong>
- <span className="search-result-subline">
- {app.description ? `${app.description} · ` : ''}
- {app.ready ? 'Ready' : 'Starting up'}
- </span>
- </div>
- <span className="search-result-tag">App</span>
- </SelectableOption>
- ))}
- </div>
- </section>
- )}
-
- {!totalMatches && !teamDirectoryLoading && !pluginsAppsLoading && (
- <p className="search-results-empty">
- No matches for "{searchQuery.trim()}". Try a member email, team name, context,
- agent, connector, plugin, or app.
- </p>
- )}
- </div>
- </div>
- )}
- </div>
- </div>
-
- <div className="header-utilities">
- <div className="notification-bell-wrapper" ref={notificationsRef}>
- <IconButton
- className={`notification-bell${totalAttentionCount > 0 ? ' has-attention' : ''}`}
- data-testid="notification-bell"
- aria-label="Notifications and approvals"
- aria-haspopup="dialog"
- aria-expanded={notificationsOpen}
- label="Notifications and approvals"
- title={notificationButtonLabel}
- onClick={() => {
- setNotificationsOpen(open => !open)
- setSearchOpen(false)
- }}
- >
- <svg
- xmlns="http://www.w3.org/2000/svg"
- fill="none"
- viewBox="0 0 24 24"
- stroke="currentColor"
- strokeWidth="2"
- >
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"
- />
- </svg>
- {totalAttentionCount > 0 && (
- <span
- className="notification-bell-badge"
- data-testid="notification-bell-badge"
- aria-hidden="true"
- >
- {totalAttentionCount > 9 ? '9+' : totalAttentionCount}
- </span>
- )}
- </IconButton>
- {notificationTrayVisible && (
- <div
- className={`notification-menu${
- notificationTrayUsesDrawer ? ' notification-menu--app-drawer' : ''
- }`}
- role="dialog"
- aria-label="Notifications and approvals"
- >
- <div className="notification-menu-body">
- {pendingApprovalsCount > 0 && (
- <section className="notification-menu-section">
- <div className="notification-menu-section-header">
- <div className="notification-menu-section-heading">
- <strong>Pending approvals</strong>
- <span className="notification-menu-section-meta">
- Approve or deny workflow requests that are waiting on you.
- </span>
- </div>
- </div>
- <div className="notification-approval-list">
- {pendingApprovals.map(approval => {
- const actionInFlight = pendingApprovalActionId === approval.id
- const msUntilExpiry = new Date(approval.expiresAt).getTime() - Date.now()
- const isExpired = msUntilExpiry <= 0
- const isExpiringSoon = !isExpired && msUntilExpiry < 60_000
-
- return (
- <article
- key={approval.id}
- data-testid="workflow-approval-card"
- className={`notification-item${isExpiringSoon ? ' expiring-soon' : ''}${
- isExpired ? ' expired' : ''
- }`}
- >
- <div className="notification-item-head">
- <div className="notification-item-title-block">
- <strong className="notification-item-recipe">
- {approval.recipeName}
- </strong>
- <span className="notification-item-namespace">
- {approval.recipeNamespace}
- </span>
- </div>
- <span className="notification-item-time">
- Requested{' '}
- {formatApprovalTimestamp(approval.requestedAt, 'relative')}
- </span>
- </div>
-
- <p className="notification-item-message">{approval.payload.message}</p>
-
- <div className="notification-item-meta">
- {approval.correlation?.stepId && (
- <Pill className="notification-item-chip" tone="neutral">
- Step: {approval.correlation.stepId}
- </Pill>
- )}
- {approval.target.teamName && (
- <Pill className="notification-item-chip" tone="neutral">
- Team: {approval.target.teamName}
- </Pill>
- )}
- <Pill
- className="notification-item-chip"
- tone={isExpired ? 'danger' : isExpiringSoon ? 'warning' : 'neutral'}
- >
- {isExpired
- ? 'Expired'
- : `Expires ${formatApprovalTimestamp(approval.expiresAt, 'absolute')}`}
- </Pill>
- </div>
-
- <div className="notification-item-actions">
- {isExpired ? (
- <span className="notification-item-expired-label">
- This approval has expired
- </span>
- ) : (
- <>
- <Button
- className="approval-action-btn approve"
- color="success"
- data-testid="workflow-approval-approve"
- onClick={() =>
- void onDecidePendingApproval(approval.id, 'approve')
- }
- disabled={actionInFlight}
- size="sm"
- variant="soft"
- >
- {actionInFlight ? 'Working...' : 'Approve'}
- </Button>
- <Button
- className="approval-action-btn deny"
- color="danger"
- data-testid="workflow-approval-deny"
- onClick={() =>
- void onDecidePendingApproval(approval.id, 'deny')
- }
- disabled={actionInFlight}
- size="sm"
- variant="soft"
- >
- Deny
- </Button>
- </>
- )}
- </div>
- </article>
- )
- })}
- </div>
- </section>
- )}
-
- {notifications.length > 0 && (
- <section className="notification-menu-section">
- <div className="notification-menu-section-header">
- <div className="notification-menu-section-heading">
- <div className="notification-menu-title-row">
- <strong>Inbox ({inboxNotificationCount})</strong>
- {pendingApprovalsLoading && (
- <span
- className="notification-inline-spinner"
- aria-label="Refreshing inbox"
- />
- )}
- </div>
- <span className="notification-menu-section-meta">
- Updates from agents, workflows, and plugins.
- </span>
- </div>
- <div className="notification-menu-header-actions">
- <Button
- className="notification-clear-btn"
- color="neutral"
- onClick={onClearNotifications}
- size="sm"
- variant="soft"
- >
- Clear
- </Button>
- </div>
- </div>
- <div className="notification-menu-list">
- {notifications.map(notification => (
- <div
- key={notification.id}
- data-testid="notification-menu-item"
- className={`notification-menu-item${
- notification.kind === 'approval_required' ? '' : ' is-clickable'
- }${notification.read ? '' : ' unread'}`}
- onClick={event => handleNotificationCardClick(event, notification)}
- onKeyDown={event => handleNotificationCardKeyDown(event, notification)}
- role={notification.kind === 'approval_required' ? undefined : 'button'}
- tabIndex={notification.kind === 'approval_required' ? undefined : 0}
- >
- <div className="notification-menu-item-header">
- <p className="notification-menu-agent">{notification.agentName}</p>
- <span className="notification-menu-time">
- {formatNotificationTime(notification.timestamp)}
- </span>
- </div>
- {notification.kind === 'approval_required' ? (
- <p className="notification-menu-text">
- {resolveNotificationActionText(notification)}
- </p>
- ) : (
- <div className="notification-menu-text notification-menu-text--markdown">
- <ReactMarkdown remarkPlugins={[remarkGfm]}>
- {notificationPreviewText(notification.kind, notification.text)}
- </ReactMarkdown>
- </div>
- )}
- <div className="notification-menu-footer">
- <Pill
- className={`notification-pill notification-pill-footer ${notificationPillClass(
- notification.kind
- )}`}
- tone={notificationPillTone(notification.kind)}
- >
- {notificationPillLabel(notification.kind)}
- </Pill>
- <div className="notification-menu-actions">
- <IconButton
- className="notification-delete-btn"
- color="danger"
- label="Delete notification"
- onClick={() => onRemoveNotification(notification.id)}
- size="sm"
- title="Delete notification"
- variant="ghost"
- >
- <svg viewBox="0 0 16 16" aria-hidden="true">
- <path d="M3.5 4.5h9" />
- <path d="M6 4.5V3.6c0-.6.5-1.1 1.1-1.1h1.8c.6 0 1.1.5 1.1 1.1v.9" />
- <path d="M5 4.5v8.1c0 .7.6 1.4 1.4 1.4h3.2c.8 0 1.4-.7 1.4-1.4V4.5" />
- <path d="M7 7v4.5" />
- <path d="M9 7v4.5" />
- </svg>
- </IconButton>
- {notification.kind !== 'approval_required' && (
- <Button
- className="notification-open-btn"
- color="primary"
- onClick={() => openNotification(notification)}
- size="xs"
- variant="soft"
- >
- Open
- </Button>
- )}
- {notification.kind === 'approval_required' &&
- !notification.approvalState && (
- <>
- <Button
- className="notification-action-btn approve"
- color="success"
- disabled={
- Boolean(notificationActionById[notification.id]) ||
- !notification.approval
- }
- onClick={() => {
- if (!notification.approval) return
- void onApproveNotification(notification)
- }}
- size="xs"
- variant="soft"
- >
- {notificationActionById[notification.id] === 'approving'
- ? 'Approving...'
- : 'Approve'}
- </Button>
- <Button
- className="notification-action-btn deny"
- color="danger"
- disabled={
- Boolean(notificationActionById[notification.id]) ||
- !notification.approval
- }
- onClick={() => {
- if (!notification.approval) return
- void onDenyNotification(notification)
- }}
- size="xs"
- variant="soft"
- >
- {notificationActionById[notification.id] === 'denying'
- ? 'Denying...'
- : 'Deny'}
- </Button>
- </>
- )}
- {notification.kind === 'approval_required' &&
- notification.approvalState && (
- <span
- className={`notification-action-state ${notification.approvalState}`}
- >
- {notification.approvalState === 'approved'
- ? 'Approved'
- : 'Denied'}
- </span>
- )}
- </div>
- </div>
- </div>
- ))}
- </div>
- </section>
- )}
-
- {!pendingApprovalsLoading && !pendingApprovalsCount && !notifications.length && (
- <p className="notification-menu-empty">
- No notifications or pending approvals right now.
- </p>
- )}
- </div>
- </div>
- )}
- </div>
- </div>
- </header>
- )
-})
+export type { AppHeaderProps } from './types'
diff --git a/desktop-app/ui/src/components/AppHeader/types.ts b/desktop-app/ui/src/components/AppHeader/types.ts
index 297392d91..bfdfad544 100644
--- a/desktop-app/ui/src/components/AppHeader/types.ts
+++ b/desktop-app/ui/src/components/AppHeader/types.ts
@@ -1,50 +1,8 @@
-export type AppHeaderProps = {
- searchFocusRequestId?: number
- notificationOpenRequestId?: number
- notificationTrayMode?: 'overlay' | 'drawer'
- notificationTrayReady?: boolean
- onNotificationTrayOpenChange?: (open: boolean) => void
- onShellOverlayOpenChange?: (open: boolean) => void
-}
-
-export type SearchMemberResult = {
- email: string
- id: string
- key: string
- label: string
- role: string
- teamId: string
- teamName: string
-}
-
-export type SearchEntityResult = {
- fromSelectedScope: boolean
- fromUserScope: boolean
- key: string
- teamNames: 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 = {
- id: string
- name: string
- memberCount: number
-}
-
-export type SearchPluginResult = {
- key: string
- name: string
- namespace: string
- status: string | null
-}
-
-export type SearchAppResult = {
- key: string
- appRef: string
- label: string
- description: string | null
- ready: boolean
-}
+export type {
+ HeaderActionsProps as AppHeaderProps,
+ SearchAppResult,
+ SearchEntityResult,
+ SearchMemberResult,
+ SearchPluginResult,
+ SearchTeamResult,
+} from '@components/HeaderActions/types'
diff --git a/desktop-app/ui/src/components/HeaderActions/index.tsx b/desktop-app/ui/src/components/HeaderActions/index.tsx
new file mode 100644
index 000000000..6480f8852
--- /dev/null
+++ b/desktop-app/ui/src/components/HeaderActions/index.tsx
@@ -0,0 +1,1213 @@
+import React, { useEffect, useMemo, useRef, useState } from 'react'
+import { useNavigationContext } from '@contexts/NavigationContext'
+import { useNotificationsContext } from '@contexts/NotificationsContext'
+import ReactMarkdown from 'react-markdown'
+import remarkGfm from 'remark-gfm'
+import { Button, IconButton, Pill, SelectableOption, TextInput } from '@components/Common'
+import { DESKTOP_ROUTES } from '@constants/navigation'
+import { useAgentsDataController } from '@hooks/domain/useAgentsDataController'
+import { useContextsDataController } from '@hooks/domain/useContextsDataController'
+import { useMcpServersDataController } from '@hooks/domain/useMcpServersDataController'
+import { useSearchPluginsAppsController } from '@hooks/domain/useSearchPluginsAppsController'
+import { useTeamsDataController } from '@hooks/domain/useTeamsDataController'
+import { useClickOutside } from '@hooks/useClickOutside'
+import { notificationKindLabel, notificationPreviewText } from '@/lib/notifications'
+import type { AppNotificationKind } from '@/uiTypes'
+import type {
+ HeaderActionsProps,
+ SearchAppResult,
+ SearchEntityResult,
+ SearchMemberResult,
+ SearchPluginResult,
+ SearchTeamResult,
+} from './types'
+
+const SEARCH_PLACEHOLDER = 'Search'
+
+function formatApprovalTimestamp(value: string, mode: 'relative' | 'absolute'): string {
+ const date = new Date(value)
+ if (Number.isNaN(date.getTime())) {
+ return mode === 'relative' ? 'unknown time' : 'unknown deadline'
+ }
+
+ if (mode === 'absolute') {
+ return new Intl.DateTimeFormat(undefined, {
+ month: 'short',
+ day: 'numeric',
+ hour: '2-digit',
+ minute: '2-digit',
+ }).format(date)
+ }
+
+ const deltaMs = date.getTime() - Date.now()
+ const deltaMinutes = Math.round(deltaMs / 60_000)
+ const absMinutes = Math.abs(deltaMinutes)
+
+ if (absMinutes < 1) return 'just now'
+ if (absMinutes < 60) return `${absMinutes}m ${deltaMinutes >= 0 ? 'from now' : 'ago'}`
+ const absHours = Math.round(absMinutes / 60)
+ if (absHours < 24) return `${absHours}h ${deltaMinutes >= 0 ? 'from now' : 'ago'}`
+ const absDays = Math.round(absHours / 24)
+ return `${absDays}d ${deltaMinutes >= 0 ? 'from now' : 'ago'}`
+}
+
+function resolveNotificationActionText(
+ notification: ReturnType<typeof useNotificationsContext>['notifications'][number]
+): string {
+ const explicit = String(notification.approval?.displayName || '').trim()
+ if (explicit) return explicit
+ const raw = String(notification.text || '').trim()
+ if (!raw) return 'Approval required'
+ const sanitized = raw
+ .replace(/needs your approval\.?$/i, '')
+ .replace(/^approval required for /i, '')
+ .trim()
+ return sanitized || raw
+}
+
+function notificationPillClass(kind: AppNotificationKind): string {
+ if (kind === 'approval_required') return 'approval'
+ if (kind === 'workflow_completed') return 'workflow'
+ if (kind === 'sdk_notification') return 'workflow'
+ return 'reply'
+}
+
+function notificationPillTone(kind: AppNotificationKind): 'warning' | 'accent' | 'success' {
+ if (kind === 'approval_required') return 'warning'
+ if (kind === 'workflow_completed') return 'success'
+ if (kind === 'sdk_notification') return 'accent'
+ return 'accent'
+}
+
+function notificationPillLabel(kind: AppNotificationKind): string {
+ return notificationKindLabel(kind)
+}
+
+export const HeaderActions = React.memo(function HeaderActions({
+ placement = 'default',
+ searchFocusRequestId = 0,
+ notificationOpenRequestId = 0,
+ notificationTrayMode = 'overlay',
+ notificationTrayReady = true,
+ onNotificationTrayOpenChange,
+ onShellOverlayOpenChange,
+}: HeaderActionsProps) {
+ const { accessCatalog: agentsAccessCatalog } = useAgentsDataController()
+ const { contextIds, contextDisplayById } = useContextsDataController()
+ const { globalMcpServers, mcpServersByAgent } = useMcpServersDataController()
+ const {
+ teams,
+ teamMembers,
+ teamDirectory,
+ loading: teamDirectoryLoading,
+ teamDirectoryHydrated,
+ currentTeamId,
+ ensureHydrated: onEnsureTeamDirectory,
+ } = useTeamsDataController()
+ const {
+ plugins: searchPlugins,
+ apps: searchApps,
+ loading: pluginsAppsLoading,
+ ensureLoaded: ensurePluginsAppsLoaded,
+ } = useSearchPluginsAppsController()
+ const { navItem, handleNavSelect, handleOpenContextDetails, handleOpenTeamDetails } =
+ useNavigationContext()
+ const {
+ notifications,
+ unreadNotificationCount,
+ notificationActionById,
+ pendingApprovals,
+ pendingApprovalsLoading,
+ pendingApprovalActionId,
+ markNotificationsRead: onMarkNotificationsRead,
+ clearNotifications: onClearNotifications,
+ removeNotification: onRemoveNotification,
+ handleOpenNotification: onOpenNotification,
+ handleApproveNotification: onApproveNotification,
+ handleDenyNotification: onDenyNotification,
+ handleRefreshPendingApprovals: onRefreshPendingApprovals,
+ handleDecidePendingApproval: onDecidePendingApproval,
+ } = useNotificationsContext()
+
+ const onOpenAgents = () => handleNavSelect(DESKTOP_ROUTES.agents)
+ const onOpenConnectors = () => handleNavSelect(DESKTOP_ROUTES.connectors)
+ const [now, setNow] = useState(Date.now())
+ const [searchQuery, setSearchQuery] = useState('')
+ const [searchOpen, setSearchOpen] = useState(false)
+ const [notificationsOpen, setNotificationsOpen] = useState(false)
+ const searchRef = useRef<HTMLDivElement | null>(null)
+ const searchInputRef = useRef<HTMLInputElement | null>(null)
+ const notificationsRef = useRef<HTMLDivElement | null>(null)
+ const searchDirectoryInFlightRef = useRef(false)
+ const searchDirectoryRefreshQueryRef = useRef('')
+ const accessCatalog = agentsAccessCatalog
+ const notificationTrayUsesDrawer = notificationTrayMode === 'drawer'
+ const notificationTrayVisible =
+ notificationsOpen && (!notificationTrayUsesDrawer || notificationTrayReady)
+ const titlebarPlacement = placement === 'titlebar'
+ const titlebarForeground = 'var(--titlebar-action-ink)'
+ const titlebarControlStyle = titlebarPlacement
+ ? {
+ background: 'var(--titlebar-action-surface)',
+ borderColor: 'var(--titlebar-action-border)',
+ color: titlebarForeground,
+ WebkitTextFillColor: titlebarForeground,
+ }
+ : undefined
+
+ useEffect(() => {
+ const timer = window.setInterval(() => setNow(Date.now()), 30_000)
+ return () => window.clearInterval(timer)
+ }, [])
+
+ useClickOutside(searchRef, searchOpen, () => setSearchOpen(false))
+ useClickOutside(notificationsRef, notificationsOpen, () => setNotificationsOpen(false))
+
+ useEffect(() => {
+ if (searchFocusRequestId <= 0) return
+ setNotificationsOpen(false)
+ // Open based on query presence rather than delegating to the input's
+ // onFocus: when the field is already focused (e.g. Escape then re-triggering
+ // the shortcut) focus() is a no-op and onFocus would not re-fire. Read the
+ // live input value so this stays keyed only on the request id.
+ setSearchOpen((searchInputRef.current?.value ?? '').trim().length > 0)
+ searchInputRef.current?.focus()
+ }, [searchFocusRequestId])
+
+ useEffect(() => {
+ if (notificationOpenRequestId <= 0) return
+ setSearchOpen(false)
+ setNotificationsOpen(true)
+ }, [notificationOpenRequestId])
+
+ React.useLayoutEffect(() => {
+ onShellOverlayOpenChange?.(searchOpen || (notificationsOpen && !notificationTrayUsesDrawer))
+ onNotificationTrayOpenChange?.(notificationsOpen)
+ }, [
+ notificationTrayUsesDrawer,
+ notificationsOpen,
+ onNotificationTrayOpenChange,
+ onShellOverlayOpenChange,
+ searchOpen,
+ ])
+
+ useEffect(() => {
+ return () => {
+ onShellOverlayOpenChange?.(false)
+ onNotificationTrayOpenChange?.(false)
+ }
+ }, [onNotificationTrayOpenChange, onShellOverlayOpenChange])
+
+ useEffect(() => {
+ if (!notificationsOpen) return
+ void onRefreshPendingApprovals()
+ }, [notificationsOpen, onRefreshPendingApprovals])
+
+ useEffect(() => {
+ if (!notificationsOpen || unreadNotificationCount === 0) return
+ onMarkNotificationsRead()
+ }, [notificationsOpen, onMarkNotificationsRead, unreadNotificationCount])
+
+ const normalizedSearch = searchQuery.trim().toLowerCase()
+ const hasSearch = normalizedSearch.length > 0
+
+ const teamNameById = useMemo(() => {
+ const mapping: Record<string, string> = {}
+ for (const team of teams) {
+ mapping[team.id] = team.name
+ }
+ return mapping
+ }, [teams])
+
+ const currentTeamName = teamNameById[currentTeamId] || currentTeamId || 'Workspace team'
+
+ const memberInitial = (member: { label: string; email: string }) => {
+ const source = member.label || member.email
+ return source ? source.charAt(0).toUpperCase() : '?'
+ }
+
+ const formatNotificationTime = (timestamp: number) => {
+ const elapsedMs = Math.max(0, now - timestamp)
+ if (elapsedMs < 60_000) return 'just now'
+ if (elapsedMs < 3_600_000) return `${Math.floor(elapsedMs / 60_000)}m ago`
+ if (elapsedMs < 86_400_000) return `${Math.floor(elapsedMs / 3_600_000)}h ago`
+ return `${Math.floor(elapsedMs / 86_400_000)}d ago`
+ }
+
+ const openNotification = (notification: (typeof notifications)[number]) => {
+ setNotificationsOpen(false)
+ void onOpenNotification(notification)
+ }
+
+ const isNestedNotificationAction = (event: React.SyntheticEvent<HTMLDivElement>) => {
+ const target = event.target
+ if (!(target instanceof Element)) return false
+ const interactiveTarget = target.closest(
+ 'button, a, input, select, textarea, [role="button"], [role="link"]'
+ )
+ return interactiveTarget !== null && interactiveTarget !== event.currentTarget
+ }
+
+ const handleNotificationCardClick = (
+ event: React.MouseEvent<HTMLDivElement>,
+ notification: (typeof notifications)[number]
+ ) => {
+ if (notification.kind === 'approval_required') return
+ if (isNestedNotificationAction(event)) return
+ openNotification(notification)
+ }
+
+ const handleNotificationCardKeyDown = (
+ event: React.KeyboardEvent<HTMLDivElement>,
+ notification: (typeof notifications)[number]
+ ) => {
+ if (notification.kind === 'approval_required') return
+ if (event.key !== 'Enter' && event.key !== ' ') return
+ if (isNestedNotificationAction(event)) return
+ event.preventDefault()
+ openNotification(notification)
+ }
+
+ const selectedTeamMembers = useMemo<SearchMemberResult[]>(() => {
+ return teamMembers.map(member => ({
+ key: `${currentTeamId}:${member.id}`,
+ id: member.id,
+ label: (member.name || member.email).trim(),
+ email: member.email,
+ role: member.role,
+ teamId: currentTeamId,
+ teamName: currentTeamName,
+ }))
+ }, [currentTeamId, currentTeamName, teamMembers])
+
+ const otherTeamMembers = useMemo<SearchMemberResult[]>(() => {
+ const rows: SearchMemberResult[] = []
+ for (const team of teams) {
+ if (team.id === currentTeamId) continue
+ const members = teamDirectory[team.id]?.members || []
+ for (const member of members) {
+ rows.push({
+ key: `${team.id}:${member.id}`,
+ id: member.id,
+ label: (member.name || member.email).trim(),
+ email: member.email,
+ role: member.role,
+ teamId: team.id,
+ teamName: team.name,
+ })
+ }
+ }
+ return rows
+ }, [currentTeamId, teamDirectory, teams])
+
+ const aggregatedAgents = useMemo<SearchEntityResult[]>(() => {
+ const byName = new Map<
+ string,
+ { fromSelectedScope: boolean; fromUserScope: boolean; teamNames: Set<string> }
+ >()
+ const add = (
+ value: string,
+ options: { selectedScope?: boolean; userScope?: boolean; teamName?: string } = {}
+ ) => {
+ const normalized = value.trim()
+ if (!normalized) return
+ const current = byName.get(normalized) || {
+ fromSelectedScope: false,
+ fromUserScope: false,
+ teamNames: new Set<string>(),
+ }
+ if (options.selectedScope) current.fromSelectedScope = true
+ if (options.userScope) current.fromUserScope = true
+ if (options.teamName) current.teamNames.add(options.teamName)
+ byName.set(normalized, current)
+ }
+
+ if (accessCatalog) {
+ for (const agentName of accessCatalog.agentNames) {
+ add(agentName, { selectedScope: true })
+ }
+ for (const agentName of accessCatalog.userAgentNames) {
+ add(agentName, { selectedScope: true, userScope: true })
+ }
+ for (const agentName of accessCatalog.teamAgentNames) {
+ add(agentName, { selectedScope: true, teamName: currentTeamName })
+ }
+ } else {
+ const currentTeamAgents = teamDirectory[currentTeamId]?.agentNames || []
+ for (const agentName of currentTeamAgents) {
+ add(agentName, { selectedScope: true, teamName: currentTeamName })
+ }
+ }
+
+ if (!accessCatalog) {
+ for (const team of teams) {
+ if (team.id === currentTeamId) continue
+ const names = teamDirectory[team.id]?.agentNames || []
+ for (const agentName of names) {
+ add(agentName, { teamName: team.name })
+ }
+ }
+ }
+
+ // 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?.agentDisplayByName
+ return [...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)),
+ }))
+ }, [accessCatalog, currentTeamId, currentTeamName, teamDirectory, teams])
+
+ const filteredSelectedMembers = useMemo(
+ () =>
+ hasSearch
+ ? selectedTeamMembers.filter(
+ member =>
+ member.label.toLowerCase().includes(normalizedSearch) ||
+ member.email.toLowerCase().includes(normalizedSearch) ||
+ member.role.toLowerCase().includes(normalizedSearch) ||
+ member.teamName.toLowerCase().includes(normalizedSearch)
+ )
+ : [],
+ [hasSearch, selectedTeamMembers, normalizedSearch]
+ )
+ const filteredOtherMembers = useMemo(
+ () =>
+ hasSearch
+ ? otherTeamMembers.filter(
+ member =>
+ member.label.toLowerCase().includes(normalizedSearch) ||
+ member.email.toLowerCase().includes(normalizedSearch) ||
+ member.role.toLowerCase().includes(normalizedSearch) ||
+ member.teamName.toLowerCase().includes(normalizedSearch)
+ )
+ : [],
+ [hasSearch, otherTeamMembers, normalizedSearch]
+ )
+ const filteredMembers = useMemo(
+ () =>
+ [...filteredSelectedMembers, ...filteredOtherMembers].sort((left, right) => {
+ const labelCompare = left.label.localeCompare(right.label)
+ if (labelCompare !== 0) return labelCompare
+ return left.teamName.localeCompare(right.teamName)
+ }),
+ [filteredOtherMembers, filteredSelectedMembers]
+ )
+ const filteredAgents = useMemo(
+ () =>
+ hasSearch
+ ? aggregatedAgents.filter(
+ agent =>
+ agent.value.toLowerCase().includes(normalizedSearch) ||
+ agent.display.toLowerCase().includes(normalizedSearch) ||
+ agent.teamNames.some(teamName => teamName.toLowerCase().includes(normalizedSearch))
+ )
+ : [],
+ [aggregatedAgents, hasSearch, normalizedSearch]
+ )
+ const aggregatedContexts = useMemo<SearchEntityResult[]>(() => {
+ const byId = new Map<string, { fromSelectedScope: boolean; teamNames: Set<string> }>()
+ const add = (contextId: string, options: { selectedScope?: boolean; teamName?: string }) => {
+ const normalized = contextId.trim()
+ if (!normalized) return
+ const current = byId.get(normalized) || {
+ fromSelectedScope: false,
+ teamNames: new Set<string>(),
+ }
+ if (options.selectedScope) current.fromSelectedScope = true
+ if (options.teamName) current.teamNames.add(options.teamName)
+ byId.set(normalized, current)
+ }
+
+ for (const contextId of contextIds) {
+ add(contextId, { selectedScope: true })
+ }
+
+ if (!contextIds.length) {
+ for (const team of teams) {
+ const ids = teamDirectory[team.id]?.contextIds || []
+ for (const contextId of ids) {
+ add(contextId, { teamName: team.name })
+ }
+ }
+ }
+
+ return [...byId.entries()]
+ .sort(([a], [b]) => a.localeCompare(b))
+ .map(([value, details]) => ({
+ key: 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)),
+ }))
+ }, [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))
+ )
+ : [],
+ [aggregatedContexts, hasSearch, normalizedSearch]
+ )
+ const filteredConnectors = useMemo<SearchEntityResult[]>(() => {
+ if (!hasSearch) return []
+ const connectorsByName = new Map<string, Set<string>>()
+ const add = (serverName: string, agentName?: string) => {
+ const normalized = serverName.trim()
+ if (!normalized) return
+ const agents = connectorsByName.get(normalized) || new Set<string>()
+ if (agentName) agents.add(agentName)
+ connectorsByName.set(normalized, agents)
+ }
+
+ for (const server of globalMcpServers) add(server.name)
+ for (const [agentName, serverNames] of Object.entries(mcpServersByAgent)) {
+ for (const serverName of serverNames) add(String(serverName), agentName)
+ }
+
+ return [...connectorsByName.entries()]
+ .filter(
+ ([serverName, agentNames]) =>
+ serverName.toLowerCase().includes(normalizedSearch) ||
+ [...agentNames].some(agentName => agentName.toLowerCase().includes(normalizedSearch))
+ )
+ .sort(([a], [b]) => a.localeCompare(b))
+ .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)),
+ }))
+ }, [globalMcpServers, hasSearch, mcpServersByAgent, normalizedSearch])
+ const filteredTeams = useMemo<SearchTeamResult[]>(
+ () =>
+ hasSearch
+ ? teams
+ .filter(team => {
+ const members =
+ team.id === currentTeamId
+ ? teamMembers.length
+ : (teamDirectory[team.id]?.members || []).length
+ return (
+ team.name.toLowerCase().includes(normalizedSearch) ||
+ String(members).includes(normalizedSearch)
+ )
+ })
+ .map(team => ({
+ id: team.id,
+ name: team.name,
+ memberCount:
+ team.id === currentTeamId
+ ? teamMembers.length
+ : (teamDirectory[team.id]?.members || []).length,
+ }))
+ : [],
+ [currentTeamId, hasSearch, normalizedSearch, teamDirectory, teamMembers.length, teams]
+ )
+ const filteredPlugins = useMemo<SearchPluginResult[]>(
+ () =>
+ hasSearch
+ ? searchPlugins
+ .filter(
+ plugin =>
+ plugin.name.toLowerCase().includes(normalizedSearch) ||
+ plugin.namespace.toLowerCase().includes(normalizedSearch)
+ )
+ .sort((left, right) => left.name.localeCompare(right.name))
+ .map(plugin => ({
+ key: `${plugin.namespace}/${plugin.name}`,
+ name: plugin.name,
+ namespace: plugin.namespace,
+ status: plugin.status ?? null,
+ }))
+ : [],
+ [hasSearch, normalizedSearch, searchPlugins]
+ )
+ const filteredApps = useMemo<SearchAppResult[]>(() => {
+ if (!hasSearch) return []
+ return searchApps
+ .map(app => ({
+ key: app.appRef,
+ appRef: app.appRef,
+ label: (app.title ?? '').trim() || app.appRef,
+ description: (app.description ?? '').trim() || null,
+ ready: app.ready,
+ }))
+ .filter(
+ app =>
+ app.label.toLowerCase().includes(normalizedSearch) ||
+ app.appRef.toLowerCase().includes(normalizedSearch) ||
+ (app.description?.toLowerCase().includes(normalizedSearch) ?? false)
+ )
+ .sort((left, right) => left.label.localeCompare(right.label))
+ }, [hasSearch, normalizedSearch, searchApps])
+
+ const totalMatches =
+ filteredTeams.length +
+ filteredMembers.length +
+ filteredAgents.length +
+ filteredContexts.length +
+ filteredConnectors.length +
+ filteredPlugins.length +
+ filteredApps.length
+ const pendingApprovalsCount = pendingApprovals.length
+ const inboxNotificationCount = notifications.length
+ const totalAttentionCount = pendingApprovalsCount + unreadNotificationCount
+ const notificationButtonLabel =
+ totalAttentionCount === 0
+ ? 'Inbox'
+ : `${totalAttentionCount} item${totalAttentionCount === 1 ? '' : 's'} in inbox`
+
+ const navigateToSection = (target: 'agents' | 'connectors' | 'plugins' | 'apps') => {
+ setSearchOpen(false)
+ if (target === 'agents') {
+ onOpenAgents()
+ return
+ }
+ if (target === 'connectors') {
+ onOpenConnectors()
+ return
+ }
+ handleNavSelect(target === 'plugins' ? DESKTOP_ROUTES.plugins : DESKTOP_ROUTES.apps)
+ }
+
+ const navigateToTeam = (teamId: string) => {
+ setSearchOpen(false)
+ handleOpenTeamDetails(teamId)
+ }
+
+ const navigateToContext = (contextId: string) => {
+ setSearchOpen(false)
+ handleOpenContextDetails(contextId)
+ }
+
+ useEffect(() => {
+ if (!searchOpen || !hasSearch) {
+ searchDirectoryRefreshQueryRef.current = ''
+ return
+ }
+ if (teamDirectoryLoading) return
+ if (searchDirectoryInFlightRef.current) return
+ if (searchDirectoryRefreshQueryRef.current === normalizedSearch) return
+ searchDirectoryRefreshQueryRef.current = normalizedSearch
+ searchDirectoryInFlightRef.current = true
+ void Promise.resolve(onEnsureTeamDirectory())
+ .catch(() => undefined)
+ .finally(() => {
+ searchDirectoryInFlightRef.current = false
+ })
+ }, [hasSearch, normalizedSearch, onEnsureTeamDirectory, searchOpen, teamDirectoryLoading])
+
+ useEffect(() => {
+ if (!searchOpen || !hasSearch) return
+ void ensurePluginsAppsLoaded()
+ }, [ensurePluginsAppsLoaded, hasSearch, searchOpen])
+
+ return (
+ <header className={`top-bar${titlebarPlacement ? ' top-bar--titlebar' : ''}`}>
+ <div className="header-left">
+ <div
+ className={`global-search${titlebarPlacement ? ' global-search--titlebar' : ''}${
+ searchOpen ? ' is-open' : ''
+ }`}
+ ref={searchRef}
+ >
+ {titlebarPlacement ? (
+ <span
+ aria-hidden="true"
+ className="global-search__titlebar-icon"
+ style={{ color: titlebarForeground, opacity: 1 }}
+ >
+ ⌕
+ </span>
+ ) : null}
+ <TextInput
+ ref={searchInputRef}
+ type="text"
+ placeholder={titlebarPlacement ? '' : SEARCH_PLACEHOLDER}
+ className={`search-input${titlebarPlacement ? ' search-input--titlebar' : ''}`}
+ aria-label="Search"
+ title={SEARCH_PLACEHOLDER}
+ style={titlebarControlStyle}
+ value={searchQuery}
+ onChange={event => {
+ setSearchQuery(event.target.value)
+ setSearchOpen(event.target.value.trim().length > 0)
+ }}
+ onFocus={() => setSearchOpen(searchQuery.trim().length > 0)}
+ onKeyDown={event => {
+ if (event.key === 'Escape') {
+ setSearchOpen(false)
+ }
+ }}
+ />
+ {titlebarPlacement && !searchQuery ? (
+ <span
+ aria-hidden="true"
+ className="search-input__titlebar-placeholder"
+ style={{ color: titlebarForeground, opacity: 1 }}
+ >
+ {SEARCH_PLACEHOLDER}
+ </span>
+ ) : null}
+ {searchOpen && hasSearch && (
+ <div className="global-search-results">
+ <div className="search-results-card">
+ <div className="search-results-header-row">
+ <strong>Search Results</strong>
+ <span className="search-results-meta">
+ {totalMatches} match{totalMatches === 1 ? '' : 'es'}
+ </span>
+ </div>
+
+ {teamDirectoryLoading && !teamDirectoryHydrated && (
+ <p className="search-results-loading">
+ Loading members and agents from your other teams...
+ </p>
+ )}
+
+ {pluginsAppsLoading && !searchPlugins.length && !searchApps.length && (
+ <p className="search-results-loading">Loading plugins and apps...</p>
+ )}
+
+ {Boolean(filteredTeams.length) && (
+ <section className="search-results-group">
+ <header className="search-results-group-title">Teams</header>
+ <div className="search-results-list">
+ {filteredTeams.map(team => (
+ <SelectableOption
+ key={team.id}
+ className="search-result-item search-result-item-button"
+ onClick={() => navigateToTeam(team.id)}
+ size="sm"
+ >
+ <div className="search-result-main">
+ <strong>{team.name}</strong>
+ <span className="search-result-subline">
+ {team.memberCount} member{team.memberCount === 1 ? '' : 's'}
+ </span>
+ </div>
+ <span className="search-result-tag">Team</span>
+ </SelectableOption>
+ ))}
+ </div>
+ </section>
+ )}
+
+ {Boolean(filteredContexts.length) && (
+ <section className="search-results-group">
+ <header className="search-results-group-title">Contexts</header>
+ <div className="search-results-list">
+ {filteredContexts.map(context => (
+ <SelectableOption
+ key={context.key}
+ className="search-result-item search-result-item-button"
+ onClick={() => navigateToContext(context.value)}
+ size="sm"
+ >
+ <div className="search-result-main">
+ <strong>{context.display}</strong>
+ <span className="search-result-subline">
+ {context.teamNames.length
+ ? `Teams: ${context.teamNames.join(', ')}`
+ : 'Access scope'}
+ </span>
+ </div>
+ <span className="search-result-tag">Context</span>
+ </SelectableOption>
+ ))}
+ </div>
+ </section>
+ )}
+
+ {Boolean(filteredMembers.length) && (
+ <section className="search-results-group">
+ <header className="search-results-group-title">Members</header>
+ <div className="search-results-list">
+ {filteredMembers.map(member => (
+ <SelectableOption
+ key={member.key}
+ className="search-result-item search-result-item-button"
+ onClick={() => navigateToTeam(member.teamId)}
+ size="sm"
+ >
+ <span className="team-member-initial-avatar">
+ {memberInitial(member)}
+ </span>
+ <div className="search-result-main">
+ <strong>{member.label}</strong>
+ <span className="search-result-subline">
+ {member.email}
+ {member.role && (
+ <>
+ {' '}
+ {' · '}
+ {member.role}
+ </>
+ )}
+ </span>
+ </div>
+ <span className="search-result-tag">{member.teamName}</span>
+ </SelectableOption>
+ ))}
+ </div>
+ </section>
+ )}
+
+ {Boolean(filteredAgents.length) && (
+ <section className="search-results-group">
+ <header className="search-results-group-title">Agents</header>
+ <div className="search-results-list">
+ {filteredAgents.map(agent => (
+ <SelectableOption
+ key={agent.key}
+ className="search-result-item search-result-item-button"
+ onClick={() => navigateToSection('agents')}
+ size="sm"
+ >
+ <div className="search-result-main">
+ <strong>{agent.display}</strong>
+ <span className="search-result-subline">
+ {agent.teamNames.length
+ ? `Teams: ${agent.teamNames.join(', ')}`
+ : 'No team mapping'}
+ </span>
+ </div>
+ </SelectableOption>
+ ))}
+ </div>
+ </section>
+ )}
+
+ {Boolean(filteredConnectors.length) && (
+ <section className="search-results-group">
+ <header className="search-results-group-title">Connectors</header>
+ <div className="search-results-list">
+ {filteredConnectors.map(connector => (
+ <SelectableOption
+ key={connector.key}
+ className="search-result-item search-result-item-button"
+ onClick={() => navigateToSection('connectors')}
+ size="sm"
+ >
+ <div className="search-result-main">
+ <strong>{connector.value}</strong>
+ <span className="search-result-subline">
+ {connector.teamNames.length
+ ? `Agents: ${connector.teamNames.join(', ')}`
+ : 'Available connector'}
+ </span>
+ </div>
+ </SelectableOption>
+ ))}
+ </div>
+ </section>
+ )}
+
+ {Boolean(filteredPlugins.length) && (
+ <section className="search-results-group">
+ <header className="search-results-group-title">Plugins</header>
+ <div className="search-results-list">
+ {filteredPlugins.map(plugin => (
+ <SelectableOption
+ key={plugin.key}
+ className="search-result-item search-result-item-button"
+ onClick={() => navigateToSection('plugins')}
+ size="sm"
+ >
+ <div className="search-result-main">
+ <strong>{plugin.name}</strong>
+ <span className="search-result-subline">
+ {plugin.namespace} · {plugin.status ?? 'Status unknown'}
+ </span>
+ </div>
+ <span className="search-result-tag">Plugin</span>
+ </SelectableOption>
+ ))}
+ </div>
+ </section>
+ )}
+
+ {Boolean(filteredApps.length) && (
+ <section className="search-results-group">
+ <header className="search-results-group-title">Apps</header>
+ <div className="search-results-list">
+ {filteredApps.map(app => (
+ <SelectableOption
+ key={app.key}
+ className="search-result-item search-result-item-button"
+ onClick={() => navigateToSection('apps')}
+ size="sm"
+ >
+ <div className="search-result-main">
+ <strong>{app.label}</strong>
+ <span className="search-result-subline">
+ {app.description ? `${app.description} · ` : ''}
+ {app.ready ? 'Ready' : 'Starting up'}
+ </span>
+ </div>
+ <span className="search-result-tag">App</span>
+ </SelectableOption>
+ ))}
+ </div>
+ </section>
+ )}
+
+ {!totalMatches && !teamDirectoryLoading && !pluginsAppsLoading && (
+ <p className="search-results-empty">
+ No matches for "{searchQuery.trim()}". Try a member email, team name, context,
+ agent, connector, plugin, or app.
+ </p>
+ )}
+ </div>
+ </div>
+ )}
+ </div>
+ </div>
+
+ <div className="header-utilities">
+ <div className="notification-bell-wrapper" ref={notificationsRef}>
+ <IconButton
+ className={`notification-bell${titlebarPlacement ? ' notification-bell--titlebar' : ''}${
+ totalAttentionCount > 0 ? ' has-attention' : ''
+ }`}
+ data-testid="notification-bell"
+ aria-label="Notifications and approvals"
+ aria-haspopup="dialog"
+ aria-expanded={notificationsOpen}
+ label="Notifications and approvals"
+ title={notificationButtonLabel}
+ style={titlebarControlStyle}
+ onClick={() => {
+ setNotificationsOpen(open => !open)
+ setSearchOpen(false)
+ }}
+ >
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ fill="none"
+ viewBox="0 0 24 24"
+ stroke="currentColor"
+ strokeWidth={titlebarPlacement ? '2.3' : '2'}
+ style={titlebarPlacement ? { color: titlebarForeground } : undefined}
+ >
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"
+ />
+ </svg>
+ {totalAttentionCount > 0 && (
+ <span
+ className="notification-bell-badge"
+ data-testid="notification-bell-badge"
+ aria-hidden="true"
+ >
+ {totalAttentionCount > 9 ? '9+' : totalAttentionCount}
+ </span>
+ )}
+ </IconButton>
+ {notificationTrayVisible && (
+ <div
+ className={`notification-menu${
+ notificationTrayUsesDrawer ? ' notification-menu--app-drawer' : ''
+ }`}
+ role="dialog"
+ aria-label="Notifications and approvals"
+ >
+ <div className="notification-menu-body">
+ {pendingApprovalsCount > 0 && (
+ <section className="notification-menu-section">
+ <div className="notification-menu-section-header">
+ <div className="notification-menu-section-heading">
+ <strong>Pending approvals</strong>
+ <span className="notification-menu-section-meta">
+ Approve or deny workflow requests that are waiting on you.
+ </span>
+ </div>
+ </div>
+ <div className="notification-approval-list">
+ {pendingApprovals.map(approval => {
+ const actionInFlight = pendingApprovalActionId === approval.id
+ const msUntilExpiry = new Date(approval.expiresAt).getTime() - Date.now()
+ const isExpired = msUntilExpiry <= 0
+ const isExpiringSoon = !isExpired && msUntilExpiry < 60_000
+
+ return (
+ <article
+ key={approval.id}
+ data-testid="workflow-approval-card"
+ className={`notification-item${isExpiringSoon ? ' expiring-soon' : ''}${
+ isExpired ? ' expired' : ''
+ }`}
+ >
+ <div className="notification-item-head">
+ <div className="notification-item-title-block">
+ <strong className="notification-item-recipe">
+ {approval.recipeName}
+ </strong>
+ <span className="notification-item-namespace">
+ {approval.recipeNamespace}
+ </span>
+ </div>
+ <span className="notification-item-time">
+ Requested{' '}
+ {formatApprovalTimestamp(approval.requestedAt, 'relative')}
+ </span>
+ </div>
+
+ <p className="notification-item-message">{approval.payload.message}</p>
+
+ <div className="notification-item-meta">
+ {approval.correlation?.stepId && (
+ <Pill className="notification-item-chip" tone="neutral">
+ Step: {approval.correlation.stepId}
+ </Pill>
+ )}
+ {approval.target.teamName && (
+ <Pill className="notification-item-chip" tone="neutral">
+ Team: {approval.target.teamName}
+ </Pill>
+ )}
+ <Pill
+ className="notification-item-chip"
+ tone={isExpired ? 'danger' : isExpiringSoon ? 'warning' : 'neutral'}
+ >
+ {isExpired
+ ? 'Expired'
+ : `Expires ${formatApprovalTimestamp(approval.expiresAt, 'absolute')}`}
+ </Pill>
+ </div>
+
+ <div className="notification-item-actions">
+ {isExpired ? (
+ <span className="notification-item-expired-label">
+ This approval has expired
+ </span>
+ ) : (
+ <>
+ <Button
+ className="approval-action-btn approve"
+ color="success"
+ data-testid="workflow-approval-approve"
+ onClick={() =>
+ void onDecidePendingApproval(approval.id, 'approve')
+ }
+ disabled={actionInFlight}
+ size="sm"
+ variant="soft"
+ >
+ {actionInFlight ? 'Working...' : 'Approve'}
+ </Button>
+ <Button
+ className="approval-action-btn deny"
+ color="danger"
+ data-testid="workflow-approval-deny"
+ onClick={() =>
+ void onDecidePendingApproval(approval.id, 'deny')
+ }
+ disabled={actionInFlight}
+ size="sm"
+ variant="soft"
+ >
+ Deny
+ </Button>
+ </>
+ )}
+ </div>
+ </article>
+ )
+ })}
+ </div>
+ </section>
+ )}
+
+ {notifications.length > 0 && (
+ <section className="notification-menu-section">
+ <div className="notification-menu-section-header">
+ <div className="notification-menu-section-heading">
+ <div className="notification-menu-title-row">
+ <strong>Inbox ({inboxNotificationCount})</strong>
+ {pendingApprovalsLoading && (
+ <span
+ className="notification-inline-spinner"
+ aria-label="Refreshing inbox"
+ />
+ )}
+ </div>
+ <span className="notification-menu-section-meta">
+ Updates from agents, workflows, and plugins.
+ </span>
+ </div>
+ <div className="notification-menu-header-actions">
+ <Button
+ className="notification-clear-btn"
+ color="neutral"
+ onClick={onClearNotifications}
+ size="sm"
+ variant="soft"
+ >
+ Clear
+ </Button>
+ </div>
+ </div>
+ <div className="notification-menu-list">
+ {notifications.map(notification => (
+ <div
+ key={notification.id}
+ data-testid="notification-menu-item"
+ className={`notification-menu-item${
+ notification.kind === 'approval_required' ? '' : ' is-clickable'
+ }${notification.read ? '' : ' unread'}`}
+ onClick={event => handleNotificationCardClick(event, notification)}
+ onKeyDown={event => handleNotificationCardKeyDown(event, notification)}
+ role={notification.kind === 'approval_required' ? undefined : 'button'}
+ tabIndex={notification.kind === 'approval_required' ? undefined : 0}
+ >
+ <div className="notification-menu-item-header">
+ <p className="notification-menu-agent">{notification.agentName}</p>
+ <span className="notification-menu-time">
+ {formatNotificationTime(notification.timestamp)}
+ </span>
+ </div>
+ {notification.kind === 'approval_required' ? (
+ <p className="notification-menu-text">
+ {resolveNotificationActionText(notification)}
+ </p>
+ ) : (
+ <div className="notification-menu-text notification-menu-text--markdown">
+ <ReactMarkdown remarkPlugins={[remarkGfm]}>
+ {notificationPreviewText(notification.kind, notification.text)}
+ </ReactMarkdown>
+ </div>
+ )}
+ <div className="notification-menu-footer">
+ <Pill
+ className={`notification-pill notification-pill-footer ${notificationPillClass(
+ notification.kind
+ )}`}
+ tone={notificationPillTone(notification.kind)}
+ >
+ {notificationPillLabel(notification.kind)}
+ </Pill>
+ <div className="notification-menu-actions">
+ <IconButton
+ className="notification-delete-btn"
+ color="danger"
+ label="Delete notification"
+ onClick={() => onRemoveNotification(notification.id)}
+ size="sm"
+ title="Delete notification"
+ variant="ghost"
+ >
+ <svg viewBox="0 0 16 16" aria-hidden="true">
+ <path d="M3.5 4.5h9" />
+ <path d="M6 4.5V3.6c0-.6.5-1.1 1.1-1.1h1.8c.6 0 1.1.5 1.1 1.1v.9" />
+ <path d="M5 4.5v8.1c0 .7.6 1.4 1.4 1.4h3.2c.8 0 1.4-.7 1.4-1.4V4.5" />
+ <path d="M7 7v4.5" />
+ <path d="M9 7v4.5" />
+ </svg>
+ </IconButton>
+ {notification.kind !== 'approval_required' && (
+ <Button
+ className="notification-open-btn"
+ color="primary"
+ onClick={() => openNotification(notification)}
+ size="xs"
+ variant="soft"
+ >
+ Open
+ </Button>
+ )}
+ {notification.kind === 'approval_required' &&
+ !notification.approvalState && (
+ <>
+ <Button
+ className="notification-action-btn approve"
+ color="success"
+ disabled={
+ Boolean(notificationActionById[notification.id]) ||
+ !notification.approval
+ }
+ onClick={() => {
+ if (!notification.approval) return
+ void onApproveNotification(notification)
+ }}
+ size="xs"
+ variant="soft"
+ >
+ {notificationActionById[notification.id] === 'approving'
+ ? 'Approving...'
+ : 'Approve'}
+ </Button>
+ <Button
+ className="notification-action-btn deny"
+ color="danger"
+ disabled={
+ Boolean(notificationActionById[notification.id]) ||
+ !notification.approval
+ }
+ onClick={() => {
+ if (!notification.approval) return
+ void onDenyNotification(notification)
+ }}
+ size="xs"
+ variant="soft"
+ >
+ {notificationActionById[notification.id] === 'denying'
+ ? 'Denying...'
+ : 'Deny'}
+ </Button>
+ </>
+ )}
+ {notification.kind === 'approval_required' &&
+ notification.approvalState && (
+ <span
+ className={`notification-action-state ${notification.approvalState}`}
+ >
+ {notification.approvalState === 'approved'
+ ? 'Approved'
+ : 'Denied'}
+ </span>
+ )}
+ </div>
+ </div>
+ </div>
+ ))}
+ </div>
+ </section>
+ )}
+
+ {!pendingApprovalsLoading && !pendingApprovalsCount && !notifications.length && (
+ <p className="notification-menu-empty">
+ No notifications or pending approvals right now.
+ </p>
+ )}
+ </div>
+ </div>
+ )}
+ </div>
+ </div>
+ </header>
+ )
+})
diff --git a/desktop-app/ui/src/components/HeaderActions/types.ts b/desktop-app/ui/src/components/HeaderActions/types.ts
new file mode 100644
index 000000000..f4dec379f
--- /dev/null
+++ b/desktop-app/ui/src/components/HeaderActions/types.ts
@@ -0,0 +1,51 @@
+export type HeaderActionsProps = {
+ placement?: 'default' | 'titlebar'
+ searchFocusRequestId?: number
+ notificationOpenRequestId?: number
+ notificationTrayMode?: 'overlay' | 'drawer'
+ notificationTrayReady?: boolean
+ onNotificationTrayOpenChange?: (open: boolean) => void
+ onShellOverlayOpenChange?: (open: boolean) => void
+}
+
+export type SearchMemberResult = {
+ email: string
+ id: string
+ key: string
+ label: string
+ role: string
+ teamId: string
+ teamName: string
+}
+
+export type SearchEntityResult = {
+ fromSelectedScope: boolean
+ fromUserScope: boolean
+ key: string
+ teamNames: 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 = {
+ id: string
+ name: string
+ memberCount: number
+}
+
+export type SearchPluginResult = {
+ key: string
+ name: string
+ namespace: string
+ status: string | null
+}
+
+export type SearchAppResult = {
+ key: string
+ appRef: string
+ label: string
+ description: string | null
+ ready: boolean
+}
diff --git a/desktop-app/ui/src/components/WindowTitleBar/__tests__/WindowTitleBar.test.tsx b/desktop-app/ui/src/components/WindowTitleBar/__tests__/WindowTitleBar.test.tsx
index 8f9a99ec7..a25e3e0e2 100644
--- a/desktop-app/ui/src/components/WindowTitleBar/__tests__/WindowTitleBar.test.tsx
+++ b/desktop-app/ui/src/components/WindowTitleBar/__tests__/WindowTitleBar.test.tsx
@@ -1,7 +1,8 @@
// @vitest-environment jsdom
+import React from 'react'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
-import { WindowTitleBar, resolveWindowControlsPlatform } from '..'
+import { TitlebarActionsPortal, WindowTitleBar, resolveWindowControlsPlatform } from '..'
import type { WindowControlsState } from '../types'
afterEach(() => {
@@ -96,4 +97,50 @@ describe('WindowTitleBar', () => {
expect(screen.getByRole('button', { name: 'Maximize window' })).toBeTruthy()
})
})
+
+ it('renders reusable titlebar actions beside the native window controls', () => {
+ setNavigatorPlatform('MacIntel')
+ installWindowControls()
+
+ render(
+ <WindowTitleBar
+ actions={
+ <button type="button" aria-label="Search">
+ Search
+ </button>
+ }
+ />
+ )
+
+ expect(screen.getByRole('button', { name: 'Search' })).toBeTruthy()
+ expect(screen.getByRole('button', { name: 'Close window' })).toBeTruthy()
+ })
+
+ it('portals provider-backed actions above the titlebar background', async () => {
+ setNavigatorPlatform('MacIntel')
+ installWindowControls()
+
+ function Harness() {
+ const [actionsRoot, setActionsRoot] = React.useState<HTMLDivElement | null>(null)
+
+ return (
+ <>
+ <WindowTitleBar actionsRef={setActionsRoot} />
+ <div className="app-root">
+ <TitlebarActionsPortal container={actionsRoot}>
+ <button type="button" aria-label="Search">
+ Search
+ </button>
+ </TitlebarActionsPortal>
+ </div>
+ </>
+ )
+ }
+
+ render(<Harness />)
+
+ const search = await screen.findByRole('button', { name: 'Search' })
+ expect(search.closest('.window-titlebar')).toBeTruthy()
+ expect(search.closest('.app-root')).toBeNull()
+ })
})
diff --git a/desktop-app/ui/src/components/WindowTitleBar/index.tsx b/desktop-app/ui/src/components/WindowTitleBar/index.tsx
index ef4e173fe..09ea0fd3c 100644
--- a/desktop-app/ui/src/components/WindowTitleBar/index.tsx
+++ b/desktop-app/ui/src/components/WindowTitleBar/index.tsx
@@ -1,6 +1,13 @@
import React from 'react'
+import { createPortal } from 'react-dom'
import { joinClasses } from '@lib/classNames'
-import type { WindowControlAction, WindowControlsPlatform, WindowControlsState } from './types'
+import type {
+ TitlebarActionsPortalProps,
+ WindowControlAction,
+ WindowControlsPlatform,
+ WindowControlsState,
+ WindowTitleBarProps,
+} from './types'
const DEFAULT_WINDOW_CONTROLS_STATE: WindowControlsState = {
fullscreen: false,
@@ -31,7 +38,11 @@ function getWindowControlsApi() {
return window.evenfire?.window
}
-export function WindowTitleBar() {
+export function TitlebarActionsPortal({ children, container }: TitlebarActionsPortalProps) {
+ return container ? createPortal(children, container) : null
+}
+
+export function WindowTitleBar({ actions, actionsRef }: WindowTitleBarProps) {
const [controlsState, setControlsState] = React.useState<WindowControlsState>(
DEFAULT_WINDOW_CONTROLS_STATE
)
@@ -101,8 +112,17 @@ export function WindowTitleBar() {
</button>
))}
</div>
+ <div className="window-titlebar__actions" ref={actionsRef}>
+ {actions}
+ </div>
</header>
)
}
-export type { WindowControlAction, WindowControlsPlatform, WindowControlsState } from './types'
+export type {
+ TitlebarActionsPortalProps,
+ WindowControlAction,
+ WindowControlsPlatform,
+ WindowControlsState,
+ WindowTitleBarProps,
+} from './types'
diff --git a/desktop-app/ui/src/components/WindowTitleBar/types.ts b/desktop-app/ui/src/components/WindowTitleBar/types.ts
index ad9add232..529ef58cd 100644
--- a/desktop-app/ui/src/components/WindowTitleBar/types.ts
+++ b/desktop-app/ui/src/components/WindowTitleBar/types.ts
@@ -1,3 +1,5 @@
+import type React from 'react'
+
export type WindowControlAction = 'close' | 'minimize' | 'toggleMaximize'
export type WindowControlsPlatform = 'linux' | 'mac' | 'windows'
@@ -6,3 +8,13 @@ export type WindowControlsState = {
fullscreen: boolean
maximized: boolean
}
+
+export type WindowTitleBarProps = {
+ actions?: React.ReactNode
+ actionsRef?: React.Ref<HTMLDivElement>
+}
+
+export type TitlebarActionsPortalProps = {
+ children: React.ReactNode
+ container: HTMLDivElement | null
+}
diff --git a/desktop-app/ui/src/styles.css b/desktop-app/ui/src/styles.css
index a4a5a1345..edc67c28c 100644
--- a/desktop-app/ui/src/styles.css
+++ b/desktop-app/ui/src/styles.css
@@ -80,6 +80,9 @@ h3 {
}
.window-titlebar {
+ position: relative;
+ z-index: var(--layer-header);
+ isolation: isolate;
height: var(--window-titlebar-height);
display: flex;
align-items: center;
@@ -91,6 +94,135 @@ h3 {
-webkit-app-region: drag;
}
+.window-titlebar__actions {
+ --titlebar-action-border: var(--titlebar-control-border);
+ --titlebar-action-ink: var(--titlebar-control-ink);
+ --titlebar-action-muted-ink: var(--titlebar-control-ink);
+ --titlebar-action-surface: var(--titlebar-control-surface);
+
+ position: fixed;
+ top: 0;
+ right: var(--space-2);
+ left: calc((var(--window-titlebar-control-size) * 3) + (var(--space-1) * 2) + var(--space-4));
+ z-index: calc(var(--layer-header) + 1);
+ height: var(--window-titlebar-height);
+ display: flex;
+ align-items: center;
+ justify-content: flex-end;
+ min-width: 0;
+ pointer-events: none;
+ -webkit-app-region: no-drag;
+}
+
+:root[data-theme='dark'] .window-titlebar__actions {
+ --titlebar-action-border: var(--titlebar-control-border);
+ --titlebar-action-ink: var(--titlebar-control-ink);
+ --titlebar-action-muted-ink: var(--titlebar-control-ink);
+ --titlebar-action-surface: var(--titlebar-control-surface);
+}
+
+.window-titlebar__actions .top-bar {
+ position: static;
+ inset: auto;
+ height: var(--window-titlebar-height);
+ width: 100%;
+ z-index: auto;
+ align-items: center;
+ gap: var(--space-2);
+ pointer-events: auto;
+ -webkit-app-region: no-drag;
+}
+
+.window-titlebar__actions .header-left {
+ flex: 1 1 auto;
+ justify-content: flex-end;
+ min-width: 0;
+}
+
+.window-titlebar__actions .header-utilities {
+ flex: 0 0 auto;
+}
+
+.window-titlebar__actions .global-search {
+ --global-search-expanded: clamp(160px, 20vw, 280px);
+ --global-search-expanded-min: 0;
+ flex: 0 1 var(--global-search-expanded);
+ width: var(--global-search-expanded);
+ min-width: 0;
+ max-width: min(var(--global-search-expanded), 100%);
+ margin-right: 0;
+}
+
+.window-titlebar__actions .global-search:focus-within,
+.window-titlebar__actions .global-search.is-open {
+ width: var(--global-search-expanded);
+ min-width: 0;
+}
+
+.window-titlebar__actions .search-input {
+ height: 30px;
+ min-height: 30px;
+ padding-left: 34px;
+ border-color: var(--titlebar-action-border);
+ background: var(--titlebar-action-surface);
+ color: var(--titlebar-action-ink);
+ box-shadow:
+ 0 0 0 1px rgba(17, 24, 39, 0.08),
+ 0 6px 14px rgba(var(--overlay-rgb), 0.1);
+}
+
+.window-titlebar__actions .global-search::before {
+ inset: 0 auto 0 11px;
+ place-items: center;
+ color: var(--titlebar-action-ink);
+ font-size: var(--font-size-lg);
+}
+
+.window-titlebar__actions .search-input::placeholder {
+ color: var(--titlebar-action-muted-ink);
+ opacity: 1;
+}
+
+.window-titlebar__actions .search-input:focus {
+ border-color: rgba(var(--focus-rgb), 0.85);
+ box-shadow:
+ 0 0 0 2px rgba(var(--focus-rgb), 0.2),
+ 0 6px 14px rgba(var(--overlay-rgb), 0.1);
+}
+
+.window-titlebar__actions .global-search-results {
+ top: calc(100% + var(--space-1));
+ right: 0;
+ width: min(720px, calc(100vw - var(--space-4)));
+}
+
+.window-titlebar__actions .notification-bell {
+ width: 30px;
+ height: 30px;
+ min-height: 30px;
+ border-color: var(--titlebar-action-border);
+ background: var(--titlebar-action-surface);
+ box-shadow:
+ 0 0 0 1px rgba(17, 24, 39, 0.08),
+ 0 6px 14px rgba(var(--overlay-rgb), 0.1);
+}
+
+.window-titlebar__actions .notification-bell svg {
+ width: 16px;
+ height: 16px;
+ color: var(--titlebar-action-ink);
+}
+
+.window-titlebar__actions .notification-bell:hover {
+ border-color: rgba(var(--accent-rgb), 0.64);
+ background: var(--surface-hover);
+}
+
+.window-titlebar__actions .notification-bell:hover svg,
+.window-titlebar__actions .notification-bell:focus-visible svg {
+ color: var(--text);
+}
+
.window-titlebar__controls {
display: flex;
align-items: center;
@@ -187,6 +319,10 @@ h3 {
min-width: calc((var(--window-titlebar-mac-control-size) * 3) + (var(--space-1) * 2));
}
+.window-titlebar--platform-mac .window-titlebar__actions {
+ left: calc((var(--window-titlebar-mac-control-size) * 3) + (var(--space-1) * 2) + var(--space-4));
+}
+
.window-titlebar--platform-mac .window-control-button {
width: var(--window-titlebar-mac-control-size);
min-width: var(--window-titlebar-mac-control-size);
@@ -2412,6 +2548,10 @@ h3 {
right: var(--space-2);
}
+.content-panel.content-panel--agent-chat.content-panel--titlebar-actions {
+ padding-top: var(--space-1);
+}
+
.content-panel.content-panel--agent-chat > .agent-page {
flex: 1 1 0;
min-height: 0;
@@ -13197,6 +13337,100 @@ pre {
}
}
+.window-titlebar__actions .search-input {
+ border-color: var(--titlebar-action-border) !important;
+ background: var(--titlebar-action-surface) !important;
+ color: var(--titlebar-action-ink) !important;
+ -webkit-text-fill-color: var(--titlebar-action-ink) !important;
+}
+
+.window-titlebar__actions .search-input--titlebar {
+ border-color: var(--titlebar-action-border) !important;
+ background: var(--titlebar-action-surface) !important;
+ color: var(--titlebar-action-ink) !important;
+ opacity: 1 !important;
+ -webkit-text-fill-color: var(--titlebar-action-ink) !important;
+}
+
+.window-titlebar__actions .global-search::before,
+.window-titlebar__actions .global-search--titlebar::before {
+ color: var(--titlebar-action-ink) !important;
+}
+
+.window-titlebar__actions .global-search--titlebar::before {
+ content: none !important;
+}
+
+.window-titlebar__actions .global-search__titlebar-icon {
+ position: absolute;
+ inset: 0 auto 0 11px;
+ z-index: 1;
+ display: grid;
+ place-items: center;
+ color: var(--titlebar-action-ink) !important;
+ font-size: var(--font-size-lg);
+ font-weight: 600;
+ line-height: 1;
+ pointer-events: none;
+}
+
+.window-titlebar__actions .search-input__titlebar-placeholder {
+ position: absolute;
+ inset: 0 auto 0 34px;
+ z-index: 1;
+ display: flex;
+ align-items: center;
+ color: var(--titlebar-action-ink) !important;
+ font-size: var(--font-size-md);
+ font-weight: var(--font-weight-semibold);
+ line-height: var(--line-height-tight);
+ pointer-events: none;
+}
+
+.window-titlebar__actions .search-input::placeholder,
+.window-titlebar__actions .search-input--titlebar::placeholder {
+ color: var(--titlebar-action-ink) !important;
+ opacity: 1 !important;
+}
+
+.window-titlebar__actions .search-input--titlebar::placeholder {
+ color: transparent !important;
+}
+
+.window-titlebar__actions .notification-bell {
+ border-color: var(--titlebar-action-border) !important;
+ background: var(--titlebar-action-surface) !important;
+}
+
+.window-titlebar__actions .notification-bell--titlebar {
+ border-color: var(--titlebar-action-border) !important;
+ background: var(--titlebar-action-surface) !important;
+ color: var(--titlebar-action-ink) !important;
+ opacity: 1 !important;
+}
+
+.window-titlebar__actions .notification-bell svg,
+.window-titlebar__actions .notification-bell--titlebar svg {
+ color: var(--titlebar-action-ink) !important;
+ stroke: var(--titlebar-action-ink) !important;
+}
+
+:root[data-theme='dark'] .window-titlebar__actions .search-input,
+:root[data-theme='dark'] .window-titlebar__actions .notification-bell {
+ border-color: var(--titlebar-action-border) !important;
+ background: var(--titlebar-action-surface) !important;
+}
+
+:root[data-theme='dark'] .window-titlebar__actions .search-input,
+:root[data-theme='dark'] .window-titlebar__actions .global-search::before,
+:root[data-theme='dark'] .window-titlebar__actions .notification-bell svg {
+ color: var(--titlebar-action-ink) !important;
+}
+
+:root[data-theme='dark'] .window-titlebar__actions .search-input::placeholder {
+ color: var(--titlebar-action-ink) !important;
+}
+
/* Agent Files tab - read-only browser of attached SharedFileSystems */
.shared-files-tab {
display: flex;
diff --git a/desktop-app/ui/src/styles/tokens.css b/desktop-app/ui/src/styles/tokens.css
index 0e4f4ca26..990e8efef 100644
--- a/desktop-app/ui/src/styles/tokens.css
+++ b/desktop-app/ui/src/styles/tokens.css
@@ -158,6 +158,9 @@
--window-control-mac-minimize: rgb(255, 189, 46);
--window-control-mac-expand: rgb(40, 201, 64);
--window-control-mac-border: rgba(var(--overlay-rgb), 0.28);
+ --titlebar-control-ink: #ffffff;
+ --titlebar-control-border: rgba(255, 255, 255, 0.58);
+ --titlebar-control-surface: rgb(var(--panel-rgb));
/* chat-view session tabs (Chrome-style: shrink to a floor, cap at a ceiling) */
--chat-tab-max: 220px;
@@ -282,4 +285,7 @@
--message-artifact-panel-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
--mcp-health-shell-surface: rgba(var(--panel-rgb), 0.96);
--mcp-health-rows-surface: rgba(var(--panel-rgb), 0.86);
+ --titlebar-control-ink: #000000;
+ --titlebar-control-border: rgba(var(--overlay-rgb), 0.68);
+ --titlebar-control-surface: rgb(var(--panel-rgb));
}