Skip to content

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

TypeScript

fix(desktop-ui): restore OAuth authorize/disconnect in the agent Connectors tab

Diego Zacariase3c01c2cf43d
diff --git a/desktop-app/ui/src/components/McpServerHealthTable.tsx b/desktop-app/ui/src/components/McpServerHealthTable.tsx
index 77af9168e..2558bd25c 100644
--- a/desktop-app/ui/src/components/McpServerHealthTable.tsx
+++ b/desktop-app/ui/src/components/McpServerHealthTable.tsx
@@ -7,7 +7,11 @@ import {
mergeAgentHealth,
} from '../../../src/mcpServerHealth'
import type { AgentWithMcpServers, HostRuntimeStatus } from '../../../src/types'
-import type { McpServerHealthTableProps } from './McpServerHealthTable.types'
+import type { ConnectorActionInput } from '../hooks/domain/useConnectorsController'
+import type {
+ McpServerConnectorAction,
+ McpServerHealthTableProps,
+} from './McpServerHealthTable.types'
const LABEL_TEXT: Record<McpServerUiLabel, string> = {
running: 'Running',
@@ -42,7 +46,11 @@ export function McpServerHealthTable({
refreshing,
defaultExpanded = false,
alwaysExpanded = false,
+ connectorActions,
+ onAuthorize,
+ onDisconnect,
}: McpServerHealthTableProps) {
+ const showActions = connectorActions !== undefined
const [expanded, setExpanded] = useState(defaultExpanded)
const isExpanded = alwaysExpanded || expanded
@@ -187,14 +195,29 @@ export function McpServerHealthTable({
<th className="da-table__col-header" scope="col">
MCP Server Name
</th>
- <th className="da-table__col-header da-table__col-header--right" scope="col">
+ <th
+ className={`da-table__col-header${showActions ? '' : ' da-table__col-header--right'}`}
+ scope="col"
+ >
Status
</th>
+ {showActions ? (
+ <th className="da-table__col-header da-table__col-header--right" scope="col">
+ Actions
+ </th>
+ ) : null}
</tr>
</thead>
<tbody>
{table.rows.map(row => (
- <McpServerHealthRow key={row.name} row={row} />
+ <McpServerHealthRow
+ key={row.name}
+ row={row}
+ showActions={showActions}
+ action={connectorActions?.get(row.name)}
+ onAuthorize={onAuthorize}
+ onDisconnect={onDisconnect}
+ />
))}
</tbody>
</DataTable>
@@ -204,7 +227,19 @@ export function McpServerHealthTable({
)
}
-function McpServerHealthRow({ row }: { row: MergedMcpServerRow }) {
+function McpServerHealthRow({
+ row,
+ showActions,
+ action,
+ onAuthorize,
+ onDisconnect,
+}: {
+ row: MergedMcpServerRow
+ showActions: boolean
+ action: McpServerConnectorAction | undefined
+ onAuthorize?: (input: ConnectorActionInput) => void
+ onDisconnect?: (input: ConnectorActionInput) => void
+}) {
const label = row.label
const hint = row.reason ? (REASON_HINT[row.reason] ?? '') : row.message || ''
const needsAttention = ATTENTION_LABELS.has(label)
@@ -226,7 +261,7 @@ function McpServerHealthRow({ row }: { row: MergedMcpServerRow }) {
) : null}
</span>
</td>
- <td className="da-table__cell da-table__cell--right">
+ <td className={`da-table__cell${showActions ? '' : ' da-table__cell--right'}`}>
<span className="mcp-health-status">
<span
className={`mcp-health-chip mcp-health-chip--${label}`}
@@ -236,6 +271,43 @@ function McpServerHealthRow({ row }: { row: MergedMcpServerRow }) {
</span>
</span>
</td>
+ {showActions ? (
+ <td className="da-table__cell da-table__cell--right">
+ {action ? (
+ action.authorized ? (
+ <Button
+ color="danger"
+ disabled={action.busy}
+ loading={action.busy}
+ onClick={event => {
+ event.stopPropagation()
+ onDisconnect?.(action.actionInput)
+ }}
+ onKeyDown={event => event.stopPropagation()}
+ size="sm"
+ variant="ghost"
+ >
+ Disconnect
+ </Button>
+ ) : (
+ <Button
+ color="primary"
+ disabled={action.busy}
+ loading={action.busy}
+ onClick={event => {
+ event.stopPropagation()
+ onAuthorize?.(action.actionInput)
+ }}
+ onKeyDown={event => event.stopPropagation()}
+ size="sm"
+ variant="soft"
+ >
+ Authorize
+ </Button>
+ )
+ ) : null}
+ </td>
+ ) : null}
</tr>
)
}
diff --git a/desktop-app/ui/src/components/McpServerHealthTable.types.ts b/desktop-app/ui/src/components/McpServerHealthTable.types.ts
index 4c185cb9d..648bf8312 100644
--- a/desktop-app/ui/src/components/McpServerHealthTable.types.ts
+++ b/desktop-app/ui/src/components/McpServerHealthTable.types.ts
@@ -1,3 +1,21 @@
+import type { ConnectorActionInput } from '../hooks/domain/useConnectorsController'
+
+/**
+ * Per-connector OAuth action data for one health row, keyed by mcp-server name.
+ * The parent (AgentWorkspace) derives this from `deriveConnectorRows` filtered to
+ * the selected agent, including ONLY rows for which `isActionableConnector` is
+ * true — so the presence of an entry means the row has an Authorize/Disconnect
+ * button. The table stays dumb: it never re-derives actionability.
+ */
+export interface McpServerConnectorAction {
+ /** Passed straight back to the parent's `authorize`/`disconnect` handlers. */
+ actionInput: ConnectorActionInput
+ /** `true` → render Disconnect; `false` → render Authorize. */
+ authorized: boolean
+ /** Busy state anchored to the grant (`pendingKey === grantKey`) — disables/loads the button. */
+ busy: boolean
+}
+
export interface McpServerHealthTableProps {
hostRef: string
/** Names this agent is configured to use (from session catalog). */
@@ -24,4 +42,15 @@ export interface McpServerHealthTableProps {
* Forces the table body to stay expanded and disables collapsing.
*/
alwaysExpanded?: boolean
+ /**
+ * Optional per-connector OAuth action data, keyed by mcp-server name. When
+ * provided, an Actions column renders; a row whose name maps to an entry gets
+ * an Authorize/Disconnect button. Absent (health-only usage) → no Actions
+ * column, identical to the prior two-column table.
+ */
+ connectorActions?: Map<string, McpServerConnectorAction>
+ /** Fired when the Authorize button is clicked for a `requires_setup` connector. */
+ onAuthorize?: (input: ConnectorActionInput) => void
+ /** Fired when the Disconnect button is clicked for an `authorized` connector. */
+ onDisconnect?: (input: ConnectorActionInput) => void
}
diff --git a/desktop-app/ui/src/components/agents/AgentWorkspace.tsx b/desktop-app/ui/src/components/agents/AgentWorkspace.tsx
index a10021028..529f7f568 100644
--- a/desktop-app/ui/src/components/agents/AgentWorkspace.tsx
+++ b/desktop-app/ui/src/components/agents/AgentWorkspace.tsx
@@ -11,14 +11,21 @@ import type { PageBreadcrumbItem } from '@components/PageBreadcrumb/types'
import { ResourceBreadcrumbSwitcher } from '@components/ResourceBreadcrumbSwitcher'
import { IconAgents } from '@components/SidebarNav/icons'
import { useAgentsDataController } from '@hooks/domain/useAgentsDataController'
+import {
+ type ConnectorActionInput,
+ isActionableConnector,
+ useConnectorsController,
+} from '@hooks/domain/useConnectorsController'
import { useContextsDataController } from '@hooks/domain/useContextsDataController'
import { useMcpServersDataController } from '@hooks/domain/useMcpServersDataController'
import { useTeamsDataController } from '@hooks/domain/useTeamsDataController'
import { useClickOutside } from '@hooks/useClickOutside'
+import { deriveConnectorRows } from '@lib/connectorRows'
import { deriveScopedMembers } from '@lib/scopedMembers'
import type { ScopedMemberContextDetails, ScopedMemberTeamRow } from '@lib/scopedMembers.types'
import type { AgentWorkspaceRoute } from '../../uiTypes'
import { McpServerHealthTable } from '../McpServerHealthTable'
+import type { McpServerConnectorAction } from '../McpServerHealthTable.types'
import { SharedFilesTab } from '../SharedFilesTab'
import { ActivityDashboard } from './ActivityDashboard'
import { AgentTitleSelector } from './AgentTitleSelector'
@@ -92,6 +99,16 @@ export function AgentWorkspace({ mode = 'agents', scrollContainerRef }: AgentWor
const activeSessionState = activeChatId ? sessionStateByChatId[activeChatId] : undefined
const { hostRuntimeStatus } = useMcpRuntimeContext()
const { scrollChatToBottom } = useAgentChatActionsContext()
+ // Connectors action controller (spec §5.E). Its own observer over the shared,
+ // app-coordinated `connectors` query cache — same pattern McpServersPage uses.
+ // `pendingKey`/`authorize`/`disconnect` MUST come from this same instance so
+ // the busy spinner and the action stay paired.
+ const {
+ agents: connectorAgents,
+ pendingKey: connectorPendingKey,
+ authorize: authorizeConnector,
+ disconnect: disconnectConnector,
+ } = useConnectorsController()
const [chatScrollNavVisible, setChatScrollNavVisible] = useState(true)
const [scrollToBottomChatId, setScrollToBottomChatId] = useState<string | null>(null)
@@ -135,6 +152,43 @@ export function AgentWorkspace({ mode = 'agents', scrollContainerRef }: AgentWor
const selectedAgentMcpServerNames = selectedAgent
? selectedAgentMcpServers.map(server => server.name)
: []
+
+ // OAuth Authorize/Disconnect actions for THIS agent's connectors, keyed by
+ // mcp-server name so the health table can join them onto its rows. Reuse the
+ // shared `deriveConnectorRows` fold (one row per (connector, agent), canonical
+ // status stamped) filtered to `selectedAgent`, keeping only actionable
+ // (oauth-governed) connectors — a `no_oauth` row is Secret-managed and has no
+ // button. Busy is anchored to the GRANT (`pendingKey === grantKey`) so a shared
+ // grant shows every sibling busy, exactly like McpServersPage.
+ //
+ // Join invariant: the button surfaces on the health table's rows, which are the
+ // agent's MAPPED mcp-servers (`selectedAgentMcpServers`). Mapping is independent
+ // of authorization, so a mapped-but-unauthorized oauth server (`requires_setup`)
+ // still has a health row and therefore an Authorize button — the case this fix
+ // restores. A connector that `listConnectors` reports but the catalog does not
+ // map to this agent is intentionally NOT this agent's connector and shows no row
+ // here. The only gap is transient: while the catalog is mid-hydration
+ // (`selectedAgentMcpServerMappingAvailable` false) there are no rows and thus no
+ // buttons, which self-heals once the post-auth bootstrap populates the catalog.
+ const connectorActionsByName = useMemo(() => {
+ if (!selectedAgent) return undefined
+ const map = new Map<string, McpServerConnectorAction>()
+ for (const row of deriveConnectorRows(connectorAgents)) {
+ if (row.agentName !== selectedAgent) continue
+ if (!isActionableConnector(row.connector)) continue
+ const actionInput: ConnectorActionInput = {
+ agentName: row.agentName,
+ contextRef: row.contextRef,
+ connector: row.connector,
+ }
+ map.set(row.connector.name, {
+ actionInput,
+ authorized: row.connector.status === 'authorized',
+ busy: connectorPendingKey === row.grantKey,
+ })
+ }
+ return map
+ }, [connectorAgents, selectedAgent, connectorPendingKey])
const selectedAgentContext = selectedAgent
? String(agentContextByName[selectedAgent] || '').trim()
: ''
@@ -445,6 +499,13 @@ export function AgentWorkspace({ mode = 'agents', scrollContainerRef }: AgentWor
status={hostRuntimeStatus}
now={mcpHealthNow}
alwaysExpanded
+ connectorActions={connectorActionsByName}
+ onAuthorize={input => {
+ authorizeConnector(input).catch(() => undefined)
+ }}
+ onDisconnect={input => {
+ disconnectConnector(input).catch(() => undefined)
+ }}
/>
</section>
)}
diff --git a/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.chatScroll.test.tsx b/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.chatScroll.test.tsx
index 7e20ed42c..55bfc17ba 100644
--- a/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.chatScroll.test.tsx
+++ b/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.chatScroll.test.tsx
@@ -43,6 +43,22 @@ vi.mock('@hooks/domain/useMcpServersDataController', () => ({
selectedAgentMcpServers: [],
}),
}))
+// AgentWorkspace now mounts useConnectorsController (Connectors tab OAuth
+// actions). Its useQuery needs a QueryClientProvider this test does not set up;
+// stub the hook while keeping the real pure helpers (isActionableConnector).
+vi.mock('@hooks/domain/useConnectorsController', async importActual => ({
+ ...(await importActual<typeof import('@hooks/domain/useConnectorsController')>()),
+ useConnectorsController: () => ({
+ loading: false,
+ error: null,
+ agents: [],
+ pendingKey: null,
+ refresh: vi.fn(),
+ reset: vi.fn(),
+ authorize: vi.fn(async () => undefined),
+ disconnect: vi.fn(async () => undefined),
+ }),
+}))
vi.mock('../ComposerPanel', () => ({ ComposerPanel: () => null }))
vi.mock('../ContextWindowIndicator', () => ({ ContextWindowIndicator: () => null }))
vi.mock('../InFlightAssistantPlaceholder', () => ({ InFlightAssistantPlaceholder: () => null }))
diff --git a/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.connectors.test.tsx b/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.connectors.test.tsx
new file mode 100644
index 000000000..5c0ca7c3c
--- /dev/null
+++ b/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.connectors.test.tsx
@@ -0,0 +1,209 @@
+// @vitest-environment jsdom
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { cleanup, fireEvent, render, screen, within } from '@testing-library/react'
+import type { RpcConnectorsResult } from '../../../../../src/types'
+import { AgentWorkspace } from '../AgentWorkspace'
+
+// Regression (agent Connectors tab lost OAuth Authorize/Disconnect): the tab
+// used to render ONLY the health table, which never had the action. This test
+// drives the join between the shared connectors controller and the health table.
+
+const mcpMock = vi.hoisted(() => ({
+ selectedAgentMcpServers: [] as { name: string }[],
+}))
+
+const navMock = vi.hoisted(() => ({
+ selectedAgent: 'trader' as string | null,
+ selectedAgentRoute: 'mcp-servers' as string,
+}))
+
+// Controlled connectors controller. Spies are asserted for the exact action
+// payload; `agents` is typed off the RpcConnectorsResult contract (T1 — derived
+// from the producer's shape, not an invented payload).
+const connectorsMock = vi.hoisted(() => ({
+ agents: [] as RpcConnectorsResult['agents'],
+ pendingKey: null as string | null,
+ authorize: vi.fn(async () => undefined),
+ disconnect: vi.fn(async () => undefined),
+}))
+
+vi.mock('@hooks/domain/useAgentsDataController', () => ({
+ useAgentsDataController: () => ({ agentNames: ['trader'] }),
+}))
+vi.mock('@hooks/domain/useContextsDataController', () => ({
+ useContextsDataController: () => ({ accessCatalog: null }),
+}))
+vi.mock('@hooks/domain/useMcpServersDataController', () => ({
+ useMcpServersDataController: () => ({
+ agentContextByName: {},
+ agentDisplayByName: {},
+ selectedAgentMcpServers: mcpMock.selectedAgentMcpServers,
+ }),
+}))
+vi.mock('@hooks/domain/useTeamsDataController', () => ({
+ useTeamsDataController: () => ({
+ teams: [],
+ currentTeamId: '',
+ teamMembers: [],
+ teamDirectory: {},
+ ensureHydrated: vi.fn(async () => undefined),
+ }),
+}))
+vi.mock('@contexts/AuthContext', () => ({
+ useAuthContext: () => ({ me: null }),
+}))
+vi.mock('@contexts/NavigationContext', () => ({
+ useNavigationContext: () => ({
+ selectedAgent: navMock.selectedAgent,
+ selectedAgentRoute: navMock.selectedAgentRoute,
+ handleBackToAgents: vi.fn(),
+ handleOpenAgentWorkspace: vi.fn(),
+ handleSelectChatAgent: vi.fn(),
+ }),
+}))
+vi.mock('@contexts/ChatListContext', () => ({
+ useChatListContext: () => ({ sessionStateByChatId: {}, activeChatId: null }),
+}))
+vi.mock('@contexts/McpRuntimeContext', () => ({
+ useMcpRuntimeContext: () => ({ hostRuntimeStatus: null }),
+}))
+vi.mock('@contexts/AgentChatActionsContext', () => ({
+ useAgentChatActionsContext: () => ({ scrollChatToBottom: vi.fn() }),
+}))
+vi.mock('@hooks/useClickOutside', () => ({ useClickOutside: vi.fn() }))
+vi.mock('../ComposerPanel', () => ({ ComposerPanel: () => null }))
+vi.mock('../ChatThread', () => ({ ChatThread: () => null }))
+
+// Keep the real pure helpers (isActionableConnector), stub only the hook so it
+// serves the controlled payload without a QueryClientProvider.
+vi.mock('@hooks/domain/useConnectorsController', async importActual => ({
+ ...(await importActual<typeof import('@hooks/domain/useConnectorsController')>()),
+ useConnectorsController: () => ({
+ loading: false,
+ error: null,
+ agents: connectorsMock.agents,
+ pendingKey: connectorsMock.pendingKey,
+ refresh: vi.fn(),
+ reset: vi.fn(),
+ authorize: connectorsMock.authorize,
+ disconnect: connectorsMock.disconnect,
+ }),
+}))
+
+// One agent ('trader') with an authorized oauth connector, a requires_setup
+// oauth connector, and a no_oauth (static) connector. Typed off the contract.
+const CONNECTORS: RpcConnectorsResult = {
+ userId: 'user-1',
+ agents: [
+ {
+ name: 'trader',
+ contextRef: 'ctx-1',
+ connectors: [
+ {
+ name: 'monday',
+ provider: 'monday',
+ authKind: 'oauth-user',
+ grantScope: 'user',
+ status: 'authorized',
+ },
+ {
+ name: 'clickup',
+ provider: 'clickup',
+ authKind: 'oauth-user',
+ grantScope: 'user',
+ status: 'requires_setup',
+ },
+ { name: 'filesystem', authKind: 'static', status: 'no_oauth' },
+ ],
+ },
+ ],
+}
+
+function renderTab() {
+ return render(<AgentWorkspace scrollContainerRef={{ current: null }} />)
+}
+
+const healthRow = (name: string) => screen.getByTestId(`mcp-health-row-${name}`)
+
+describe('AgentWorkspace — Connectors tab OAuth actions', () => {
+ afterEach(() => {
+ cleanup()
+ vi.clearAllMocks()
+ navMock.selectedAgent = 'trader'
+ navMock.selectedAgentRoute = 'mcp-servers'
+ connectorsMock.agents = []
+ connectorsMock.pendingKey = null
+ mcpMock.selectedAgentMcpServers = []
+ })
+
+ it('renders an Authorize button for a requires_setup connector and calls authorize with the agent-scoped action', () => {
+ connectorsMock.agents = CONNECTORS.agents
+ mcpMock.selectedAgentMcpServers = [
+ { name: 'monday' },
+ { name: 'clickup' },
+ { name: 'filesystem' },
+ ]
+
+ renderTab()
+
+ const clickup = healthRow('clickup')
+ const authorizeBtn = within(clickup).getByRole('button', { name: 'Authorize' })
+ fireEvent.click(authorizeBtn)
+
+ expect(connectorsMock.authorize).toHaveBeenCalledTimes(1)
+ expect(connectorsMock.authorize).toHaveBeenCalledWith({
+ agentName: 'trader',
+ contextRef: 'ctx-1',
+ connector: expect.objectContaining({
+ name: 'clickup',
+ status: 'requires_setup',
+ authKind: 'oauth-user',
+ }),
+ })
+ expect(connectorsMock.disconnect).not.toHaveBeenCalled()
+ })
+
+ it('renders a Disconnect button for an authorized connector and calls disconnect with the agent-scoped action', () => {
+ connectorsMock.agents = CONNECTORS.agents
+ mcpMock.selectedAgentMcpServers = [
+ { name: 'monday' },
+ { name: 'clickup' },
+ { name: 'filesystem' },
+ ]
+
+ renderTab()
+
+ const monday = healthRow('monday')
+ const disconnectBtn = within(monday).getByRole('button', { name: 'Disconnect' })
+ fireEvent.click(disconnectBtn)
+
+ expect(connectorsMock.disconnect).toHaveBeenCalledTimes(1)
+ expect(connectorsMock.disconnect).toHaveBeenCalledWith({
+ agentName: 'trader',
+ contextRef: 'ctx-1',
+ connector: expect.objectContaining({
+ name: 'monday',
+ status: 'authorized',
+ authKind: 'oauth-user',
+ }),
+ })
+ })
+
+ it('renders no OAuth action button for a no_oauth connector', () => {
+ connectorsMock.agents = CONNECTORS.agents
+ mcpMock.selectedAgentMcpServers = [
+ { name: 'monday' },
+ { name: 'clickup' },
+ { name: 'filesystem' },
+ ]
+
+ renderTab()
+
+ const filesystem = healthRow('filesystem')
+ const actionButtons = within(filesystem)
+ .queryAllByRole('button')
+ .map(b => b.textContent?.trim())
+ .filter(label => label === 'Authorize' || label === 'Disconnect')
+ expect(actionButtons).toEqual([])
+ })
+})
diff --git a/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.displayName.test.tsx b/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.displayName.test.tsx
index e0aa47c17..d1c827d6d 100644
--- a/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.displayName.test.tsx
+++ b/desktop-app/ui/src/components/agents/__tests__/AgentWorkspace.displayName.test.tsx
@@ -73,6 +73,23 @@ vi.mock('@contexts/AgentChatActionsContext', () => ({
vi.mock('@hooks/useClickOutside', () => ({ useClickOutside: vi.fn() }))
+// AgentWorkspace now mounts useConnectorsController (Connectors tab OAuth
+// actions). Its useQuery needs a QueryClientProvider these render() calls don't
+// set up; stub the hook while keeping the real pure helpers (isActionableConnector).
+vi.mock('@hooks/domain/useConnectorsController', async importActual => ({
+ ...(await importActual<typeof import('@hooks/domain/useConnectorsController')>()),
+ useConnectorsController: () => ({
+ loading: false,
+ error: null,
+ agents: [],
+ pendingKey: null,
+ refresh: vi.fn(),
+ reset: vi.fn(),
+ authorize: vi.fn(async () => undefined),
+ disconnect: vi.fn(async () => undefined),
+ }),
+}))
+
// Chat-mode children pull in a web of chat/composer contexts that are irrelevant
// to the title-selector label under test; stub them so the selector renders in
// isolation.