Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
refactor(desktop-app): redesign Connectors panel as agents-style table with context drill-in
Diego Zacariasb1c4037fcce4
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsxindex df521d4b0..c0a34d4d0 100644--- a/desktop-app/ui/src/App.tsx+++ b/desktop-app/ui/src/App.tsx@@ -1507,6 +1507,7 @@ export function App() {selectedAgent: vm.selectedAgent,selectedAgentRoute: vm.selectedAgentRoute,selectedContext: vm.selectedContext,+ selectedContextTab: vm.selectedContextTab,selectedTeam: vm.selectedTeam,handleNavSelect: vm.handleNavSelect,handleOpenAgentWorkspace: vm.handleOpenAgentWorkspace,@@ -1530,6 +1531,7 @@ export function App() {vm.selectedAgent,vm.selectedAgentRoute,vm.selectedContext,+ vm.selectedContextTab,vm.selectedTeam,])diff --git a/desktop-app/ui/src/contexts/NavigationContext.tsx b/desktop-app/ui/src/contexts/NavigationContext.tsxindex 41e5140ee..61b243e6e 100644--- a/desktop-app/ui/src/contexts/NavigationContext.tsx+++ b/desktop-app/ui/src/contexts/NavigationContext.tsx@@ -1,4 +1,5 @@import { createContext, useContext } from 'react'+import type { ContextTab } from '../pages/ContextDetailsPage.types'import type { AgentWorkspaceRoute, NavItem } from '../uiTypes'export interface NavigationContextValue {@@ -6,6 +7,7 @@ export interface NavigationContextValue {selectedAgent: string | nullselectedAgentRoute: AgentWorkspaceRouteselectedContext: string | null+ selectedContextTab: ContextTabselectedTeam: string | nullhandleNavSelect: (item: NavItem) => voidhandleOpenAgentWorkspace: (agentName: string, route?: AgentWorkspaceRoute) => void@@ -14,7 +16,7 @@ export interface NavigationContextValue {options?: { selectLatest?: boolean; chatId?: string; isRemote?: boolean; title?: string }) => voidhandleBackToAgents: () => void- handleOpenContextDetails: (contextId: string) => void+ handleOpenContextDetails: (contextId: string, tab?: ContextTab) => voidhandleBackToContexts: () => voidhandleOpenTeamDetails: (teamId: string) => voidhandleBackToTeams: () => voiddiff --git a/desktop-app/ui/src/hooks/domain/__tests__/useNavigationController.test.ts b/desktop-app/ui/src/hooks/domain/__tests__/useNavigationController.test.tsnew file mode 100644index 000000000..4c3c6ce71--- /dev/null+++ b/desktop-app/ui/src/hooks/domain/__tests__/useNavigationController.test.ts@@ -0,0 +1,35 @@+// @vitest-environment jsdom+import { describe, expect, it } from 'vitest'+import { act, renderHook } from '@testing-library/react'+import { DESKTOP_ROUTES } from '../../../constants/navigation'+import { useNavigationController } from '../useNavigationController'++describe('useNavigationController — context detail deep-link tab', () => {+ it('defaults selectedContextTab to "agents"', () => {+ const { result } = renderHook(() => useNavigationController())+ expect(result.current.selectedContextTab).toBe('agents')+ })++ it('handleOpenContextDetails(id, tab) lands on that context + tab + detail route', () => {+ 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)+ })++ it('defaults the tab to "agents" when omitted (existing callers unchanged)', () => {+ 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')+ })++ it('ignores an empty contextId', () => {+ const { result } = renderHook(() => useNavigationController())+ act(() => result.current.handleOpenContextDetails('', 'mcp-servers'))+ expect(result.current.selectedContext).toBeNull()+ expect(result.current.selectedContextTab).toBe('agents')+ })+})diff --git a/desktop-app/ui/src/hooks/domain/useConnectorsController.ts b/desktop-app/ui/src/hooks/domain/useConnectorsController.tsindex 68241587c..ca8abae20 100644Binary files a/desktop-app/ui/src/hooks/domain/useConnectorsController.ts and b/desktop-app/ui/src/hooks/domain/useConnectorsController.ts differdiff --git a/desktop-app/ui/src/hooks/domain/useNavigationController.ts b/desktop-app/ui/src/hooks/domain/useNavigationController.tsindex a56a74ad6..e79e6744a 100644--- a/desktop-app/ui/src/hooks/domain/useNavigationController.ts+++ b/desktop-app/ui/src/hooks/domain/useNavigationController.ts@@ -1,5 +1,6 @@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() {@@ -9,6 +10,7 @@ export function useNavigationController() {AGENT_WORKSPACE_ROUTES.details)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)@@ -42,9 +44,13 @@ export function useNavigationController() {setSelectedAgentRoute(AGENT_WORKSPACE_ROUTES.details)}, [])- const handleOpenContextDetails = useCallback((contextId: string) => {+ // `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) returnsetSelectedContext(contextId)+ setSelectedContextTab(tab)setNavItem(DESKTOP_ROUTES.contextDetails)}, [])@@ -58,6 +64,7 @@ export function useNavigationController() {selectedAgent,selectedAgentRoute,selectedContext,+ selectedContextTab,selectedTeam,setNavItem,setSelectedAgent,diff --git a/desktop-app/ui/src/hooks/useAppController.ts b/desktop-app/ui/src/hooks/useAppController.tsindex 883516512..98fd1e56f 100644--- a/desktop-app/ui/src/hooks/useAppController.ts+++ b/desktop-app/ui/src/hooks/useAppController.ts@@ -1211,6 +1211,7 @@ export function useAppController() {selectedAgent: nav.selectedAgent,selectedAgentRoute: nav.selectedAgentRoute,selectedContext: nav.selectedContext,+ selectedContextTab: nav.selectedContextTab,selectedTeam: nav.selectedTeam,setSelectedAgent: nav.setSelectedAgent,setSelectedContext: nav.setSelectedContext,diff --git a/desktop-app/ui/src/lib/__tests__/connectorPresentation.test.ts b/desktop-app/ui/src/lib/__tests__/connectorPresentation.test.tsnew file mode 100644index 000000000..293c5e766--- /dev/null+++ b/desktop-app/ui/src/lib/__tests__/connectorPresentation.test.ts@@ -0,0 +1,41 @@+import { describe, expect, it } from 'vitest'+import type { RpcConnector } from '../../../../src/types'+import { scopeCaption, statusPresentation } from '../connectorPresentation'++const connector = (overrides: Partial<RpcConnector>): RpcConnector => ({+ name: 'x',+ status: 'requires_setup',+ ...overrides,+})++describe('statusPresentation', () => {+ it('maps each grant status to a label + pill tone', () => {+ expect(statusPresentation('authorized')).toEqual({ label: 'Authorized', tone: 'success' })+ expect(statusPresentation('requires_setup')).toEqual({+ label: 'Requires setup',+ tone: 'warning',+ })+ expect(statusPresentation('no_oauth')).toEqual({ label: 'No OAuth', tone: 'neutral' })+ })+})++describe('scopeCaption', () => {+ it('returns null for a non-OAuth connector', () => {+ expect(scopeCaption(connector({ status: 'no_oauth' }))).toBeNull()+ })++ it('flags an oauth-context / context-scoped grant as team-shared', () => {+ expect(scopeCaption(connector({ authKind: 'oauth-context' }))).toMatch(/Shared by the team/i)+ expect(scopeCaption(connector({ grantScope: 'context' }))).toMatch(/Shared by the team/i)+ })++ it('flags an oauth-user grant as affecting all your agents', () => {+ expect(scopeCaption(connector({ authKind: 'oauth-user', grantScope: 'user' }))).toMatch(+ /Affects all your agents/i+ )+ })++ it('returns null for a non-OAuth-governed connector with a live status', () => {+ expect(scopeCaption(connector({ authKind: 'static' }))).toBeNull()+ })+})diff --git a/desktop-app/ui/src/lib/__tests__/connectorRows.test.ts b/desktop-app/ui/src/lib/__tests__/connectorRows.test.tsnew file mode 100644index 000000000..b3e16e656--- /dev/null+++ b/desktop-app/ui/src/lib/__tests__/connectorRows.test.ts@@ -0,0 +1,171 @@+import { describe, expect, it } from 'vitest'+import fc from 'fast-check'+import type { RpcAgentConnectors, RpcConnector } from '../../../../src/types'+import { connectorRowKey, deriveConnectorRows } from '../connectorRows'+import { formatMcpServerDisplayName } from '../format'++function connector(overrides: Partial<RpcConnector> & Pick<RpcConnector, 'name'>): RpcConnector {+ return { status: 'requires_setup', ...overrides }+}++function agent(+ name: string,+ contextRef: string | null,+ connectors: RpcConnector[]+): RpcAgentConnectors {+ return { name, contextRef, connectors }+}++describe('deriveConnectorRows', () => {+ it('dedups two agents that share a (server, context) into one row', () => {+ const rows = deriveConnectorRows([+ agent('agent-zeta', 'ctx-team', [connector({ name: 'monday', status: 'authorized' })]),+ agent('agent-alpha', 'ctx-team', [connector({ name: 'monday', status: 'authorized' })]),+ ])+ expect(rows).toHaveLength(1)+ expect(rows[0]?.usedByAgents).toEqual(['agent-alpha', 'agent-zeta'])+ })++ it('keeps the same server in two contexts as two adjacent rows', () => {+ const rows = deriveConnectorRows([+ agent('agent-beta', 'ctx-other', [connector({ name: 'shared-drive', status: 'authorized' })]),+ agent('agent-alpha', 'ctx-team', [+ connector({ name: 'shared-drive', status: 'requires_setup' }),+ ]),+ ])+ expect(rows).toHaveLength(2)+ // Sorted by display name then context: ctx-other before ctx-team.+ expect(rows.map(r => r.contextRef)).toEqual(['ctx-other', 'ctx-team'])+ })++ it('picks the alphabetically-first agent as the representative', () => {+ const rows = deriveConnectorRows([+ agent('agent-zeta', 'ctx-team', [connector({ name: 'monday' })]),+ agent('agent-alpha', 'ctx-team', [connector({ name: 'monday' })]),+ agent('agent-mid', 'ctx-team', [connector({ name: 'monday' })]),+ ])+ expect(rows[0]?.representativeAgent).toBe('agent-alpha')+ })++ it('sorts by display name, then real name, then context', () => {+ const rows = deriveConnectorRows([+ agent('a1', 'ctx-b', [+ connector({ name: 'zebra' }),+ connector({ name: 'mcp-alpha' }), // display name "alpha"+ ]),+ agent('a2', 'ctx-a', [connector({ name: 'alpha-remote' })]), // display name "alpha"+ ])+ // Both "alpha*" share the display name → grouped first, ordered by REAL name+ // ("alpha-remote" < "mcp-alpha"); "zebra" last.+ expect(rows.map(r => [r.connector.name, r.contextRef])).toEqual([+ ['alpha-remote', 'ctx-a'],+ ['mcp-alpha', 'ctx-b'],+ ['zebra', 'ctx-b'],+ ])+ })++ it('defensively prefers the most-connected status if a group diverges', () => {+ const rows = deriveConnectorRows([+ agent('agent-alpha', 'ctx-team', [connector({ name: 'monday', status: 'requires_setup' })]),+ agent('agent-zeta', 'ctx-team', [connector({ name: 'monday', status: 'authorized' })]),+ ])+ expect(rows).toHaveLength(1)+ expect(rows[0]?.connector.status).toBe('authorized')+ })++ it('groups connectors with no context together and exposes the row key', () => {+ const rows = deriveConnectorRows([+ agent('agent-alpha', null, [connector({ name: 'monday' })]),+ agent('agent-zeta', null, [connector({ name: 'monday' })]),+ ])+ expect(rows).toHaveLength(1)+ expect(rows[0]?.contextRef).toBeNull()+ expect(rows[0]?.key).toBe(connectorRowKey(null, 'monday'))+ })+})++/**+ * T2: `deriveConnectorRows` is a pure reconciliation with precedence+ * (`STATUS_RANK`), dedup by `(server, context)`, and a total sort order. Small+ * name/context/agent pools maximise collisions so groups actually merge. The+ * expected status precedence is spelled out HERE (the test is the spec) rather+ * than imported, so a change to the module's ranking is caught, not mirrored.+ */+describe('deriveConnectorRows — property-based invariants (T2)', () => {+ const STATUS_RANK: Record<RpcConnector['status'], number> = {+ authorized: 2,+ requires_setup: 1,+ no_oauth: 0,+ }++ const statusArb = fc.constantFrom<RpcConnector['status']>(+ 'authorized',+ 'requires_setup',+ 'no_oauth'+ )+ // Include a display-name collision ('monday' vs 'mcp-monday') and an empty+ // string to probe the null-vs-'' context sentinel.+ const nameArb = fc.constantFrom('monday', 'mcp-monday', 'clickup', 'shared-drive')+ const contextArb = fc.oneof(fc.constant(null), fc.constantFrom('ctx-a', 'ctx-b', ''))+ const agentNameArb = fc.constantFrom('agent-a', 'agent-b', 'agent-c', 'agent-d')++ const agentArb: fc.Arbitrary<RpcAgentConnectors> = fc.record({+ name: agentNameArb,+ contextRef: contextArb,+ connectors: fc.array(fc.record({ name: nameArb, status: statusArb }), { maxLength: 5 }),+ })+ const agentsArb = fc.array(agentArb, { maxLength: 6 })++ // Mirrors the module's documented sort contract (display, real name, context).+ const sortRank = (row: { connector: RpcConnector; contextRef: string | null }) => [+ formatMcpServerDisplayName(row.connector.name),+ row.connector.name,+ row.contextRef ?? '',+ ]+ const lexCompare = (a: string[], b: string[]) => {+ for (let i = 0; i < a.length; i++) {+ const c = (a[i] ?? '').localeCompare(b[i] ?? '')+ if (c !== 0) return c+ }+ return 0+ }++ it('holds the 4 invariants for arbitrary payloads', () => {+ fc.assert(+ fc.property(agentsArb, agents => {+ const rows = deriveConnectorRows(agents)++ // (1) Total order: output non-decreasing under the sort contract.+ for (let i = 1; i < rows.length; i++) {+ expect(lexCompare(sortRank(rows[i - 1]!), sortRank(rows[i]!))).toBeLessThanOrEqual(0)+ }++ // (2) No duplicate row keys.+ expect(new Set(rows.map(r => r.key)).size).toBe(rows.length)++ // (3) No agent that references a (server, context) group disappears from+ // that row's USED BY.+ for (const agent of agents) {+ for (const c of agent.connectors) {+ const row = rows.find(r => r.key === connectorRowKey(agent.contextRef, c.name))+ expect(row).toBeDefined()+ expect(row!.usedByAgents).toContain(agent.name)+ }+ }++ // (4) Row status = the max STATUS_RANK among the group's agents.+ for (const row of rows) {+ let maxRank = -1+ for (const agent of agents) {+ for (const c of agent.connectors) {+ if (connectorRowKey(agent.contextRef, c.name) === row.key) {+ maxRank = Math.max(maxRank, STATUS_RANK[c.status])+ }+ }+ }+ expect(STATUS_RANK[row.connector.status]).toBe(maxRank)+ }+ })+ )+ })+})diff --git a/desktop-app/ui/src/lib/connectorPresentation.ts b/desktop-app/ui/src/lib/connectorPresentation.tsnew file mode 100644index 000000000..14dbf55cc--- /dev/null+++ b/desktop-app/ui/src/lib/connectorPresentation.ts@@ -0,0 +1,44 @@+import type { RpcConnector } from '../../../src/types'+import { isSharedConnector } from '../hooks/domain/useConnectorsController'++/**+ * Shared presentation helpers for a connector's tri-state grant, used by BOTH+ * the top-level Connectors panel (`McpServersPage`) and the context detail's+ * Connectors tab (`ContextDetailsPage`). Single source of truth (D4) — never+ * re-derive the label/tone/caption in a second place.+ */++export type StatusPresentation = {+ label: string+ tone: 'success' | 'warning' | 'neutral'+}++export function statusPresentation(status: RpcConnector['status']): StatusPresentation {+ switch (status) {+ case 'authorized':+ return { label: 'Authorized', tone: 'success' }+ case 'requires_setup':+ return { label: 'Requires setup', tone: 'warning' }+ default:+ return { label: 'No OAuth', tone: 'neutral' }+ }+}++/**+ * The per-connector scope caption (spec §1.3 / D-1). A `oauth-user` grant is+ * global to `(server, userId)`, so acting under one agent flips the SAME server+ * across every agent that lists it; a `oauth-context` grant is shared by the+ * whole Context. Surfaced as a tooltip (title) on the status pill so the user+ * understands the blast radius before the derived state changes several rows at+ * once.+ */+export function scopeCaption(connector: RpcConnector): string | null {+ if (connector.status === 'no_oauth') return null+ if (isSharedConnector(connector)) {+ return 'Shared by the team — affects everyone in this context.'+ }+ if (connector.authKind === 'oauth-user') {+ return 'Affects all your agents that use this connector.'+ }+ return null+}diff --git a/desktop-app/ui/src/lib/connectorRows.ts b/desktop-app/ui/src/lib/connectorRows.tsnew file mode 100644index 000000000..6519a211c--- /dev/null+++ b/desktop-app/ui/src/lib/connectorRows.ts@@ -0,0 +1,119 @@+import type { RpcAgentConnectors, RpcConnector } from '../../../src/types'+import { formatMcpServerDisplayName } from './format'++/**+ * A single deduplicated row of the Connectors table.+ *+ * The payload from rpc-proxy is grouped BY AGENT, but a grant is never+ * per-agent: `oauth-context` grants are keyed by `(server, context)` and+ * `oauth-user` grants by `(server, userId)`. So the correct dedup key for the+ * view is `(server, context)` — two agents that share a Context list the SAME+ * connector once, not twice.+ */+export type ConnectorRow = {+ /** Stable per-row key `(context, server)` — also the `pendingKey` anchor. */+ key: string+ /**+ * The representative connector policy for the group. `status`/`provider`/+ * `authKind`/`grantScope` are invariant across a `(server, context)` group,+ * so any member describes the row; see the defensive status merge below.+ */+ connector: RpcConnector+ contextRef: string | null+ /**+ * The agent used to mint the RPC token for authorize/disconnect. The row is+ * no longer per-agent, but the action IPC still needs a hostRef, so we pick+ * the first agent alphabetically as a deterministic representative. (This+ * replaces spec decision D-1: the view is per `(server, context)`, and the+ * agent is only a token-minter, not part of the grant identity.)+ */+ representativeAgent: string+ /** All agents in this `(server, context)` group, sorted, for the AGENTS cell. */+ usedByAgents: string[]+}++/**+ * The single canonical key for a `(context, server)` pair. Used for BOTH the+ * grouping in `deriveConnectorRows` and the `pendingKey` busy-state anchor, so+ * a row, its group, and its busy state can never disagree.+ *+ * Anchored to the VISIBLE `(context, server)`, not to the representative agent,+ * so the busy spinner tracks the row the user clicked even though the action+ * mints its token under one agent. Two collision guards:+ * - a leading `\x01` (null) / `\x02` (present) tag so "no context" can never be+ * confused with a context literally named `''`;+ * - a non-printable `\x00` delimiter so `('a', 'b c')` and `('a b', 'c')` map+ * to distinct keys.+ */+export function connectorRowKey(contextRef: string | null, connectorName: string): string {+ const context = contextRef === null ? '\x01' : `\x02${contextRef}`+ return `${context}\x00${connectorName}`+}++// "More connected" ranking for the defensive merge below. A grant is+// per-context/per-user (not per-agent), so every agent in a `(server, context)`+// group should report the same status; if they ever diverge, prefer the most+// connected so an existing grant is never hidden behind a stale row.+const STATUS_RANK: Record<RpcConnector['status'], number> = {+ authorized: 2,+ requires_setup: 1,+ no_oauth: 0,+}++/**+ * Fold the per-agent payload into a flat, deduplicated, sorted list of+ * `(server, context)` rows. Pure and total: safe to call in a `useMemo`.+ */+export function deriveConnectorRows(agents: RpcAgentConnectors[]): ConnectorRow[] {+ const groups = new Map<+ string,+ { connector: RpcConnector; contextRef: string | null; agents: Set<string> }+ >()++ for (const agent of agents) {+ for (const connector of agent.connectors) {+ const key = connectorRowKey(agent.contextRef, connector.name)+ const existing = groups.get(key)+ if (!existing) {+ groups.set(key, {+ connector,+ contextRef: agent.contextRef,+ agents: new Set([agent.name]),+ })+ continue+ }+ existing.agents.add(agent.name)+ // Defensive only: keep the most-connected policy if statuses diverge+ // within a group (they should not — the grant is per-context/per-user).+ if (STATUS_RANK[connector.status] > STATUS_RANK[existing.connector.status]) {+ existing.connector = connector+ }+ }+ }++ const rows: ConnectorRow[] = Array.from(groups.values()).map(group => {+ const usedByAgents = Array.from(group.agents).sort((a, b) => a.localeCompare(b))+ return {+ key: connectorRowKey(group.contextRef, group.connector.name),+ connector: group.connector,+ contextRef: group.contextRef,+ representativeAgent: usedByAgents[0] ?? '',+ usedByAgents,+ }+ })++ // Stable total order: displayed name, then real name, then context. Purely+ // presentational — groups the same connector's contexts contiguously and+ // keeps the output deterministic for a given payload.+ rows.sort((a, b) => {+ const byDisplay = formatMcpServerDisplayName(a.connector.name).localeCompare(+ formatMcpServerDisplayName(b.connector.name)+ )+ if (byDisplay !== 0) return byDisplay+ const byName = a.connector.name.localeCompare(b.connector.name)+ if (byName !== 0) return byName+ return (a.contextRef ?? '').localeCompare(b.contextRef ?? '')+ })++ return rows+}diff --git a/desktop-app/ui/src/pages/ContextDetailsPage.tsx b/desktop-app/ui/src/pages/ContextDetailsPage.tsxindex 74a5fe39d..b95e40c29 100644--- a/desktop-app/ui/src/pages/ContextDetailsPage.tsx+++ b/desktop-app/ui/src/pages/ContextDetailsPage.tsx@@ -1,10 +1,17 @@import { useEffect, useMemo, useState } from 'react'-import { DataTable, EmptyState, ReferenceTag, TabButton } from '@components/Common'+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'@@ -16,6 +23,7 @@ export function ContextDetailsPage() {const { accessCatalog: contextsAccessCatalog } = useContextsDataController()const {selectedContext,+ selectedContextTab,handleBackToContexts,handleOpenContextDetails,handleOpenTeamDetails,@@ -35,12 +43,25 @@ export function ContextDetailsPage() {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()- const [activeTab, setActiveTab] = useState<ContextTab>('agents')+ // 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('agents')- }, [selectedContext])+ setActiveTab(selectedContextTab ?? 'agents')+ }, [selectedContext, selectedContextTab])const selectedContextDetails = useMemo(() => {if (!selectedContext || !contextsAccessCatalog) return null@@ -232,12 +253,6 @@ export function ContextDetailsPage() {return [...deduped.values()]}, [contextTeamRows, me, selectedContextDetails])- const mappingSourceLabel = (source: string): string => {- if (source === 'context-map') return 'Context map'- if (source === 'agent-derived') return 'Agent derived'- return 'Workspace preview'- }-const hasContextCatalogMcpMap = useMemo(() => {if (!selectedContext || !mcpAccessCatalog?.contextMcpServers) return falsereturn Object.prototype.hasOwnProperty.call(mcpAccessCatalog.contextMcpServers, selectedContext)@@ -304,6 +319,16 @@ export function ContextDetailsPage() {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 mcpServerMappingUnavailableMessageif (selectedContextMcpServersUnscoped) {@@ -541,9 +566,6 @@ export function ContextDetailsPage() {<th className="da-table__col-header" scope="col">Server</th>- <th className="da-table__col-header" scope="col">- URL- </th><th className="da-table__col-header da-table__col-header--center" scope="col">Agents</th>@@ -551,60 +573,115 @@ export function ContextDetailsPage() {Mapped agent names</th><th className="da-table__col-header" scope="col">- Source+ Status+ </th>+ <th className="da-table__col-header da-table__col-header--right" scope="col">+ Actions</th></tr></thead><tbody>- {contextMcpServerDetails.map(server => (- <tr key={server.name}>- <td className="da-table__cell">- <span className="context-mcp-server-name">{server.name}</span>- </td>- <td className="da-table__cell">- <span className="context-mcp-url">- {server.url ? (- <code>{server.url}</code>+ {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="muted">-</span>+ <span className="context-mcp-agent-list">-</span>)}- </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}`}+ </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">- {/* 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">- <span className="context-mcp-source">- {mappingSourceLabel(server.mappingSource)}- </span>- </td>- </tr>- ))}+ 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>)}diff --git a/desktop-app/ui/src/pages/McpServersPage.tsx b/desktop-app/ui/src/pages/McpServersPage.tsxindex b9fe45ea6..bbbd81ccc 100644--- a/desktop-app/ui/src/pages/McpServersPage.tsx+++ b/desktop-app/ui/src/pages/McpServersPage.tsx@@ -1,169 +1,216 @@-import { Button, EmptyState, Pill, StatusBanner } from '@components/Common'+import { useMemo } from 'react'+import { Button, DataTable, EmptyState, Pill, ReferenceTag, StatusBanner } from '@components/Common'+import { scopeCaption, statusPresentation } from '@lib/connectorPresentation'+import { type ConnectorRow, deriveConnectorRows } from '@lib/connectorRows'import { formatMcpServerDisplayName } from '@lib/format'-import type { RpcConnector } from '../../../src/types'+import { useNavigationContext } from '../contexts/NavigationContext'import {- connectorActionKey,+ type ConnectorActionInput,isActionableConnector,- isSharedConnector,useConnectorsController,} from '../hooks/domain/useConnectorsController'+import { clickableRowProps } from '../lib/clickableRowProps'-const CONNECTORS_GRID_COLS =- 'minmax(10rem, 1.4fr) minmax(8rem, 0.6fr) minmax(12rem, 1.4fr) minmax(7rem, auto)'+function ConnectorRowView({+ row,+ busy,+ onAuthorize,+ onDisconnect,+ onOpenContext,+ onOpenAgent,+}: {+ row: ConnectorRow+ busy: boolean+ onAuthorize: (input: ConnectorActionInput) => void+ onDisconnect: (input: ConnectorActionInput) => void+ onOpenContext: (contextRef: string) => void+ onOpenAgent: (agentName: string) => void+}) {+ const { connector, contextRef } = row+ const presentation = statusPresentation(connector.status)+ const caption = scopeCaption(connector)+ // The action IPC needs a hostRef to mint the token; the row is per+ // (server, context), so we act under the deterministic representative agent.+ const actionInput: ConnectorActionInput = {+ agentName: row.representativeAgent,+ contextRef,+ connector,+ }-type StatusPresentation = {- label: string- tone: 'success' | 'warning' | 'neutral'-}+ // 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).+ const rowProps = contextRef+ ? {+ className: 'da-table__row--clickable',+ ...clickableRowProps(() => onOpenContext(contextRef), {+ ariaLabel: `Open connectors for context ${contextRef}`,+ }),+ }+ : {}-function statusPresentation(status: RpcConnector['status']): StatusPresentation {- switch (status) {- case 'authorized':- return { label: 'Authorized', tone: 'success' }- case 'requires_setup':- return { label: 'Requires setup', tone: 'warning' }- default:- return { label: 'No OAuth', tone: 'neutral' }- }-}+ return (+ <tr {...rowProps}>+ <td className="da-table__cell">+ <span className="context-id-cell">+ <strong>{formatMcpServerDisplayName(connector.name)}</strong>+ {connector.provider ? <span className="muted"> · {connector.provider}</span> : null}+ </span>+ </td>-/**- * The per-connector scope caption (spec §1.3 / D-1). A `oauth-user` grant is- * global to `(server, userId)`, so acting under one agent flips the SAME server- * across every agent that lists it; a `oauth-context` grant is shared by the- * whole Context. Surfaced verbatim so the user understands the blast radius- * before the derived state changes several rows at once.- */-function scopeCaption(connector: RpcConnector): string | null {- if (connector.status === 'no_oauth') return null- if (isSharedConnector(connector)) {- return 'Shared by the team — affects everyone in this context.'- }- if (connector.authKind === 'oauth-user') {- return 'Affects all your agents that use this connector.'- }- return null+ <td className="da-table__cell">+ {contextRef ? (+ <ReferenceTag kind="context" title={`Context: ${contextRef}`}>+ {contextRef}+ </ReferenceTag>+ ) : (+ <span className="agent-table-muted">—</span>+ )}+ </td>++ <td className="da-table__cell">+ {row.usedByAgents.length ? (+ <span className="reference-tag-list">+ {row.usedByAgents.map(agentName => (+ <ReferenceTag+ key={agentName}+ kind="agent"+ onClick={event => {+ event.stopPropagation()+ onOpenAgent(agentName)+ }}+ // The row's clickableRowProps installs an Enter/Space onKeyDown+ // on the <tr>; stop keyboard activation from bubbling so a chip+ // press opens the agent instead of navigating the row.+ onKeyDown={event => event.stopPropagation()}+ title={agentName}+ aria-label={`Open agent ${agentName}`}+ >+ {agentName}+ </ReferenceTag>+ ))}+ </span>+ ) : (+ <span className="agent-table-muted">None</span>+ )}+ </td>++ <td className="da-table__cell">+ <Pill tone={presentation.tone} size="sm" title={caption ?? undefined}>+ {presentation.label}+ </Pill>+ </td>++ <td className="da-table__cell da-table__cell--right">+ {!isActionableConnector(connector) ? null : connector.status === 'authorized' ? (+ <Button+ color="danger"+ disabled={busy}+ loading={busy}+ onClick={event => {+ // Keep the click on the button — don't trigger the row navigation.+ event.stopPropagation()+ onDisconnect(actionInput)+ }}+ // Same guard for keyboard: Enter/Space on the button must not bubble+ // to the row's onKeyDown and navigate as well.+ onKeyDown={event => event.stopPropagation()}+ size="sm"+ variant="ghost"+ >+ Disconnect+ </Button>+ ) : (+ <Button+ color="primary"+ disabled={busy}+ loading={busy}+ onClick={event => {+ event.stopPropagation()+ onAuthorize(actionInput)+ }}+ onKeyDown={event => event.stopPropagation()}+ size="sm"+ variant="soft"+ >+ Authorize+ </Button>+ )}+ </td>+ </tr>+ )}export function McpServersPage() {const { loading, error, agents, pendingKey, authorize, disconnect } = useConnectorsController()+ const { handleOpenContextDetails, handleOpenAgentWorkspace } = useNavigationContext()- const hasAgents = agents.length > 0+ const rows = useMemo(() => deriveConnectorRows(agents), [agents])+ const hasRows = rows.length > 0return (<section className="page"><div className="page-header"><h2>Connectors</h2><p className="muted">- Review the connectors available to each agent, authorize the ones that require setup, and- disconnect the ones you no longer want to grant.+ Review the connectors available across your agents, authorize the ones that require setup,+ and disconnect the ones you no longer want.</p></div><div className="page-layout">{error ? <StatusBanner tone="error">{error}</StatusBanner> : null}- {loading && !hasAgents ? (- <section className="page-card">+ <section className="page-card mcp-servers-board-card" aria-label="Connectors">+ {loading && !hasRows ? (<EmptyState title="Loading" body="Fetching your connectors…" />- </section>- ) : !hasAgents ? (- <section className="page-card">+ ) : !hasRows ? (<EmptyStatetitle="No connectors"body="No agents with connectors are available for your account yet."/>- </section>- ) : (- agents.map(agent => {- const contextRef = agent.contextRef- return (- <section- className="page-card"- key={agent.name}- aria-labelledby={`agent-${agent.name}`}- >- <div className="page-card__header">- <div>- <h3 id={`agent-${agent.name}`}>{agent.name}</h3>- <p className="muted">- {contextRef ? `Context: ${contextRef}` : 'No context assigned'}- </p>- </div>- </div>-- {agent.connectors.length === 0 ? (- <EmptyState- title="No connectors"- body="This agent's context lists no connectors."+ ) : (+ <DataTable frameless fullBleed className="mcp-servers-data-table">+ <thead>+ <tr>+ <th className="da-table__col-header" scope="col">+ Connector+ </th>+ <th className="da-table__col-header" scope="col">+ Context+ </th>+ <th className="da-table__col-header" scope="col">+ Agents+ </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>+ {rows.map(row => (+ <ConnectorRowView+ key={row.key}+ row={row}+ busy={pendingKey === row.key}+ onAuthorize={input => {+ authorize(input).catch(() => undefined)+ }}+ onDisconnect={input => {+ disconnect(input).catch(() => undefined)+ }}+ onOpenContext={contextRef =>+ handleOpenContextDetails(contextRef, 'mcp-servers')+ }+ onOpenAgent={agentName => handleOpenAgentWorkspace(agentName, 'mcp-servers')}/>- ) : (- <div className="da-grid" style={{ '--da-grid-cols': CONNECTORS_GRID_COLS }}>- <div className="da-grid__head">- <span className="da-grid__col-header">Connector</span>- <span className="da-grid__col-header">Status</span>- <span className="da-grid__col-header">Scope</span>- <span className="da-grid__col-header da-grid__col-header--right">- Actions- </span>- </div>- <div className="da-grid__body">- {agent.connectors.map(connector => {- const presentation = statusPresentation(connector.status)- const caption = scopeCaption(connector)- const actionKey = connectorActionKey(agent.name, connector.name)- const busy = pendingKey === actionKey- const actionInput = { agentName: agent.name, contextRef, connector }- return (- <div className="da-grid__row" key={`${agent.name}:${connector.name}`}>- <span className="da-grid__cell">- {formatMcpServerDisplayName(connector.name)}- {connector.provider ? (- <span className="muted"> · {connector.provider}</span>- ) : null}- </span>- <span className="da-grid__cell">- <Pill tone={presentation.tone} size="sm">- {presentation.label}- </Pill>- </span>- <span className="da-grid__cell muted">{caption ?? '—'}</span>- <span className="da-grid__cell da-grid__cell--right">- {!isActionableConnector(connector) ? null : connector.status ===- 'authorized' ? (- <Button- color="danger"- disabled={busy}- loading={busy}- onClick={() => disconnect(actionInput).catch(() => undefined)}- size="sm"- variant="ghost"- >- Disconnect- </Button>- ) : (- <Button- color="primary"- disabled={busy}- loading={busy}- onClick={() => authorize(actionInput).catch(() => undefined)}- size="sm"- variant="soft"- >- Authorize- </Button>- )}- </span>- </div>- )- })}- </div>- </div>- )}- </section>- )- })- )}+ ))}+ </tbody>+ </DataTable>+ )}+ </section></div></section>)diff --git a/desktop-app/ui/src/pages/__tests__/ContextDetailsPage.test.tsx b/desktop-app/ui/src/pages/__tests__/ContextDetailsPage.test.tsxindex bb9aea45d..33e5ff75f 100644--- a/desktop-app/ui/src/pages/__tests__/ContextDetailsPage.test.tsx+++ b/desktop-app/ui/src/pages/__tests__/ContextDetailsPage.test.tsx@@ -5,6 +5,7 @@ import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-liimport { AppService } from '../../../../src/appService'import type {AccessCatalog,+ RpcAgentConnectors,SessionMe,TeamDirectoryEntry,TeamMember,@@ -14,9 +15,11 @@ 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', () => ({@@ -31,6 +34,13 @@ 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.@@ -52,6 +62,7 @@ vi.mock('electron', () => ({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',@@ -94,6 +105,7 @@ type DataOverrides = {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 => ({@@ -197,6 +209,20 @@ const makeMcpServersDataValue = (...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> => ({@@ -221,6 +247,7 @@ const makeNavValue = (overrides: Partial<NavigationContextValue> = {}): NavigatiselectedAgent: null,selectedAgentRoute: 'details',selectedContext: 'ctx-alpha',+ selectedContextTab: 'agents',selectedTeam: null,handleNavSelect: vi.fn(),handleOpenAgentWorkspace: vi.fn(),@@ -246,6 +273,7 @@ function buildTree(makeMcpServersDataValue(accessCatalog, dataOverrides.mcpServers))useTeamsDataControllerMock.mockReturnValue(makeTeamsDataValue(dataOverrides.teams))+ useConnectorsControllerMock.mockReturnValue(makeConnectorsValue(dataOverrides.connectors))return (<AuthContext.Provider value={makeAuthValue(dataOverrides.auth)}>@@ -347,6 +375,169 @@ describe('ContextDetailsPage', () => {})})+// 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 overdiff --git a/desktop-app/ui/src/pages/__tests__/McpServersPage.test.tsx b/desktop-app/ui/src/pages/__tests__/McpServersPage.test.tsxindex 2fbd54982..59e49bf49 100644--- a/desktop-app/ui/src/pages/__tests__/McpServersPage.test.tsx+++ b/desktop-app/ui/src/pages/__tests__/McpServersPage.test.tsx@@ -1,24 +1,33 @@// @vitest-environment jsdom-import type { ReactNode } from 'react'import { afterEach, describe, expect, it, vi } from 'vitest'import { QueryClient, QueryClientProvider } from '@tanstack/react-query'-import { cleanup, render, screen, waitFor, within } from '@testing-library/react'+import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'import type { RpcConnectorsResult } from '../../../../src/types'import { desktopQueryKeys } from '../../hooks/domain/queryKeys'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', () => ({+ useNavigationContext: () => navMock,+}))+/*** T1: the fixture is typed as `RpcConnectorsResult` — the exact contract the IPC* bridge resolves from rpc-proxy's `GET /api/v1/rpc/connectors` (U1). The- * compiler rejects any field the producer would not emit, and the U1 layer has- * its own real-producer (Postgres + upsertOAuthGrant) integration tests.- * T4: assertions are on the OBSERVABLE chip label + action the user sees.+ * payload is grouped BY AGENT; the page dedups it to one row per+ * `(server, context)`. Fixture exercises dedup (two agents, same context, same+ * server), a contextless connector, and the tri-state chip + actionability.*/const CONNECTORS: RpcConnectorsResult = {userId: 'user-1',agents: [{- name: 'agent-alpha',+ name: 'agent-zeta',contextRef: 'ctx-team',connectors: [{@@ -45,6 +54,34 @@ const CONNECTORS: RpcConnectorsResult = {},],},+ {+ name: 'agent-alpha',+ contextRef: 'ctx-team',+ connectors: [+ // Same context + server as agent-zeta's monday → dedups to ONE row.+ // AGENTS = both; representative (for actions) = agent-alpha (alphabetical).+ {+ name: 'monday',+ provider: 'monday',+ authKind: 'oauth-user',+ grantScope: 'user',+ status: 'authorized',+ },+ ],+ },+ {+ name: 'agent-orphan',+ contextRef: null,+ connectors: [+ {+ name: 'loner',+ provider: 'loner',+ authKind: 'oauth-user',+ grantScope: 'user',+ status: 'requires_setup',+ },+ ],+ },],}@@ -73,55 +110,128 @@ function renderPage(result: RpcConnectorsResult) {)}-describe('McpServersPage — tri-state chip + actionability (T5#3, T4)', () => {+const allRows = (container: HTMLElement) =>+ Array.from(container.querySelectorAll<HTMLElement>('.mcp-servers-data-table tbody tr'))+const rowName = (row: HTMLElement) =>+ row.querySelector('.context-id-cell')?.textContent?.trim() ?? ''+const contextText = (row: HTMLElement) =>+ row.querySelector('.reference-tag--context .reference-tag__label')?.textContent?.trim() ?? null+const chipText = (row: HTMLElement) => row.querySelector('.ui-pill')?.textContent?.trim() ?? null+const rowByName = (rows: HTMLElement[], name: string) => {+ const row = rows.find(r => rowName(r).startsWith(name))+ if (!row) throw new Error(`row not found for ${name}`)+ return row+}++describe('McpServersPage — da-table layout + navigation', () => {afterEach(() => {cleanup()- vi.restoreAllMocks()+ vi.clearAllMocks()delete (window as { clerum?: unknown }).clerum})- it('distinguishes the 3 statuses and only authorized/requires_setup are actionable', async () => {+ it('(a) clicking a row deep-links to that context Connectors tab', async () => {installClerum(CONNECTORS)const { container } = renderPage(CONNECTORS)+ await waitFor(() => expect(screen.getByRole('heading', { name: 'Connectors' })).toBeTruthy())- // The agent group renders once the query resolves.- await waitFor(() => expect(screen.getByRole('heading', { name: 'agent-alpha' })).toBeTruthy())-- const rows = Array.from(container.querySelectorAll<HTMLElement>('.da-grid__body .da-grid__row'))- // One row per connector in the fixture.- expect(rows).toHaveLength(4)-- const rowByFirstCellText = (needle: string) => {- const row = rows.find(r => (r.textContent ?? '').includes(needle))- if (!row) throw new Error(`row not found for ${needle}`)- return row- }- const chipText = (row: HTMLElement) =>- row.querySelector('.ui-pill')?.textContent?.trim() ?? null- const buttonNames = (row: HTMLElement) =>+ const mondayRow = rowByName(allRows(container), 'monday')+ expect(contextText(mondayRow)).toBe('ctx-team')+ fireEvent.click(mondayRow)++ expect(navMock.handleOpenContextDetails).toHaveBeenCalledWith('ctx-team', 'mcp-servers')+ })++ it('(b) mouse OR keyboard on Authorize/Disconnect fires the action WITHOUT navigating', () => {+ const rpc = installClerum(CONNECTORS)+ const { container } = renderPage(CONNECTORS)+ const rows = allRows(container)++ // Disconnect on the authorized monday row: acts under the representative+ // (agent-alpha, alphabetical) and does NOT trigger the row navigation.+ const mondayRow = rowByName(rows, 'monday')+ const disconnectBtn = within(mondayRow).getByRole('button', { name: 'Disconnect' })+ fireEvent.click(disconnectBtn)+ expect(rpc.disconnectMcpServer).toHaveBeenCalledWith('monday', 'agent-alpha', undefined, {+ shared: false,+ })+ expect(navMock.handleOpenContextDetails).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.)+ fireEvent.keyDown(disconnectBtn, { key: 'Enter' })+ fireEvent.keyDown(disconnectBtn, { key: ' ' })+ expect(navMock.handleOpenContextDetails).not.toHaveBeenCalled()++ // Authorize on the requires_setup clickup row.+ const clickupRow = rowByName(rows, 'clickup')+ const authorizeBtn = within(clickupRow).getByRole('button', { name: 'Authorize' })+ fireEvent.click(authorizeBtn)+ expect(rpc.connectMcpServer).toHaveBeenCalledWith('clickup', 'agent-zeta', undefined, {+ confirmShared: false,+ })+ fireEvent.keyDown(authorizeBtn, { key: 'Enter' })+ expect(navMock.handleOpenContextDetails).not.toHaveBeenCalled()+ })++ it('(c) mouse OR keyboard on an agent chip opens the agent WITHOUT navigating the row', () => {+ installClerum(CONNECTORS)+ const { container } = renderPage(CONNECTORS)++ const mondayRow = rowByName(allRows(container), 'monday')+ // monday is listed by agent-alpha AND agent-zeta.+ const chip = within(mondayRow).getByRole('button', { name: 'Open agent agent-zeta' })+ fireEvent.click(chip)+ expect(navMock.handleOpenAgentWorkspace).toHaveBeenCalledWith('agent-zeta', 'mcp-servers')+ expect(navMock.handleOpenContextDetails).not.toHaveBeenCalled()++ // 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()+ })++ it('(d) a contextless row is not clickable and never navigates', () => {+ installClerum(CONNECTORS)+ const { container } = renderPage(CONNECTORS)++ const lonerRow = rowByName(allRows(container), 'loner')+ expect(contextText(lonerRow)).toBeNull()+ // 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()+ })++ it('(e) distinguishes the 3 statuses and only authorized/requires_setup are actionable', () => {+ installClerum(CONNECTORS)+ const { container } = renderPage(CONNECTORS)+ const rows = allRows(container)++ const buttonLabels = (row: HTMLElement) =>within(row).queryAllByRole('button')+ // Drop the row-surface button (its label starts with "Open connectors")..map(b => b.textContent?.trim())+ .filter(label => label === 'Authorize' || label === 'Disconnect')++ const monday = rowByName(rows, 'monday')+ expect(chipText(monday)).toBe('Authorized')+ expect(buttonLabels(monday)).toEqual(['Disconnect'])++ const clickup = rowByName(rows, 'clickup')+ expect(chipText(clickup)).toBe('Requires setup')+ expect(buttonLabels(clickup)).toEqual(['Authorize'])++ const filesystem = rowByName(rows, 'filesystem')+ expect(chipText(filesystem)).toBe('No OAuth')+ expect(buttonLabels(filesystem)).toEqual([])- // authorized → "Authorized" chip + Disconnect only.- const authorizedRow = rowByFirstCellText('monday')- expect(chipText(authorizedRow)).toBe('Authorized')- expect(buttonNames(authorizedRow)).toEqual(['Disconnect'])-- // requires_setup (oauth-user) → "Requires setup" chip + Authorize only.- const requiresRow = rowByFirstCellText('clickup')- expect(chipText(requiresRow)).toBe('Requires setup')- expect(buttonNames(requiresRow)).toEqual(['Authorize'])-- // no_oauth → "No OAuth" chip + NO action button (not actionable on this rail).- const noOauthRow = rowByFirstCellText('filesystem')- expect(chipText(noOauthRow)).toBe('No OAuth')- expect(buttonNames(noOauthRow)).toEqual([])-- // oauth-context requires_setup → actionable AND flagged as shared/team-wide.- const sharedRow = rowByFirstCellText('shared-drive')- expect(chipText(sharedRow)).toBe('Requires setup')- expect(buttonNames(sharedRow)).toEqual(['Authorize'])- expect(within(sharedRow).getByText(/Shared by the team/i)).toBeTruthy()+ // oauth-user status pill surfaces the blast-radius caption as a tooltip.+ expect(monday.querySelector('.ui-pill')?.getAttribute('title')).toMatch(+ /Affects all your agents/i+ )})})diff --git a/desktop-app/ui/src/pages/__tests__/TeamsPage.test.tsx b/desktop-app/ui/src/pages/__tests__/TeamsPage.test.tsxindex 17ee1c5c1..fdb989721 100644--- a/desktop-app/ui/src/pages/__tests__/TeamsPage.test.tsx+++ b/desktop-app/ui/src/pages/__tests__/TeamsPage.test.tsx@@ -108,6 +108,7 @@ const makeNavigationValue = (selectedAgent: null,selectedAgentRoute: 'details',selectedContext: null,+ selectedContextTab: 'agents',selectedTeam: null,handleNavSelect: vi.fn(),handleOpenAgentWorkspace: vi.fn(),diff --git a/desktop-app/ui/src/styles.css b/desktop-app/ui/src/styles.cssindex bd9f0975d..dda77adb9 100644--- a/desktop-app/ui/src/styles.css+++ b/desktop-app/ui/src/styles.css@@ -7655,12 +7655,14 @@ h3 {remaining page-specific hooks are `context-detail-page` / `team-detail-page`(used for scoped token overrides). */+/* Card that frames the connectors `da-table` (which renders frameless + full+ bleed), mirroring `.contexts-board-card`: the page-card supplies the single+ frame; the table lays out inside it. */.mcp-servers-board-card {min-height: 0;min-width: 0;display: grid;align-content: start;- gap: var(--space-2-5);}.mcp-servers-board-header {@@ -8107,12 +8109,6 @@ h3 {word-break: break-word;}-.context-mcp-url code {- font-size: var(--font-size-xs);- color: var(--text-muted);- word-break: break-all;-}-.context-mcp-count {justify-self: center;min-width: 26px;@@ -8126,11 +8122,6 @@ h3 {word-break: break-word;}-.context-mcp-source {- color: var(--text-dim);- font-size: var(--font-size-sm);-}-.context-members-name {color: var(--text);font-weight: 600;