Skip to content

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

TypeScript

refactor(control-ui): reconcile table sync with agent access

Josuéaed09a42c6fd
diff --git a/control-ui/app/profile-admin/teams/[teamId]/page.tsx b/control-ui/app/profile-admin/teams/[teamId]/page.tsx
index f07962ad1..8de2a8153 100644
--- a/control-ui/app/profile-admin/teams/[teamId]/page.tsx
+++ b/control-ui/app/profile-admin/teams/[teamId]/page.tsx
@@ -43,16 +43,16 @@ import { formatTeamRole, permissionsForTeamRole } from '../../../../lib/teamRole
type Role = 'admin' | 'inviter' | 'member'
-type TeamTab = 'members' | 'contexts' | 'agents'
-const TEAM_TABS: TeamTab[] = ['members', 'contexts', 'agents']
+type TeamTab = 'members' | 'agents'
+const TEAM_TABS: TeamTab[] = ['members', 'agents']
const TEAM_TAB_LABELS: Record<TeamTab, string> = {
members: 'Members',
- contexts: 'Contexts',
agents: 'Agents',
}
function parseTeamTab(value: string | undefined): TeamTab {
+ if (value === 'contexts') return 'agents'
return TEAM_TABS.includes(value as TeamTab) ? (value as TeamTab) : 'members'
}
@@ -174,13 +174,11 @@ export default function TeamDetailsPage() {
const [addingMember, setAddingMember] = useState(false)
const [addMemberError, setAddMemberError] = useState('')
- const [showAddContext, setShowAddContext] = useState(false)
const [showAddAgent, setShowAddAgent] = useState(false)
const [availableContextIds, setAvailableContextIds] = useState<string[]>([])
const [assignedContextIds, setAssignedContextIds] = useState<string[]>([])
const [deletedContextIds, setDeletedContextIds] = useState<string[]>([])
- const [selectedContextIdsToAdd, setSelectedContextIdsToAdd] = useState<string[]>([])
const [hosts, setHosts] = useState<HostResource[]>([])
const [assignedAgentNames, setAssignedAgentNames] = useState<string[]>([])
const [observedAgentNames, setObservedAgentNames] = useState<string[]>([])
@@ -463,44 +461,6 @@ export default function TeamDetailsPage() {
}
}
- async function saveContexts(next: string[], message: string) {
- if (isNew) return
- setBusy(true)
- setError('')
- try {
- const normalized = Array.from(new Set(next.map(v => v.trim()).filter(Boolean)))
- const updated = await updateAdminTeamContexts(teamId, normalized)
- const partition = partitionVisibleAccess(
- updated.contextIds || [],
- availableContextIds,
- updated.deletedContextIds || []
- )
- setAssignedContextIds(partition.active)
- setDeletedContextIds(partition.deleted)
- setSelectedContextIdsToAdd([])
- showToast(message, { tone: 'success' })
- } catch (e) {
- setError(e instanceof Error ? e.message : 'Failed to update team contexts')
- } finally {
- setBusy(false)
- }
- }
-
- async function removeContextAccess(contextId: string) {
- const shouldRemove = await confirm({
- title: 'Remove Context Access',
- message: `Remove ${teamName || 'this team'}'s access to ${contextId}?`,
- confirmLabel: 'Remove access',
- tone: 'danger',
- })
- if (!shouldRemove) return
-
- await saveContexts(
- assignedContextIds.filter(id => id !== contextId),
- 'Team contexts updated.'
- )
- }
-
async function saveAgents(next: string[], message: string) {
if (isNew) return
setBusy(true)
@@ -568,13 +528,6 @@ export default function TeamDetailsPage() {
})),
[existingMemberIds, users]
)
- const availableContextOptions = useMemo(
- () =>
- availableContextIds
- .filter(contextId => !assignedContextIds.includes(contextId))
- .map(contextId => ({ value: contextId, label: contextId })),
- [assignedContextIds, availableContextIds]
- )
const availableAgentOptions = useMemo(
() =>
hostNameOptions
@@ -613,15 +566,6 @@ export default function TeamDetailsPage() {
>
Add member
</button>
- ) : !isNew && activeTab === 'contexts' ? (
- <button
- type="button"
- className="cu-btn cu-btn--primary cu-btn--sm"
- onClick={() => setShowAddContext(true)}
- disabled={busy}
- >
- Add context
- </button>
) : !isNew && activeTab === 'agents' ? (
<button
type="button"
@@ -694,7 +638,7 @@ export default function TeamDetailsPage() {
? 'Name the new team.'
: initialLoading
? 'Loading team details...'
- : 'Members, contexts, and agent access.'
+ : 'Members and agent access.'
}
tabAriaLabel="Team sections"
tabs={
@@ -972,77 +916,6 @@ export default function TeamDetailsPage() {
</>
)}
- {activeTab === 'contexts' && (
- <>
- <p className="cu-muted cu-detail-section-copy">Contexts this team may access.</p>
- {initialLoading ? (
- <div role="list">
- {[1, 2, 3].map(i => (
- <div key={i} className="cu-skeleton--row">
- <div
- className="cu-skeleton cu-skeleton--cell"
- style={{ width: '12rem' }}
- ></div>
- <div
- className="cu-skeleton cu-skeleton--cell"
- style={{ width: '4rem' }}
- ></div>
- </div>
- ))}
- </div>
- ) : assignedContextIds.length === 0 ? (
- <div className="cu-empty" style={{ padding: '0.5rem 0' }}>
- No contexts linked.
- </div>
- ) : (
- <RecordList>
- {assignedContextIds.map(contextId => (
- <RecordListRow key={contextId} className="cu-access-row">
- <button
- type="button"
- className="cu-link"
- onClick={() => router.push(CONTROL_ROUTES.contexts.detail(contextId))}
- >
- {contextId}
- </button>
- <RowActionMenu
- ariaLabel={`Actions for context ${contextId}`}
- actions={[
- {
- key: 'view',
- label: 'View context details',
- onSelect: () =>
- router.push(CONTROL_ROUTES.contexts.detail(contextId)),
- },
- {
- key: 'remove',
- label: 'Remove context',
- danger: true,
- disabled: busy,
- onSelect: () => void removeContextAccess(contextId),
- },
- ]}
- />
- </RecordListRow>
- ))}
- </RecordList>
- )}
- {!initialLoading && deletedContextIds.length > 0 && (
- <>
- <p className="cu-muted cu-deleted-access-heading">Deleted contexts</p>
- <div role="list">
- {deletedContextIds.map(contextId => (
- <div key={contextId} className="cu-access-row" role="listitem">
- <span>{contextId}</span>
- <span className="cu-muted">Deleted</span>
- </div>
- ))}
- </div>
- </>
- )}
- </>
- )}
-
{activeTab === 'agents' && (
<>
<p className="cu-muted cu-detail-section-copy">Agents this team may use.</p>
@@ -1321,90 +1194,6 @@ export default function TeamDetailsPage() {
</div>
)}
- {showAddContext && (
- <div
- style={{
- position: 'fixed',
- inset: 0,
- background: 'rgba(0, 0, 0, 0.6)',
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- zIndex: 1000,
- padding: '1rem',
- }}
- role="presentation"
- onClick={e => {
- if (e.target === e.currentTarget && !busy) setShowAddContext(false)
- }}
- >
- <div
- className="cu-modal-panel cu-modal-panel--selection"
- role="dialog"
- aria-labelledby="add-context-title"
- onClick={e => e.stopPropagation()}
- >
- <div className="cu-modal-panel__head">
- <strong id="add-context-title" style={{ fontSize: '1rem', lineHeight: 1.35 }}>
- Add context
- </strong>
- <button
- type="button"
- className="cu-btn cu-btn--icon cu-btn--ghost"
- onClick={() => setShowAddContext(false)}
- disabled={busy}
- aria-label="Close"
- >
- <IconX width={18} height={18} />
- </button>
- </div>
-
- <div className="cu-field">
- <label htmlFor="team-context-picker">Contexts</label>
- <SelectionDropdown
- id="team-context-picker"
- inline
- value={selectedContextIdsToAdd}
- onChange={setSelectedContextIdsToAdd}
- options={availableContextOptions}
- placeholder="Select contexts"
- searchPlaceholder="Search contexts..."
- selectionLabel="Selected contexts"
- emptyLabel="No available contexts."
- disabled={busy}
- />
- </div>
-
- <div className="cu-modal-panel__foot">
- <button
- type="button"
- className="cu-btn cu-btn--ghost cu-btn--sm"
- onClick={() => setShowAddContext(false)}
- disabled={busy}
- >
- Cancel
- </button>
- <button
- type="button"
- className="cu-btn cu-btn--primary"
- onClick={() => {
- void saveContexts(
- [...assignedContextIds, ...selectedContextIdsToAdd],
- selectedContextIdsToAdd.length === 1
- ? 'Team context updated.'
- : 'Team contexts updated.'
- )
- setShowAddContext(false)
- }}
- disabled={busy || selectedContextIdsToAdd.length === 0}
- >
- {selectedContextIdsToAdd.length > 1 ? 'Add contexts' : 'Add context'}
- </button>
- </div>
- </div>
- </div>
- )}
-
{showAddAgent && (
<div
style={{
diff --git a/control-ui/app/profile-admin/users/[userId]/page.tsx b/control-ui/app/profile-admin/users/[userId]/page.tsx
index c4bc8df8d..b7eb52314 100644
--- a/control-ui/app/profile-admin/users/[userId]/page.tsx
+++ b/control-ui/app/profile-admin/users/[userId]/page.tsx
@@ -50,18 +50,11 @@ import { formatTeamRole, permissionsForTeamRole } from '../../../../lib/teamRole
type TeamRole = 'admin' | 'inviter' | 'member'
-type UserTab =
- | 'contact'
- | 'approval-dms'
- | 'communication-channels'
- | 'contexts'
- | 'teams'
- | 'agents'
+type UserTab = 'contact' | 'approval-dms' | 'communication-channels' | 'teams' | 'agents'
const USER_TABS: UserTab[] = [
'contact',
'approval-dms',
'communication-channels',
- 'contexts',
'teams',
'agents',
]
@@ -70,12 +63,12 @@ const USER_TAB_LABELS: Record<UserTab, string> = {
contact: 'Contact',
'approval-dms': 'Approval DMs',
'communication-channels': 'Communication Channels',
- contexts: 'Contexts',
teams: 'Teams',
agents: 'Agents',
}
function parseUserTab(value: string | undefined): UserTab {
+ if (value === 'contexts') return 'agents'
return USER_TABS.includes(value as UserTab) ? (value as UserTab) : 'contact'
}
@@ -93,7 +86,6 @@ export default function UserDetailsPage() {
const [error, setError] = useState('')
const [initialLoading, setInitialLoading] = useState(true)
const [editingContact, setEditingContact] = useState(false)
- const [showAddContext, setShowAddContext] = useState(false)
const [showAddAgent, setShowAddAgent] = useState(false)
const [showAddTeam, setShowAddTeam] = useState(false)
@@ -117,7 +109,6 @@ export default function UserDetailsPage() {
const [availableContextIds, setAvailableContextIds] = useState<string[]>([])
const [assignedContextIds, setAssignedContextIds] = useState<string[]>([])
const [deletedContextIds, setDeletedContextIds] = useState<string[]>([])
- const [selectedContextIdsToAdd, setSelectedContextIdsToAdd] = useState<string[]>([])
const [hosts, setHosts] = useState<HostResource[]>([])
const [assignedAgentNames, setAssignedAgentNames] = useState<string[]>([])
const [observedAgentNames, setObservedAgentNames] = useState<string[]>([])
@@ -147,13 +138,6 @@ export default function UserDetailsPage() {
).sort((a, b) => a.localeCompare(b)),
[hosts]
)
- const availableContextOptions = useMemo(
- () =>
- availableContextIds
- .filter(contextId => !assignedContextIds.includes(contextId))
- .map(contextId => ({ value: contextId, label: contextId })),
- [assignedContextIds, availableContextIds]
- )
const availableTeamOptions = useMemo(
() =>
allTeams
@@ -340,43 +324,6 @@ export default function UserDetailsPage() {
}
}
- async function saveContexts(next: string[], message: string) {
- setBusy(true)
- setError('')
- try {
- const normalized = Array.from(new Set(next.map(v => v.trim()).filter(Boolean)))
- const updated = await updateAdminUserContexts(userId, normalized)
- const partition = partitionVisibleAccess(
- updated.contextIds || [],
- availableContextIds,
- updated.deletedContextIds || []
- )
- setAssignedContextIds(partition.active)
- setDeletedContextIds(partition.deleted)
- setSelectedContextIdsToAdd([])
- showToast(message, { tone: 'success' })
- } catch (e) {
- setError(e instanceof Error ? e.message : 'Failed to update member context access')
- } finally {
- setBusy(false)
- }
- }
-
- async function removeContextAccess(contextId: string) {
- const shouldRemove = await confirm({
- title: 'Remove Context Access',
- message: `Remove ${userName || emailDraft || 'this member'}'s access to ${contextId}?`,
- confirmLabel: 'Remove access',
- tone: 'danger',
- })
- if (!shouldRemove) return
-
- await saveContexts(
- assignedContextIds.filter(id => id !== contextId),
- 'Context access updated.'
- )
- }
-
async function addUserToTeams() {
if (selectedTeamIdsToAdd.length === 0) return
setBusy(true)
@@ -553,16 +500,7 @@ export default function UserDetailsPage() {
}
const activeTabAction =
- activeTab === 'contexts' ? (
- <button
- type="button"
- className="cu-btn cu-btn--primary cu-btn--sm"
- onClick={() => setShowAddContext(true)}
- disabled={busy}
- >
- Add context
- </button>
- ) : activeTab === 'teams' ? (
+ activeTab === 'teams' ? (
<button
type="button"
className="cu-btn cu-btn--primary cu-btn--sm"
@@ -595,7 +533,7 @@ export default function UserDetailsPage() {
subtitle={
initialLoading
? 'Loading member details...'
- : 'Channels, approval DMs, context access, teams, and agents.'
+ : 'Channels, approval DMs, connector access, teams, and agents.'
}
tabAriaLabel="Member sections"
tabs={USER_TABS.map(tab => ({
@@ -968,103 +906,6 @@ export default function UserDetailsPage() {
</>
)}
- {activeTab === 'contexts' && (
- <>
- <p className="cu-muted cu-detail-section-copy">Contexts this member may access.</p>
- {initialLoading ? (
- <div className="eft-table-viewport cu-table-wrap">
- <DataTable className="eft-table cu-table">
- <thead>
- <tr>
- <th>Context</th>
- <th></th>
- </tr>
- </thead>
- <tbody>
- {[1, 2, 3].map(i => (
- <tr key={i}>
- <td>
- <div
- className="cu-skeleton cu-skeleton--cell"
- style={{ width: '10rem' }}
- ></div>
- </td>
- <td></td>
- </tr>
- ))}
- </tbody>
- </DataTable>
- </div>
- ) : assignedContextIds.length === 0 ? (
- <div className="cu-empty" style={{ padding: '0.5rem 0' }}>
- No contexts assigned.
- </div>
- ) : (
- <div className="eft-table-viewport cu-table-wrap">
- <DataTable className="eft-table cu-table">
- <thead>
- <tr>
- <th>Context</th>
- <th></th>
- </tr>
- </thead>
- <tbody>
- {assignedContextIds.map(contextId => (
- <tr key={contextId}>
- <td>
- <button
- type="button"
- className="cu-link"
- onClick={() => router.push(CONTROL_ROUTES.contexts.detail(contextId))}
- >
- {contextId}
- </button>
- </td>
- <td className="cu-table__cell-actions">
- <RowActionsMenu
- ariaLabel={`Actions for ${contextId}`}
- actions={[
- {
- key: 'view',
- label: 'View details',
- onClick: () => router.push(CONTROL_ROUTES.contexts.detail(contextId)),
- },
- {
- key: 'remove',
- label: 'Remove access',
- onClick: () => void removeContextAccess(contextId),
- disabled: busy,
- danger: true,
- },
- ]}
- />
- </td>
- </tr>
- ))}
- </tbody>
- </DataTable>
- </div>
- )}
- {!initialLoading && deletedContextIds.length > 0 && (
- <>
- <p className="cu-muted cu-deleted-access-heading">Deleted contexts</p>
- <div className="eft-table-viewport cu-table-wrap">
- <DataTable className="eft-table cu-table">
- <tbody>
- {deletedContextIds.map(contextId => (
- <tr key={contextId}>
- <td>{contextId}</td>
- <td className="cu-muted">Deleted</td>
- </tr>
- ))}
- </tbody>
- </DataTable>
- </div>
- </>
- )}
- </>
- )}
-
{activeTab === 'teams' && (
<>
<p className="cu-muted cu-detail-section-copy">Team memberships and roles.</p>
@@ -1348,90 +1189,6 @@ export default function UserDetailsPage() {
</div>
) : null}
- {showAddContext && (
- <div
- style={{
- position: 'fixed',
- inset: 0,
- background: 'rgba(0, 0, 0, 0.6)',
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- zIndex: 1000,
- padding: '1rem',
- }}
- role="presentation"
- onClick={e => {
- if (e.target === e.currentTarget && !busy) setShowAddContext(false)
- }}
- >
- <div
- className="cu-modal-panel cu-modal-panel--selection"
- role="dialog"
- aria-labelledby="add-context-title"
- onClick={e => e.stopPropagation()}
- >
- <div className="cu-modal-panel__head">
- <strong id="add-context-title" style={{ fontSize: '1rem', lineHeight: 1.35 }}>
- Add context
- </strong>
- <button
- type="button"
- className="cu-btn cu-btn--icon cu-btn--ghost"
- onClick={() => setShowAddContext(false)}
- disabled={busy}
- aria-label="Close"
- >
- <IconX width={18} height={18} />
- </button>
- </div>
-
- <div className="cu-field">
- <label htmlFor="member-context-picker">Contexts</label>
- <SelectionDropdown
- id="member-context-picker"
- inline
- value={selectedContextIdsToAdd}
- onChange={setSelectedContextIdsToAdd}
- options={availableContextOptions}
- placeholder="Select contexts"
- searchPlaceholder="Search contexts..."
- selectionLabel="Selected contexts"
- emptyLabel="No available contexts."
- disabled={busy}
- />
- </div>
-
- <div className="cu-modal-panel__foot">
- <button
- type="button"
- className="cu-btn cu-btn--ghost cu-btn--sm"
- onClick={() => setShowAddContext(false)}
- disabled={busy}
- >
- Cancel
- </button>
- <button
- type="button"
- className="cu-btn cu-btn--primary"
- onClick={() => {
- void saveContexts(
- [...assignedContextIds, ...selectedContextIdsToAdd],
- selectedContextIdsToAdd.length === 1
- ? 'Context access updated.'
- : 'Contexts access updated.'
- )
- setShowAddContext(false)
- }}
- disabled={busy || selectedContextIdsToAdd.length === 0}
- >
- {selectedContextIdsToAdd.length > 1 ? 'Add contexts' : 'Add context'}
- </button>
- </div>
- </div>
- </div>
- )}
-
{showAddTeam && (
<div
style={{
diff --git a/control-ui/components/McpServerTable.tsx b/control-ui/components/McpServerTable.tsx
index 9c516837d..8b0b8d90a 100644
--- a/control-ui/components/McpServerTable.tsx
+++ b/control-ui/components/McpServerTable.tsx
@@ -2,8 +2,9 @@
import React, { useMemo, useState } from 'react'
import { DataTable, TableRow, TableStateRow, TruncatedText } from '@clerum/frontend-components'
+import { canAssignConnectorToContext } from '../lib/connectorOAuthAccess'
import type {
- ConnectorContextBinding,
+ ConnectorAgentBinding,
McpServerStatus,
McpServerTableProps,
} from './McpServerTable.types'
@@ -16,7 +17,7 @@ import type { TableHeaderColumn } from './TableHeaderRow/types'
import { TablePanelHeader } from './TablePanelHeader'
import { IconRefresh, IconX } from './icons'
-const ENABLED_TOOLTIP = 'Enabled controls whether this server is available to contexts and agents.'
+const ENABLED_TOOLTIP = 'Enabled controls whether this server is available to agents.'
type ConnectorSortKey = 'name' | 'description' | 'managed' | 'enabled' | 'status'
type SortDirection = 'asc' | 'desc'
@@ -82,11 +83,11 @@ function StatusBadge({ status }: { status?: McpServerStatus }) {
export function McpServerTable({
items,
accessByConnectorKey,
- contexts = [],
- onOpenContext,
- onAddToContexts,
- onRemoveFromContext,
- updatingContextMembershipKey,
+ agentBindingsByConnectorName = {},
+ agentTargets = [],
+ onAddToAgents,
+ onRemoveFromAgents,
+ updatingAgentAccessKey,
onDelete,
onEdit,
deletingKey,
@@ -100,9 +101,9 @@ export function McpServerTable({
const [searchQuery, setSearchQuery] = useState('')
const [sortKey, setSortKey] = useState<ConnectorSortKey>('name')
const [sortDirection, setSortDirection] = useState<SortDirection>('asc')
- const [serverKeyAddingContexts, setServerKeyAddingContexts] = useState<string | null>(null)
+ const [serverKeyAddingAgents, setServerKeyAddingAgents] = useState<string | null>(null)
const [serverKeyViewingAccess, setServerKeyViewingAccess] = useState<string | null>(null)
- const [selectedContextNamesToAdd, setSelectedContextNamesToAdd] = useState<string[]>([])
+ const [selectedAgentNamesToAdd, setSelectedAgentNamesToAdd] = useState<string[]>([])
const accessDialogRef = React.useRef<HTMLElement | null>(null)
const accessCloseButtonRef = React.useRef<HTMLButtonElement | null>(null)
const accessOpenerRef = React.useRef<HTMLElement | null>(null)
@@ -232,19 +233,19 @@ export function McpServerTable({
return column
})
- function contextsForConnector(name: string): ConnectorContextBinding[] {
- return contexts.filter(context => context.mcpServers.includes(name))
+ function bindingsForConnector(name: string): ConnectorAgentBinding[] {
+ return agentBindingsByConnectorName[name] ?? []
}
- function openAddContexts(key: string) {
- setSelectedContextNamesToAdd([])
- setServerKeyAddingContexts(key)
+ function openAddAgents(key: string) {
+ setSelectedAgentNamesToAdd([])
+ setServerKeyAddingAgents(key)
}
- function closeAddContexts() {
- if (updatingContextMembershipKey) return
- setSelectedContextNamesToAdd([])
- setServerKeyAddingContexts(null)
+ function closeAddAgents() {
+ if (updatingAgentAccessKey) return
+ setSelectedAgentNamesToAdd([])
+ setServerKeyAddingAgents(null)
}
function openAccessDetails(key: string) {
@@ -280,7 +281,7 @@ export function McpServerTable({
/>
) : null
}
- subtitle="Browse connector deployments and context bindings."
+ subtitle="Browse connector deployments and agent access."
actionsClassName="cu-table-panel__actions--mcp"
primaryAction={
onInstallFromRegistry ? (
@@ -340,8 +341,8 @@ export function McpServerTable({
) : (
filteredRows.map(({ key, namespace, name, item }) => {
const spec = item.spec || {}
- const assignedContexts = contextsForConnector(name)
- const contextMembershipBusy = updatingContextMembershipKey === key
+ const agentBindings = bindingsForConnector(name)
+ const agentAccessBusy = updatingAgentAccessKey === key
return (
<TableRow
className={onEdit ? 'cu-table__row cu-table__row--clickable' : undefined}
@@ -378,13 +379,13 @@ export function McpServerTable({
},
]
: []),
- ...(onAddToContexts
+ ...(onAddToAgents
? [
{
- key: 'add-contexts',
- label: 'Add to contexts',
- disabled: contextMembershipBusy,
- onClick: () => openAddContexts(key),
+ key: 'add-agents',
+ label: 'Add to agents',
+ disabled: agentAccessBusy,
+ onClick: () => openAddAgents(key),
},
]
: []),
@@ -393,13 +394,16 @@ export function McpServerTable({
label: 'View access details',
onClick: () => openAccessDetails(key),
},
- ...(onRemoveFromContext
- ? assignedContexts.map(context => ({
- key: `remove-context-${context.name}`,
- label: `Remove from ${context.name}`,
- disabled: contextMembershipBusy,
+ ...(onRemoveFromAgents
+ ? agentBindings.map(binding => ({
+ key: `remove-agents-${binding.contextRef}`,
+ label:
+ binding.agents.length === 1
+ ? `Remove from ${binding.agents[0].label}`
+ : `Remove from ${binding.agents.length} agents`,
+ disabled: agentAccessBusy,
onClick: () =>
- void onRemoveFromContext({ name, namespace }, context.name),
+ void onRemoveFromAgents({ name, namespace }, binding),
}))
: []),
...(onDelete
@@ -423,44 +427,50 @@ export function McpServerTable({
</tbody>
</DataTable>
</div>
- {serverKeyAddingContexts
+ {serverKeyAddingAgents
? (() => {
- const row = rows.find(candidate => candidate.key === serverKeyAddingContexts)
- if (!row || !onAddToContexts) return null
- const assignedNames = new Set(
- contextsForConnector(row.name).map(context => context.name)
+ const row = rows.find(candidate => candidate.key === serverKeyAddingAgents)
+ if (!row || !onAddToAgents) return null
+ const boundAgentNames = new Set(
+ bindingsForConnector(row.name).flatMap(binding =>
+ binding.agents.map(agent => agent.id)
+ )
)
- const contextOptions = contexts
- .filter(context => !assignedNames.has(context.name))
- .map(context => ({
- value: context.name,
- label: context.name,
- description: context.description || undefined,
+ const agentOptions = agentTargets
+ .filter(
+ target =>
+ !boundAgentNames.has(target.name) &&
+ canAssignConnectorToContext(row.item.spec, target.contextRef)
+ )
+ .map(target => ({
+ value: target.name,
+ label: target.label,
+ description: target.name,
}))
- const busy = updatingContextMembershipKey === row.key
+ const busy = updatingAgentAccessKey === row.key
return (
<div
className="cu-modal-backdrop"
role="presentation"
onClick={event => {
- if (event.target === event.currentTarget && !busy) closeAddContexts()
+ if (event.target === event.currentTarget && !busy) closeAddAgents()
}}
>
<div
className="cu-modal-panel cu-modal-panel--selection"
role="dialog"
aria-modal="true"
- aria-labelledby="add-connector-context-title"
+ aria-labelledby="add-connector-agents-title"
onClick={event => event.stopPropagation()}
>
<div className="cu-modal-panel__head">
- <h3 id="add-connector-context-title" className="cu-modal-panel__title">
- Add connector to contexts
+ <h3 id="add-connector-agents-title" className="cu-modal-panel__title">
+ Give agents access to this connector
</h3>
<button
type="button"
className="cu-btn cu-btn--icon cu-btn--ghost"
- onClick={closeAddContexts}
+ onClick={closeAddAgents}
disabled={busy}
aria-label="Close"
>
@@ -469,17 +479,17 @@ export function McpServerTable({
</div>
<div className="cu-field">
- <label htmlFor="connector-context-picker">Contexts</label>
+ <label htmlFor="connector-agent-picker">Agents</label>
<SelectionDropdown
- id="connector-context-picker"
+ id="connector-agent-picker"
inline
- value={selectedContextNamesToAdd}
- onChange={setSelectedContextNamesToAdd}
- options={contextOptions}
- placeholder="Select contexts"
- searchPlaceholder="Search contexts..."
- selectionLabel="Selected contexts"
- emptyLabel="No available contexts."
+ value={selectedAgentNamesToAdd}
+ onChange={setSelectedAgentNamesToAdd}
+ options={agentOptions}
+ placeholder="Select agents"
+ searchPlaceholder="Search agents..."
+ selectionLabel="Selected agents"
+ emptyLabel="No other agents available."
disabled={busy}
/>
</div>
@@ -488,7 +498,7 @@ export function McpServerTable({
<button
type="button"
className="cu-btn cu-btn--ghost cu-btn--sm"
- onClick={closeAddContexts}
+ onClick={closeAddAgents}
disabled={busy}
>
Cancel
@@ -497,17 +507,23 @@ export function McpServerTable({
type="button"
className="cu-btn cu-btn--primary"
onClick={async () => {
- if (selectedContextNamesToAdd.length === 0) return
- await onAddToContexts(
+ if (selectedAgentNamesToAdd.length === 0) return
+ const selected = agentTargets.filter(target =>
+ selectedAgentNamesToAdd.includes(target.name)
+ )
+ await onAddToAgents(
{ namespace: row.namespace, name: row.name },
- selectedContextNamesToAdd
+ selected.map(target => ({
+ name: target.name,
+ contextRef: target.contextRef,
+ }))
)
- setSelectedContextNamesToAdd([])
- setServerKeyAddingContexts(null)
+ setSelectedAgentNamesToAdd([])
+ setServerKeyAddingAgents(null)
}}
- disabled={busy || selectedContextNamesToAdd.length === 0}
+ disabled={busy || selectedAgentNamesToAdd.length === 0}
>
- {selectedContextNamesToAdd.length > 1 ? 'Add to contexts' : 'Add to context'}
+ {selectedAgentNamesToAdd.length > 1 ? 'Add to agents' : 'Add to agent'}
</button>
</div>
</div>
@@ -520,17 +536,12 @@ export function McpServerTable({
const row = rows.find(candidate => candidate.key === serverKeyViewingAccess)
if (!row) return null
const access = accessByConnectorKey?.[row.key]
- const linkedContexts = contextsForConnector(row.name)
+ const linkedAgents = bindingsForConnector(row.name).flatMap(binding => binding.agents)
const groups = [
- {
- key: 'contexts',
- label: 'Contexts',
- items: linkedContexts.map(item => ({ key: item.name, label: item.name })),
- },
{
key: 'agents',
label: 'Agents',
- items: (access?.agents ?? []).map(item => ({ key: item.id, label: item.label })),
+ items: linkedAgents.map(item => ({ key: item.id, label: item.label })),
},
{
key: 'teams',
@@ -573,19 +584,7 @@ export function McpServerTable({
{group.items.length ? (
<ul className="cu-registry-context-access__list">
{group.items.map(item => (
- <li key={item.key}>
- {group.key === 'contexts' && onOpenContext ? (
- <button
- className="cu-link"
- onClick={() => onOpenContext(item.label)}
- type="button"
- >
- {item.label}
- </button>
- ) : (
- item.label
- )}
- </li>
+ <li key={item.key}>{item.label}</li>
))}
</ul>
) : (
diff --git a/control-ui/components/__tests__/HostTable.test.tsx b/control-ui/components/__tests__/HostTable.test.tsx
index b038876ad..53df92984 100644
--- a/control-ui/components/__tests__/HostTable.test.tsx
+++ b/control-ui/components/__tests__/HostTable.test.tsx
@@ -168,8 +168,8 @@ describe('HostTable providers column rendering', () => {
})
// UT-9 — the row shows the editable display name (spec.host) as the primary
-// label, with the immutable identifier (metadata.name / slug) as visible
-// secondary text; the search haystack matches BOTH.
+// label. The immutable identifier (metadata.name / slug) remains searchable
+// without restoring a visible identifier column.
describe('HostTable display name column (UT-9)', () => {
function makeDisplayHost(name: string, displayName: string): HostItem {
return {
@@ -182,20 +182,19 @@ describe('HostTable display name column (UT-9)', () => {
}
}
- it('renders the display name as primary and the slug as secondary', () => {
+ it('renders the display name as the primary row label without an identifier column', () => {
renderHostTable([makeDisplayHost('prod-x', 'Prod X')])
const row = screen.getByLabelText('Open agent prod-x')
expect(within(row).getByText('Prod X')).toBeInTheDocument()
- expect(within(row).getByText('prod-x')).toBeInTheDocument()
+ expect(within(row).queryByText('prod-x')).not.toBeInTheDocument()
})
it('falls back to the slug as the primary label when spec.host is blank', () => {
renderHostTable([makeDisplayHost('prod-x', ' ')])
const row = screen.getByLabelText('Open agent prod-x')
- // The fallback is visible in the primary and explicit identifier columns.
- expect(within(row).getAllByText('prod-x')).toHaveLength(2)
+ expect(within(row).getAllByText('prod-x')).toHaveLength(1)
})
it('filters rows by the display name', () => {
diff --git a/control-ui/components/__tests__/McpServerTable.test.tsx b/control-ui/components/__tests__/McpServerTable.test.tsx
index 7a10cf7e4..50824b3da 100644
--- a/control-ui/components/__tests__/McpServerTable.test.tsx
+++ b/control-ui/components/__tests__/McpServerTable.test.tsx
@@ -74,6 +74,10 @@ function makeContextBinding(options: {
}
}
+function makeAgentBinding(contextRef: string, agents: Array<{ id: string; label: string }>) {
+ return { contextRef, agents }
+}
+
// ─────────────────────────────────────────────────────────────────────────────
// StatusBadge precedence
// ─────────────────────────────────────────────────────────────────────────────
@@ -263,16 +267,21 @@ describe('McpServerTable — connector access summaries', () => {
render(
<McpServerTable
items={items}
- accessByConnectorKey={{
- 'mcp-server/airtable-server': {
- agents: [
+ agentBindingsByConnectorName={{
+ 'airtable-server': [
+ makeAgentBinding('ctx-alpha', [
{ id: 'agent-alpha', label: 'agent-alpha' },
{ id: 'bravo', label: 'bravo' },
{ id: 'charlie', label: 'charlie' },
{ id: 'delta', label: 'delta' },
{ id: 'echo', label: 'echo' },
{ id: 'foxtrot', label: 'foxtrot' },
- ],
+ ]),
+ ],
+ }}
+ accessByConnectorKey={{
+ 'mcp-server/airtable-server': {
+ agents: [],
users: [{ id: 'user-1', label: 'Ada Lovelace' }],
teams: [{ id: 'team-1', label: 'Research' }],
},
@@ -302,13 +311,15 @@ describe('McpServerTable — connector access summaries', () => {
}
})
- it('preserves context navigation and accessible access-dialog focus behavior', () => {
- const onOpenContext = vi.fn()
+ it('preserves accessible access-dialog focus behavior without context links', () => {
render(
<McpServerTable
items={[makeItem({ name: 'airtable-server' })]}
- contexts={[makeContextBinding({ name: 'research', mcpServers: ['airtable-server'] })]}
- onOpenContext={onOpenContext}
+ agentBindingsByConnectorName={{
+ 'airtable-server': [
+ makeAgentBinding('research', [{ id: 'agent-alpha', label: 'agent-alpha' }]),
+ ],
+ }}
/>
)
@@ -319,14 +330,12 @@ describe('McpServerTable — connector access summaries', () => {
fireEvent.click(screen.getByRole('menuitem', { name: 'View access details' }))
const close = screen.getByRole('button', { name: 'Close' })
- const contextLink = screen.getByRole('button', { name: 'research' })
+ const agentLabel = screen.getByText('agent-alpha')
expect(close).toHaveFocus()
fireEvent.keyDown(window, { key: 'Tab' })
- expect(contextLink).toHaveFocus()
+ expect(agentLabel).toBeInTheDocument()
fireEvent.keyDown(window, { key: 'Tab', shiftKey: true })
expect(close).toHaveFocus()
- fireEvent.click(contextLink)
- expect(onOpenContext).toHaveBeenCalledWith('research')
fireEvent.keyDown(window, { key: 'Escape' })
expect(screen.queryByRole('dialog', { name: 'Access for airtable-server' })).toBeNull()
@@ -410,15 +419,11 @@ describe('McpServerTable — connector access summaries', () => {
})
})
-describe('McpServerTable — context membership', () => {
+describe('McpServerTable — agent membership', () => {
it('does not display a stale legacy contextRef without authoritative allowlist membership', () => {
render(
<McpServerTable
items={[makeItem({ name: 'airtable-server', contextRef: 'removed-context' })]}
- contexts={[
- makeContextBinding({ name: 'removed-context' }),
- makeContextBinding({ name: 'active-context', mcpServers: ['another-server'] }),
- ]}
accessByConnectorKey={{}}
/>
)
@@ -427,72 +432,73 @@ describe('McpServerTable — context membership', () => {
fireEvent.click(screen.getByRole('menuitem', { name: 'View access details' }))
expect(screen.queryByText('removed-context')).not.toBeInTheDocument()
- expect(screen.getByText('No contexts linked.')).toBeInTheDocument()
expect(screen.getByText('No agents linked.')).toBeInTheDocument()
expect(screen.getByText('No teams linked.')).toBeInTheDocument()
expect(screen.getByText('No users linked.')).toBeInTheDocument()
})
- it('shows attached contexts and lets an operator remove the connector from one', async () => {
- const onRemoveFromContext = vi.fn().mockResolvedValue(undefined)
+ it('shows attached agents and lets an operator remove the connector from one binding', async () => {
+ const onRemoveFromAgents = vi.fn().mockResolvedValue(undefined)
const items = [makeItem({ name: 'airtable-server' })]
render(
<McpServerTable
items={items}
- contexts={[
- makeContextBinding({
- name: 'research',
- description: 'Research tools',
- mcpServers: ['airtable-server'],
- }),
- makeContextBinding({ name: 'sales' }),
- ]}
- onAddToContexts={vi.fn().mockResolvedValue(undefined)}
- onRemoveFromContext={onRemoveFromContext}
+ agentBindingsByConnectorName={{
+ 'airtable-server': [
+ makeAgentBinding('research', [{ id: 'agent-alpha', label: 'Agent Alpha' }]),
+ ],
+ }}
+ onAddToAgents={vi.fn().mockResolvedValue(undefined)}
+ onRemoveFromAgents={onRemoveFromAgents}
/>
)
fireEvent.click(screen.getByRole('button', { name: 'Actions for connector airtable-server' }))
- fireEvent.click(screen.getByRole('menuitem', { name: 'Remove from research' }))
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Remove from Agent Alpha' }))
- expect(onRemoveFromContext).toHaveBeenCalledWith(
+ expect(onRemoveFromAgents).toHaveBeenCalledWith(
{ namespace: 'mcp-server', name: 'airtable-server' },
- 'research'
+ makeAgentBinding('research', [{ id: 'agent-alpha', label: 'Agent Alpha' }])
)
})
- it('uses the Context detail selection modal to add the connector to more contexts', async () => {
- const onAddToContexts = vi.fn().mockResolvedValue(undefined)
+ it('uses the agent selection modal to add the connector to more agents', async () => {
+ const onAddToAgents = vi.fn().mockResolvedValue(undefined)
const items = [makeItem({ name: 'airtable-server' })]
render(
<McpServerTable
items={items}
- contexts={[
- makeContextBinding({ name: 'research', mcpServers: ['airtable-server'] }),
- makeContextBinding({ name: 'sales', description: 'Sales tools' }),
+ agentBindingsByConnectorName={{
+ 'airtable-server': [
+ makeAgentBinding('research', [{ id: 'agent-alpha', label: 'Agent Alpha' }]),
+ ],
+ }}
+ agentTargets={[
+ { name: 'agent-alpha', label: 'Agent Alpha', contextRef: 'research' },
+ { name: 'sales', label: 'Sales', contextRef: 'sales-context' },
]}
- onAddToContexts={onAddToContexts}
- onRemoveFromContext={vi.fn().mockResolvedValue(undefined)}
+ onAddToAgents={onAddToAgents}
+ onRemoveFromAgents={vi.fn().mockResolvedValue(undefined)}
/>
)
fireEvent.click(screen.getByRole('button', { name: 'Actions for connector airtable-server' }))
- fireEvent.click(screen.getByRole('menuitem', { name: 'Add to contexts' }))
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Add to agents' }))
- const dialog = screen.getByRole('dialog', { name: 'Add connector to contexts' })
+ const dialog = screen.getByRole('dialog', { name: 'Give agents access to this connector' })
expect(dialog).toBeInTheDocument()
expect(dialog).toHaveAttribute('aria-modal', 'true')
expect(dialog.parentElement).toHaveClass('cu-modal-backdrop')
- expect(screen.getByLabelText('Contexts')).toBeInTheDocument()
- expect(screen.queryByText('No available contexts.')).not.toBeInTheDocument()
+ expect(screen.getByLabelText('Agents')).toBeInTheDocument()
+ expect(screen.queryByText('No other agents available.')).not.toBeInTheDocument()
- fireEvent.click(screen.getByRole('option', { name: 'sales' }))
- fireEvent.click(screen.getByRole('button', { name: 'Add to context' }))
+ fireEvent.click(screen.getByRole('option', { name: 'Sales' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Add to agent' }))
await waitFor(() =>
- expect(onAddToContexts).toHaveBeenCalledWith(
+ expect(onAddToAgents).toHaveBeenCalledWith(
{ namespace: 'mcp-server', name: 'airtable-server' },
- ['sales']
+ [{ name: 'sales', contextRef: 'sales-context' }]
)
)
})
diff --git a/control-ui/lib/__tests__/routeResolution.test.ts b/control-ui/lib/__tests__/routeResolution.test.ts
index 32588f10f..f65ed0658 100644
--- a/control-ui/lib/__tests__/routeResolution.test.ts
+++ b/control-ui/lib/__tests__/routeResolution.test.ts
@@ -207,23 +207,4 @@ describe('CONTROL_ROUTES App Router resolution', () => {
])
)
})
-
- it('resolves public detail roots and their default tab slugs', async () => {
- const redirects = ((await nextConfig.redirects?.()) ?? []) as RouteRule[]
- const rewrites = ((await nextConfig.rewrites?.()) ?? []) as RouteRule[]
- const appRoutes = appRoutePatterns()
-
- for (const pathname of [
- CONTROL_ROUTES.usersAndTeams.user('user-1'),
- CONTROL_ROUTES.usersAndTeams.userTab('user-1', 'contact'),
- CONTROL_ROUTES.usersAndTeams.team('team-1'),
- CONTROL_ROUTES.usersAndTeams.teamTab('team-1', 'members'),
- CONTROL_ROUTES.agents.detail('agent-1'),
- CONTROL_ROUTES.agents.tab('agent-1', 'overview'),
- CONTROL_ROUTES.contexts.detail('context-1'),
- CONTROL_ROUTES.contexts.connectors('context-1'),
- ]) {
- expect(resolvesToAppRoute(pathname, redirects, rewrites, appRoutes)).toBe(true)
- }
- })
})
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index c0efbcd99..278a1675a 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.543",
+ "version": "0.1.544",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.543",
+ "version": "0.1.544",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/frontend-components": "file:../packages/frontend-components",
diff --git a/control-ui/package.json b/control-ui/package.json
index dd26adc96..62b7f4db8 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.543",
+ "version": "0.1.544",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",