Skip to content

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

TypeScript

refactor(desktop-ui): connectors list is one row per (connector, agent)

Diego Zacariasb6ca65996d87
diff --git a/desktop-app/test/e2e-playwright/qa-recorder-connectors.spec.ts b/desktop-app/test/e2e-playwright/qa-recorder-connectors.spec.ts
index 2737b60d9..c15d2a888 100644
--- a/desktop-app/test/e2e-playwright/qa-recorder-connectors.spec.ts
+++ b/desktop-app/test/e2e-playwright/qa-recorder-connectors.spec.ts
@@ -54,10 +54,22 @@ test('optional QA recorder: Desktop connectors journey', async ({}, testInfo) =>
connectorsTable.or(healthTable).or(emptyHeading).or(healthEmpty).or(errorAlert)
).toBeVisible({ timeout: 20_000 })
- // (2) If the connectors table is present, assert its container rendered.
- // Rows may be empty — we only assert the table shell, not row count.
+ // (2) If the connectors table is present, assert its container rendered and
+ // that it is the agent-centric (connector, agent) list: an "Agent" column,
+ // and NO legacy "Context" / multi-chip "Agents" columns. Rows may be empty —
+ // clicking a row deep-links to THAT agent's Connectors tab, but we don't
+ // exercise navigation here (rows may be absent). We only assert the shell.
if (await connectorsTable.isVisible().catch(() => false)) {
await expect(connectorsTable).toBeVisible()
+ await expect(
+ connectorsTable.getByRole('columnheader', { name: 'Agent', exact: true })
+ ).toBeVisible()
+ await expect(
+ connectorsTable.getByRole('columnheader', { name: 'Context', exact: true })
+ ).toHaveCount(0)
+ await expect(
+ connectorsTable.getByRole('columnheader', { name: 'Agents', exact: true })
+ ).toHaveCount(0)
}
// (3) Toggle health detail if a toggle is exposed on this surface, then
diff --git a/desktop-app/ui/src/lib/__tests__/connectorRows.test.ts b/desktop-app/ui/src/lib/__tests__/connectorRows.test.ts
index b3e16e656..b6fbf0805 100644
--- a/desktop-app/ui/src/lib/__tests__/connectorRows.test.ts
+++ b/desktop-app/ui/src/lib/__tests__/connectorRows.test.ts
@@ -1,9 +1,19 @@
import { describe, expect, it } from 'vitest'
import fc from 'fast-check'
import type { RpcAgentConnectors, RpcConnector } from '../../../../src/types'
-import { connectorRowKey, deriveConnectorRows } from '../connectorRows'
+import { connectorRenderKey, connectorRowKey, deriveConnectorRows } from '../connectorRows'
import { formatMcpServerDisplayName } from '../format'
+// T1 (fixture honesty): the input `RpcAgentConnectors[]` is the RAW output of
+// rpc-proxy (`GET /api/v1/rpc/connectors`); the desktop client passes it through
+// verbatim, so there is NO local producer to derive a fixture from. The
+// authoritative producer is rpc-proxy (external). We therefore do NOT hand-write
+// a "realistic" payload pretending to be rpc-proxy; instead the property-test
+// below fuzzes the whole typed contract domain, and the real golden — if ever
+// wanted — is captured from the producer-backed lane
+// (`test/e2e-playwright/qa-recorder-connectors.spec.ts`), never by hand. The
+// `connector()`/`agent()` helpers only build the typed contract domain (they are
+// not standing in for another layer's serialization), which is legitimate.
function connector(overrides: Partial<RpcConnector> & Pick<RpcConnector, 'name'>): RpcConnector {
return { status: 'requires_setup', ...overrides }
}
@@ -17,16 +27,29 @@ function agent(
}
describe('deriveConnectorRows', () => {
- it('dedups two agents that share a (server, context) into one row', () => {
+ it('explodes two agents that share a (server, context) into two per-agent rows', () => {
+ // Agent-centric model (spec §5.E): one row per (connector, agent). Two agents
+ // that share the SAME grant `(server, context)` produce TWO rows — same
+ // grantKey (the grant identity + busy anchor), distinct renderKey/agentName.
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'])
+ expect(rows).toHaveLength(2)
+ // Sorted by ... agent name as the final tie-break: alpha before zeta.
+ expect(rows.map(r => r.agentName)).toEqual(['agent-alpha', 'agent-zeta'])
+ // Both share the ONE grant identity.
+ const grantKey = connectorRowKey('ctx-team', 'monday')
+ expect(rows.map(r => r.grantKey)).toEqual([grantKey, grantKey])
+ // But each row's React key is unique per (agent, context, server).
+ expect(rows.map(r => r.renderKey)).toEqual([
+ connectorRenderKey('agent-alpha', 'ctx-team', 'monday'),
+ connectorRenderKey('agent-zeta', 'ctx-team', 'monday'),
+ ])
+ expect(new Set(rows.map(r => r.renderKey)).size).toBe(2)
})
- it('keeps the same server in two contexts as two adjacent rows', () => {
+ it('keeps the same server in two contexts as two rows carrying their own agent', () => {
const rows = deriveConnectorRows([
agent('agent-beta', 'ctx-other', [connector({ name: 'shared-drive', status: 'authorized' })]),
agent('agent-alpha', 'ctx-team', [
@@ -36,18 +59,38 @@ describe('deriveConnectorRows', () => {
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'])
+ expect(rows.map(r => r.agentName)).toEqual(['agent-beta', 'agent-alpha'])
})
- it('picks the alphabetically-first agent as the representative', () => {
+ it('collapses a single agent that lists the same connector twice (anomaly) by renderKey', () => {
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' })]),
+ agent('agent-alpha', 'ctx-team', [
+ connector({ name: 'monday', status: 'requires_setup' }),
+ connector({ name: 'monday', status: 'authorized' }),
+ ]),
])
- expect(rows[0]?.representativeAgent).toBe('agent-alpha')
+ // Same (agent, context, server) collapses to ONE render row...
+ expect(rows).toHaveLength(1)
+ expect(rows[0]?.agentName).toBe('agent-alpha')
+ // ...carrying the canonical (max STATUS_RANK) status of the grant.
+ expect(rows[0]?.connector.status).toBe('authorized')
+ })
+
+ it('stamps every sibling row of a grant with the canonical (max STATUS_RANK) status', () => {
+ // Status merge is now proved as: all rows of the SAME grantKey carry the
+ // identical canonical status, regardless of the per-agent crude status.
+ 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(2)
+ const grantKey = connectorRowKey('ctx-team', 'monday')
+ expect(rows.every(r => r.grantKey === grantKey)).toBe(true)
+ // BOTH siblings show 'authorized' — coherent with the busy-state fold by grant.
+ expect(rows.map(r => r.connector.status)).toEqual(['authorized', 'authorized'])
})
- it('sorts by display name, then real name, then context', () => {
+ it('sorts by display name, then real name, then context, then agent', () => {
const rows = deriveConnectorRows([
agent('a1', 'ctx-b', [
connector({ name: 'zebra' }),
@@ -57,39 +100,50 @@ describe('deriveConnectorRows', () => {
])
// 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'],
+ expect(rows.map(r => [r.connector.name, r.contextRef, r.agentName])).toEqual([
+ ['alpha-remote', 'ctx-a', 'a2'],
+ ['mcp-alpha', 'ctx-b', 'a1'],
+ ['zebra', 'ctx-b', 'a1'],
])
})
- it('defensively prefers the most-connected status if a group diverges', () => {
+ it('breaks ties on agent name when display/name/context all match', () => {
const rows = deriveConnectorRows([
- agent('agent-alpha', 'ctx-team', [connector({ name: 'monday', status: 'requires_setup' })]),
- agent('agent-zeta', 'ctx-team', [connector({ name: 'monday', status: 'authorized' })]),
+ 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).toHaveLength(1)
- expect(rows[0]?.connector.status).toBe('authorized')
+ expect(rows.map(r => r.agentName)).toEqual(['agent-alpha', 'agent-mid', 'agent-zeta'])
})
- it('groups connectors with no context together and exposes the row key', () => {
+ it('keeps contextless (oauth-user) grants clickable per-agent and exposes both keys', () => {
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'))
+ // Two agents, no context → two per-agent rows (NOT deduplicated).
+ expect(rows).toHaveLength(2)
+ expect(rows.every(r => r.contextRef === null)).toBe(true)
+ const grantKey = connectorRowKey(null, 'monday')
+ expect(rows.every(r => r.grantKey === grantKey)).toBe(true)
+ expect(rows.map(r => r.renderKey)).toEqual([
+ connectorRenderKey('agent-alpha', null, 'monday'),
+ connectorRenderKey('agent-zeta', 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.
+ * (`STATUS_RANK` folded per GRANT), an explode to one row per (agent, connector),
+ * and a total sort order. Small name/context/agent pools maximise collisions so
+ * grants actually merge AND multiple agents share a grant. 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.
+ *
+ * CAVEAT: each property targets the CORRECT key —
+ * - uniqueness is a property of renderKey (the React key),
+ * - status coherence is a property of grantKey (the grant identity).
*/
describe('deriveConnectorRows — property-based invariants (T2)', () => {
const STATUS_RANK: Record<RpcConnector['status'], number> = {
@@ -116,11 +170,16 @@ describe('deriveConnectorRows — property-based invariants (T2)', () => {
})
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 }) => [
+ // Mirrors the module's documented sort contract (display, real name, context, agent).
+ const sortRank = (row: {
+ connector: RpcConnector
+ contextRef: string | null
+ agentName: string
+ }) => [
formatMcpServerDisplayName(row.connector.name),
row.connector.name,
row.contextRef ?? '',
+ row.agentName,
]
const lexCompare = (a: string[], b: string[]) => {
for (let i = 0; i < a.length; i++) {
@@ -135,35 +194,56 @@ describe('deriveConnectorRows — property-based invariants (T2)', () => {
fc.property(agentsArb, agents => {
const rows = deriveConnectorRows(agents)
- // (1) Total order: output non-decreasing under the sort contract.
+ // (1) Total order: output non-decreasing under the sort contract
+ // (display, name, context, AGENT).
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)
+ // (2) No duplicate RENDER keys (the React key must be unique per row).
+ expect(new Set(rows.map(r => r.renderKey)).size).toBe(rows.length)
- // (3) No agent that references a (server, context) group disappears from
- // that row's USED BY.
+ // (3) Bijection with the payload: every (agent, connector) pair maps to
+ // exactly one row, and no row invents an absent pair. The set of the
+ // rows' renderKeys equals the set of renderKeys derivable from the
+ // payload (agent-lists-same-name-twice collapses to one renderKey on
+ // BOTH sides, so equality still holds).
+ const expected = new Set<string>()
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)
+ expected.add(connectorRenderKey(agent.name, agent.contextRef, c.name))
}
}
-
- // (4) Row status = the max STATUS_RANK among the group's agents.
+ const actual = new Set(rows.map(r => r.renderKey))
+ expect(actual.size).toBe(expected.size)
+ for (const rk of expected) expect(actual.has(rk)).toBe(true)
+ // Nothing invented: every row's (agentName, grantKey) is a real payload pair.
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(row.renderKey).toBe(
+ connectorRenderKey(row.agentName, row.contextRef, row.connector.name)
+ )
+ expect(row.grantKey).toBe(connectorRowKey(row.contextRef, row.connector.name))
+ expect(expected.has(row.renderKey)).toBe(true)
+ }
+
+ // (4) Status coherence per GRANT: all rows sharing a grantKey carry an
+ // identical status, equal to the max STATUS_RANK of that grant's
+ // appearances in the payload.
+ const grantMaxRank = new Map<string, number>()
+ for (const agent of agents) {
+ for (const c of agent.connectors) {
+ const gk = connectorRowKey(agent.contextRef, c.name)
+ grantMaxRank.set(gk, Math.max(grantMaxRank.get(gk) ?? -1, STATUS_RANK[c.status]))
}
- expect(STATUS_RANK[row.connector.status]).toBe(maxRank)
+ }
+ const seenStatusByGrant = new Map<string, RpcConnector['status']>()
+ for (const row of rows) {
+ // canonical == max rank of the grant
+ expect(STATUS_RANK[row.connector.status]).toBe(grantMaxRank.get(row.grantKey))
+ // siblings agree
+ const prev = seenStatusByGrant.get(row.grantKey)
+ if (prev !== undefined) expect(row.connector.status).toBe(prev)
+ seenStatusByGrant.set(row.grantKey, row.connector.status)
}
})
)
diff --git a/desktop-app/ui/src/lib/connectorRows.ts b/desktop-app/ui/src/lib/connectorRows.ts
index 6519a211c..df26f38b6 100644
--- a/desktop-app/ui/src/lib/connectorRows.ts
+++ b/desktop-app/ui/src/lib/connectorRows.ts
@@ -2,44 +2,55 @@ import type { RpcAgentConnectors, RpcConnector } from '../../../src/types'
import { formatMcpServerDisplayName } from './format'
/**
- * A single deduplicated row of the Connectors table.
+ * A single 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.
+ * In the agent-centric model (spec §5.E) the table shows ONE row per
+ * `(connector, agent)`: clicking a row deep-links to THAT agent's Connectors
+ * tab. The grant itself is never per-agent — `oauth-context`/`grantScope:'context'`
+ * grants are keyed by `(server, context)` and `oauth-user` grants by
+ * `(server, userId)` — so a row carries TWO keys:
+ *
+ * - `renderKey` — unique per `(agent, context, server)`; the React key.
+ * - `grantKey` — the GRANT identity `(context, server)`; the anchor for the
+ * `pendingKey` busy-state and the authorize/disconnect action.
+ *
+ * Two agents that share a grant produce two rows with the SAME `grantKey` and
+ * DISTINCT `renderKey`. `agentName` is the row's own agent: both the deep-link
+ * target and the RPC-token minter for the action.
*/
export type ConnectorRow = {
- /** Stable per-row key `(context, server)` — also the `pendingKey` anchor. */
- key: string
+ /** React key — UNIQUE per row: `(agent, context, server)`. */
+ renderKey: 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.
+ * Grant identity `(context, server)` = `connectorRowKey(contextRef, name)`.
+ * The `pendingKey` busy-state anchor and the action target. Shared by every
+ * sibling row of the same grant.
+ */
+ grantKey: string
+ /**
+ * The connector policy for this row, with the grant's CANONICAL status
+ * stamped in (max `STATUS_RANK` across all `(agent, connector)` appearances of
+ * the grant) so sibling rows can never disagree on status. `provider`/
+ * `authKind`/`grantScope` are invariant across the grant, so this row's own
+ * connector describes them.
*/
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.)
+ * The agent this row belongs to: the deep-link destination AND the agent used
+ * to mint the RPC token for authorize/disconnect.
*/
- representativeAgent: string
- /** All agents in this `(server, context)` group, sorted, for the AGENTS cell. */
- usedByAgents: string[]
+ agentName: 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.
+ * The single canonical key for a `(context, server)` pair — the GRANT identity.
+ * Used for BOTH the status fold in `deriveConnectorRows` and the `pendingKey`
+ * busy-state anchor, so a row, its grant, 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:
+ * Anchored to the VISIBLE `(context, server)`, not to the agent, so the busy
+ * spinner tracks the grant 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
@@ -50,10 +61,29 @@ export function connectorRowKey(contextRef: string | null, connectorName: string
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.
+/**
+ * The React key for a row — UNIQUE per `(agent, context, server)`. Prefixes the
+ * agent name onto the grant key with the same `\x00` delimiter, so two agents
+ * sharing a grant get distinct render keys while still exposing the shared
+ * `grantKey` for the busy-state/action.
+ *
+ * Injectivity relies on `agentName` containing no `\x00`: the FIRST `\x00`
+ * cleanly splits the agent prefix from the grant key (whose own `\x01`/`\x02`
+ * tag + `\x00` guards keep it injective in `(contextRef, connectorName)`). Agent
+ * names are DNS labels, so `\x00` can never appear — the boundary is unambiguous.
+ */
+export function connectorRenderKey(
+ agentName: string,
+ contextRef: string | null,
+ connectorName: string
+): string {
+ return `${agentName}\x00${connectorRowKey(contextRef, connectorName)}`
+}
+
+// "More connected" ranking for the status fold below. A grant is
+// per-context/per-user (not per-agent), so every agent that lists a grant 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,
@@ -61,50 +91,54 @@ const STATUS_RANK: Record<RpcConnector['status'], number> = {
}
/**
- * Fold the per-agent payload into a flat, deduplicated, sorted list of
- * `(server, context)` rows. Pure and total: safe to call in a `useMemo`.
+ * Fold the per-agent payload into a flat, sorted list of `(connector, agent)`
+ * rows. Pure and total: safe to call in a `useMemo`.
+ *
+ * Two passes:
+ * 1. Fold the CANONICAL status per grant (`max STATUS_RANK` across every
+ * `(agent, connector)` appearance of that grant).
+ * 2. Explode to one row per `(agent, connector)`, stamping each sibling row
+ * with the grant's canonical status. A single agent that lists the same
+ * connector twice (an anomaly) collapses by `renderKey`.
*/
export function deriveConnectorRows(agents: RpcAgentConnectors[]): ConnectorRow[] {
- const groups = new Map<
- string,
- { connector: RpcConnector; contextRef: string | null; agents: Set<string> }
- >()
-
+ // Pass 1: canonical status per grant.
+ const canonicalStatus = new Map<string, RpcConnector['status']>()
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 grantKey = connectorRowKey(agent.contextRef, connector.name)
+ const current = canonicalStatus.get(grantKey)
+ if (current === undefined || STATUS_RANK[connector.status] > STATUS_RANK[current]) {
+ canonicalStatus.set(grantKey, connector.status)
}
}
}
- 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,
+ // Pass 2: one row per (agent, connector). Dedup by renderKey collapses a
+ // single agent that lists the same connector.name twice (anomaly); distinct
+ // agents are never collapsed.
+ const byRenderKey = new Map<string, ConnectorRow>()
+ for (const agent of agents) {
+ for (const connector of agent.connectors) {
+ const grantKey = connectorRowKey(agent.contextRef, connector.name)
+ const renderKey = connectorRenderKey(agent.name, agent.contextRef, connector.name)
+ if (byRenderKey.has(renderKey)) continue
+ const status = canonicalStatus.get(grantKey) ?? connector.status
+ byRenderKey.set(renderKey, {
+ renderKey,
+ grantKey,
+ connector: { ...connector, status },
+ contextRef: agent.contextRef,
+ agentName: agent.name,
+ })
}
- })
+ }
+
+ const rows = Array.from(byRenderKey.values())
- // 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.
+ // Stable total order: displayed name, then real name, then context, then
+ // agent. Purely presentational — groups the same connector's rows 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)
@@ -112,7 +146,9 @@ export function deriveConnectorRows(agents: RpcAgentConnectors[]): ConnectorRow[
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 ?? '')
+ const byContext = (a.contextRef ?? '').localeCompare(b.contextRef ?? '')
+ if (byContext !== 0) return byContext
+ return a.agentName.localeCompare(b.agentName)
})
return rows
diff --git a/desktop-app/ui/src/pages/McpServersPage.tsx b/desktop-app/ui/src/pages/McpServersPage.tsx
index 26af86f83..e6c814d50 100644
--- a/desktop-app/ui/src/pages/McpServersPage.tsx
+++ b/desktop-app/ui/src/pages/McpServersPage.tsx
@@ -24,29 +24,26 @@ function ConnectorRowView({
onDisconnect: (input: ConnectorActionInput) => void
onOpenAgent: (agentName: string) => void
}) {
- const { connector, contextRef } = row
+ const { connector, contextRef, agentName } = 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.
+ // (connector, agent), so we act under the row's own agent.
const actionInput: ConnectorActionInput = {
- agentName: row.representativeAgent,
+ agentName,
contextRef,
connector,
}
- // 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(() => onOpenAgent(row.representativeAgent), {
- ariaLabel: `Open connectors for agent ${row.representativeAgent}`,
- }),
- }
- : {}
+ // Every row deep-links to ITS agent's Connectors tab. In the agent-centric
+ // model every row has an agent (contextless `oauth-user` rows included), so
+ // every row is clickable.
+ const rowProps = {
+ className: 'da-table__row--clickable',
+ ...clickableRowProps(() => onOpenAgent(agentName), {
+ ariaLabel: `Open connectors for agent ${agentName}`,
+ }),
+ }
return (
<tr {...rowProps}>
@@ -58,40 +55,11 @@ function ConnectorRowView({
</td>
<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>
- )}
+ {/* Presentational: the whole row already navigates to this agent, so the
+ tag carries no click/key handlers of its own. */}
+ <ReferenceTag kind="agent" title={agentName} aria-label={`Agent ${agentName}`}>
+ {agentName}
+ </ReferenceTag>
</td>
<td className="da-table__cell">
@@ -176,10 +144,7 @@ export function McpServersPage() {
Connector
</th>
<th className="da-table__col-header" scope="col">
- Context
- </th>
- <th className="da-table__col-header" scope="col">
- Agents
+ Agent
</th>
<th className="da-table__col-header" scope="col">
Status
@@ -192,9 +157,13 @@ export function McpServersPage() {
<tbody>
{rows.map(row => (
<ConnectorRowView
- key={row.key}
+ key={row.renderKey}
row={row}
- busy={pendingKey === row.key}
+ // Busy is a property of the GRANT, never the render row:
+ // authorizing/disconnecting a shared grant must show every
+ // sibling row busy, so anchor on grantKey (matches the
+ // controller's pendingKey = connectorRowKey).
+ busy={pendingKey === row.grantKey}
onAuthorize={input => {
authorize(input).catch(() => undefined)
}}
diff --git a/desktop-app/ui/src/pages/__tests__/McpServersPage.test.tsx b/desktop-app/ui/src/pages/__tests__/McpServersPage.test.tsx
index 59fd148e2..676aceff3 100644
--- a/desktop-app/ui/src/pages/__tests__/McpServersPage.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/McpServersPage.test.tsx
@@ -18,9 +18,10 @@ vi.mock('../../contexts/NavigationContext', () => ({
/**
* 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
- * 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.
+ * payload is grouped BY AGENT; the page explodes it to one row per
+ * `(connector, agent)` (spec §5.E). Fixture exercises a grant shared by two
+ * agents (two rows, one grantKey), a contextless `oauth-user` connector, and the
+ * tri-state chip + actionability.
*/
const CONNECTORS: RpcConnectorsResult = {
userId: 'user-1',
@@ -57,8 +58,9 @@ 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).
+ // Same context + server as agent-zeta's monday → SAME grant, but the
+ // agent-centric list shows a SEPARATE per-agent row. Each row deep-links
+ // to its own agent and acts under its own agent.
{
name: 'monday',
provider: 'monday',
@@ -113,12 +115,14 @@ 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 agentTag = (row: HTMLElement) =>
+ row.querySelector('.reference-tag--agent .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}`)
+// One row per (connector, agent): identify by BOTH so the two `monday` sibling
+// rows are addressable independently.
+const rowBy = (rows: HTMLElement[], name: string, agent: string) => {
+ const row = rows.find(r => rowName(r).startsWith(name) && agentTag(r) === agent)
+ if (!row) throw new Error(`row not found for ${name} / ${agent}`)
return row
}
@@ -129,18 +133,22 @@ describe('McpServersPage — da-table layout + navigation', () => {
delete (window as { clerum?: unknown }).clerum
})
- it('(a) clicking a row deep-links to the representative agent Connectors tab', async () => {
+ it('(a) a shared grant renders one row per agent, each deep-linking to ITS agent', async () => {
installClerum(CONNECTORS)
const { container } = renderPage(CONNECTORS)
await waitFor(() => expect(screen.getByRole('heading', { name: 'Connectors' })).toBeTruthy())
- const mondayRow = rowByName(allRows(container), 'monday')
- expect(contextText(mondayRow)).toBe('ctx-team')
- fireEvent.click(mondayRow)
+ const rows = allRows(container)
+ // monday is granted to agent-alpha AND agent-zeta → TWO rows, one per agent.
+ const alphaRow = rowBy(rows, 'monday', 'agent-alpha')
+ const zetaRow = rowBy(rows, 'monday', 'agent-zeta')
+
+ fireEvent.click(alphaRow)
+ expect(navMock.handleOpenAgentWorkspace).toHaveBeenLastCalledWith('agent-alpha', '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')
+ fireEvent.click(zetaRow)
+ expect(navMock.handleOpenAgentWorkspace).toHaveBeenLastCalledWith('agent-zeta', 'mcp-servers')
+ expect(navMock.handleOpenAgentWorkspace).toHaveBeenCalledTimes(2)
})
it('(b) mouse OR keyboard on Authorize/Disconnect fires the action WITHOUT navigating', () => {
@@ -148,10 +156,10 @@ describe('McpServersPage — da-table layout + navigation', () => {
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' })
+ // Disconnect on agent-alpha's authorized monday row: acts under agent-alpha
+ // (the row's OWN agent) and does NOT trigger the row navigation.
+ const alphaMonday = rowBy(rows, 'monday', 'agent-alpha')
+ const disconnectBtn = within(alphaMonday).getByRole('button', { name: 'Disconnect' })
fireEvent.click(disconnectBtn)
expect(rpc.disconnectMcpServer).toHaveBeenCalledWith('monday', 'agent-alpha', undefined, {
shared: false,
@@ -159,14 +167,13 @@ describe('McpServersPage — da-table layout + navigation', () => {
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 navigates the row.)
+ // row's clickableRowProps onKeyDown and navigate.
fireEvent.keyDown(disconnectBtn, { key: 'Enter' })
fireEvent.keyDown(disconnectBtn, { key: ' ' })
expect(navMock.handleOpenAgentWorkspace).not.toHaveBeenCalled()
- // Authorize on the requires_setup clickup row.
- const clickupRow = rowByName(rows, 'clickup')
+ // Authorize on the requires_setup clickup row (agent-zeta) → acts under agent-zeta.
+ const clickupRow = rowBy(rows, 'clickup', 'agent-zeta')
const authorizeBtn = within(clickupRow).getByRole('button', { name: 'Authorize' })
fireEvent.click(authorizeBtn)
expect(rpc.connectMcpServer).toHaveBeenCalledWith('clickup', 'agent-zeta', undefined, {
@@ -176,36 +183,33 @@ describe('McpServersPage — da-table layout + navigation', () => {
expect(navMock.handleOpenAgentWorkspace).not.toHaveBeenCalled()
})
- it('(c) mouse OR keyboard on an agent chip opens the agent WITHOUT navigating the row', () => {
+ it('(c) the Agent cell is presentational — no nested interactive control of its own', () => {
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)
- // 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.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.handleOpenAgentWorkspace).toHaveBeenCalledTimes(1)
+ const alphaMonday = rowBy(allRows(container), 'monday', 'agent-alpha')
+ // The agent tag renders as a plain (non-button) tag: the row already
+ // navigates to that agent, so the tag carries no click/key handlers.
+ const tag = alphaMonday.querySelector('.reference-tag--agent')
+ expect(tag).not.toBeNull()
+ expect(tag?.tagName.toLowerCase()).toBe('span')
+ // The only actionable button in an authorized row is Disconnect.
+ const buttons = within(alphaMonday)
+ .queryAllByRole('button')
+ .map(b => b.textContent?.trim())
+ .filter(label => label === 'Authorize' || label === 'Disconnect')
+ expect(buttons).toEqual(['Disconnect'])
})
- it('(d) a contextless row is not clickable and never navigates', () => {
+ it('(d) a contextless (oauth-user) row is clickable and deep-links to its agent', () => {
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()
+ const lonerRow = rowBy(allRows(container), 'loner', 'agent-orphan')
+ // Row-level button semantics ARE present now — every row navigates.
+ expect(lonerRow.getAttribute('role')).toBe('button')
fireEvent.click(lonerRow)
- expect(navMock.handleOpenAgentWorkspace).not.toHaveBeenCalled()
+ expect(navMock.handleOpenAgentWorkspace).toHaveBeenCalledWith('agent-orphan', 'mcp-servers')
})
it('(e) distinguishes the 3 statuses and only authorized/requires_setup are actionable', () => {
@@ -220,15 +224,15 @@ describe('McpServersPage — da-table layout + navigation', () => {
.map(b => b.textContent?.trim())
.filter(label => label === 'Authorize' || label === 'Disconnect')
- const monday = rowByName(rows, 'monday')
+ const monday = rowBy(rows, 'monday', 'agent-zeta')
expect(chipText(monday)).toBe('Authorized')
expect(buttonLabels(monday)).toEqual(['Disconnect'])
- const clickup = rowByName(rows, 'clickup')
+ const clickup = rowBy(rows, 'clickup', 'agent-zeta')
expect(chipText(clickup)).toBe('Requires setup')
expect(buttonLabels(clickup)).toEqual(['Authorize'])
- const filesystem = rowByName(rows, 'filesystem')
+ const filesystem = rowBy(rows, 'filesystem', 'agent-zeta')
expect(chipText(filesystem)).toBe('No OAuth')
expect(buttonLabels(filesystem)).toEqual([])
diff --git a/desktop-app/ui/src/styles.css b/desktop-app/ui/src/styles.css
index c16226d52..29ebadf7a 100644
--- a/desktop-app/ui/src/styles.css
+++ b/desktop-app/ui/src/styles.css
@@ -11349,7 +11349,7 @@ pre {
}
.mcp-servers-data-table {
- min-width: 860px;
+ min-width: 680px;
}
.context-agents-data-table,