Skip to content

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

TypeScript

fix(control-ui): r1-h3 retain connector access failures

Josué050f6a59ad9c
diff --git a/control-ui/app/mcp-servers/page.tsx b/control-ui/app/mcp-servers/page.tsx
index e353bd1f8..5d502bbfe 100644
--- a/control-ui/app/mcp-servers/page.tsx
+++ b/control-ui/app/mcp-servers/page.tsx
@@ -297,19 +297,19 @@ export default function McpServersPage() {
async function addConnectorToAgents(
server: { name: string; namespace: string },
agents: Array<{ name: string; contextRef: string }>
- ) {
+ ): Promise<boolean> {
const key = `${server.namespace}/${server.name}`
const contextRefs = [...new Set(agents.map(agent => agent.contextRef))]
const connector = mcpServers.find(item => connectorKey(item) === key)
const oauthScopeError = connectorContextAssignmentError(connector?.spec, contextRefs)
if (oauthScopeError) {
setError(oauthScopeError)
- return
+ return false
}
const resolvedTargets = contextRefs.map(contextRef => contextForAlias(contexts, contextRef))
if (resolvedTargets.some(target => !target)) {
setError('One or more selected agents could not be resolved. Please refresh and try again.')
- return
+ return false
}
const targets = Array.from(
new Map(
@@ -340,9 +340,11 @@ export default function McpServersPage() {
: `Connector ${server.name} added to ${agents.length} agents.`,
{ tone: 'success' }
)
+ return true
} catch (e) {
- if (isSilentApiError(e)) return
+ if (isSilentApiError(e)) return false
setError(connectorAccessMutationError(e, `Failed to give agents access to ${server.name}`))
+ return false
} finally {
setUpdatingAgentAccessKey(null)
}
diff --git a/control-ui/components/McpServerTable.tsx b/control-ui/components/McpServerTable.tsx
index 81c4121da..3a365261a 100644
--- a/control-ui/components/McpServerTable.tsx
+++ b/control-ui/components/McpServerTable.tsx
@@ -108,6 +108,7 @@ export function McpServerTable({
const [sortKey, setSortKey] = useState<ConnectorSortKey>('name')
const [sortDirection, setSortDirection] = useState<SortDirection>('asc')
const [serverKeyAddingAgents, setServerKeyAddingAgents] = useState<string | null>(null)
+ const [addAgentsError, setAddAgentsError] = useState('')
const [serverKeyViewingAccess, setServerKeyViewingAccess] = useState<string | null>(null)
const [selectedAgentNamesToAdd, setSelectedAgentNamesToAdd] = useState<string[]>([])
const accessDialogRef = React.useRef<HTMLElement | null>(null)
@@ -243,17 +244,19 @@ export function McpServerTable({
return agentBindingsByConnectorName[name] ?? []
}
- function openAddAgents(key: string) {
- setSelectedAgentNamesToAdd([])
- setServerKeyAddingAgents(key)
- }
-
function closeAddAgents() {
if (updatingAgentAccessKey) return
+ setAddAgentsError('')
setSelectedAgentNamesToAdd([])
setServerKeyAddingAgents(null)
}
+ function openAddAgents(key: string) {
+ setAddAgentsError('')
+ setSelectedAgentNamesToAdd([])
+ setServerKeyAddingAgents(key)
+ }
+
function openAccessDetails(key: string) {
accessOpenerRef.current =
document.activeElement instanceof HTMLElement ? document.activeElement : null
@@ -459,17 +462,24 @@ export function McpServerTable({
<MultiSelectActionDialog
actionLabel={selectedAgentNamesToAdd.length > 1 ? 'Add to agents' : 'Add to agent'}
emptyMessage="No other agents available."
+ error={addAgentsError || undefined}
items={agentOptions}
noMatchesMessage="No matching agents."
onAction={async selectedIds => {
const selected = agentTargets.filter(target => selectedIds.includes(target.name))
- await onAddToAgents(
+ const added = await onAddToAgents(
{ namespace: row.namespace, name: row.name },
selected.map(target => ({
name: target.name,
contextRef: target.contextRef,
}))
)
+ if (!added) {
+ setAddAgentsError(
+ 'Connector access could not be updated. Review the error and retry.'
+ )
+ return
+ }
setSelectedAgentNamesToAdd([])
setServerKeyAddingAgents(null)
}}
diff --git a/control-ui/components/McpServerTable.types.ts b/control-ui/components/McpServerTable.types.ts
index 2cfa81679..5d9dc6e1b 100644
--- a/control-ui/components/McpServerTable.types.ts
+++ b/control-ui/components/McpServerTable.types.ts
@@ -75,7 +75,7 @@ export type McpServerTableProps = {
onAddToAgents?: (
server: ServerRef,
agents: Array<{ name: string; contextRef: string }>
- ) => Promise<void>
+ ) => Promise<boolean>
onRemoveFromAgents?: (server: ServerRef, binding: ConnectorAgentBinding) => Promise<void>
updatingAgentAccessKey?: string | null
onDelete?: (server: ServerRef) => Promise<void>
diff --git a/control-ui/components/__tests__/McpServerTable.test.tsx b/control-ui/components/__tests__/McpServerTable.test.tsx
index 3b74b594a..b31ebcc06 100644
--- a/control-ui/components/__tests__/McpServerTable.test.tsx
+++ b/control-ui/components/__tests__/McpServerTable.test.tsx
@@ -431,7 +431,7 @@ describe('McpServerTable — agent membership', () => {
makeAgentBinding('research', [{ id: 'agent-alpha', label: 'Agent Alpha' }]),
],
}}
- onAddToAgents={vi.fn().mockResolvedValue(undefined)}
+ onAddToAgents={vi.fn().mockResolvedValue(true)}
onRemoveFromAgents={onRemoveFromAgents}
/>
)
@@ -446,7 +446,7 @@ describe('McpServerTable — agent membership', () => {
})
it('uses the agent selection modal to add the connector to more agents', async () => {
- const onAddToAgents = vi.fn().mockResolvedValue(undefined)
+ const onAddToAgents = vi.fn().mockResolvedValue(true)
const items = [makeItem({ name: 'airtable-server' })]
render(
<McpServerTable
@@ -485,6 +485,30 @@ describe('McpServerTable — agent membership', () => {
)
)
})
+
+ it('retains the selected agent and dialog error when connector access fails', async () => {
+ const onAddToAgents = vi.fn().mockResolvedValue(false)
+ render(
+ <McpServerTable
+ items={[makeItem({ name: 'airtable-server' })]}
+ agentTargets={[{ name: 'sales', label: 'Sales', contextRef: 'sales-context' }]}
+ onAddToAgents={onAddToAgents}
+ />
+ )
+
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for connector airtable-server' }))
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Add to agents' }))
+ const dialog = screen.getByRole('dialog', { name: 'Give agents access to this connector' })
+ const sales = within(dialog).getByRole('checkbox', { name: /Sales/ })
+ fireEvent.click(sales)
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Add to agent' }))
+
+ expect(await within(dialog).findByRole('alert')).toHaveTextContent(
+ 'Connector access could not be updated'
+ )
+ expect(sales).toBeChecked()
+ expect(dialog).toBeInTheDocument()
+ })
})
// ─────────────────────────────────────────────────────────────────────────────
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index f86739981..66155611a 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.627",
+ "version": "0.1.628",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.627",
+ "version": "0.1.628",
"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 1c40a4a97..9ee5d9fcd 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.627",
+ "version": "0.1.628",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",