Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(connectors): surface connect/disconnect write failures to the user (R1-B1)
Diego Zacarias114d0c044517
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/useConnectorsController.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/useConnectorsController.test.tsxindex ec487e3a3..2f0aff46e 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/useConnectorsController.test.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/useConnectorsController.test.tsx@@ -131,6 +131,56 @@ describe('useConnectorsController — click→IPC invariants (T5, T4)', () => {await waitFor(() => expect(connectorNames(result)).toEqual(['monday']))})+ it('surfaces an action error when a disconnect WRITE fails, without changing the list (B-1)', async () => {+ const rpc = installClerum()+ const { result } = renderController()++ await act(async () => {+ await result.current.refresh()+ })+ await waitFor(() => expect(connectorNames(result)).toEqual(['shared-drive', 'monday']))++ // The revoke rejects (403 context_membership_denied / 502 / network). Pre-B-1+ // the rejection was swallowed and the screen matched a cancelled dialog.+ rpc.disconnectMcpServer.mockRejectedValueOnce(new Error('context_membership_denied'))+ await act(async () => {+ // The hook no longer rejects; guard anyway so a regression (re-throw)+ // surfaces as a failed assertion below, not an unhandled rejection.+ await result.current+ .disconnect({ agentName: AGENT, contextRef: CTX, connector: SHARED })+ .catch(() => undefined)+ })++ // Observable: an error is surfaced, the grant is still listed (nothing was+ // revoked), and the row is no longer busy.+ await waitFor(() =>+ expect(result.current.actionError).toEqual(+ expect.stringContaining('context_membership_denied')+ )+ )+ expect(connectorNames(result)).toEqual(['shared-drive', 'monday'])+ expect(result.current.pendingKey).toBeNull()+ })++ it('clears a prior action error when the next action starts (B-1)', async () => {+ const rpc = installClerum()+ const { result } = renderController()++ rpc.disconnectMcpServer.mockRejectedValueOnce(new Error('boom'))+ await act(async () => {+ await result.current+ .disconnect({ agentName: AGENT, contextRef: CTX, connector: SHARED })+ .catch(() => undefined)+ })+ await waitFor(() => expect(result.current.actionError).toContain('boom'))++ // A fresh action resets the banner before it runs.+ await act(async () => {+ await result.current.authorize({ agentName: AGENT, contextRef: CTX, connector: USER })+ })+ expect(result.current.actionError).toBeNull()+ })+it('disconnect does NOT refresh the panel when the confirm dialog is cancelled', async () => {const rpc = installClerum()const { result } = renderController()diff --git a/desktop-app/ui/src/hooks/domain/useConnectorsController.ts b/desktop-app/ui/src/hooks/domain/useConnectorsController.tsindex ca8abae20..553a12aba 100644--- a/desktop-app/ui/src/hooks/domain/useConnectorsController.ts+++ b/desktop-app/ui/src/hooks/domain/useConnectorsController.ts@@ -2,6 +2,7 @@ import { useCallback, useMemo, useState } from 'react'import { useQuery, useQueryClient } from '@tanstack/react-query'import type { RpcAgentConnectors, RpcConnector } from '../../../../src/types'import { connectorRowKey } from '../../lib/connectorRows'+import { formatMcpServerDisplayName } from '../../lib/format'import { desktopQueryKeys } from './queryKeys'const EMPTY_AGENTS: RpcAgentConnectors[] = []@@ -10,6 +11,22 @@ function toErrorMessage(error: unknown): string {return error instanceof Error ? error.message : String(error)}+/**+ * User-facing copy for a connect/disconnect WRITE failure. The action call+ * sites used to swallow the rejection (`.catch(() => undefined)`), so a 403 /+ * 502 / network drop looked identical to a cancelled dialog: the grant stayed+ * live and the user believed they had changed it. The hook now records the+ * outcome and both pages render it in the error banner they already mount.+ */+function toActionErrorMessage(+ verb: 'connect' | 'disconnect',+ connector: Pick<RpcConnector, 'name'>,+ error: unknown+): string {+ const name = formatMcpServerDisplayName(connector.name)+ return `Couldn't ${verb} "${name}". ${toErrorMessage(error)}`+}+/*** A connector is "shared by the team" when its grant is keyed by Context, not by* user (spec §1.3). Authorizing/disconnecting it affects EVERYONE in the@@ -37,6 +54,11 @@ export type ConnectorActionInput = {export function useConnectorsController() {const queryClient = useQueryClient()const [pendingKey, setPendingKey] = useState<string | null>(null)+ // The OUTCOME of the last write (connect/disconnect). The hook owns the action+ // lifecycle (`pendingKey` start / `finally` end); it must also own the error,+ // because neither page imports `pushToast` and the query `error` below only+ // ever reflects the READ (`listConnectors`), never a write.+ const [actionError, setActionError] = useState<string | null>(null)// Mirrors the sibling data-controllers (useMcpServersDataController /// useContextsDataController): the query is app-coordinated, never@@ -80,6 +102,7 @@ export function useConnectorsController() {// Anchor the busy state to the VISIBLE (context, server) row, not to the// representative agent, so the spinner tracks the row the user clicked.const key = connectorRowKey(contextRef, connector.name)+ setActionError(null)setPendingKey(key)try {// The grant becomes present only after the OAuth deep-link returns; U3's@@ -88,6 +111,8 @@ export function useConnectorsController() {await window.clerum.rpc.connectMcpServer(connector.name, agentName, contextId, {confirmShared: shared,})+ } catch (error) {+ setActionError(toActionErrorMessage('connect', connector, error))} finally {setPendingKey(current => (current === key ? null : current))}@@ -102,6 +127,7 @@ export function useConnectorsController() {// Anchor the busy state to the VISIBLE (context, server) row, not to the// representative agent, so the spinner tracks the row the user clicked.const key = connectorRowKey(contextRef, connector.name)+ setActionError(null)setPendingKey(key)try {const result = await window.clerum.rpc.disconnectMcpServer(@@ -116,6 +142,12 @@ export function useConnectorsController() {await refresh()}return result+ } catch (error) {+ // A rejected DELETE (403 context_membership_denied, 502, network) leaves+ // the grant LIVE; surface it so the final screen is not identical to a+ // cancelled dialog. Returns undefined (no confirmed revoke) after that.+ setActionError(toActionErrorMessage('disconnect', connector, error))+ return undefined} finally {setPendingKey(current => (current === key ? null : current))}@@ -129,6 +161,7 @@ export function useConnectorsController() {() => ({loading: query.status === 'pending' || query.fetchStatus === 'fetching',error: query.error ? toErrorMessage(query.error) : null,+ actionError,agents,pendingKey,refresh,@@ -137,6 +170,7 @@ export function useConnectorsController() {disconnect,}),[+ actionError,agents,authorize,disconnect,diff --git a/desktop-app/ui/src/pages/ContextDetailsPage.tsx b/desktop-app/ui/src/pages/ContextDetailsPage.tsxindex b95e40c29..5ff0c5673 100644--- a/desktop-app/ui/src/pages/ContextDetailsPage.tsx+++ b/desktop-app/ui/src/pages/ContextDetailsPage.tsx@@ -1,5 +1,13 @@import { useEffect, useMemo, useState } from 'react'-import { Button, DataTable, EmptyState, Pill, ReferenceTag, TabButton } from '@components/Common'+import {+ Button,+ DataTable,+ EmptyState,+ Pill,+ ReferenceTag,+ StatusBanner,+ TabButton,+} from '@components/Common'import { PageBreadcrumb } from '@components/PageBreadcrumb'import { ResourceBreadcrumbSwitcher } from '@components/ResourceBreadcrumbSwitcher'import { scopeCaption, statusPresentation } from '@lib/connectorPresentation'@@ -50,6 +58,7 @@ export function ContextDetailsPage() {const {agents: connectorAgents,pendingKey: connectorPendingKey,+ actionError: connectorActionError,authorize: authorizeConnector,disconnect: disconnectConnector,} = useConnectorsController()@@ -548,6 +557,9 @@ export function ContextDetailsPage() {{activeTab === 'mcp-servers' && (<div className="context-resource-list">+ {connectorActionError ? (+ <StatusBanner tone="error">{connectorActionError}</StatusBanner>+ ) : null}{selectedContextMcpServersUnscoped && (<p className="muted">Preview mode: this list is not yet filtered by the selected context.@@ -653,7 +665,8 @@ export function ContextDetailsPage() {loading={busy}onClick={event => {event.stopPropagation()- disconnectConnector(actionInput).catch(() => undefined)+ // Failures surface via `connectorActionError`.+ void disconnectConnector(actionInput)}}size="sm"variant="ghost"@@ -667,7 +680,7 @@ export function ContextDetailsPage() {loading={busy}onClick={event => {event.stopPropagation()- authorizeConnector(actionInput).catch(() => undefined)+ void authorizeConnector(actionInput)}}size="sm"variant="soft"diff --git a/desktop-app/ui/src/pages/McpServersPage.tsx b/desktop-app/ui/src/pages/McpServersPage.tsxindex bbbd81ccc..10b180a5d 100644--- a/desktop-app/ui/src/pages/McpServersPage.tsx+++ b/desktop-app/ui/src/pages/McpServersPage.tsx@@ -141,7 +141,8 @@ function ConnectorRowView({}export function McpServersPage() {- const { loading, error, agents, pendingKey, authorize, disconnect } = useConnectorsController()+ const { loading, error, actionError, agents, pendingKey, authorize, disconnect } =+ useConnectorsController()const { handleOpenContextDetails, handleOpenAgentWorkspace } = useNavigationContext()const rows = useMemo(() => deriveConnectorRows(agents), [agents])@@ -158,7 +159,11 @@ export function McpServersPage() {</div><div className="page-layout">- {error ? <StatusBanner tone="error">{error}</StatusBanner> : null}+ {error ? (+ <StatusBanner tone="error">{error}</StatusBanner>+ ) : actionError ? (+ <StatusBanner tone="error">{actionError}</StatusBanner>+ ) : null}<section className="page-card mcp-servers-board-card" aria-label="Connectors">{loading && !hasRows ? (@@ -196,10 +201,12 @@ export function McpServersPage() {row={row}busy={pendingKey === row.key}onAuthorize={input => {- authorize(input).catch(() => undefined)+ // The hook records any write failure in `actionError` and+ // never rejects, so the call site no longer swallows it.+ void authorize(input)}}onDisconnect={input => {- disconnect(input).catch(() => undefined)+ void disconnect(input)}}onOpenContext={contextRef =>handleOpenContextDetails(contextRef, 'mcp-servers')