Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
refactor(desktop-ui): agent-centric workspace; remove Contexts and Teams
Diego Zacarias6da223b20b81
diff --git a/desktop-app/src/__tests__/desktopCommands.test.ts b/desktop-app/src/__tests__/desktopCommands.test.tsindex 0ccc3127e..189ea7c98 100644--- a/desktop-app/src/__tests__/desktopCommands.test.ts+++ b/desktop-app/src/__tests__/desktopCommands.test.ts@@ -149,8 +149,6 @@ describe('Desktop command registry', () => {it('keeps every approved contextual palette action unbound', () => {for (const id of ['navigate.plugins',- 'navigate.contexts',- 'navigate.teams','navigate.connectors','navigate.files','sidebar.toggle',diff --git a/desktop-app/src/desktopCommands.ts b/desktop-app/src/desktopCommands.tsindex dce1223d5..66d602f31 100644--- a/desktop-app/src/desktopCommands.ts+++ b/desktop-app/src/desktopCommands.ts@@ -322,34 +322,6 @@ const definitions = [visibleInPalette: true,visibleInSettings: false,},- {- id: 'navigate.contexts',- label: 'Go to Contexts',- description: 'Open the Contexts workspace.',- group: 'Navigation',- order: 190,- defaultBinding: null,- sources: ['host', 'sandbox'],- eligibility: 'always',- modalPolicy: 'block',- actionOwner: 'renderer',- visibleInPalette: true,- visibleInSettings: false,- },- {- id: 'navigate.teams',- label: 'Go to Teams',- description: 'Open the Teams workspace.',- group: 'Navigation',- order: 200,- defaultBinding: null,- sources: ['host', 'sandbox'],- eligibility: 'always',- modalPolicy: 'block',- actionOwner: 'renderer',- visibleInPalette: true,- visibleInSettings: false,- },{id: 'navigate.connectors',label: 'Go to Connectors',diff --git a/desktop-app/src/preload.ts b/desktop-app/src/preload.tsindex 67c0b7611..4152d14c1 100644--- a/desktop-app/src/preload.ts+++ b/desktop-app/src/preload.ts@@ -36,8 +36,6 @@ const DESKTOP_COMMAND_IDS = new Set<DesktopCommandId>(['navigate.agents','notifications.open','navigate.plugins',- 'navigate.contexts',- 'navigate.teams','navigate.connectors','navigate.files','sidebar.toggle',diff --git a/desktop-app/test/e2e-playwright/qa-recorder-agents.spec.ts b/desktop-app/test/e2e-playwright/qa-recorder-agents.spec.tsindex 5003756e7..a118aa7fd 100644--- a/desktop-app/test/e2e-playwright/qa-recorder-agents.spec.ts+++ b/desktop-app/test/e2e-playwright/qa-recorder-agents.spec.ts@@ -16,11 +16,11 @@ import {// Optional QA recorder journey for the Desktop App agents fleet and workspace.//// Read-only throughout: it launches the real Electron window headfully with-// video, signs in as the exact QA identity, walks the Resources -> Agents fleet,-// lands on the chatllm agent's chat composer, and exercises the agent workspace-// route switcher (Details / Connectors / Contexts / Activity). No chat messages-// are sent and no confirm flag is required; every test still guards the loopback-// targets up front. See docs/testing/optional-playwright-qa-recorder.md.+// video, signs in as the exact QA identity, walks the Agents fleet, lands on the+// chatllm agent's chat composer, and exercises the agent workspace route switcher+// (Connectors / Members / Activity). No chat messages are sent and no confirm+// flag is required; every test still guards the loopback targets up front. See+// docs/testing/optional-playwright-qa-recorder.md.test('optional QA recorder: Desktop agents journey — fleet', async ({}, testInfo) => {await assertAllowedTarget('EXTERNAL_REST_API_BASE_URL', EXTERNAL_REST_API_BASE_URL)@@ -104,10 +104,10 @@ test('optional QA recorder: Desktop agents journey — workspace routes', asyncawait login(page, credentials)await openAgentsPage(page)- // Enter the chatllm workspace in agents-mode (Details route) by clicking its- // fleet row. Resilient to the auto-selected-chat landing: if the fleet did- // not render, the route-switching portion is skipped and we still capture a- // proof of whatever shell is present.+ // Enter the chatllm workspace in agents-mode (default Connectors route) by+ // clicking its fleet row. Resilient to the auto-selected-chat landing: if the+ // fleet did not render, the route-switching portion is skipped and we still+ // capture a proof of whatever shell is present.const exactAgentRow = page.locator('.agents-table-row-clickable', { hasText: hostRef }).first()const composer = page.getByRole('textbox', { name: 'Agent message composer' })const emptyState = page.getByText('No agents available')@@ -117,11 +117,11 @@ test('optional QA recorder: Desktop agents journey — workspace routes', asyncawait exactAgentRow.click()// Agents-mode workspace: breadcrumb shows Agents / <agent> / <route>, and- // the default Details section renders its hero shell.+ // the default Connectors section renders its hero shell.const agentBreadcrumb = page.getByLabel('Agent breadcrumb')await expect(agentBreadcrumb).toBeVisible({ timeout: 20_000 })await expect(agentBreadcrumb).toContainText(hostRef)- await expect(page.locator('section[aria-label="Agent details"]')).toBeVisible({+ await expect(page.locator('section[aria-label="Agent connectors"]')).toBeVisible({timeout: 20_000,})@@ -129,8 +129,8 @@ test('optional QA recorder: Desktop agents journey — workspace routes', async// aria-label "Switch agent section") across the workspace resource routes// exposed by the agent menu, asserting each section shell renders.const routes: Array<{ menuLabel: string; sectionAriaLabel: string }> = [+ { menuLabel: 'Members', sectionAriaLabel: 'Agent members' },{ menuLabel: 'Connectors', sectionAriaLabel: 'Agent connectors' },- { menuLabel: 'Contexts', sectionAriaLabel: 'Agent contexts' },{ menuLabel: 'Activity', sectionAriaLabel: 'Agent activity' },]for (const { menuLabel, sectionAriaLabel } of routes) {diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsxindex c0a34d4d0..33e1c64d4 100644--- a/desktop-app/ui/src/App.tsx+++ b/desktop-app/ui/src/App.tsx@@ -65,8 +65,6 @@ import {import { AgentsPage } from '@pages/AgentsPage'import { AuthPage } from '@pages/AuthPage'import { ChatPage } from '@pages/ChatPage'-import { ContextDetailsPage } from '@pages/ContextDetailsPage'-import { ContextsPage } from '@pages/ContextsPage'import { FilesPage } from '@pages/FilesPage'import { McpServersPage } from '@pages/McpServersPage'import { SandboxUiPage } from '@pages/SandboxUiPage'@@ -75,8 +73,6 @@ import type {SandboxUiShortcutOpenResult,} from '@pages/SandboxUiPage.types'import { SettingsPage } from '@pages/SettingsPage'-import { TeamDetailsPage } from '@pages/TeamDetailsPage'-import { TeamsPage } from '@pages/TeamsPage'import { UnavailablePage } from '@pages/UnavailablePage'import { WorkflowsPage } from '@pages/WorkflowsPage'import type { PendingSandboxUiDeepLink, SandboxUiDeepLinkEnvelope } from '@/App.types'@@ -1209,15 +1205,11 @@ export function App() {}if (commandId === 'navigate.plugins' ||- commandId === 'navigate.contexts' ||- commandId === 'navigate.teams' ||commandId === 'navigate.connectors' ||commandId === 'navigate.files') {const routes = {'navigate.plugins': DESKTOP_ROUTES.plugins,- 'navigate.contexts': DESKTOP_ROUTES.contexts,- 'navigate.teams': DESKTOP_ROUTES.teams,'navigate.connectors': DESKTOP_ROUTES.connectors,'navigate.files': DESKTOP_ROUTES.files,} as const@@ -1506,33 +1498,19 @@ export function App() {navItem: vm.navItem,selectedAgent: vm.selectedAgent,selectedAgentRoute: vm.selectedAgentRoute,- selectedContext: vm.selectedContext,- selectedContextTab: vm.selectedContextTab,- selectedTeam: vm.selectedTeam,handleNavSelect: vm.handleNavSelect,handleOpenAgentWorkspace: vm.handleOpenAgentWorkspace,handleSelectChatAgent: handleSelectChatAgentWithTabs,handleBackToAgents: vm.handleBackToAgents,- handleOpenContextDetails: vm.handleOpenContextDetails,- handleBackToContexts: vm.handleBackToContexts,- handleOpenTeamDetails: vm.handleOpenTeamDetails,- handleBackToTeams: vm.handleBackToTeams,}),[vm.handleBackToAgents,- vm.handleBackToContexts,- vm.handleBackToTeams,vm.handleNavSelect,vm.handleOpenAgentWorkspace,- vm.handleOpenContextDetails,- vm.handleOpenTeamDetails,handleSelectChatAgentWithTabs,vm.navItem,vm.selectedAgent,vm.selectedAgentRoute,- vm.selectedContext,- vm.selectedContextTab,- vm.selectedTeam,])@@ -1794,13 +1772,7 @@ export function App() {<DesktopStateProvider value={desktopStateValue}><main className="app-shell"><SidebarNav- navItem={- vm.navItem === DESKTOP_ROUTES.teamDetails- ? DESKTOP_ROUTES.teams- : vm.navItem === DESKTOP_ROUTES.contextDetails- ? DESKTOP_ROUTES.contexts- : vm.navItem- }+ navItem={vm.navItem}activeSandboxUiApp={activeSandboxUiApp}availableSandboxUiApps={availableSandboxUiApps}collapsed={sidebarCollapsed}@@ -1856,7 +1828,6 @@ export function App() {{vm.navItem === DESKTOP_ROUTES.agents && (<AgentsPage scrollContainerRef={contentPanelRef} />)}- {vm.navItem === DESKTOP_ROUTES.contexts && <ContextsPage />}{vm.navItem === DESKTOP_ROUTES.files && (<FilesPagepushToast={vm.pushToast}@@ -1865,9 +1836,6 @@ export function App() {/>)}{vm.navItem === DESKTOP_ROUTES.connectors && <McpServersPage />}- {vm.navItem === DESKTOP_ROUTES.contextDetails && (- <ContextDetailsPage />- )}{vm.navItem === DESKTOP_ROUTES.plugins && <WorkflowsPage />}{vm.navItem === DESKTOP_ROUTES.apps && (<SandboxUiPage@@ -1916,8 +1884,6 @@ export function App() {}/>)}- {vm.navItem === DESKTOP_ROUTES.teams && <TeamsPage />}- {vm.navItem === DESKTOP_ROUTES.teamDetails && <TeamDetailsPage />}</section></section></main>diff --git a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsxindex 107bc742d..e5d2d3079 100644--- a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx+++ b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx@@ -102,8 +102,6 @@ vi.mock('@components/SidebarNav', () => ({vi.mock('@pages/AgentsPage', () => ({ AgentsPage: () => null }))vi.mock('@pages/AuthPage', () => ({ AuthPage: () => null }))vi.mock('@pages/ChatPage', () => ({ ChatPage: () => null }))-vi.mock('@pages/ContextDetailsPage', () => ({ ContextDetailsPage: () => null }))-vi.mock('@pages/ContextsPage', () => ({ ContextsPage: () => null }))vi.mock('@pages/FilesPage', () => ({ FilesPage: () => null }))vi.mock('@pages/McpServersPage', () => ({ McpServersPage: () => null }))vi.mock('@pages/SandboxUiPage', () => ({@@ -121,8 +119,6 @@ vi.mock('@pages/SettingsPage', () => ({return null},}))-vi.mock('@pages/TeamDetailsPage', () => ({ TeamDetailsPage: () => null }))-vi.mock('@pages/TeamsPage', () => ({ TeamsPage: () => null }))vi.mock('@pages/UnavailablePage', () => ({ UnavailablePage: () => null }))vi.mock('@pages/WorkflowsPage', () => ({ WorkflowsPage: () => null }))@@ -164,8 +160,6 @@ function makeController(overrides: Partial<AppController> = {}): AppController {navItem: DESKTOP_ROUTES.chat,selectedAgent: null,selectedAgentRoute: null,- selectedContext: null,- selectedTeam: null,activeChatId: null,chatList: [],latestChatSessions: [],@@ -427,8 +421,6 @@ describe('App deep-link orchestration', () => {for (const [commandId, route] of [['navigate.plugins', DESKTOP_ROUTES.plugins],- ['navigate.contexts', DESKTOP_ROUTES.contexts],- ['navigate.teams', DESKTOP_ROUTES.teams],['navigate.connectors', DESKTOP_ROUTES.connectors],['navigate.files', DESKTOP_ROUTES.files],] as const) {diff --git a/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx b/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsxindex efa91c5e4..db409f8f9 100644--- a/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx+++ b/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx@@ -243,9 +243,7 @@ describe('AppHeader notification tray presentation', () => {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('title')).toBe('Search agents, connectors, plugins or apps...')})it('uses the full search label above the constrained-width breakpoint', () => {@@ -254,12 +252,8 @@ describe('AppHeader notification tray presentation', () => {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 agents, connectors, plugins or apps...')+ expect(search.getAttribute('title')).toBe('Search agents, connectors, plugins or apps...')})it('opens and focuses the existing global search for a command request', () => {diff --git a/desktop-app/ui/src/components/AppHeader/index.tsx b/desktop-app/ui/src/components/AppHeader/index.tsxindex cc1d94a0f..b8c0f524e 100644--- a/desktop-app/ui/src/components/AppHeader/index.tsx+++ b/desktop-app/ui/src/components/AppHeader/index.tsx@@ -6,7 +6,6 @@ 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'@@ -17,12 +16,10 @@ import type {AppHeaderProps,SearchAppResult,SearchEntityResult,- SearchMemberResult,SearchPluginResult,- SearchTeamResult,} from './types'-const FULL_SEARCH_PLACEHOLDER = 'Search teams, contexts, members, agents or connectors...'+const FULL_SEARCH_PLACEHOLDER = 'Search agents, connectors, plugins or apps...'const COMPACT_SEARCH_PLACEHOLDER = 'Search workspace...'const COMPACT_SEARCH_BREAKPOINT = 1220@@ -94,11 +91,9 @@ export const AppHeader = React.memo(function AppHeader({onShellOverlayOpenChange,}: AppHeaderProps) {const { accessCatalog: agentsAccessCatalog } = useAgentsDataController()- const { contextIds, contextDisplayById } = useContextsDataController()const { globalMcpServers, mcpServersByAgent } = useMcpServersDataController()const {teams,- teamMembers,teamDirectory,loading: teamDirectoryLoading,teamDirectoryHydrated,@@ -111,8 +106,7 @@ export const AppHeader = React.memo(function AppHeader({loading: pluginsAppsLoading,ensureLoaded: ensurePluginsAppsLoaded,} = useSearchPluginsAppsController()- const { navItem, handleNavSelect, handleOpenContextDetails, handleOpenTeamDetails } =- useNavigationContext()+ const { handleNavSelect } = useNavigationContext()const {notifications,unreadNotificationCount,@@ -218,11 +212,6 @@ export const AppHeader = React.memo(function AppHeader({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'@@ -265,38 +254,6 @@ export const AppHeader = React.memo(function AppHeader({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,@@ -363,41 +320,6 @@ export const AppHeader = React.memo(function AppHeader({}))}, [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@@ -410,59 +332,6 @@ export const AppHeader = React.memo(function AppHeader({: [],[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>>()@@ -496,31 +365,6 @@ export const AppHeader = React.memo(function AppHeader({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@@ -560,13 +404,7 @@ export const AppHeader = React.memo(function AppHeader({}, [hasSearch, normalizedSearch, searchApps])const totalMatches =- filteredTeams.length +- filteredMembers.length +- filteredAgents.length +- filteredContexts.length +- filteredConnectors.length +- filteredPlugins.length +- filteredApps.length+ filteredAgents.length + filteredConnectors.length + filteredPlugins.length + filteredApps.lengthconst pendingApprovalsCount = pendingApprovals.lengthconst inboxNotificationCount = notifications.lengthconst totalAttentionCount = pendingApprovalsCount + unreadNotificationCount@@ -588,16 +426,6 @@ export const AppHeader = React.memo(function AppHeader({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 = ''@@ -663,90 +491,6 @@ export const AppHeader = React.memo(function AppHeader({<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>@@ -848,8 +592,7 @@ export const AppHeader = React.memo(function AppHeader({{!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.+ No matches for "{searchQuery.trim()}". Try an agent, connector, plugin, or app.</p>)}</div>diff --git a/desktop-app/ui/src/components/agents/AgentWorkspace.tsx b/desktop-app/ui/src/components/agents/AgentWorkspace.tsxindex 97a61355e..a10021028 100644--- a/desktop-app/ui/src/components/agents/AgentWorkspace.tsx+++ b/desktop-app/ui/src/components/agents/AgentWorkspace.tsx@@ -1,18 +1,22 @@import { useCallback, useEffect, useMemo, useRef, useState } from 'react'import type { RefObject } from 'react'import { useAgentChatActionsContext } from '@contexts/AgentChatActionsContext'+import { useAuthContext } from '@contexts/AuthContext'import { useChatListContext } from '@contexts/ChatListContext'import { useMcpRuntimeContext } from '@contexts/McpRuntimeContext'import { useNavigationContext } from '@contexts/NavigationContext'-import { DataTable, EmptyState, IconButton, MenuItem, ReferenceTag } from '@components/Common'+import { DataTable, EmptyState, IconButton, MenuItem } from '@components/Common'import { PageBreadcrumb } from '@components/PageBreadcrumb'import type { PageBreadcrumbItem } from '@components/PageBreadcrumb/types'import { ResourceBreadcrumbSwitcher } from '@components/ResourceBreadcrumbSwitcher'-import { IconAgents, IconConnectors, IconContexts } from '@components/SidebarNav/icons'+import { IconAgents } from '@components/SidebarNav/icons'import { useAgentsDataController } from '@hooks/domain/useAgentsDataController'import { useContextsDataController } from '@hooks/domain/useContextsDataController'import { useMcpServersDataController } from '@hooks/domain/useMcpServersDataController'+import { useTeamsDataController } from '@hooks/domain/useTeamsDataController'import { useClickOutside } from '@hooks/useClickOutside'+import { deriveScopedMembers } from '@lib/scopedMembers'+import type { ScopedMemberContextDetails, ScopedMemberTeamRow } from '@lib/scopedMembers.types'import type { AgentWorkspaceRoute } from '../../uiTypes'import { McpServerHealthTable } from '../McpServerHealthTable'import { SharedFilesTab } from '../SharedFilesTab'@@ -69,15 +73,17 @@ export function AgentWorkspace({ mode = 'agents', scrollContainerRef }: AgentWorhandleBackToAgents: onBackToAgents,handleOpenAgentWorkspace: onOpenAgentWorkspace,handleSelectChatAgent: onSelectChatAgent,- handleOpenContextDetails,} = useNavigationContext()const { agentNames } = useAgentsDataController()+ const { me } = useAuthContext()+ const { accessCatalog } = useContextsDataController()const {- contextIds,- contextDisplayById,- loading: contextsLoading,- error: contextsError,- } = useContextsDataController()+ teams,+ currentTeamId,+ teamMembers,+ teamDirectory,+ ensureHydrated: ensureTeamsHydrated,+ } = useTeamsDataController()const { agentContextByName, agentDisplayByName, selectedAgentMcpServers } =useMcpServersDataController({selectedAgent,@@ -139,16 +145,57 @@ export function AgentWorkspace({ mode = 'agents', scrollContainerRef }: AgentWorconst selectedAgentDisplay = selectedAgent? (agentDisplayByName[selectedAgent] ?? selectedAgent): null- const visibleContextIds = useMemo(- () =>- selectedAgentContext- ? [- selectedAgentContext,- ...contextIds.filter(contextId => contextId !== selectedAgentContext),- ]- : contextIds,- [contextIds, selectedAgentContext]++ // Members tab (spec §5.C). The context detail the projection needs is+ // reachable from the same app-coordinated caches AgentWorkspace already reads:+ // - availableToUser/availableToTeam/userId derive from the access catalog+ // (useContextsDataController) given the agent's contextRef;+ // - the mapped teams and their members come from the team directory+ // (useTeamsDataController).+ // No new fetch/IPC — this is a pure projection over cached data (deriveScopedMembers).+ const agentContextRef = selectedAgentContext || null+ const memberContextDetails = useMemo<ScopedMemberContextDetails>(() => {+ if (!agentContextRef || !accessCatalog) return null+ return {+ availableToUser: accessCatalog.userContextIds.includes(agentContextRef),+ availableToTeam: accessCatalog.teamContextIds.includes(agentContextRef),+ userId: accessCatalog.userId,+ }+ }, [accessCatalog, agentContextRef])+ const currentTeam = useMemo(+ () => teams.find(team => team.id === currentTeamId) ?? null,+ [teams, currentTeamId]+ )+ const memberTeamRows = useMemo<ScopedMemberTeamRow[]>(() => {+ if (!agentContextRef) return []+ const rowsByTeamId = new Map<string, ScopedMemberTeamRow>()+ // Iterate teams alphabetically by name so members list in a stable,+ // human-friendly order — parity with the previous ContextDetailsPage panel,+ // which sorted contextTeamRows by team.name. deriveScopedMembers preserves+ // insertion order, so the ordering guarantee lives here at the call site.+ const teamsByName = [...teams].sort((a, b) => a.name.localeCompare(b.name))+ for (const team of teamsByName) {+ const entry = teamDirectory[team.id]+ if (!entry?.contextIds.includes(agentContextRef)) continue+ rowsByTeamId.set(team.id, { members: entry.members || [] })+ }+ if (memberContextDetails?.availableToTeam && currentTeam && !rowsByTeamId.has(currentTeam.id)) {+ rowsByTeamId.set(currentTeam.id, { members: teamMembers })+ }+ return [...rowsByTeamId.values()]+ }, [+ agentContextRef,+ currentTeam,+ memberContextDetails?.availableToTeam,+ teamDirectory,+ teamMembers,+ teams,+ ])+ const scopedMembers = useMemo(+ () => deriveScopedMembers(memberContextDetails, memberTeamRows, me),+ [memberContextDetails, memberTeamRows, me])+const isChatMode = mode === 'chat'const isChatScrollNavMode = isChatMode && Boolean(activeChatId)const rootBreadcrumbLabel = mode === 'chat' ? 'Chat' : 'Agents'@@ -163,13 +210,11 @@ export function AgentWorkspace({ mode = 'agents', scrollContainerRef }: AgentWorconst routeSubtitle =selectedAgentRoute === 'mcp-servers'? 'Connector health and mappings for this agent.'- : selectedAgentRoute === 'contexts'- ? 'Authorized contexts available to this agent.'+ : selectedAgentRoute === 'members'+ ? 'People with access to this agent through its context.': selectedAgentRoute === 'shared-files'? 'Agent files available through this agent.'- : selectedAgentRoute === 'activity'- ? 'Recent conversations, messages, tool calls, and errors.'- : 'Workspace status and queue details for this agent.'+ : 'Recent conversations, messages, tool calls, and errors.'const agentOptions = useMemo(// id stays the identifier (drives selection/matching); label shows the@@ -188,9 +233,9 @@ export function AgentWorkspace({ mode = 'agents', scrollContainerRef }: AgentWor// Agent selector dropdown for the greeting title row. Each row has two// targets: the agent NAME (click → start/switch a chat with that agent) and- // the 3-dots (click → open a sections sub-menu: Details / Connectors /- // Contexts / Agent Files / Activity, navigating into that agent's workspace- // without switching the chat). This mirrors the chatAgentRouteMenu pattern.+ // the 3-dots (click → open a sections sub-menu: Connectors / Members /+ // Agent Files / Activity, navigating into that agent's workspace without+ // switching the chat). This mirrors the chatAgentRouteMenu pattern.const agentSwitcherLabel = (<AgentTitleSelectorariaLabel={isChatMode ? 'Switch chat agent' : 'Switch agent'}@@ -291,6 +336,15 @@ export function AgentWorkspace({ mode = 'agents', scrollContainerRef }: AgentWorsetChatAgentRouteMenuOpen(false)}, [selectedAgent])+ // The Members tab reads the team directory (see memberTeamRows). It is an+ // app-coordinated query, so a deep-link straight into the Members tab may+ // arrive before the post-paint bootstrap hydrated it — ensure it once here.+ useEffect(() => {+ if (!isChatMode && selectedAgentRoute === 'members') {+ void ensureTeamsHydrated()+ }+ }, [ensureTeamsHydrated, isChatMode, selectedAgentRoute])+useEffect(() => {if (!isChatScrollNavMode) {setChatScrollNavVisible(true)@@ -395,51 +449,30 @@ export function AgentWorkspace({ mode = 'agents', scrollContainerRef }: AgentWor</section>)}- {!isChatMode && selectedAgentRoute === 'contexts' && (- <section className="agent-workspace-panel" aria-label="Agent contexts">+ {!isChatMode && selectedAgentRoute === 'members' && (+ <section className="agent-workspace-panel" aria-label="Agent members"><AgentHero agentName={selectedAgentDisplay} subtitle={routeSubtitle} />- {contextsLoading && !visibleContextIds.length ? (- <EmptyState title="Loading" body="Fetching authorized contexts..." />- ) : contextsError && !visibleContextIds.length ? (- <div className="composer-error" role="alert">- <p className="error-text">{contextsError}</p>- </div>- ) : visibleContextIds.length ? (- <DataTable className="agent-contexts-data-table">+ {scopedMembers.length ? (+ <DataTable className="agent-members-data-table"><thead><tr><th className="da-table__col-header" scope="col">- Context+ Member</th><th className="da-table__col-header" scope="col">- Scope</th></tr></thead><tbody>- {visibleContextIds.map(contextId => (- <tr key={contextId}>+ {scopedMembers.map(member => (+ <tr key={member.id}><td className="da-table__cell">- <ReferenceTag- kind="context"- onClick={() => handleOpenContextDetails(contextId)}- title={contextId}- aria-label={`Open context ${contextId}`}- >- {/* Visible context name (spec.displayName); fall back- to the id (Decision #6) when no display exists OR- the display is blank/whitespace-only (an out-of-band- write must never render an empty context label). */}- {(contextDisplayById[contextId] ?? '').trim() || contextId}- </ReferenceTag>+ <span className="context-members-name">{member.label}</span></td><td className="da-table__cell">- <span className="agent-table-muted">- {contextId === selectedAgentContext- ? `Mapped to ${selectedAgent}`- : 'Available'}- </span>+ <span className="context-members-email">{member.secondary || '-'}</span></td></tr>))}@@ -447,8 +480,8 @@ export function AgentWorkspace({ mode = 'agents', scrollContainerRef }: AgentWor</DataTable>) : (<EmptyState- title="No contexts"- body="No contexts are currently mapped to this workspace."+ title="No members"+ body="No members are available for this agent in the current API scope."/>)}</section>@@ -469,73 +502,6 @@ export function AgentWorkspace({ mode = 'agents', scrollContainerRef }: AgentWor</section>)}- {!isChatMode && selectedAgentRoute === 'details' && (- <section- className="agent-workspace-panel agent-details-panel"- aria-label="Agent details"- >- <AgentHero- agentName={selectedAgentDisplay}- subtitle="Agent details"- subtitleTone="eyebrow"- />-- <div className="agent-details-resource-grid">- <section className="agent-details-resource" aria-label="Mapped context">- <span className="agent-details-resource-icon" aria-hidden="true">- <IconContexts />- </span>- <div className="agent-details-resource-copy">- <span className="agent-details-resource-label">Context</span>- {selectedAgentContext ? (- <ReferenceTag- kind="context"- onClick={() => onOpenAgentWorkspace(selectedAgent ?? '', 'contexts')}- title={selectedAgentContext}- aria-label={`Open contexts for ${selectedAgent}`}- >- {selectedAgentContext}- </ReferenceTag>- ) : (- <span className="agent-table-muted">No mapped context</span>- )}- </div>- </section>-- <section className="agent-details-resource" aria-label="Mapped connectors">- <span className="agent-details-resource-icon" aria-hidden="true">- <IconConnectors />- </span>- <div className="agent-details-resource-copy">- <span className="agent-details-resource-label">- Connectors- {selectedAgentMcpServerNames.length- ? ` · ${selectedAgentMcpServerNames.length}`- : ''}- </span>- {selectedAgentMcpServerNames.length ? (- <span className="reference-tag-list">- {selectedAgentMcpServerNames.slice(0, 6).map(serverName => (- <ReferenceTag- key={`${selectedAgent}:${serverName}`}- kind="connector"- onClick={() => onOpenAgentWorkspace(selectedAgent ?? '', 'mcp-servers')}- title={serverName}- aria-label={`Open connectors for ${selectedAgent}`}- >- {serverName}- </ReferenceTag>- ))}- </span>- ) : (- <span className="agent-table-muted">No mapped connectors</span>- )}- </div>- </section>- </div>- </section>- )}-{!isChatMode && selectedAgentRoute === 'activity' && (<section className="agent-workspace-panel" aria-label="Agent activity"><AgentHero agentName={selectedAgentDisplay} subtitle={routeSubtitle} />diff --git a/desktop-app/ui/src/components/agents/FleetBoard.tsx b/desktop-app/ui/src/components/agents/FleetBoard.tsxindex e39acff50..d60de2d69 100644--- a/desktop-app/ui/src/components/agents/FleetBoard.tsx+++ b/desktop-app/ui/src/components/agents/FleetBoard.tsx@@ -48,7 +48,6 @@ export function FleetBoard() {useMcpServersDataController()const {handleOpenAgentWorkspace: onOpenAgentWorkspace,- handleOpenTeamDetails: onOpenTeamDetails,handleSelectChatAgent: onSelectAgent,selectedAgent,} = useNavigationContext()@@ -250,8 +249,8 @@ export function FleetBoard() {<trkey={row.agent}className="da-table__row--clickable agents-table-row-clickable"- {...clickableRowProps(() => onOpenAgentWorkspace(row.agent, 'details'), {- ariaLabel: `Open details for ${row.agent}`,+ {...clickableRowProps(() => onOpenAgentWorkspace(row.agent, 'mcp-servers'), {+ ariaLabel: `Open agent ${row.agent}`,})}><td className="da-table__cell">@@ -277,12 +276,7 @@ export function FleetBoard() {<ReferenceTagkey={`${row.agent}:${team.id}`}kind="team"- onClick={event => {- event.stopPropagation()- onOpenTeamDetails(team.id)- }}title={team.name}- aria-label={`Open team ${team.name}`}>{team.name}</ReferenceTag>diff --git a/desktop-app/ui/src/components/agents/__tests__/AgentTitleSelector.test.tsx b/desktop-app/ui/src/components/agents/__tests__/AgentTitleSelector.test.tsxindex 533d50b18..638cc1f6e 100644--- a/desktop-app/ui/src/components/agents/__tests__/AgentTitleSelector.test.tsx+++ b/desktop-app/ui/src/components/agents/__tests__/AgentTitleSelector.test.tsx@@ -135,10 +135,10 @@ describe('AgentTitleSelector', () => {const dots = findDotsItem('Beta')fireEvent.click(dots)- expect(screen.queryByRole('menuitem', { name: 'Details' })).not.toBeNull()+ expect(screen.queryByRole('menuitem', { name: 'Connectors' })).not.toBeNull()fireEvent.click(dots)- expect(screen.queryByRole('menuitem', { name: 'Details' })).toBeNull()+ expect(screen.queryByRole('menuitem', { name: 'Connectors' })).toBeNull()})it('shows the empty label when there are no options', () => {diff --git a/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.chatScroll.test.tsx b/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.chatScroll.test.tsxindex 93e2cdba2..7e20ed42c 100644--- a/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.chatScroll.test.tsx+++ b/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.chatScroll.test.tsx@@ -19,7 +19,19 @@ vi.mock('@hooks/domain/useAgentsDataController', () => ({useAgentsDataController: () => ({ agentNames: ['agent-x'] }),}))vi.mock('@hooks/domain/useContextsDataController', () => ({- useContextsDataController: () => ({ contextIds: [], loading: false, error: null }),+ useContextsDataController: () => ({ accessCatalog: null }),+}))+vi.mock('@hooks/domain/useTeamsDataController', () => ({+ useTeamsDataController: () => ({+ teams: [],+ currentTeamId: '',+ teamMembers: [],+ teamDirectory: {},+ ensureHydrated: vi.fn(async () => undefined),+ }),+}))+vi.mock('@contexts/AuthContext', () => ({+ useAuthContext: () => ({ me: null }),}))vi.mock('@hooks/domain/useMcpServersDataController', () => ({useMcpServersDataController: () => ({diff --git a/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.displayName.test.tsx b/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.displayName.test.tsxindex 22c74094d..e0aa47c17 100644--- a/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.displayName.test.tsx+++ b/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.displayName.test.tsx@@ -3,25 +3,13 @@ import { afterEach, describe, expect, it, vi } from 'vitest'import { cleanup, fireEvent, render, screen } from '@testing-library/react'import { AgentWorkspace } from '../AgentWorkspace'-// UT-11 (spec §5, F3 desktop-app) — Context display with the single sanctioned-// fallback `contextDisplayById[id] ?? id`:-// - WITH display: a context whose displayName ("Prod Ctx") differs from its id-// renders the display.-// - WITHOUT display: a context with no displayName renders its id-// (metadata.name) — the only fallback.--const contextsMock = vi.hoisted(() => ({- contextIds: [] as string[],- contextDisplayById: {} as Record<string, string>,-}))-const mcpMock = vi.hoisted(() => ({agentDisplayByName: {} as Record<string, string>,}))const navMock = vi.hoisted(() => ({selectedAgent: 'product-agent' as string | null,- selectedAgentRoute: 'contexts' as string,+ selectedAgentRoute: 'members' as string,}))const agentsMock = vi.hoisted(() => ({@@ -33,12 +21,7 @@ vi.mock('@hooks/domain/useAgentsDataController', () => ({}))vi.mock('@hooks/domain/useContextsDataController', () => ({- useContextsDataController: () => ({- contextIds: contextsMock.contextIds,- contextDisplayById: contextsMock.contextDisplayById,- loading: false,- error: null,- }),+ useContextsDataController: () => ({ accessCatalog: null }),}))vi.mock('@hooks/domain/useMcpServersDataController', () => ({@@ -49,6 +32,20 @@ vi.mock('@hooks/domain/useMcpServersDataController', () => ({}),}))+vi.mock('@hooks/domain/useTeamsDataController', () => ({+ useTeamsDataController: () => ({+ teams: [],+ currentTeamId: '',+ teamMembers: [],+ teamDirectory: {},+ ensureHydrated: vi.fn(async () => undefined),+ }),+}))++vi.mock('@contexts/AuthContext', () => ({+ useAuthContext: () => ({ me: null }),+}))+vi.mock('@contexts/NavigationContext', () => ({useNavigationContext: () => ({selectedAgent: navMock.selectedAgent,@@ -56,7 +53,6 @@ vi.mock('@contexts/NavigationContext', () => ({handleBackToAgents: vi.fn(),handleOpenAgentWorkspace: vi.fn(),handleSelectChatAgent: vi.fn(),- handleOpenContextDetails: vi.fn(),}),}))@@ -83,62 +79,24 @@ vi.mock('@hooks/useClickOutside', () => ({ useClickOutside: vi.fn() }))vi.mock('../ComposerPanel', () => ({ ComposerPanel: () => null }))vi.mock('../ChatThread', () => ({ ChatThread: () => null }))-describe('AgentWorkspace context rows — visible name (UT-11)', () => {- afterEach(() => {- cleanup()- contextsMock.contextIds = []- contextsMock.contextDisplayById = {}- mcpMock.agentDisplayByName = {}- navMock.selectedAgent = 'product-agent'- navMock.selectedAgentRoute = 'contexts'- vi.clearAllMocks()- })-- it('renders the context display when present and the id when absent', () => {- contextsMock.contextIds = ['ctx-with', 'ctx-plain']- contextsMock.contextDisplayById = { 'ctx-with': 'Prod Ctx' }-- render(<AgentWorkspace scrollContainerRef={{ current: null }} />)-- // Branch WITH display: renders "Prod Ctx", not the id.- expect(screen.getByText('Prod Ctx')).toBeTruthy()- expect(screen.queryByText('ctx-with')).toBeNull()- // Branch WITHOUT display: renders the id (metadata.name) — single fallback.- expect(screen.getByText('ctx-plain')).toBeTruthy()- })-- it('falls back to the id when the context display is blank/whitespace-only', () => {- // An out-of-band write (e.g. kubectl bypassing control-api validation) can- // leave a whitespace-only spec.displayName. The row must render the stable- // id, never a blank context label (same class as R4-M1 GfsAgentAccessSection).- contextsMock.contextIds = ['ctx-blank']- contextsMock.contextDisplayById = { 'ctx-blank': ' ' }-- render(<AgentWorkspace scrollContainerRef={{ current: null }} />)-- // Observable text is the id, not the whitespace-only display.- expect(screen.getByText('ctx-blank')).toBeTruthy()- })-})-// R1-M3 (desktop-app): the workspace hero title must show the agent DISPLAY name// (spec.host, arriving as agentDisplayByName[name]) — not the raw identifier// (metadata.name) the tables map to a display elsewhere. Single sanctioned// fallback `agentDisplayByName[name] ?? name` (Decision #6): the id shows only-// when no display exists. The hero renders on the details route.+// when no display exists. The hero renders on any resource route (here Members).describe('AgentWorkspace hero + breadcrumb — visible agent name (R1-M3)', () => {afterEach(() => {cleanup()mcpMock.agentDisplayByName = {}navMock.selectedAgent = 'product-agent'- navMock.selectedAgentRoute = 'contexts'+ navMock.selectedAgentRoute = 'members'agentsMock.agentNames = ['product-agent']vi.clearAllMocks()})it('renders the agent display name in the hero AND the breadcrumb when a display differs from the id', () => {navMock.selectedAgent = 'alpha'- navMock.selectedAgentRoute = 'details'+ navMock.selectedAgentRoute = 'members'mcpMock.agentDisplayByName = { alpha: 'Alpha Host' }render(<AgentWorkspace scrollContainerRef={{ current: null }} />)@@ -157,7 +115,7 @@ describe('AgentWorkspace hero + breadcrumb — visible agent name (R1-M3)', () =it('falls back to the identifier in the hero AND the breadcrumb when no display exists', () => {navMock.selectedAgent = 'alpha'- navMock.selectedAgentRoute = 'details'+ navMock.selectedAgentRoute = 'members'mcpMock.agentDisplayByName = {}render(<AgentWorkspace scrollContainerRef={{ current: null }} />)@@ -177,7 +135,7 @@ describe('AgentWorkspace title selector — visible agent name (R1-M3)', () => {cleanup()mcpMock.agentDisplayByName = {}navMock.selectedAgent = 'product-agent'- navMock.selectedAgentRoute = 'contexts'+ navMock.selectedAgentRoute = 'members'agentsMock.agentNames = ['product-agent']vi.clearAllMocks()})diff --git a/desktop-app/ui/src/components/agents/__tests__/FleetBoard.deeplink.test.tsx b/desktop-app/ui/src/components/agents/__tests__/FleetBoard.deeplink.test.tsxnew file mode 100644index 000000000..1a0c4be9f--- /dev/null+++ b/desktop-app/ui/src/components/agents/__tests__/FleetBoard.deeplink.test.tsx@@ -0,0 +1,68 @@+// @vitest-environment jsdom+import { afterEach, describe, expect, it, vi } from 'vitest'+import { cleanup, fireEvent, render, screen } from '@testing-library/react'+import { FleetBoard } from '../FleetBoard'++// FleetBoard deep-links: a fleet row and its Connectors column must both open+// the agent workspace on the Connectors (mcp-servers) tab — never the removed+// `details` tab (Fase 2, spec §5.D).++const nav = vi.hoisted(() => ({+ handleOpenAgentWorkspace: vi.fn(),+ handleOpenTeamDetails: vi.fn(),+ handleSelectChatAgent: vi.fn(),+ selectedAgent: null as string | null,+}))++vi.mock('@contexts/NavigationContext', () => ({+ useNavigationContext: () => nav,+}))+vi.mock('@contexts/AgentActivityContext', () => ({+ useAgentActivityContext: () => ({ agentLastActiveByAgent: {} }),+}))+vi.mock('@contexts/AgentChatActionsContext', () => ({+ useAgentChatActionsContext: () => ({ handleCreateChat: vi.fn() }),+}))+vi.mock('@hooks/domain/useAgentsDataController', () => ({+ useAgentsDataController: () => ({+ agentNames: ['agent-x'],+ userAgentNames: ['agent-x'],+ teamAgentNames: [],+ }),+}))+vi.mock('@hooks/domain/useTeamsDataController', () => ({+ useTeamsDataController: () => ({+ teams: [],+ currentTeamId: '',+ teamDirectory: {},+ ensureHydrated: vi.fn(async () => undefined),+ }),+}))+vi.mock('@hooks/domain/useMcpServersDataController', () => ({+ useMcpServersDataController: () => ({+ agentMcpServerCountByAgent: { 'agent-x': 2 },+ agentMcpServersByAgent: { 'agent-x': [{ name: 'monday' }, { name: 'jira' }] },+ mcpServerMappingUnavailableMessage: 'unavailable',+ }),+}))++describe('FleetBoard — deep-link to the Connectors tab', () => {+ afterEach(() => {+ cleanup()+ vi.clearAllMocks()+ })++ it('clicking a fleet row opens the agent workspace on the Connectors (mcp-servers) tab', () => {+ const { container } = render(<FleetBoard />)+ const row = container.querySelector<HTMLElement>('.agents-table-row-clickable')+ expect(row).not.toBeNull()+ fireEvent.click(row as HTMLElement)+ expect(nav.handleOpenAgentWorkspace).toHaveBeenCalledWith('agent-x', 'mcp-servers')+ })++ it('the Connectors column button opens the agent workspace on the Connectors tab', () => {+ render(<FleetBoard />)+ fireEvent.click(screen.getByRole('button', { name: 'Open connectors for agent-x' }))+ expect(nav.handleOpenAgentWorkspace).toHaveBeenCalledWith('agent-x', 'mcp-servers')+ })+})diff --git a/desktop-app/ui/src/components/agents/agentRoutes.ts b/desktop-app/ui/src/components/agents/agentRoutes.tsindex 67291e801..8110bf70d 100644--- a/desktop-app/ui/src/components/agents/agentRoutes.ts+++ b/desktop-app/ui/src/components/agents/agentRoutes.ts@@ -2,17 +2,15 @@ import { SHOW_AGENT_FILES_UI } from '@constants/agentFeatures'import type { AgentWorkspaceRoute } from '../../uiTypes'export const AGENT_ROUTE_LABELS: Record<AgentWorkspaceRoute, string> = {- details: 'Details','mcp-servers': 'Connectors',- contexts: 'Contexts',+ members: 'Members','shared-files': 'Agent Files',activity: 'Activity',}export const AGENT_ROUTE_OPTIONS: AgentWorkspaceRoute[] = [- 'details','mcp-servers',- 'contexts',+ 'members',...(SHOW_AGENT_FILES_UI ? (['shared-files'] as AgentWorkspaceRoute[]) : []),'activity',]diff --git a/desktop-app/ui/src/constants/__tests__/navigation.test.ts b/desktop-app/ui/src/constants/__tests__/navigation.test.tsindex db547e0fe..0258d7841 100644--- a/desktop-app/ui/src/constants/__tests__/navigation.test.ts+++ b/desktop-app/ui/src/constants/__tests__/navigation.test.ts@@ -16,4 +16,22 @@ describe('desktop navigation routes', () => {expect(AGENT_WORKSPACE_ROUTES.connectors).toBe('mcp-servers')expect(AGENT_WORKSPACE_ROUTES.sharedFiles).toBe('shared-files')})++ it('drops Contexts and Teams from the top-level contract (F2 deep removal)', () => {+ expect(DESKTOP_ROUTES).not.toHaveProperty('contexts')+ expect(DESKTOP_ROUTES).not.toHaveProperty('contextDetails')+ expect(DESKTOP_ROUTES).not.toHaveProperty('teams')+ expect(DESKTOP_ROUTES).not.toHaveProperty('teamDetails')+ })++ it('agent workspace routes are connectors/members/shared-files/activity only', () => {+ expect(AGENT_WORKSPACE_ROUTES).toEqual({+ connectors: 'mcp-servers',+ members: 'members',+ sharedFiles: 'shared-files',+ activity: 'activity',+ })+ expect(AGENT_WORKSPACE_ROUTES).not.toHaveProperty('details')+ expect(AGENT_WORKSPACE_ROUTES).not.toHaveProperty('contexts')+ })})diff --git a/desktop-app/ui/src/constants/navigation.ts b/desktop-app/ui/src/constants/navigation.tsindex 7d216a560..4c45d46b4 100644--- a/desktop-app/ui/src/constants/navigation.ts+++ b/desktop-app/ui/src/constants/navigation.ts@@ -7,10 +7,6 @@ export const DESKTOP_ROUTES = {plugins: 'workflows',agents: 'agents',connectors: 'mcp-servers',- contexts: 'contexts',- contextDetails: 'context-details',- teams: 'teams',- teamDetails: 'team-details',files: 'files',settings: 'settings',} as const@@ -18,9 +14,8 @@ export const DESKTOP_ROUTES = {export type DesktopRoute = (typeof DESKTOP_ROUTES)[keyof typeof DESKTOP_ROUTES]export const AGENT_WORKSPACE_ROUTES = {- details: 'details',connectors: 'mcp-servers',- contexts: 'contexts',+ members: 'members',sharedFiles: 'shared-files',activity: 'activity',} as constdiff --git a/desktop-app/ui/src/contexts/NavigationContext.tsx b/desktop-app/ui/src/contexts/NavigationContext.tsxindex 61b243e6e..69e5cf0b9 100644--- a/desktop-app/ui/src/contexts/NavigationContext.tsx+++ b/desktop-app/ui/src/contexts/NavigationContext.tsx@@ -1,14 +1,10 @@import { createContext, useContext } from 'react'-import type { ContextTab } from '../pages/ContextDetailsPage.types'import type { AgentWorkspaceRoute, NavItem } from '../uiTypes'export interface NavigationContextValue {navItem: NavItemselectedAgent: string | nullselectedAgentRoute: AgentWorkspaceRoute- selectedContext: string | null- selectedContextTab: ContextTab- selectedTeam: string | nullhandleNavSelect: (item: NavItem) => voidhandleOpenAgentWorkspace: (agentName: string, route?: AgentWorkspaceRoute) => voidhandleSelectChatAgent: (@@ -16,10 +12,6 @@ export interface NavigationContextValue {options?: { selectLatest?: boolean; chatId?: string; isRemote?: boolean; title?: string }) => voidhandleBackToAgents: () => void- handleOpenContextDetails: (contextId: string, tab?: ContextTab) => void- handleBackToContexts: () => void- handleOpenTeamDetails: (teamId: string) => void- handleBackToTeams: () => void}const NavigationContext = createContext<NavigationContextValue | null>(null)diff --git a/desktop-app/ui/src/hooks/domain/__tests__/useNavigationController.test.ts b/desktop-app/ui/src/hooks/domain/__tests__/useNavigationController.test.tsindex 4c3c6ce71..4eee6fdfd 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/useNavigationController.test.ts+++ b/desktop-app/ui/src/hooks/domain/__tests__/useNavigationController.test.ts@@ -1,35 +1,40 @@// @vitest-environment jsdomimport { describe, expect, it } from 'vitest'import { act, renderHook } from '@testing-library/react'-import { DESKTOP_ROUTES } from '../../../constants/navigation'+import { AGENT_WORKSPACE_ROUTES, DESKTOP_ROUTES } from '../../../constants/navigation'import { useNavigationController } from '../useNavigationController'-describe('useNavigationController — context detail deep-link tab', () => {- it('defaults selectedContextTab to "agents"', () => {+describe('useNavigationController — agent-centric navigation (Fase 2)', () => {+ it('defaults selectedAgentRoute to Connectors (mcp-servers), not details', () => {const { result } = renderHook(() => useNavigationController())- expect(result.current.selectedContextTab).toBe('agents')+ expect(result.current.selectedAgentRoute).toBe(AGENT_WORKSPACE_ROUTES.connectors)+ expect(result.current.selectedAgentRoute).toBe('mcp-servers')})- it('handleOpenContextDetails(id, tab) lands on that context + tab + detail route', () => {+ it('handleBackToAgents resets the workspace route to Connectors', () => {const { result } = renderHook(() => useNavigationController())- act(() => result.current.handleOpenContextDetails('ctx-1', 'mcp-servers'))- expect(result.current.selectedContext).toBe('ctx-1')- expect(result.current.selectedContextTab).toBe('mcp-servers')- expect(result.current.navItem).toBe(DESKTOP_ROUTES.contextDetails)+ act(() => result.current.setSelectedAgentRoute(AGENT_WORKSPACE_ROUTES.activity))+ act(() => result.current.handleBackToAgents())+ expect(result.current.selectedAgent).toBeNull()+ expect(result.current.selectedAgentRoute).toBe('mcp-servers')})- it('defaults the tab to "agents" when omitted (existing callers unchanged)', () => {+ it('opening chat/agents from the nav resets the route to Connectors', () => {const { result } = renderHook(() => useNavigationController())- act(() => result.current.handleOpenContextDetails('ctx-2', 'mcp-servers'))- act(() => result.current.handleOpenContextDetails('ctx-3'))- expect(result.current.selectedContext).toBe('ctx-3')- expect(result.current.selectedContextTab).toBe('agents')+ act(() => result.current.setSelectedAgentRoute(AGENT_WORKSPACE_ROUTES.members))+ act(() => result.current.handleNavSelect(DESKTOP_ROUTES.agents))+ expect(result.current.selectedAgentRoute).toBe('mcp-servers')})- it('ignores an empty contextId', () => {+ it('no longer exposes the removed context/teams handlers or state', () => {const { result } = renderHook(() => useNavigationController())- act(() => result.current.handleOpenContextDetails('', 'mcp-servers'))- expect(result.current.selectedContext).toBeNull()- expect(result.current.selectedContextTab).toBe('agents')+ const controller = result.current as Record<string, unknown>+ expect(controller.handleOpenContextDetails).toBeUndefined()+ expect(controller.handleBackToContexts).toBeUndefined()+ expect(controller.handleOpenTeamDetails).toBeUndefined()+ expect(controller.handleBackToTeams).toBeUndefined()+ expect(controller.selectedContext).toBeUndefined()+ expect(controller.selectedContextTab).toBeUndefined()+ expect(controller.selectedTeam).toBeUndefined()})})diff --git a/desktop-app/ui/src/hooks/domain/useNavigationController.ts b/desktop-app/ui/src/hooks/domain/useNavigationController.tsindex e79e6744a..143a73f31 100644--- a/desktop-app/ui/src/hooks/domain/useNavigationController.ts+++ b/desktop-app/ui/src/hooks/domain/useNavigationController.ts@@ -1,81 +1,36 @@import { useCallback, useState } from 'react'import { AGENT_WORKSPACE_ROUTES, DESKTOP_ROUTES } from '../../constants/navigation'-import type { ContextTab } from '../../pages/ContextDetailsPage.types'import type { AgentWorkspaceRoute, NavItem } from '../../uiTypes'export function useNavigationController() {const [navItem, setNavItem] = useState<NavItem>(DESKTOP_ROUTES.chat)const [selectedAgent, setSelectedAgent] = useState<string | null>(null)const [selectedAgentRoute, setSelectedAgentRoute] = useState<AgentWorkspaceRoute>(- AGENT_WORKSPACE_ROUTES.details+ AGENT_WORKSPACE_ROUTES.connectors)- const [selectedContext, setSelectedContext] = useState<string | null>(null)- const [selectedContextTab, setSelectedContextTab] = useState<ContextTab>('agents')- const [selectedTeam, setSelectedTeam] = useState<string | null>(null)// Basic nav select — does NOT call cross-domain handlers (no workflow refresh here)const handleNavSelect = useCallback((item: NavItem) => {setNavItem(item)if (item === DESKTOP_ROUTES.agents || item === DESKTOP_ROUTES.chat) {setSelectedAgent(null)- setSelectedAgentRoute(AGENT_WORKSPACE_ROUTES.details)+ setSelectedAgentRoute(AGENT_WORKSPACE_ROUTES.connectors)}- if (item === DESKTOP_ROUTES.contexts) {- setSelectedContext(null)- }- if (item === DESKTOP_ROUTES.teams) {- setSelectedTeam(null)- }- }, [])-- const handleOpenTeamDetails = useCallback((teamId: string) => {- if (!teamId) return- setSelectedTeam(teamId)- setNavItem(DESKTOP_ROUTES.teamDetails)- }, [])-- const handleBackToTeams = useCallback(() => {- setSelectedTeam(null)- setNavItem(DESKTOP_ROUTES.teams)}, [])const handleBackToAgents = useCallback(() => {setSelectedAgent(null)- setSelectedAgentRoute(AGENT_WORKSPACE_ROUTES.details)- }, [])-- // `tab` lets a caller deep-link to a specific tab of the context detail (e.g.- // the Connectors panel routing to a context's Connectors tab). Defaults to- // 'agents' so every existing single-arg caller keeps its current behavior.- const handleOpenContextDetails = useCallback((contextId: string, tab: ContextTab = 'agents') => {- if (!contextId) return- setSelectedContext(contextId)- setSelectedContextTab(tab)- setNavItem(DESKTOP_ROUTES.contextDetails)- }, [])-- const handleBackToContexts = useCallback(() => {- setSelectedContext(null)- setNavItem(DESKTOP_ROUTES.contexts)+ setSelectedAgentRoute(AGENT_WORKSPACE_ROUTES.connectors)}, [])return {navItem,selectedAgent,selectedAgentRoute,- selectedContext,- selectedContextTab,- selectedTeam,setNavItem,setSelectedAgent,setSelectedAgentRoute,- setSelectedContext,- setSelectedTeam,handleNavSelect,- handleOpenTeamDetails,- handleBackToTeams,handleBackToAgents,- handleOpenContextDetails,- handleBackToContexts,}}diff --git a/desktop-app/ui/src/hooks/useAppController.ts b/desktop-app/ui/src/hooks/useAppController.tsindex 98fd1e56f..5e3d0eb3a 100644--- a/desktop-app/ui/src/hooks/useAppController.ts+++ b/desktop-app/ui/src/hooks/useAppController.ts@@ -8,7 +8,7 @@ import type {WorkflowRecipeResource,WorkflowRunsResult,} from '../../../src/types'-import { DESKTOP_ROUTES } from '../constants/navigation'+import { AGENT_WORKSPACE_ROUTES, DESKTOP_ROUTES } from '../constants/navigation'import { pickLatestAgent } from '../lib/agents'import { toPrettyJson } from '../lib/format'import { summarizeWorkflowResource } from '../lib/workflows'@@ -488,35 +488,22 @@ export function useAppController() {route: DESKTOP_ROUTES.agents,refresh: () => agentsData.refreshWithCatalog(getCatalogRefreshPromise()),},- {- route: DESKTOP_ROUTES.contexts,- refresh: () => contextsData.refreshWithCatalog(getCatalogRefreshPromise()),- },{route: DESKTOP_ROUTES.connectors,refresh: () => mcpServersData.refreshWithCatalog(getCatalogRefreshPromise()),},- { route: DESKTOP_ROUTES.teams, refresh: teamsData.refresh },{ route: DESKTOP_ROUTES.plugins, refresh: refreshWorkflowsData },] as const- const activeRoute =- route === DESKTOP_ROUTES.contextDetails- ? DESKTOP_ROUTES.contexts- : route === DESKTOP_ROUTES.teamDetails- ? DESKTOP_ROUTES.teams- : route- const current = refreshers.find(entry => entry.route === activeRoute)+ const current = refreshers.find(entry => entry.route === route)if (current) await current.refresh()},[agentsData.refreshWithCatalog,- contextsData.refreshWithCatalog,getCatalogRefreshPromise,mcpServersData.refreshWithCatalog,refreshWorkflowsData,- teamsData.refresh,])@@ -535,37 +522,6 @@ export function useAppController() {nav.setSelectedAgent,])- useEffect(() => {- if (!auth.isAuthenticated) return- if (contextsData.accessCatalog && nav.selectedContext) {- if (!contextsData.contextIds.includes(nav.selectedContext)) {- nav.setSelectedContext(null)- }- }- }, [- auth.isAuthenticated,- contextsData.accessCatalog,- contextsData.contextIds,- nav.selectedContext,- nav.setSelectedContext,- ])-- useEffect(() => {- if (!auth.isAuthenticated) return- if (teamsData.teamDirectoryHydrated && nav.selectedTeam) {- const available = teamsData.teams.map(team => team.id)- if (!available.includes(nav.selectedTeam)) {- nav.setSelectedTeam(null)- }- }- }, [- auth.isAuthenticated,- nav.selectedTeam,- nav.setSelectedTeam,- teamsData.teamDirectoryHydrated,- teamsData.teams,- ])-const switchTeamForWorkspace = useCallback(async (teamId: string, options: { announce?: boolean } = {}) => {const { announce = true } = options@@ -817,7 +773,7 @@ export function useAppController() {// ─── Cross-domain: handleOpenAgentWorkspace ───const handleOpenAgentWorkspace = useCallback(- (agentName: string, route: AgentWorkspaceRoute = 'details') => {+ (agentName: string, route: AgentWorkspaceRoute = AGENT_WORKSPACE_ROUTES.connectors) => {if (!agentName) returnchat.setPendingChatSelection(agentName, null)chat.clearActiveChat()@@ -859,7 +815,7 @@ export function useAppController() {// D.4: switchToChat is now a single unified path (no isRemote) — the// server is the source of truth and hydrates server-only chats itself.void chat.switchToChat(agentName, targetChatId)- nav.setSelectedAgentRoute('details')+ nav.setSelectedAgentRoute(AGENT_WORKSPACE_ROUTES.connectors)nav.setNavItem(DESKTOP_ROUTES.chat)return}@@ -879,7 +835,7 @@ export function useAppController() {if (!targetChatId) {chat.clearActiveChat()}- nav.setSelectedAgentRoute('details')+ nav.setSelectedAgentRoute(AGENT_WORKSPACE_ROUTES.connectors)nav.setSelectedAgent(agentName)nav.setNavItem(DESKTOP_ROUTES.chat)},@@ -1210,22 +1166,13 @@ export function useAppController() {navItem: nav.navItem,selectedAgent: nav.selectedAgent,selectedAgentRoute: nav.selectedAgentRoute,- selectedContext: nav.selectedContext,- selectedContextTab: nav.selectedContextTab,- selectedTeam: nav.selectedTeam,setSelectedAgent: nav.setSelectedAgent,- setSelectedContext: nav.setSelectedContext,- setSelectedTeam: nav.setSelectedTeam,handleNavSelect,handleOpenAgentWorkspace,handleSelectChatAgent,handleEnsureTeamContext: ensureTeamContext,getCurrentTeamId,handleBackToAgents: nav.handleBackToAgents,- handleOpenContextDetails: nav.handleOpenContextDetails,- handleBackToContexts: nav.handleBackToContexts,- handleOpenTeamDetails: nav.handleOpenTeamDetails,- handleBackToTeams: nav.handleBackToTeams,handleRefreshWorkspaceData: refreshWorkspaceDataForRoute,// Notificationsdiff --git a/desktop-app/ui/src/lib/__tests__/scopedMembers.test.ts b/desktop-app/ui/src/lib/__tests__/scopedMembers.test.tsnew file mode 100644index 000000000..d47fba99f--- /dev/null+++ b/desktop-app/ui/src/lib/__tests__/scopedMembers.test.ts@@ -0,0 +1,122 @@+import { describe, expect, it } from 'vitest'+import type { SessionMe, TeamMember } from '../../../../src/types'+import { deriveScopedMembers } from '../scopedMembers'+import type { ScopedMemberContextDetails, ScopedMemberTeamRow } from '../scopedMembers.types'++// The `me` and team-member shapes come from other layers (session + team+// directory), so the fixtures are typed against their real producer types+// (`SessionMe`, `TeamMember`) — TS enforces the shape the layers actually emit.+// `contextDetails` is NOT another layer's serialized output: it is a trivial+// in-component projection of AccessCatalog fields (userContextIds.includes(ref)+// etc.), so it is constructed by hand, minimally.+const ME: SessionMe = {+ id: 'user-1',+ email: '[email protected]',+ name: 'Demo User',+ picture: null,+ teamId: 'team-1',+ teamName: 'Core Team',+ role: 'member',+}++const ALICE: TeamMember = {+ id: 'member-1',+ email: '[email protected]',+ name: 'Alice',+ role: 'member',+ status: 'active',+}++const teamRow = (members: TeamMember[]): ScopedMemberTeamRow => ({ members })++describe('deriveScopedMembers', () => {+ it('(a) includes self when availableToUser (name label, email secondary)', () => {+ const details: ScopedMemberContextDetails = {+ availableToUser: true,+ availableToTeam: false,+ userId: 'user-1',+ }+ const result = deriveScopedMembers(details, [], ME)+ expect(result).toEqual([+ { id: 'user-1', label: 'Demo User', secondary: '[email protected]', role: 'user' },+ ])+ })++ it('(a2) omits self when availableToUser is false', () => {+ const details: ScopedMemberContextDetails = {+ availableToUser: false,+ availableToTeam: false,+ userId: 'user-1',+ }+ expect(deriveScopedMembers(details, [], ME)).toEqual([])+ })++ it('(b) includes team members when availableToTeam', () => {+ const details: ScopedMemberContextDetails = {+ availableToUser: false,+ availableToTeam: true,+ userId: 'user-1',+ }+ const result = deriveScopedMembers(details, [teamRow([ALICE])], ME)+ expect(result).toEqual([+ { id: 'member-1', label: 'Alice', secondary: '[email protected]', role: 'member' },+ ])+ })++ it('(b2) omits team members when availableToTeam is false', () => {+ const details: ScopedMemberContextDetails = {+ availableToUser: false,+ availableToTeam: false,+ userId: 'user-1',+ }+ expect(deriveScopedMembers(details, [teamRow([ALICE])], ME)).toEqual([])+ })++ it('(c) dedupes by id (self also present as a team member => one row)', () => {+ const selfAsMember: TeamMember = {+ id: 'user-1',+ email: '[email protected]',+ name: 'Demo User',+ role: 'admin',+ status: 'active',+ }+ const details: ScopedMemberContextDetails = {+ availableToUser: true,+ availableToTeam: true,+ userId: 'user-1',+ }+ const result = deriveScopedMembers(details, [teamRow([selfAsMember, ALICE])], ME)+ expect(result.map(row => row.id)).toEqual(['user-1', 'member-1'])+ // First writer wins: the self row (role 'user') survives the dedupe.+ expect(result[0]).toEqual({+ id: 'user-1',+ label: 'Demo User',+ secondary: '[email protected]',+ role: 'user',+ })+ })++ it('(d) contextDetails === null yields [] and does not throw (A3 invariant)', () => {+ expect(() => deriveScopedMembers(null, [teamRow([ALICE])], ME)).not.toThrow()+ expect(deriveScopedMembers(null, [teamRow([ALICE])], ME)).toEqual([])+ expect(deriveScopedMembers(null, [], null)).toEqual([])+ })++ it('falls back to email then userId for the self label when name/email missing', () => {+ const noName: SessionMe = { ...ME, name: null }+ expect(+ deriveScopedMembers(+ { availableToUser: true, availableToTeam: false, userId: 'user-1' },+ [],+ noName+ )+ ).toEqual([{ id: 'user-1', label: '[email protected]', role: 'user' }])++ const noMe = deriveScopedMembers(+ { availableToUser: true, availableToTeam: false, userId: 'user-1' },+ [],+ null+ )+ expect(noMe).toEqual([{ id: 'user-1', label: 'user-1', role: 'user' }])+ })+})diff --git a/desktop-app/ui/src/lib/scopedMembers.ts b/desktop-app/ui/src/lib/scopedMembers.tsnew file mode 100644index 000000000..acda54d9e--- /dev/null+++ b/desktop-app/ui/src/lib/scopedMembers.ts@@ -0,0 +1,56 @@+import type {+ ScopedMember,+ ScopedMemberContextDetails,+ ScopedMemberMe,+ ScopedMemberTeamRow,+} from './scopedMembers.types'++/**+ * Pure projection of the members visible for an agent's mapped context (spec+ * §5.C Members tab). Moved verbatim from `ContextDetailsPage.scopedMembers`:+ *+ * - self is included when `availableToUser` (label falls back email → userId);+ * - every member of the mapped teams is included when `availableToTeam`;+ * - the result is deduplicated by id, first writer wins (so the self row, which+ * is pushed first, survives when the same person is also a team member).+ *+ * A3 invariant: `contextDetails === null` (the agent has no mapped context)+ * yields `[]` and never throws.+ */+export function deriveScopedMembers(+ contextDetails: ScopedMemberContextDetails,+ teamRows: ScopedMemberTeamRow[],+ me: ScopedMemberMe+): ScopedMember[] {+ if (!contextDetails) return []++ const rows: ScopedMember[] = []++ if (contextDetails.availableToUser) {+ rows.push({+ id: contextDetails.userId,+ label: me?.name || me?.email || contextDetails.userId,+ ...(me?.name && me?.email ? { secondary: me.email } : {}),+ role: 'user',+ })+ }++ if (contextDetails.availableToTeam) {+ for (const teamRow of teamRows) {+ for (const member of teamRow.members) {+ rows.push({+ id: member.id,+ label: member.name || member.email,+ ...(member.name ? { secondary: member.email } : {}),+ role: member.role,+ })+ }+ }+ }++ const deduped = new Map<string, ScopedMember>()+ for (const item of rows) {+ if (!deduped.has(item.id)) deduped.set(item.id, item)+ }+ return [...deduped.values()]+}diff --git a/desktop-app/ui/src/lib/scopedMembers.types.ts b/desktop-app/ui/src/lib/scopedMembers.types.tsnew file mode 100644index 000000000..3d981e90c--- /dev/null+++ b/desktop-app/ui/src/lib/scopedMembers.types.ts@@ -0,0 +1,31 @@+import type { TeamMember } from '../../../src/types'++/**+ * The context-detail fields the Members projection needs. A trivial in-component+ * projection of AccessCatalog (`userContextIds.includes(ref)` →+ * `availableToUser`, etc.), so it is built inline by the caller — not another+ * layer's serialized output. `null` when the agent has no mapped context.+ */+export type ScopedMemberContextDetails = {+ availableToUser: boolean+ availableToTeam: boolean+ userId: string+} | null++/** A team whose directory entry maps the context; only its members are read. */+export type ScopedMemberTeamRow = {+ members: TeamMember[]+}++/** The `me` fields the self row needs (a subset of `SessionMe`). */+export type ScopedMemberMe = {+ name?: string | null+ email?: string | null+} | null++export type ScopedMember = {+ id: string+ label: string+ secondary?: string+ role: string+}diff --git a/desktop-app/ui/src/pages/ContextDetailsPage.tsx b/desktop-app/ui/src/pages/ContextDetailsPage.tsxdeleted file mode 100644index b95e40c29..000000000--- a/desktop-app/ui/src/pages/ContextDetailsPage.tsx+++ /dev/null@@ -1,789 +0,0 @@-import { useEffect, useMemo, useState } from 'react'-import { Button, DataTable, EmptyState, Pill, ReferenceTag, TabButton } from '@components/Common'-import { PageBreadcrumb } from '@components/PageBreadcrumb'-import { ResourceBreadcrumbSwitcher } from '@components/ResourceBreadcrumbSwitcher'-import { scopeCaption, statusPresentation } from '@lib/connectorPresentation'-import { deriveConnectorRows } from '@lib/connectorRows'-import { SharedFilesTab } from '../components/SharedFilesTab'-import { useAuthContext } from '../contexts/AuthContext'-import { useNavigationContext } from '../contexts/NavigationContext'-import {- type ConnectorActionInput,- isActionableConnector,- useConnectorsController,-} from '../hooks/domain/useConnectorsController'-import { useContextsDataController } from '../hooks/domain/useContextsDataController'-import { useMcpServersDataController } from '../hooks/domain/useMcpServersDataController'-import { useTeamsDataController } from '../hooks/domain/useTeamsDataController'-import { clickableRowProps } from '../lib/clickableRowProps'-import type { ContextTab } from './ContextDetailsPage.types'--export function ContextDetailsPage() {- const { me } = useAuthContext()- const { accessCatalog: contextsAccessCatalog } = useContextsDataController()- const {- selectedContext,- selectedContextTab,- handleBackToContexts,- handleOpenContextDetails,- handleOpenTeamDetails,- handleOpenAgentWorkspace,- } = useNavigationContext()- const {- agentNames,- agentDisplayByName,- agentContextByName,- mcpServersByAgent,- accessCatalog: mcpAccessCatalog,- selectedContextMcpServers,- selectedContextMcpServerDetails,- selectedContextMcpServerMappingAvailable,- selectedContextMcpServersUnscoped,- globalMcpServers,- mcpServerMappingUnavailableMessage,- } = useMcpServersDataController({ selectedContext })- const { teams, currentTeamId, teamMembers, teamDirectory } = useTeamsDataController()- // Same app-coordinated query as the top-level Connectors panel (shared- // queryKey → reads cache, no second fetch). We overlay its tri-state grant +- // Authorize/Disconnect onto the context's connector rows via the SAME- // controller (D4: single action/confirmation path, not a re-implementation).- const {- agents: connectorAgents,- pendingKey: connectorPendingKey,- authorize: authorizeConnector,- disconnect: disconnectConnector,- } = useConnectorsController()-- // Land on the tab the navigation requested (defaults to 'agents'); re-sync- // when either the context or the requested tab changes so a deep-link to the- // same context but a different tab still switches.- const [activeTab, setActiveTab] = useState<ContextTab>(selectedContextTab ?? 'agents')-- useEffect(() => {- setActiveTab(selectedContextTab ?? 'agents')- }, [selectedContext, selectedContextTab])-- const selectedContextDetails = useMemo(() => {- if (!selectedContext || !contextsAccessCatalog) return null- return {- id: selectedContext,- availableToUser: contextsAccessCatalog.userContextIds.includes(selectedContext),- availableToTeam: contextsAccessCatalog.teamContextIds.includes(selectedContext),- totalContexts: contextsAccessCatalog.contextIds.length,- userId: contextsAccessCatalog.userId,- teamId: contextsAccessCatalog.teamId || 'none',- }- }, [contextsAccessCatalog, selectedContext])-- const selectedContextName = selectedContext || 'Context details'- const contextOptions = useMemo(() => {- const optionsById = new Map<string, string>()- for (const contextId of contextsAccessCatalog?.contextIds || []) {- optionsById.set(contextId, contextId)- }- for (const entry of Object.values(teamDirectory)) {- for (const contextId of entry.contextIds || []) {- optionsById.set(contextId, contextId)- }- }- return [...optionsById.entries()]- .sort(([left], [right]) => left.localeCompare(right))- .map(([id, label]) => ({ id, label }))- }, [contextsAccessCatalog?.contextIds, teamDirectory])- const selectedRow = useMemo(() => {- if (!selectedContextDetails) return null- return {- id: selectedContextDetails.id,- availableToUser: selectedContextDetails.availableToUser,- availableToTeam: selectedContextDetails.availableToTeam,- }- }, [selectedContextDetails])-- const currentTeam = useMemo(- () => teams.find(team => team.id === currentTeamId) ?? null,- [teams, currentTeamId]- )-- const contextTeamRows = useMemo(() => {- if (!selectedContext) return []- const hasAgentContextMap = Object.keys(agentContextByName).length > 0- const scopedAgentNamesForTeam = (names: string[], contextIds: string[]) => {- const uniqueNames = [...new Set(names || [])]- if (!hasAgentContextMap) return uniqueNames- const onlySelectedContext = contextIds.length === 1 && contextIds[0] === selectedContext- return uniqueNames.filter(agentName => {- const mappedContext = String(agentContextByName[agentName] || '').trim()- if (mappedContext) return mappedContext === selectedContext- return onlySelectedContext- })- }- const rowsByTeamId = new Map<- string,- {- agentNames: string[]- members: typeof teamMembers- team: (typeof teams)[number]- }- >()-- for (const team of teams) {- const entry = teamDirectory[team.id]- if (!entry?.contextIds.includes(selectedContext)) continue- rowsByTeamId.set(team.id, {- agentNames: scopedAgentNamesForTeam(entry.agentNames || [], entry.contextIds || []).sort(- (a, b) => a.localeCompare(b)- ),- members: entry.members || [],- team,- })- }-- if (- selectedContextDetails?.availableToTeam &&- currentTeam &&- !rowsByTeamId.has(currentTeam.id)- ) {- rowsByTeamId.set(currentTeam.id, {- agentNames: scopedAgentNamesForTeam(mcpAccessCatalog?.teamAgentNames || [], [- selectedContext,- ]).sort((a, b) => a.localeCompare(b)),- members: teamMembers,- team: currentTeam,- })- }-- return [...rowsByTeamId.values()].sort((left, right) =>- left.team.name.localeCompare(right.team.name)- )- }, [- agentContextByName,- currentTeam,- mcpAccessCatalog?.teamAgentNames,- selectedContext,- selectedContextDetails?.availableToTeam,- teamDirectory,- teamMembers,- teams,- ])-- const scopedAgents = useMemo(() => {- if (!selectedContext) return []- const rowsByAgentName = new Map<- string,- {- connectors: string[]- name: string- teams: Array<{ id: string; name: string }>- }- >()-- const ensureAgent = (name: string) => {- const agentName = name.trim()- if (!agentName) return null- const existing = rowsByAgentName.get(agentName)- if (existing) return existing- const row = {- connectors: [...new Set(mcpServersByAgent[agentName] || [])].sort((a, b) =>- a.localeCompare(b)- ),- name: agentName,- teams: [],- }- rowsByAgentName.set(agentName, row)- return row- }-- for (const name of agentNames) {- if (String(agentContextByName[name] || '').trim() === selectedContext) {- ensureAgent(name)- }- }-- for (const teamRow of contextTeamRows) {- for (const agentName of teamRow.agentNames) {- const row = ensureAgent(agentName)- if (!row || row.teams.some(team => team.id === teamRow.team.id)) continue- row.teams.push({ id: teamRow.team.id, name: teamRow.team.name })- }- }-- return [...rowsByAgentName.values()]- .map(row => ({- ...row,- teams: row.teams.sort((left, right) => left.name.localeCompare(right.name)),- }))- .sort((left, right) => left.name.localeCompare(right.name))- }, [agentContextByName, agentNames, contextTeamRows, mcpServersByAgent, selectedContext])-- const scopedAgentNames = useMemo(() => scopedAgents.map(agent => agent.name), [scopedAgents])-- const scopedMembers = useMemo(() => {- if (!selectedContextDetails) return []- const rows: Array<{ id: string; label: string; secondary?: string; role: string }> = []-- if (selectedContextDetails.availableToUser) {- rows.push({- id: selectedContextDetails.userId,- label: me?.name || me?.email || selectedContextDetails.userId,- secondary: me?.name && me?.email ? me.email : undefined,- role: 'user',- })- }-- if (selectedContextDetails.availableToTeam) {- for (const teamRow of contextTeamRows) {- for (const member of teamRow.members) {- rows.push({- id: member.id,- label: member.name || member.email,- secondary: member.name ? member.email : undefined,- role: member.role,- })- }- }- }-- const deduped = new Map<- string,- { id: string; label: string; secondary?: string; role: string }- >()- for (const item of rows) {- if (!deduped.has(item.id)) deduped.set(item.id, item)- }- return [...deduped.values()]- }, [contextTeamRows, me, selectedContextDetails])-- const hasContextCatalogMcpMap = useMemo(() => {- if (!selectedContext || !mcpAccessCatalog?.contextMcpServers) return false- return Object.prototype.hasOwnProperty.call(mcpAccessCatalog.contextMcpServers, selectedContext)- }, [mcpAccessCatalog, selectedContext])-- const hasDerivedContextMcpMap = useMemo(() => {- if (!selectedContext) return false- for (const agentName of scopedAgentNames) {- if ((mcpServersByAgent[agentName] || []).length > 0) return true- }- return false- }, [mcpServersByAgent, scopedAgentNames, selectedContext])-- const contextMcpServerDetails = useMemo(() => {- const detailsByName = new Map(- selectedContextMcpServerDetails.map(server => [server.name, server])- )- const serverNames = new Set(detailsByName.keys())- for (const agentName of scopedAgentNames) {- for (const serverName of mcpServersByAgent[agentName] || []) {- serverNames.add(serverName)- }- }- for (const server of selectedContextMcpServers) {- serverNames.add(server.name)- }-- const selectedUrlByName = new Map(- selectedContextMcpServers.map(server => [server.name, server.url || ''])- )- const globalUrlByName = new Map(globalMcpServers.map(server => [server.name, server.url || '']))-- return [...serverNames]- .sort((left, right) => left.localeCompare(right))- .map(serverName => {- const existing = detailsByName.get(serverName)- const mappedAgents = new Set(existing?.mappedAgents || [])- for (const agentName of scopedAgentNames) {- if ((mcpServersByAgent[agentName] || []).includes(serverName)) {- mappedAgents.add(agentName)- }- }- const mappedAgentNames = [...mappedAgents].sort((left, right) => left.localeCompare(right))- const url =- existing?.url || selectedUrlByName.get(serverName) || globalUrlByName.get(serverName)- return {- name: serverName,- ...(url ? { url } : {}),- mappedAgentCount: Math.max(existing?.mappedAgentCount || 0, mappedAgentNames.length),- mappedAgents: mappedAgentNames,- mappingSource:- existing?.mappingSource ||- (mappedAgentNames.length ? 'agent-derived' : 'workspace-preview'),- }- })- }, [- globalMcpServers,- mcpServersByAgent,- scopedAgentNames,- selectedContextMcpServerDetails,- selectedContextMcpServers,- ])-- const contextMcpServerMappingAvailable =- selectedContextMcpServerMappingAvailable || contextMcpServerDetails.length > 0-- // Read-model rows for THIS context only, indexed by server name so each table- // row can look up its grant/actions. Empty (no status/actions) when the- // connectors query is not yet cached — graceful degrade, never a fetch.- const connectorRowByName = useMemo(() => {- const rows = deriveConnectorRows(- connectorAgents.filter(agent => agent.contextRef === selectedContext)- )- return new Map(rows.map(row => [row.connector.name, row]))- }, [connectorAgents, selectedContext])-- const contextMcpUnavailableBody = useMemo(() => {- if (!selectedContext) return mcpServerMappingUnavailableMessage- if (selectedContextMcpServersUnscoped) {- return `No context-scoped mapping was found for "${selectedContext}". The workspace preview is unscoped, so it cannot confirm which connectors belong to this context.`- }- const missingSources: string[] = []- if (!hasContextCatalogMcpMap) {- missingSources.push('catalog contextMcpServers entry')- }- if (!hasDerivedContextMcpMap) {- missingSources.push('agent-derived context mapping')- }- if (!missingSources.length) {- return mcpServerMappingUnavailableMessage- }- return `No context-scoped MCP mapping is available for "${selectedContext}". Missing source(s): ${missingSources.join(', ')}.`- }, [- hasContextCatalogMcpMap,- hasDerivedContextMcpMap,- mcpServerMappingUnavailableMessage,- selectedContext,- selectedContextMcpServersUnscoped,- ])-- const contextMcpNoServersBody = useMemo(() => {- if (!selectedContext) return 'No connectors are currently mapped to this context.'- if (selectedContextMcpServersUnscoped) {- return `The workspace MCP preview returned ${globalMcpServers.length} server(s), but none can be safely assigned to "${selectedContext}" from scoped data.`- }- return `No connectors are currently mapped to "${selectedContext}".`- }, [globalMcpServers.length, selectedContext, selectedContextMcpServersUnscoped])-- if (!selectedContext || !selectedRow || !selectedContextDetails) {- return (- <section className="page context-detail-page">- <PageBreadcrumb- ariaLabel="Context breadcrumb"- items={[- { label: 'Contexts', onClick: handleBackToContexts },- { label: selectedContextName, onClick: handleBackToContexts },- ]}- />- <div className="page-header">- <h2>{selectedContextName}</h2>- <p className="muted">Agents, teams, and members mapped to this context.</p>- </div>- <section className="teams-detail-page-card">- <EmptyState- title="Context not found"- body="This context is not available in your workspace scope."- />- </section>- </section>- )- }-- return (- <section className="page context-detail-page">- <PageBreadcrumb- ariaLabel="Context breadcrumb"- items={[- { label: 'Contexts', onClick: handleBackToContexts },- {- label: (- <ResourceBreadcrumbSwitcher- ariaLabel="Switch context"- emptyLabel="No contexts"- options={contextOptions}- selectedId={selectedRow.id}- selectedLabel={selectedRow.id}- onSelect={handleOpenContextDetails}- />- ),- },- ]}- />-- <section className="teams-detail-page-card">- <div className="page-card__header">- <div>- <h3>{selectedRow.id}</h3>- <p className="muted">- Review context details, agents, teams, and members from the available API scope.- </p>- </div>- </div>-- <nav className="page-tabs context-tabs" aria-label="Context sections">- <TabButton- active={activeTab === 'agents'}- className="context-tab"- onClick={() => setActiveTab('agents')}- >- Agents- </TabButton>- <TabButton- active={activeTab === 'mcp-servers'}- className="context-tab"- onClick={() => setActiveTab('mcp-servers')}- >- Connectors- </TabButton>- <TabButton- active={activeTab === 'teams'}- className="context-tab"- onClick={() => setActiveTab('teams')}- >- Teams- </TabButton>- <TabButton- active={activeTab === 'members'}- className="context-tab"- onClick={() => setActiveTab('members')}- >- Members- </TabButton>- <TabButton- active={activeTab === 'shared-files'}- className="context-tab"- onClick={() => setActiveTab('shared-files')}- >- Agent Files- </TabButton>- </nav>-- {activeTab === 'agents' && (- <div className="context-resource-list">- {!scopedAgents.length && (- <EmptyState title="No agents" body="No agents are mapped to this context." />- )}- {!!scopedAgents.length && (- <DataTable className="context-agents-data-table">- <thead>- <tr>- <th className="da-table__col-header" scope="col">- Agent- </th>- <th className="da-table__col-header" scope="col">- Teams- </th>- <th className="da-table__col-header" scope="col">- Connectors- </th>- </tr>- </thead>- <tbody>- {scopedAgents.map(agent => (- <tr- key={agent.name}- className="da-table__row--clickable"- {...clickableRowProps(() => handleOpenAgentWorkspace(agent.name), {- ariaLabel: `Open agent ${agent.name}`,- })}- >- <td className="da-table__cell">- <span className="context-id-cell">- {/* Visible agent name (spec.host). The catalog map is- total only over catalog agents; scopedAgents also- carries cross-team agents added from the team- directory (no catalog display source), so fall back- to the identifier for those — not the Decision #6- `|| name` guard. */}- <strong>{agentDisplayByName[agent.name] ?? agent.name}</strong>- </span>- </td>- <td className="da-table__cell">- {agent.teams.length ? (- <span className="reference-tag-list">- {agent.teams.map(team => (- <ReferenceTag- key={`${agent.name}:${team.id}`}- kind="team"- onClick={event => {- event.stopPropagation()- handleOpenTeamDetails(team.id)- }}- title={team.name}- aria-label={`Open team ${team.name}`}- >- {team.name}- </ReferenceTag>- ))}- </span>- ) : (- <span className="agent-table-muted">-</span>- )}- </td>- <td className="da-table__cell">- {agent.connectors.length ? (- <span className="reference-tag-list">- {agent.connectors.map(serverName => (- <ReferenceTag- key={`${agent.name}:${serverName}`}- kind="connector"- onClick={event => {- event.stopPropagation()- handleOpenAgentWorkspace(agent.name, 'mcp-servers')- }}- title={serverName}- aria-label={`Open ${serverName} connectors for agent ${agent.name}`}- >- {serverName}- </ReferenceTag>- ))}- </span>- ) : (- <span className="agent-table-muted">None</span>- )}- </td>- </tr>- ))}- </tbody>- </DataTable>- )}- </div>- )}-- {activeTab === 'mcp-servers' && (- <div className="context-resource-list">- {selectedContextMcpServersUnscoped && (- <p className="muted">- Preview mode: this list is not yet filtered by the selected context.- </p>- )}- {!contextMcpServerMappingAvailable && (- <EmptyState title="Connector mapping unavailable" body={contextMcpUnavailableBody} />- )}- {contextMcpServerMappingAvailable && !contextMcpServerDetails.length && (- <EmptyState title="No connectors" body={contextMcpNoServersBody} />- )}- {contextMcpServerMappingAvailable && contextMcpServerDetails.length > 0 && (- <DataTable className="context-mcp-servers-data-table">- <thead>- <tr>- <th className="da-table__col-header" scope="col">- Server- </th>- <th className="da-table__col-header da-table__col-header--center" scope="col">- Agents- </th>- <th className="da-table__col-header" scope="col">- Mapped agent names- </th>- <th className="da-table__col-header" scope="col">- Status- </th>- <th className="da-table__col-header da-table__col-header--right" scope="col">- Actions- </th>- </tr>- </thead>- <tbody>- {contextMcpServerDetails.map(server => {- // Overlay the shared read-model onto this mapping row. No- // match (or query not cached) → no status/actions, degrade- // to a muted dash rather than fabricating a grant.- const connectorRow = connectorRowByName.get(server.name)- const connector = connectorRow?.connector- const presentation = connector ? statusPresentation(connector.status) : null- const caption = connector ? scopeCaption(connector) : null- const busy = connectorRow ? connectorPendingKey === connectorRow.key : false- // Same action contract as the top-level panel: mint under- // the row's representative agent for THIS context.- const actionInput: ConnectorActionInput | null = connectorRow- ? {- agentName: connectorRow.representativeAgent,- contextRef: connectorRow.contextRef,- connector: connectorRow.connector,- }- : null- const actionable = Boolean(- connector && isActionableConnector(connector) && actionInput- )- return (- <tr key={server.name}>- <td className="da-table__cell">- <span className="context-mcp-server-name">{server.name}</span>- </td>- <td className="da-table__cell da-table__cell--center">- <span className="context-mcp-count">{server.mappedAgentCount}</span>- </td>- <td className="da-table__cell">- {server.mappedAgents.length > 0 ? (- <span className="reference-tag-list">- {server.mappedAgents.map(agentName => (- <ReferenceTag- key={`${server.name}:${agentName}`}- kind="agent"- onClick={() => handleOpenAgentWorkspace(agentName, 'mcp-servers')}- title={agentName}- aria-label={`Open connectors for agent ${agentName}`}- >- {/* Visible agent name (spec.host). mappedAgents- can include cross-team agents (from scoped- context detail sources) absent from the- catalog map, so fall back to the identifier- for those — not the Decision #6 `|| name`- guard. */}- {agentDisplayByName[agentName] ?? agentName}- </ReferenceTag>- ))}- </span>- ) : (- <span className="context-mcp-agent-list">-</span>- )}- </td>- <td className="da-table__cell">- {presentation ? (- <Pill tone={presentation.tone} size="sm" title={caption ?? undefined}>- {presentation.label}- </Pill>- ) : (- <span className="agent-table-muted">—</span>- )}- </td>- <td className="da-table__cell da-table__cell--right">- {actionable && actionInput ? (- connector?.status === 'authorized' ? (- <Button- color="danger"- disabled={busy}- loading={busy}- onClick={event => {- event.stopPropagation()- disconnectConnector(actionInput).catch(() => undefined)- }}- size="sm"- variant="ghost"- >- Disconnect- </Button>- ) : (- <Button- color="primary"- disabled={busy}- loading={busy}- onClick={event => {- event.stopPropagation()- authorizeConnector(actionInput).catch(() => undefined)- }}- size="sm"- variant="soft"- >- Authorize- </Button>- )- ) : (- <span className="agent-table-muted">—</span>- )}- </td>- </tr>- )- })}- </tbody>- </DataTable>- )}- </div>- )}-- {activeTab === 'teams' && (- <div className="context-resource-list">- {!contextTeamRows.length && (- <EmptyState- title="No team access"- body="No team is mapped to this context in this API scope."- />- )}- {contextTeamRows.length > 0 && (- <DataTable className="context-teams-data-table">- <thead>- <tr>- <th className="da-table__col-header" scope="col">- Team- </th>- <th className="da-table__col-header da-table__col-header--center" scope="col">- Role- </th>- <th className="da-table__col-header da-table__col-header--center" scope="col">- Context Access- </th>- </tr>- </thead>- <tbody>- {contextTeamRows.map(row => (- <tr- key={row.team.id}- className="da-table__row--clickable"- {...clickableRowProps(() => handleOpenTeamDetails(row.team.id), {- ariaLabel: `Open team ${row.team.name}`,- })}- >- <td className="da-table__cell">- <ReferenceTag kind="team" title={row.team.name}>- {row.team.name}- </ReferenceTag>- </td>- <td className="da-table__cell da-table__cell--center">- <span className="context-scope-badge context-scope-team">- {row.team.role}- </span>- </td>- <td className="da-table__cell da-table__cell--center">- <span className="context-access-pill allowed">Allowed</span>- </td>- </tr>- ))}- </tbody>- </DataTable>- )}- </div>- )}-- {activeTab === 'shared-files' && (- <div className="context-resource-list">- <SharedFilesTab contextId={selectedRow.id} />- </div>- )}-- {activeTab === 'members' && (- <div className="context-resource-list">- {!scopedMembers.length && (- <EmptyState- title="No members"- body="No members are mapped in the available API scope for this context."- />- )}- {scopedMembers.length > 0 && (- <DataTable className="context-members-data-table">- <thead>- <tr>- <th className="da-table__col-header" scope="col">- Member- </th>- <th className="da-table__col-header" scope="col">- </th>- </tr>- </thead>- <tbody>- {scopedMembers.map(member => (- <tr key={member.id}>- <td className="da-table__cell">- <span className="context-members-name">{member.label}</span>- </td>- <td className="da-table__cell">- <span className="context-members-email">{member.secondary || '-'}</span>- </td>- </tr>- ))}- </tbody>- </DataTable>- )}- </div>- )}- </section>- </section>- )-}diff --git a/desktop-app/ui/src/pages/ContextDetailsPage.types.ts b/desktop-app/ui/src/pages/ContextDetailsPage.types.tsdeleted file mode 100644index dae64d73f..000000000--- a/desktop-app/ui/src/pages/ContextDetailsPage.types.ts+++ /dev/null@@ -1,39 +0,0 @@-import type { TeamMember, TeamSummary } from '../../../src/types'-import type { ContextMcpServerDetail, ScopedMcpServer } from '../uiTypes'--export type ContextScope = 'shared' | 'user' | 'team' | 'unknown'-export type ContextTab = 'agents' | 'mcp-servers' | 'teams' | 'members' | 'shared-files'--export type ContextDetails = {- id: string- availableToUser: boolean- availableToTeam: boolean- totalContexts: number- userId: string- teamId: string-} | null--export type ContextDetailsPageProps = {- contextIds: string[]- selectedContext: string | null- selectedContextDetails: ContextDetails- userContextIds: string[]- teamContextIds: string[]- agentNames: string[]- userAgentNames: string[]- teamAgentNames: string[]- teams: TeamSummary[]- currentTeamId: string- teamMembers: TeamMember[]- meName?: string | null- meEmail?: string | null- selectedContextMcpServers: ScopedMcpServer[]- selectedContextMcpServerDetails: ContextMcpServerDetail[]- selectedContextMcpServerMappingAvailable: boolean- selectedContextMcpServersUnscoped: boolean- mcpServerMappingUnavailableMessage: string- onBackToContexts: () => void- onOpenContextDetails: (id: string) => void- onOpenTeamDetails: (id: string) => void- onOpenAgentWorkspace: (agentName: string) => void-}diff --git a/desktop-app/ui/src/pages/ContextsPage.tsx b/desktop-app/ui/src/pages/ContextsPage.tsxdeleted file mode 100644index 68ab88fdd..000000000--- a/desktop-app/ui/src/pages/ContextsPage.tsx+++ /dev/null@@ -1,76 +0,0 @@-import { useMemo } from 'react'-import { DataTable, EmptyState } from '@components/Common'-import { useNavigationContext } from '../contexts/NavigationContext'-import { useContextsDataController } from '../hooks/domain/useContextsDataController'-import { clickableRowProps } from '../lib/clickableRowProps'--export function ContextsPage() {- const { contextIds, loading, error } = useContextsDataController()- const { selectedContext, handleOpenContextDetails } = useNavigationContext()-- const contextRows = useMemo(- () => [...contextIds].sort((a, b) => a.localeCompare(b)).map(id => ({ id })),- [contextIds]- )-- return (- <section className="page">- <div className="page-header">- <h2>Contexts</h2>- <p className="muted">- Real access catalog for your available user and team access. Click a context to open- details.- </p>- </div>- <div className="page-layout">- <section className="page-card contexts-board-card">- {loading && !contextRows.length && (- <EmptyState title="Loading" body="Fetching authorized contexts..." />- )}- {error && !contextRows.length && !loading && (- <div className="composer-error" role="alert">- <p className="error-text">{error}</p>- </div>- )}- {!loading && !error && !contextRows.length && (- <EmptyState- title="No contexts"- body="No contexts are currently mapped to this user/team."- />- )}- {Boolean(contextRows.length) && (- <DataTable frameless fullBleed className="contexts-data-table">- <thead>- <tr>- <th className="da-table__col-header" scope="col">- Context- </th>- </tr>- </thead>- <tbody>- {contextRows.map(row => (- <tr- key={row.id}- className={`da-table__row--clickable${- selectedContext === row.id ? ' da-table__row--selected' : ''- }`}- {...clickableRowProps(() => handleOpenContextDetails(row.id), {- ariaLabel: `Open context ${row.id}`,- selected: selectedContext === row.id,- })}- >- <td className="da-table__cell">- <span className="context-id-cell">- <strong>{row.id}</strong>- </span>- </td>- </tr>- ))}- </tbody>- </DataTable>- )}- </section>- </div>- </section>- )-}diff --git a/desktop-app/ui/src/pages/McpServersPage.tsx b/desktop-app/ui/src/pages/McpServersPage.tsxindex bbbd81ccc..26af86f83 100644--- a/desktop-app/ui/src/pages/McpServersPage.tsx+++ b/desktop-app/ui/src/pages/McpServersPage.tsx@@ -16,14 +16,12 @@ function ConnectorRowView({busy,onAuthorize,onDisconnect,- onOpenContext,onOpenAgent,}: {row: ConnectorRowbusy: booleanonAuthorize: (input: ConnectorActionInput) => voidonDisconnect: (input: ConnectorActionInput) => void- onOpenContext: (contextRef: string) => voidonOpenAgent: (agentName: string) => void}) {const { connector, contextRef } = row@@ -37,13 +35,15 @@ function ConnectorRowView({connector,}- // The whole row deep-links to the context's Connectors tab — but ONLY when the- // connector has a context. Contextless rows stay non-interactive (no target).+ // The whole row deep-links to the representative agent's Connectors tab — but+ // ONLY when the connector has a mapped context (contexts are 1:1 with agents,+ // so this is the "has a real mapping" signal). Contextless rows stay+ // non-interactive (no target).const rowProps = contextRef? {className: 'da-table__row--clickable',- ...clickableRowProps(() => onOpenContext(contextRef), {- ariaLabel: `Open connectors for context ${contextRef}`,+ ...clickableRowProps(() => onOpenAgent(row.representativeAgent), {+ ariaLabel: `Open connectors for agent ${row.representativeAgent}`,}),}: {}@@ -142,7 +142,7 @@ function ConnectorRowView({export function McpServersPage() {const { loading, error, agents, pendingKey, authorize, disconnect } = useConnectorsController()- const { handleOpenContextDetails, handleOpenAgentWorkspace } = useNavigationContext()+ const { handleOpenAgentWorkspace } = useNavigationContext()const rows = useMemo(() => deriveConnectorRows(agents), [agents])const hasRows = rows.length > 0@@ -201,9 +201,6 @@ export function McpServersPage() {onDisconnect={input => {disconnect(input).catch(() => undefined)}}- onOpenContext={contextRef =>- handleOpenContextDetails(contextRef, 'mcp-servers')- }onOpenAgent={agentName => handleOpenAgentWorkspace(agentName, 'mcp-servers')}/>))}diff --git a/desktop-app/ui/src/pages/TeamDetailsPage.tsx b/desktop-app/ui/src/pages/TeamDetailsPage.tsxdeleted file mode 100644index e7a8e36dc..000000000--- a/desktop-app/ui/src/pages/TeamDetailsPage.tsx+++ /dev/null@@ -1,290 +0,0 @@-import { useEffect, useMemo, useState } from 'react'-import { DataTable, EmptyState, TabButton } from '@components/Common'-import { PageBreadcrumb } from '@components/PageBreadcrumb'-import { ResourceBreadcrumbSwitcher } from '@components/ResourceBreadcrumbSwitcher'-import { useNavigationContext } from '../contexts/NavigationContext'-import { useTeamsDataController } from '../hooks/domain/useTeamsDataController'-import { clickableRowProps } from '../lib/clickableRowProps'-import type { TeamTab } from './TeamDetailsPage.types'--export function TeamDetailsPage() {- const { teamDirectory, loading, teamDirectoryHydrated, teams } = useTeamsDataController()- const {- selectedTeam,- selectedContext,- selectedAgent,- handleOpenContextDetails,- handleOpenAgentWorkspace,- handleOpenTeamDetails,- handleBackToTeams,- } = useNavigationContext()-- const [activeTab, setActiveTab] = useState<TeamTab>('members')-- useEffect(() => {- setActiveTab('members')- }, [selectedTeam])-- const selectedTeamDetails = useMemo(() => {- if (!selectedTeam) return null- const team = teams.find(entry => entry.id === selectedTeam)- if (!team) return null- return team- }, [selectedTeam, teams])-- const selectedTeamData = selectedTeam ? teamDirectory[selectedTeam] : undefined- const selectedMembers = selectedTeamData?.members || []- const selectedContextIds = selectedTeamData?.contextIds || []- const selectedAgentNames = selectedTeamData?.agentNames || []- const selectedDataPending =- Boolean(selectedTeam) && !selectedTeamData && (loading || !teamDirectoryHydrated)- const selectedTeamName = selectedTeamDetails?.name || selectedTeam || 'Team details'- const teamOptions = useMemo(- () =>- [...teams]- .sort((left, right) => left.name.localeCompare(right.name))- .map(team => ({ id: team.id, label: team.name })),- [teams]- )-- const selectedContextRows = useMemo(- () => [...selectedContextIds].sort((a, b) => a.localeCompare(b)).map(id => ({ id })),- [selectedContextIds]- )-- const selectedAgentRows = useMemo(- () => [...selectedAgentNames].sort((a, b) => a.localeCompare(b)).map(name => ({ name })),- [selectedAgentNames]- )-- if (!selectedTeam || !selectedTeamDetails) {- return (- <section className="page team-detail-page">- <PageBreadcrumb- ariaLabel="Team breadcrumb"- items={[- { label: 'Teams', onClick: handleBackToTeams },- { label: selectedTeamName, onClick: handleBackToTeams },- ]}- />- <section className="teams-detail-page-card">- <EmptyState- title="Team not found"- body="This team is not available in your workspace scope."- />- </section>- </section>- )- }-- return (- <section className="page team-detail-page">- <PageBreadcrumb- ariaLabel="Team breadcrumb"- items={[- { label: 'Teams', onClick: handleBackToTeams },- {- label: (- <ResourceBreadcrumbSwitcher- ariaLabel="Switch team"- emptyLabel="No teams"- options={teamOptions}- selectedId={selectedTeam}- selectedLabel={selectedTeamName}- onSelect={handleOpenTeamDetails}- />- ),- },- ]}- />- <section className="teams-detail-page-card">- <div className="page-card__header">- <div>- <h3 className="team-detail-title-row">- <span>{selectedTeamDetails.name}</span>- </h3>- <p className="muted">Review members, contexts, and mapped agents for this team.</p>- </div>- </div>-- <div className="page-tabs team-tabs">- <TabButton- active={activeTab === 'members'}- className="team-tab"- onClick={() => setActiveTab('members')}- >- Members- </TabButton>- <TabButton- active={activeTab === 'contexts'}- className="team-tab"- onClick={() => setActiveTab('contexts')}- >- Contexts- </TabButton>- <TabButton- active={activeTab === 'agents'}- className="team-tab"- onClick={() => setActiveTab('agents')}- >- Agents- </TabButton>- </div>-- {activeTab === 'members' && (- <div className="team-resource-list">- {selectedDataPending && (- <div className="teams-detail-skeleton-list" aria-hidden="true">- <div className="teams-detail-skeleton-row" />- <div className="teams-detail-skeleton-row" />- <div className="teams-detail-skeleton-row" />- </div>- )}- {!selectedDataPending && (- <>- {!selectedMembers.length && (- <EmptyState- title="No members"- body="No active team members were returned by the API."- />- )}- {selectedMembers.length > 0 && (- <DataTable className="team-members-data-table">- <thead>- <tr>- <th className="da-table__col-header" scope="col">- Name- </th>- <th className="da-table__col-header" scope="col">- </th>- </tr>- </thead>- <tbody>- {selectedMembers.map(member => (- <tr key={member.id}>- <td className="da-table__cell">- <span className="context-members-name">- {member.name || member.email || '-'}- </span>- </td>- <td className="da-table__cell">- <span className="context-members-email">{member.email || '-'}</span>- </td>- </tr>- ))}- </tbody>- </DataTable>- )}- </>- )}- </div>- )}-- {activeTab === 'contexts' && (- <div className="team-resource-list">- {selectedDataPending && (- <div className="teams-detail-skeleton-list" aria-hidden="true">- <div className="teams-detail-skeleton-row" />- <div className="teams-detail-skeleton-row" />- </div>- )}- {!selectedDataPending && (- <>- {!selectedContextRows.length && (- <EmptyState- title="No contexts"- body="No team contexts are currently mapped for this team."- />- )}- {!!selectedContextRows.length && (- <DataTable className="team-contexts-data-table">- <thead>- <tr>- <th className="da-table__col-header" scope="col">- Context- </th>- </tr>- </thead>- <tbody>- {selectedContextRows.map(row => (- <tr- key={row.id}- className={`da-table__row--clickable${- selectedContext === row.id ? ' da-table__row--selected' : ''- }`}- {...clickableRowProps(() => handleOpenContextDetails(row.id), {- ariaLabel: `Open context ${row.id}`,- selected: selectedContext === row.id,- })}- >- <td className="da-table__cell">- <span className="context-id-cell">- <strong>{row.id}</strong>- </span>- </td>- </tr>- ))}- </tbody>- </DataTable>- )}- </>- )}- </div>- )}-- {activeTab === 'agents' && (- <div className="team-resource-list">- {selectedDataPending && (- <div className="teams-detail-skeleton-list" aria-hidden="true">- <div className="teams-detail-skeleton-row" />- <div className="teams-detail-skeleton-row" />- </div>- )}- {!selectedDataPending && (- <>- {!selectedAgentRows.length && (- <EmptyState- title="No agents"- body="No team agents are currently mapped for this team."- />- )}- {!!selectedAgentRows.length && (- <DataTable className="team-agents-data-table">- <thead>- <tr>- <th className="da-table__col-header" scope="col">- Agent- </th>- </tr>- </thead>- <tbody>- {selectedAgentRows.map(row => (- <tr- key={row.name}- className={`da-table__row--clickable${- selectedAgent === row.name ? ' da-table__row--selected' : ''- }`}- {...clickableRowProps(() => handleOpenAgentWorkspace(row.name), {- ariaLabel: `Open agent ${row.name}`,- selected: selectedAgent === row.name,- })}- >- <td className="da-table__cell">- <span className="context-id-cell">- <strong>{row.name}</strong>- </span>- </td>- </tr>- ))}- </tbody>- </DataTable>- )}- </>- )}- </div>- )}- </section>- </section>- )-}diff --git a/desktop-app/ui/src/pages/TeamsPage.tsx b/desktop-app/ui/src/pages/TeamsPage.tsxdeleted file mode 100644index 1bc9b4740..000000000--- a/desktop-app/ui/src/pages/TeamsPage.tsx+++ /dev/null@@ -1,345 +0,0 @@-import { useCallback, useState } from 'react'-import { createPortal } from 'react-dom'-import { Button, DataTable, EmptyState, ReferenceTag } from '@components/Common'-import type { TeamMember } from '../../../src/types'-import { useAuthContext } from '../contexts/AuthContext'-import { useNavigationContext } from '../contexts/NavigationContext'-import { useAgentsDataController } from '../hooks/domain/useAgentsDataController'-import { useTeamsDataController } from '../hooks/domain/useTeamsDataController'-import { clickableRowProps } from '../lib/clickableRowProps'--type TeamFloatingTooltip =- | {- kind: 'member'- top: number- left: number- placement: 'top' | 'bottom'- title: string- email: string- role: string- }- | {- kind: 'agent'- top: number- left: number- placement: 'top' | 'bottom'- title: string- items: string[]- overflowCount: number- }--export function TeamsPage() {- const { busy } = useAuthContext()- const { teams, loading, error, teamDirectory, teamDirectoryHydrated, truncated, refresh } =- useTeamsDataController()- const { selectedTeam, handleOpenContextDetails, handleOpenTeamDetails } = useNavigationContext()- const { agentDisplayByName } = useAgentsDataController()- const [floatingTooltip, setFloatingTooltip] = useState<TeamFloatingTooltip | null>(null)-- const setFloatingTooltipNode = useCallback(- (node: HTMLDivElement | null) => {- if (!node || !floatingTooltip) return- node.style.setProperty('--team-floating-tooltip-top', `${floatingTooltip.top}px`)- node.style.setProperty('--team-floating-tooltip-left', `${floatingTooltip.left}px`)- },- [floatingTooltip]- )-- const memberInitial = (member: TeamMember): string => {- const base = (member.name || member.email || '').trim()- return base ? base.charAt(0).toUpperCase() : '?'- }-- const memberDisplayName = (member: TeamMember): string => {- const name = (member.name || '').trim()- return name || member.email- }-- const hideFloatingTooltip = () => {- setFloatingTooltip(null)- }-- const resolveTooltipPosition = (- anchorElement: HTMLElement,- tooltipWidth: number- ): { left: number; top: number; placement: 'top' | 'bottom' } => {- const rect = anchorElement.getBoundingClientRect()- const viewportPadding = 12- const halfWidth = tooltipWidth / 2- const left = Math.max(- viewportPadding + halfWidth,- Math.min(rect.left + rect.width / 2, window.innerWidth - viewportPadding - halfWidth)- )- const prefersTop = rect.top > 120- return {- left,- top: prefersTop ? rect.top - 8 : rect.bottom + 8,- placement: prefersTop ? 'top' : 'bottom',- }- }-- const showMemberTooltip = (member: TeamMember, anchorElement: HTMLElement) => {- const position = resolveTooltipPosition(anchorElement, 220)- setFloatingTooltip({- kind: 'member',- ...position,- title: memberDisplayName(member),- email: member.email,- role: member.role,- })- }-- const showAgentTooltip = (agentNames: string[], anchorElement: HTMLElement) => {- const visibleItems = agentNames.slice(0, 6)- const overflowCount = Math.max(0, agentNames.length - visibleItems.length)- const position = resolveTooltipPosition(anchorElement, 240)- setFloatingTooltip({- kind: 'agent',- ...position,- title: `Active agents (${agentNames.length})`,- // Visible agent name (spec.host). The catalog map only covers the current- // user's accessible agents; other teams' agents have no display source here,- // so fall back to the identifier for those (not the Decision #6 `|| name`).- items: visibleItems.map(agentName => agentDisplayByName[agentName] ?? agentName),- overflowCount,- })- }-- const renderMemberStack = (members: TeamMember[], teamId: string, limit: number) => {- if (!members.length) return <span className="team-cell-muted">No members</span>- const visible = members.slice(0, limit)- return (- <span className="team-member-avatar-stack" aria-label={`${members.length} members`}>- {visible.map(member => (- <button- key={`${teamId}-${member.id}`}- className="team-member-avatar-chip"- type="button"- aria-label={`${memberDisplayName(member)} (${member.role})`}- aria-describedby="team-member-tooltip-description"- onClick={event => event.stopPropagation()}- onMouseEnter={event => showMemberTooltip(member, event.currentTarget)}- onMouseLeave={hideFloatingTooltip}- onFocus={event => showMemberTooltip(member, event.currentTarget)}- onBlur={hideFloatingTooltip}- >- <span className="team-member-initial-avatar">{memberInitial(member)}</span>- </button>- ))}- {members.length > limit && (- <span className="team-member-overflow">+{members.length - limit}</span>- )}- </span>- )- }-- return (- <section className="page">- <div className="page-header">- <h2>Members & Teams</h2>- <p className="muted">Browse all teams and review their members, contexts, and agents.</p>- </div>-- <div className="page-layout">- <section className="page-card teams-board-card">- {loading && !teams.length && (- <EmptyState title="Loading" body="Fetching teams and members..." />- )}- {error && !teams.length && !loading && (- <div className="composer-error" role="alert">- <p className="error-text">{error}</p>- </div>- )}- {truncated && (- <div className="teams-directory-warning" role="status">- <span>- Initial load returned a partial team directory. Load all teams to include every- workspace team.- </span>- <Button- onClick={() => void refresh()}- disabled={busy || loading}- color="neutral"- size="xs"- variant="ghost"- >- {loading ? 'Loading...' : 'Load all teams'}- </Button>- </div>- )}- {!loading && !error && !teams.length && (- <EmptyState title="No teams" body="No teams were returned for this account." />- )}- {Boolean(teams.length) && (- <>- <DataTable frameless fullBleed className="teams-data-table">- <thead>- <tr>- <th className="da-table__col-header" scope="col">- Team- </th>- <th className="da-table__col-header" scope="col">- Members- </th>- <th className="da-table__col-header da-table__col-header--center" scope="col">- Agents- </th>- <th className="da-table__col-header da-table__col-header--center" scope="col">- Contexts- </th>- </tr>- </thead>- <tbody>- {teams.map(team => {- const rowData = teamDirectory[team.id]- const rowMembers = rowData?.members || []- const rowContexts = rowData?.contextIds || []- const rowAgents = rowData?.agentNames || []- const isSelectedTeam = selectedTeam === team.id- const showRowSkeleton = !rowData && (loading || !teamDirectoryHydrated)- return (- <tr- key={team.id}- className={`da-table__row--clickable${- isSelectedTeam ? ' da-table__row--selected' : ''- }`}- {...clickableRowProps(() => handleOpenTeamDetails(team.id), {- selected: isSelectedTeam,- })}- >- <td className="da-table__cell">- <span className="team-table-name-cell">- <span className="team-list-title-row">- <span className="team-list-name">{team.name}</span>- </span>- <span className="team-list-subtitle">Workspace team</span>- </span>- </td>- <td className="da-table__cell">- <span className="team-table-personnel-cell">- {showRowSkeleton ? (- <span- className="teams-inline-skeleton teams-inline-skeleton-members"- aria-hidden="true"- />- ) : rowData ? (- renderMemberStack(rowMembers, team.id, 4)- ) : (- <span className="team-cell-muted">No members</span>- )}- </span>- </td>- <td className="da-table__cell da-table__cell--center">- <span className="team-table-count-cell">- {showRowSkeleton ? (- <span- className="teams-inline-skeleton teams-inline-skeleton-count"- aria-hidden="true"- />- ) : rowAgents.length > 0 ? (- <button- className="team-agent-count-chip"- type="button"- aria-label={`${rowAgents.length} active agents`}- aria-describedby="team-agent-tooltip-description"- onClick={event => event.stopPropagation()}- onMouseEnter={event =>- showAgentTooltip(rowAgents, event.currentTarget)- }- onMouseLeave={hideFloatingTooltip}- onFocus={event => showAgentTooltip(rowAgents, event.currentTarget)}- onBlur={hideFloatingTooltip}- >- <strong>{rowAgents.length}</strong>- </button>- ) : (- <strong>{rowAgents.length}</strong>- )}- <span className="team-list-subtitle">- {showRowSkeleton ? 'Loading' : rowData ? 'Active' : 'Hidden'}- </span>- </span>- </td>- <td className="da-table__cell da-table__cell--center">- <span className="team-table-context-cell">- {showRowSkeleton ? (- <span- className="teams-inline-skeleton teams-inline-skeleton-context"- aria-hidden="true"- />- ) : (- Boolean(rowContexts.length) && (- <span className="team-row-context-badges">- {rowContexts.slice(0, 2).map(contextId => (- <ReferenceTag- key={contextId}- kind="context"- onClick={event => {- event.stopPropagation()- handleOpenContextDetails(contextId)- }}- title={contextId}- aria-label={`Open context ${contextId}`}- >- {contextId}- </ReferenceTag>- ))}- </span>- )- )}- {!showRowSkeleton && !rowContexts.length && (- <span className="team-cell-muted">No contexts</span>- )}- </span>- </td>- </tr>- )- })}- </tbody>- </DataTable>- </>- )}- </section>- </div>- {floatingTooltip &&- createPortal(- <div- ref={setFloatingTooltipNode}- className={`team-floating-tooltip ${floatingTooltip.placement === 'top' ? 'is-top' : 'is-bottom'}`}- role="tooltip"- >- {floatingTooltip.kind === 'member' ? (- <>- <strong className="team-floating-tooltip-name">{floatingTooltip.title}</strong>- <span className="team-floating-tooltip-meta">{floatingTooltip.email}</span>- <span className="team-floating-tooltip-meta">{floatingTooltip.role}</span>- </>- ) : (- <>- <strong className="team-floating-tooltip-name">{floatingTooltip.title}</strong>- <span className="team-floating-tooltip-list">- {floatingTooltip.items.map(agentName => (- <span key={agentName} className="team-floating-tooltip-item">- {agentName}- </span>- ))}- {floatingTooltip.overflowCount > 0 && (- <span className="team-floating-tooltip-item">- +{floatingTooltip.overflowCount} more- </span>- )}- </span>- </>- )}- </div>,- document.body- )}- <span id="team-member-tooltip-description" className="visually-hidden">- Focus to preview member email and role details.- </span>- <span id="team-agent-tooltip-description" className="visually-hidden">- Focus to preview active agent names for this team.- </span>- </section>- )-}diff --git a/desktop-app/ui/src/pages/__tests__/ContextDetailsPage.test.tsx b/desktop-app/ui/src/pages/__tests__/ContextDetailsPage.test.tsxdeleted file mode 100644index 33e5ff75f..000000000--- a/desktop-app/ui/src/pages/__tests__/ContextDetailsPage.test.tsx+++ /dev/null@@ -1,669 +0,0 @@-// @vitest-environment jsdom-import React from 'react'-import { afterEach, beforeAll, describe, expect, it, vi } from 'vitest'-import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'-import { AppService } from '../../../../src/appService'-import type {- AccessCatalog,- RpcAgentConnectors,- SessionMe,- TeamDirectoryEntry,- TeamMember,- TeamSummary,-} from '../../../../src/types'-import { AuthContext } from '../../contexts/AuthContext'-import type { AuthContextValue } from '../../contexts/AuthContext'-import { NavigationContext } from '../../contexts/NavigationContext'-import type { NavigationContextValue } from '../../contexts/NavigationContext'-import { useConnectorsController } from '../../hooks/domain/useConnectorsController'-import { useContextsDataController } from '../../hooks/domain/useContextsDataController'-import { useMcpServersDataController } from '../../hooks/domain/useMcpServersDataController'-import { useTeamsDataController } from '../../hooks/domain/useTeamsDataController'-import type { ContextMcpServerDetail } from '../../uiTypes'-import { ContextDetailsPage } from '../ContextDetailsPage'--vi.mock('../../hooks/domain/useContextsDataController', () => ({- useContextsDataController: vi.fn(),-}))--vi.mock('../../hooks/domain/useMcpServersDataController', () => ({- useMcpServersDataController: vi.fn(),-}))--vi.mock('../../hooks/domain/useTeamsDataController', () => ({- useTeamsDataController: vi.fn(),-}))--// Stub only the hook; keep the pure helpers (isSharedConnector /-// isActionableConnector, which the page and connectorPresentation import) real.-vi.mock('../../hooks/domain/useConnectorsController', async importOriginal => {- const actual = await importOriginal<typeof import('../../hooks/domain/useConnectorsController')>()- return { ...actual, useConnectorsController: vi.fn() }-})--// AppService (imported only to derive a real AccessCatalog fixture from the-// producer — see deriveAccessCatalog) transitively imports electron at module-// load; stub it so the import resolves under jsdom.-vi.mock('electron', () => ({- app: {- isReady: () => false,- getPath: () => '/tmp/clerum-desktop-test',- getName: () => 'test',- on: () => {},- },- safeStorage: {- isEncryptionAvailable: () => false,- encryptString: () => Buffer.from(''),- decryptString: () => '',- },- shell: { openExternal: () => {} },-}))--const useContextsDataControllerMock = vi.mocked(useContextsDataController)-const useMcpServersDataControllerMock = vi.mocked(useMcpServersDataController)-const useTeamsDataControllerMock = vi.mocked(useTeamsDataController)-const useConnectorsControllerMock = vi.mocked(useConnectorsController)--const ME: SessionMe = {- id: 'user-1',- email: '[email protected]',- name: 'Demo User',- picture: null,- teamId: 'team-1',- teamName: 'Core Team',- role: null,-}--const TEAMS: TeamSummary[] = [{ id: 'team-1', name: 'Core Team', role: 'admin' }]--const TEAM_MEMBERS: TeamMember[] = [- { id: 'member-1', email: '[email protected]', name: 'Alice', role: 'member', status: 'active' },-]--const ACCESS_CATALOG: AccessCatalog = {- userId: 'user-1',- teamId: 'team-1',- contextIds: ['ctx-alpha', 'ctx-beta'],- userContextIds: ['ctx-alpha'],- teamContextIds: ['ctx-alpha'],- agentNames: ['alpha', 'beta', 'gamma', 'delta'],- userAgentNames: ['alpha', 'gamma'],- teamAgentNames: ['beta', 'gamma'],- mcpServersByAgent: {},- agentProviderByName: {},- agentContextByName: {- alpha: 'ctx-alpha',- beta: 'ctx-beta',- gamma: 'ctx-alpha',- delta: 'ctx-gamma',- },-}--type DataOverrides = {- accessCatalog?: AccessCatalog | null- auth?: Partial<AuthContextValue>- contexts?: Partial<ReturnType<typeof useContextsDataController>>- mcpServers?: Partial<ReturnType<typeof useMcpServersDataController>>- teams?: Partial<ReturnType<typeof useTeamsDataController>>- connectors?: Partial<ReturnType<typeof useConnectorsController>>-}--const makeAuthValue = (overrides: Partial<AuthContextValue> = {}): AuthContextValue => ({- booting: false,- busy: false,- statusText: 'Ready.',- statusTone: 'info',- isAuthenticated: true,- me: ME,- email: ME.email,- password: '',- desktopSetupAuthorizationToken: '',- desktopSetupStarted: false,- desktopEnvironmentSetupComplete: false,- runtimeConfigSetupName: '',- runtimeConfigSetupExternalRestApiBaseUrl: '',- runtimeConfigSetupRpcProxyBaseUrl: '',- authTransitioning: false,- runtimeConfigState: null,- desktopReleaseStatus: null,- pendingDesktopEnvironmentSetup: null,- backendSwitchHint: null,- runtimeConfigMissing: false,- showRuntimeConfigSelector: false,- dependencyHealth: null,- hasDependencyOutage: false,- setBooting: vi.fn(),- setEmail: vi.fn(),- setPassword: vi.fn(),- setDesktopSetupAuthorizationToken: vi.fn(),- setDesktopEnvironmentSetupComplete: vi.fn(),- setPendingDesktopEnvironmentSetup: vi.fn(),- setRuntimeConfigSetupName: vi.fn(),- setRuntimeConfigSetupExternalRestApiBaseUrl: vi.fn(),- setRuntimeConfigSetupRpcProxyBaseUrl: vi.fn(),- setStatus: vi.fn(),- loadSession: vi.fn(),- handlePasswordLogin: vi.fn(),- handleSwitchLoginBackend: vi.fn(),- handleStartDesktopSetup: vi.fn(),- handleCompleteDesktopSetup: vi.fn(),- handleSaveRuntimeConfig: vi.fn(),- handleDeleteRuntimeConfig: vi.fn(),- handleSelectRuntimeConfig: vi.fn(),- handleClearRuntimeConfigSelection: vi.fn(),- handleCancelDesktopEnvironmentSetup: vi.fn(),- handleConfirmDesktopEnvironmentSetup: vi.fn(),- handleOpenDesktopRelease: vi.fn(),- handleLogout: vi.fn(),- ...overrides,-})--const makeContextsDataValue = (- accessCatalog: AccessCatalog | null,- overrides: Partial<ReturnType<typeof useContextsDataController>> = {}-): ReturnType<typeof useContextsDataController> => ({- loading: false,- error: null,- accessCatalog,- contextIds: accessCatalog?.contextIds ?? [],- userContextIds: accessCatalog?.userContextIds ?? [],- teamContextIds: accessCatalog?.teamContextIds ?? [],- contextDisplayById: accessCatalog?.contextDisplayById ?? {},- sharedFilesByContext: {},- sharedFileDirectoriesByContext: {},- refresh: vi.fn(),- refreshSharedFiles: vi.fn(),- loadSharedFilesDirectory: vi.fn(),- refreshWithCatalog: vi.fn(),- reset: vi.fn(),- ...overrides,-})--const makeMcpServersDataValue = (- accessCatalog: AccessCatalog | null,- overrides: Partial<ReturnType<typeof useMcpServersDataController>> = {}-): ReturnType<typeof useMcpServersDataController> => ({- loading: false,- error: null,- accessCatalog,- agentNames: accessCatalog?.agentNames ?? [],- agentDisplayByName: accessCatalog?.agentDisplayByName ?? {},- agentContextByName: accessCatalog?.agentContextByName ?? {},- mcpServersByAgent: accessCatalog?.mcpServersByAgent ?? {},- globalMcpServers: [],- mcpServerMappingUnavailableMessage: 'MCP mapping unavailable.',- agentMcpServerCountByAgent: {},- agentMcpServersByAgent: {},- selectedAgentMcpServers: [],- selectedAgentMcpServerMappingAvailable: false,- selectedAgentMcpServersUnscoped: false,- selectedContextMcpServers: [],- selectedContextMcpServerDetails: [],- selectedContextMcpServerMappingAvailable: true,- selectedContextMcpServersUnscoped: false,- globalMcpServersHydrated: true,- globalMcpServersError: null,- refresh: vi.fn(),- refreshWithCatalog: vi.fn(),- reset: vi.fn(),- ...overrides,-})--const makeConnectorsValue = (- overrides: Partial<ReturnType<typeof useConnectorsController>> = {}-): ReturnType<typeof useConnectorsController> => ({- loading: false,- error: null,- agents: [],- pendingKey: null,- refresh: vi.fn(),- reset: vi.fn(),- authorize: vi.fn(async () => undefined),- disconnect: vi.fn(async () => ({ confirmed: true })),- ...overrides,-})--const makeTeamsDataValue = (- overrides: Partial<ReturnType<typeof useTeamsDataController>> = {}-): ReturnType<typeof useTeamsDataController> => ({- loading: false,- error: null,- teams: TEAMS,- teamMembers: TEAM_MEMBERS,- teamDirectory: {},- teamDirectoryHydrated: true,- truncated: false,- currentTeamId: 'team-1',- lastUpdatedAt: Date.now(),- refresh: vi.fn(),- refreshInitialDirectory: vi.fn(),- ensureHydrated: vi.fn(),- reset: vi.fn(),- ...overrides,-})--const makeNavValue = (overrides: Partial<NavigationContextValue> = {}): NavigationContextValue => ({- navItem: 'context-details',- selectedAgent: null,- selectedAgentRoute: 'details',- selectedContext: 'ctx-alpha',- selectedContextTab: 'agents',- selectedTeam: null,- handleNavSelect: vi.fn(),- handleOpenAgentWorkspace: vi.fn(),- handleSelectChatAgent: vi.fn(),- handleBackToAgents: vi.fn(),- handleOpenContextDetails: vi.fn(),- handleBackToContexts: vi.fn(),- handleOpenTeamDetails: vi.fn(),- handleBackToTeams: vi.fn(),- ...overrides,-})--function buildTree(- navOverrides: Partial<NavigationContextValue> = {},- dataOverrides: DataOverrides = {}-) {- const accessCatalog =- 'accessCatalog' in dataOverrides ? dataOverrides.accessCatalog! : ACCESS_CATALOG- useContextsDataControllerMock.mockReturnValue(- makeContextsDataValue(accessCatalog, dataOverrides.contexts)- )- useMcpServersDataControllerMock.mockReturnValue(- makeMcpServersDataValue(accessCatalog, dataOverrides.mcpServers)- )- useTeamsDataControllerMock.mockReturnValue(makeTeamsDataValue(dataOverrides.teams))- useConnectorsControllerMock.mockReturnValue(makeConnectorsValue(dataOverrides.connectors))-- return (- <AuthContext.Provider value={makeAuthValue(dataOverrides.auth)}>- <NavigationContext.Provider value={makeNavValue(navOverrides)}>- <ContextDetailsPage />- </NavigationContext.Provider>- </AuthContext.Provider>- )-}--function renderWithContexts(- navOverrides: Partial<NavigationContextValue> = {},- dataOverrides: DataOverrides = {}-) {- return render(buildTree(navOverrides, dataOverrides))-}--describe('ContextDetailsPage', () => {- afterEach(() => {- cleanup()- vi.clearAllMocks()- })-- it('renders not-found empty state when selectedContext is null', () => {- renderWithContexts({ selectedContext: null })- expect(screen.getByText('Context not found')).toBeTruthy()- })-- it('renders not-found empty state when accessCatalog is null', () => {- renderWithContexts({}, { accessCatalog: null })- expect(screen.getByText('Context not found')).toBeTruthy()- })-- it('renders the selected context name in the page heading', () => {- renderWithContexts()- expect(screen.getByRole('heading', { name: 'ctx-alpha' })).toBeTruthy()- })-- it('calls handleBackToContexts when clicking breadcrumb "Contexts"', () => {- const handleBackToContexts = vi.fn()- renderWithContexts({ handleBackToContexts })-- fireEvent.click(screen.getByRole('button', { name: 'Contexts' }))- expect(handleBackToContexts).toHaveBeenCalledTimes(1)- })-- it('defaults to agents tab on mount', () => {- renderWithContexts()- const agentsTab = screen.getByRole('button', { name: 'Agents' })- expect(agentsTab.className).toContain('active')- expect(screen.getByRole('button', { name: 'Open agent alpha' })).toBeTruthy()- })-- it('shows team content when switching to teams tab', () => {- renderWithContexts()- fireEvent.click(screen.getByRole('button', { name: 'Teams' }))- expect(screen.getByRole('button', { name: 'Open team Core Team' })).toBeTruthy()- })-- it('shows members content when switching to members tab', () => {- renderWithContexts()- fireEvent.click(screen.getByRole('button', { name: 'Members' }))- expect(screen.getByText('Alice')).toBeTruthy()- })-- it('resets active tab to agents when selectedContext changes', async () => {- const { rerender } = render(buildTree())-- fireEvent.click(screen.getByRole('button', { name: 'Teams' }))- expect(screen.getByRole('button', { name: 'Open team Core Team' })).toBeTruthy()-- rerender(- buildTree(- { selectedContext: 'ctx-beta' },- {- accessCatalog: {- ...ACCESS_CATALOG,- userContextIds: ['ctx-alpha', 'ctx-beta'],- teamContextIds: [],- },- }- )- )-- await waitFor(() => {- expect(screen.getByRole('button', { name: 'Agents' }).className).toContain('active')- })- expect(screen.queryByRole('button', { name: 'Open team Core Team' })).toBeNull()- expect(screen.getByRole('button', { name: 'Open agent beta' })).toBeTruthy()- })-- it('renders only agents mapped to the selected context', () => {- renderWithContexts()-- expect(screen.getByRole('button', { name: 'Open agent alpha' })).toBeTruthy()- expect(screen.getByRole('button', { name: 'Open agent gamma' })).toBeTruthy()- expect(screen.queryByRole('button', { name: 'Open agent beta' })).toBeNull()- expect(screen.queryByRole('button', { name: 'Open agent delta' })).toBeNull()- })-})--// Part 3: the context detail's Connectors tab overlays the SHARED read-model +-// Authorize/Disconnect (one controller, one action/confirmation path — D4).-describe('ContextDetailsPage — Connectors tab actions', () => {- const CONTEXT_SERVERS: ContextMcpServerDetail[] = [- { name: 'monday', mappedAgentCount: 1, mappedAgents: ['alpha'], mappingSource: 'context-map' },- { name: 'jira', mappedAgentCount: 1, mappedAgents: ['alpha'], mappingSource: 'context-map' },- {- name: 'filesystem',- mappedAgentCount: 1,- mappedAgents: ['alpha'],- mappingSource: 'context-map',- },- ]-- // Read-model grouped by agent for ctx-alpha; deriveConnectorRows keys it by- // server so the table can overlay status/actions. representativeAgent = alpha.- const CONNECTOR_AGENTS: RpcAgentConnectors[] = [- {- name: 'alpha',- contextRef: 'ctx-alpha',- connectors: [- {- name: 'monday',- provider: 'monday',- authKind: 'oauth-user',- grantScope: 'user',- status: 'requires_setup',- },- {- name: 'jira',- provider: 'jira',- authKind: 'oauth-user',- grantScope: 'user',- status: 'authorized',- },- { name: 'filesystem', authKind: 'static', status: 'no_oauth' },- ],- },- ]-- afterEach(() => {- cleanup()- vi.clearAllMocks()- })-- const openConnectorsTab = () =>- fireEvent.click(screen.getByRole('button', { name: 'Connectors' }))- const connectorRow = (container: HTMLElement, name: string) => {- const rows = Array.from(- container.querySelectorAll<HTMLElement>('.context-mcp-servers-data-table tbody tr')- )- const row = rows.find(- r => r.querySelector('.context-mcp-server-name')?.textContent?.trim() === name- )- if (!row) throw new Error(`connector row ${name} not found`)- return row- }-- it('(a) drops the URL and Source columns, adds Status + Actions', () => {- renderWithContexts(- {},- {- mcpServers: { selectedContextMcpServerDetails: CONTEXT_SERVERS },- connectors: { agents: CONNECTOR_AGENTS },- }- )- openConnectorsTab()-- expect(screen.queryByRole('columnheader', { name: 'URL' })).toBeNull()- expect(screen.queryByRole('columnheader', { name: 'Source' })).toBeNull()- expect(screen.getByRole('columnheader', { name: 'Status' })).toBeTruthy()- expect(screen.getByRole('columnheader', { name: 'Actions' })).toBeTruthy()- })-- it('(b) Authorize for requires_setup, Disconnect for authorized, neither for no_oauth', () => {- const { container } = renderWithContexts(- {},- {- mcpServers: { selectedContextMcpServerDetails: CONTEXT_SERVERS },- connectors: { agents: CONNECTOR_AGENTS },- }- )- openConnectorsTab()-- expect(- within(connectorRow(container, 'monday')).getByRole('button', { name: 'Authorize' })- ).toBeTruthy()- expect(- within(connectorRow(container, 'jira')).getByRole('button', { name: 'Disconnect' })- ).toBeTruthy()- const filesystem = connectorRow(container, 'filesystem')- expect(within(filesystem).queryByRole('button', { name: 'Authorize' })).toBeNull()- expect(within(filesystem).queryByRole('button', { name: 'Disconnect' })).toBeNull()- })-- it('(c) actions invoke the shared controller with the representative agent + context', () => {- const authorize = vi.fn(async () => undefined)- const disconnect = vi.fn(async () => ({ confirmed: true }))- const { container } = renderWithContexts(- {},- {- mcpServers: { selectedContextMcpServerDetails: CONTEXT_SERVERS },- connectors: { agents: CONNECTOR_AGENTS, authorize, disconnect },- }- )- openConnectorsTab()-- fireEvent.click(- within(connectorRow(container, 'monday')).getByRole('button', { name: 'Authorize' })- )- expect(authorize).toHaveBeenCalledWith(- expect.objectContaining({- agentName: 'alpha',- contextRef: 'ctx-alpha',- connector: expect.objectContaining({ name: 'monday' }),- })- )-- fireEvent.click(- within(connectorRow(container, 'jira')).getByRole('button', { name: 'Disconnect' })- )- expect(disconnect).toHaveBeenCalledWith(- expect.objectContaining({- agentName: 'alpha',- contextRef: 'ctx-alpha',- connector: expect.objectContaining({ name: 'jira' }),- })- )- })-- it('(d) the status pill reflects each connector state', () => {- const { container } = renderWithContexts(- {},- {- mcpServers: { selectedContextMcpServerDetails: CONTEXT_SERVERS },- connectors: { agents: CONNECTOR_AGENTS },- }- )- openConnectorsTab()-- const pill = (name: string) =>- connectorRow(container, name).querySelector('.ui-pill')?.textContent?.trim()- expect(pill('monday')).toBe('Requires setup')- expect(pill('jira')).toBe('Authorized')- expect(pill('filesystem')).toBe('No OAuth')- })-- it('degrades gracefully (no status/actions) when the read-model is not cached', () => {- const { container } = renderWithContexts(- {},- {- mcpServers: { selectedContextMcpServerDetails: CONTEXT_SERVERS },- connectors: { agents: [] },- }- )- openConnectorsTab()-- const monday = connectorRow(container, 'monday')- expect(monday.querySelector('.ui-pill')).toBeNull()- expect(within(monday).queryByRole('button', { name: 'Authorize' })).toBeNull()- })-})--// Regression: cross-team agents (H1). scopedAgents / mappedAgents can include-// agents that live only in another team's directory entry — never in the-// current team's catalog — so `agentDisplayByName` (total ONLY over-// catalog.agentNames) has no entry for them. Rendering the map lookup without a-// fallback leaves an empty cell; the fix falls back to the identifier.-describe('ContextDetailsPage — cross-team agent display (H1)', () => {- // T1: derive the catalog from the real producer (AppService.refreshAccessCatalog)- // instead of hand-tabulating it, so agentDisplayByName is genuinely total only- // over the catalog's own agents and genuinely omits the cross-team agent.- let derivedCatalog: AccessCatalog-- const CROSS_TEAM_AGENT = 'crossteam-agent'- const OTHER_TEAM: TeamSummary = { id: 'team-2', name: 'Other Team', role: 'member' }- const OTHER_TEAM_DIRECTORY: Record<string, TeamDirectoryEntry> = {- 'team-2': {- team: OTHER_TEAM,- members: [],- contextIds: ['ctx-alpha'],- agentNames: [CROSS_TEAM_AGENT],- },- }-- async function deriveAccessCatalog(): Promise<AccessCatalog> {- const service = new AppService() as unknown as {- sessionToken: string- me: SessionMe- bindCurrentChatStore: (id: string) => Promise<void>- rpcTokenManager: { getOrIssue: () => unknown; clear: () => void }- authClient: Record<string, unknown>- refreshAccessCatalog: () => Promise<AccessCatalog>- }- service.sessionToken = 'session-token'- service.me = ME- // Catalog construction does not need the chat store; keep it out of the fixture.- service.bindCurrentChatStore = async () => {}- service.rpcTokenManager = { getOrIssue: vi.fn(), clear: vi.fn() }- const currentTeamAgents = {- agentNames: ['alpha', 'gamma'],- agents: [- { name: 'alpha', displayName: 'Alpha Host', contextRef: 'ctx-alpha', mcpServers: [] },- { name: 'gamma', displayName: 'Gamma Host', contextRef: 'ctx-alpha', mcpServers: [] },- ],- }- service.authClient = {- getMe: vi.fn().mockResolvedValue(ME),- getMyContexts: vi.fn().mockResolvedValue({ contextIds: ['ctx-alpha'] }),- getMyAgents: vi.fn().mockResolvedValue(currentTeamAgents),- getTeamContexts: vi.fn().mockResolvedValue({ contextIds: ['ctx-alpha'] }),- getTeamAgents: vi.fn().mockResolvedValue(currentTeamAgents),- }- return service.refreshAccessCatalog()- }-- beforeAll(async () => {- derivedCatalog = await deriveAccessCatalog()- })-- afterEach(() => {- cleanup()- vi.clearAllMocks()- })-- it('producer catalog is total over its own agents and omits the cross-team agent', () => {- // Guards the fixture's realism (T1): if the producer ever started emitting a- // display entry for non-catalog agents, this test would no longer cover H1.- expect(Object.keys(derivedCatalog.agentDisplayByName ?? {}).sort()).toEqual(['alpha', 'gamma'])- expect(derivedCatalog.agentDisplayByName?.[CROSS_TEAM_AGENT]).toBeUndefined()- expect(derivedCatalog.agentNames).not.toContain(CROSS_TEAM_AGENT)- })-- it('shows the identifier for a cross-team agent in the agents tab (no empty cell)', () => {- renderWithContexts(- { selectedContext: 'ctx-alpha' },- {- accessCatalog: derivedCatalog,- teams: {- teams: [{ id: 'team-1', name: 'Core Team', role: 'admin' }, OTHER_TEAM],- currentTeamId: 'team-1',- teamDirectory: OTHER_TEAM_DIRECTORY,- },- }- )-- // Catalog agents still render their spec.host display name.- expect(screen.getByText('Alpha Host')).toBeTruthy()-- // T4: assert the visible cell of the cross-team row, not an intermediate. The- // row exists (aria-label uses the id), but before the fix its display cell is- // empty because agentDisplayByName has no entry for the cross-team agent.- const crossTeamRow = screen.getByRole('button', {- name: `Open agent ${CROSS_TEAM_AGENT}`,- })- expect(within(crossTeamRow).getByText(CROSS_TEAM_AGENT)).toBeTruthy()- })-- it('shows the identifier for a cross-team mapped agent in the connectors tab', () => {- renderWithContexts(- { selectedContext: 'ctx-alpha' },- {- accessCatalog: derivedCatalog,- teams: {- teams: [{ id: 'team-1', name: 'Core Team', role: 'admin' }, OTHER_TEAM],- currentTeamId: 'team-1',- teamDirectory: OTHER_TEAM_DIRECTORY,- },- mcpServers: {- selectedContextMcpServerMappingAvailable: true,- selectedContextMcpServerDetails: [- {- name: 'srv-1',- mappedAgentCount: 1,- mappedAgents: [CROSS_TEAM_AGENT],- mappingSource: 'context-map',- },- ],- },- }- )-- fireEvent.click(screen.getByRole('button', { name: 'Connectors' }))-- // T4: the mapped-agent reference tag renders the identifier (aria-label uses- // the id; the visible label was empty before the fix).- const mappedTag = screen.getByRole('button', {- name: `Open connectors for agent ${CROSS_TEAM_AGENT}`,- })- expect(within(mappedTag).getByText(CROSS_TEAM_AGENT)).toBeTruthy()- })-})diff --git a/desktop-app/ui/src/pages/__tests__/McpServersPage.test.tsx b/desktop-app/ui/src/pages/__tests__/McpServersPage.test.tsxindex 59e49bf49..59fd148e2 100644--- a/desktop-app/ui/src/pages/__tests__/McpServersPage.test.tsx+++ b/desktop-app/ui/src/pages/__tests__/McpServersPage.test.tsx@@ -9,7 +9,6 @@ import { McpServersPage } from '../McpServersPage'// Capture the navigation handlers the page deep-links through. Hoisted so the// vi.mock factory can reference it.const navMock = vi.hoisted(() => ({- handleOpenContextDetails: vi.fn(),handleOpenAgentWorkspace: vi.fn(),}))vi.mock('../../contexts/NavigationContext', () => ({@@ -130,7 +129,7 @@ describe('McpServersPage — da-table layout + navigation', () => {delete (window as { clerum?: unknown }).clerum})- it('(a) clicking a row deep-links to that context Connectors tab', async () => {+ it('(a) clicking a row deep-links to the representative agent Connectors tab', async () => {installClerum(CONNECTORS)const { container } = renderPage(CONNECTORS)await waitFor(() => expect(screen.getByRole('heading', { name: 'Connectors' })).toBeTruthy())@@ -139,7 +138,9 @@ describe('McpServersPage — da-table layout + navigation', () => {expect(contextText(mondayRow)).toBe('ctx-team')fireEvent.click(mondayRow)- expect(navMock.handleOpenContextDetails).toHaveBeenCalledWith('ctx-team', 'mcp-servers')+ // monday is mapped by agent-alpha AND agent-zeta; the representative is the+ // alphabetical first (agent-alpha) — contexts are 1:1 with agents now.+ expect(navMock.handleOpenAgentWorkspace).toHaveBeenCalledWith('agent-alpha', 'mcp-servers')})it('(b) mouse OR keyboard on Authorize/Disconnect fires the action WITHOUT navigating', () => {@@ -155,14 +156,14 @@ describe('McpServersPage — da-table layout + navigation', () => {expect(rpc.disconnectMcpServer).toHaveBeenCalledWith('monday', 'agent-alpha', undefined, {shared: false,})- expect(navMock.handleOpenContextDetails).not.toHaveBeenCalled()+ expect(navMock.handleOpenAgentWorkspace).not.toHaveBeenCalled()// Keyboard regression: Enter/Space on the button must NOT bubble to the// row's clickableRowProps onKeyDown and navigate. (Repro: without the- // button's onKeyDown stopPropagation this calls handleOpenContextDetails.)+ // button's onKeyDown stopPropagation this navigates the row.)fireEvent.keyDown(disconnectBtn, { key: 'Enter' })fireEvent.keyDown(disconnectBtn, { key: ' ' })- expect(navMock.handleOpenContextDetails).not.toHaveBeenCalled()+ expect(navMock.handleOpenAgentWorkspace).not.toHaveBeenCalled()// Authorize on the requires_setup clickup row.const clickupRow = rowByName(rows, 'clickup')@@ -172,7 +173,7 @@ describe('McpServersPage — da-table layout + navigation', () => {confirmShared: false,})fireEvent.keyDown(authorizeBtn, { key: 'Enter' })- expect(navMock.handleOpenContextDetails).not.toHaveBeenCalled()+ expect(navMock.handleOpenAgentWorkspace).not.toHaveBeenCalled()})it('(c) mouse OR keyboard on an agent chip opens the agent WITHOUT navigating the row', () => {@@ -183,14 +184,16 @@ describe('McpServersPage — da-table layout + navigation', () => {// monday is listed by agent-alpha AND agent-zeta.const chip = within(mondayRow).getByRole('button', { name: 'Open agent agent-zeta' })fireEvent.click(chip)+ // Only the chip's agent opens — the row navigation (representative+ // agent-alpha) must NOT also fire, so exactly one call, for agent-zeta.expect(navMock.handleOpenAgentWorkspace).toHaveBeenCalledWith('agent-zeta', 'mcp-servers')- expect(navMock.handleOpenContextDetails).not.toHaveBeenCalled()+ expect(navMock.handleOpenAgentWorkspace).toHaveBeenCalledTimes(1)// Keyboard regression: Enter on the chip must not navigate the row. (jsdom// doesn't synthesize a click from keydown, so the positive open-agent path// is covered by the mouse click above; here we assert the navigation guard.)fireEvent.keyDown(chip, { key: 'Enter' })- expect(navMock.handleOpenContextDetails).not.toHaveBeenCalled()+ expect(navMock.handleOpenAgentWorkspace).toHaveBeenCalledTimes(1)})it('(d) a contextless row is not clickable and never navigates', () => {@@ -202,7 +205,7 @@ describe('McpServersPage — da-table layout + navigation', () => {// No button semantics on the row itself (only the inner action button).expect(lonerRow.getAttribute('role')).toBeNull()fireEvent.click(lonerRow)- expect(navMock.handleOpenContextDetails).not.toHaveBeenCalled()+ expect(navMock.handleOpenAgentWorkspace).not.toHaveBeenCalled()})it('(e) distinguishes the 3 statuses and only authorized/requires_setup are actionable', () => {diff --git a/desktop-app/ui/src/pages/__tests__/TeamsPage.test.tsx b/desktop-app/ui/src/pages/__tests__/TeamsPage.test.tsxdeleted file mode 100644index fdb989721..000000000--- a/desktop-app/ui/src/pages/__tests__/TeamsPage.test.tsx+++ /dev/null@@ -1,181 +0,0 @@-// @vitest-environment jsdom-import React from 'react'-import { afterEach, describe, expect, it, vi } from 'vitest'-import { cleanup, fireEvent, render, screen } from '@testing-library/react'-import type { SessionMe, TeamDirectoryEntry, TeamMember, TeamSummary } from '../../../../src/types'-import { AuthContext } from '../../contexts/AuthContext'-import type { AuthContextValue } from '../../contexts/AuthContext'-import { NavigationContext } from '../../contexts/NavigationContext'-import type { NavigationContextValue } from '../../contexts/NavigationContext'-import { useTeamsDataController } from '../../hooks/domain/useTeamsDataController'-import { TeamsPage } from '../TeamsPage'--vi.mock('../../contexts/WorkspaceActionsContext', () => ({- useWorkspaceActionsContext: () => ({- handleRefreshWorkspaceData: vi.fn(),- }),-}))--vi.mock('../../hooks/domain/useTeamsDataController', () => ({- useTeamsDataController: vi.fn(),-}))--vi.mock('../../hooks/domain/useAgentsDataController', () => ({- useAgentsDataController: () => ({ agentDisplayByName: {} }),-}))--const useTeamsDataControllerMock = vi.mocked(useTeamsDataController)--const ME: SessionMe = {- id: 'user-1',- email: '[email protected]',- name: 'Demo User',- picture: null,- teamId: 'team-1',- teamName: 'Core Team',- role: null,-}--const TEAMS: TeamSummary[] = [{ id: 'team-1', name: 'Core Team', role: 'admin' }]--const TEAM_MEMBERS: TeamMember[] = [- { id: 'member-1', email: '[email protected]', name: 'Alice', role: 'member', status: 'active' },-]--const TEAM_DIRECTORY: Record<string, TeamDirectoryEntry> = {- 'team-1': {- team: TEAMS[0]!,- members: TEAM_MEMBERS,- contextIds: ['ctx-alpha'],- agentNames: ['alpha'],- },-}--const makeAuthValue = (overrides: Partial<AuthContextValue> = {}): AuthContextValue => ({- booting: false,- busy: false,- statusText: 'Ready.',- statusTone: 'info',- isAuthenticated: true,- me: ME,- email: ME.email,- password: '',- desktopSetupAuthorizationToken: '',- desktopSetupStarted: false,- desktopEnvironmentSetupComplete: false,- runtimeConfigSetupName: '',- runtimeConfigSetupExternalRestApiBaseUrl: '',- runtimeConfigSetupRpcProxyBaseUrl: '',- authTransitioning: false,- runtimeConfigState: null,- desktopReleaseStatus: null,- pendingDesktopEnvironmentSetup: null,- backendSwitchHint: null,- runtimeConfigMissing: false,- showRuntimeConfigSelector: false,- dependencyHealth: null,- hasDependencyOutage: false,- setBooting: vi.fn(),- setEmail: vi.fn(),- setPassword: vi.fn(),- setDesktopSetupAuthorizationToken: vi.fn(),- setDesktopEnvironmentSetupComplete: vi.fn(),- setPendingDesktopEnvironmentSetup: vi.fn(),- setRuntimeConfigSetupName: vi.fn(),- setRuntimeConfigSetupExternalRestApiBaseUrl: vi.fn(),- setRuntimeConfigSetupRpcProxyBaseUrl: vi.fn(),- setStatus: vi.fn(),- loadSession: vi.fn(),- handlePasswordLogin: vi.fn(),- handleSwitchLoginBackend: vi.fn(),- handleStartDesktopSetup: vi.fn(),- handleCompleteDesktopSetup: vi.fn(),- handleSaveRuntimeConfig: vi.fn(),- handleDeleteRuntimeConfig: vi.fn(),- handleSelectRuntimeConfig: vi.fn(),- handleClearRuntimeConfigSelection: vi.fn(),- handleCancelDesktopEnvironmentSetup: vi.fn(),- handleConfirmDesktopEnvironmentSetup: vi.fn(),- handleOpenDesktopRelease: vi.fn(),- handleLogout: vi.fn(),- ...overrides,-})--const makeNavigationValue = (- overrides: Partial<NavigationContextValue> = {}-): NavigationContextValue => ({- navItem: 'teams',- selectedAgent: null,- selectedAgentRoute: 'details',- selectedContext: null,- selectedContextTab: 'agents',- selectedTeam: null,- handleNavSelect: vi.fn(),- handleOpenAgentWorkspace: vi.fn(),- handleSelectChatAgent: vi.fn(),- handleBackToAgents: vi.fn(),- handleOpenContextDetails: vi.fn(),- handleBackToContexts: vi.fn(),- handleOpenTeamDetails: vi.fn(),- handleBackToTeams: vi.fn(),- ...overrides,-})--const makeTeamsDataValue = (- overrides: Partial<ReturnType<typeof useTeamsDataController>> = {}-): ReturnType<typeof useTeamsDataController> => ({- loading: false,- error: null,- teams: TEAMS,- teamMembers: TEAM_MEMBERS,- teamDirectory: TEAM_DIRECTORY,- teamDirectoryHydrated: true,- truncated: false,- currentTeamId: 'team-1',- lastUpdatedAt: Date.now(),- refresh: vi.fn(),- refreshInitialDirectory: vi.fn(),- ensureHydrated: vi.fn(),- reset: vi.fn(),- ...overrides,-})--function renderTeamsPage(teamsOverrides: Partial<ReturnType<typeof useTeamsDataController>> = {}) {- const teamsValue = makeTeamsDataValue(teamsOverrides)- useTeamsDataControllerMock.mockReturnValue(teamsValue)-- render(- <AuthContext.Provider value={makeAuthValue()}>- <NavigationContext.Provider value={makeNavigationValue()}>- <TeamsPage />- </NavigationContext.Provider>- </AuthContext.Provider>- )-- return teamsValue-}--describe('TeamsPage', () => {- afterEach(() => {- cleanup()- vi.clearAllMocks()- })-- it('shows capped initial-directory state and lets users load the full directory', () => {- const refresh = vi.fn(() => Promise.resolve())-- renderTeamsPage({ truncated: true, refresh })-- expect(screen.getByText(/partial team directory/i)).toBeTruthy()-- fireEvent.click(screen.getByRole('button', { name: 'Load all teams' }))-- expect(refresh).toHaveBeenCalledTimes(1)- })-- it('does not show the capped-directory warning for complete team data', () => {- renderTeamsPage()-- expect(screen.queryByText(/partial team directory/i)).toBeNull()- })-})