The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore(mcp): remove McpConnectionHealthToolbar and its integration
Steven Enamakelf16b80e4e0ab
diff --git a/app/src/components/channels/mcp/McpConnectionHealthToolbar.test.tsx b/app/src/components/channels/mcp/McpConnectionHealthToolbar.test.tsxdeleted file mode 100644index a0d44817e3..0000000000--- a/app/src/components/channels/mcp/McpConnectionHealthToolbar.test.tsx+++ /dev/null@@ -1,334 +0,0 @@-/**- * Tests for McpConnectionHealthToolbar — aggregate status counts +- * Retry All / Disconnect All bulk-action surface with confirmation- * dialog.- */-import { act, fireEvent, render, screen } from '@testing-library/react';-import { describe, expect, it, vi } from 'vitest';--import McpConnectionHealthToolbar from './McpConnectionHealthToolbar';-import type { ConnStatus, ServerStatus } from './types';--const statusFor = (server_id: string, status: ServerStatus): ConnStatus => ({- server_id,- qualified_name: `acme/${server_id}`,- display_name: server_id,- status,- tool_count: status === 'connected' ? 3 : 0,-});--describe('McpConnectionHealthToolbar', () => {- it('renders nothing when statuses array is empty', () => {- const { container } = render(- <McpConnectionHealthToolbar- statuses={[]}- onReconnect={async () => {}}- onDisconnect={async () => {}}- />- );- expect(container.firstChild).toBeNull();- });-- it('always shows connected + disconnected counts (even when zero)', () => {- render(- <McpConnectionHealthToolbar- statuses={[statusFor('a', 'disconnected')]}- onReconnect={async () => {}}- onDisconnect={async () => {}}- />- );- expect(screen.getByText('0 connected')).toBeInTheDocument();- expect(screen.getByText('1 idle')).toBeInTheDocument();- });-- it('only shows connecting count when there are connecting servers', () => {- const { rerender } = render(- <McpConnectionHealthToolbar- statuses={[statusFor('a', 'connected'), statusFor('b', 'error')]}- onReconnect={async () => {}}- onDisconnect={async () => {}}- />- );- expect(screen.queryByText(/connecting/)).not.toBeInTheDocument();- rerender(- <McpConnectionHealthToolbar- statuses={[statusFor('a', 'connected'), statusFor('b', 'connecting')]}- onReconnect={async () => {}}- onDisconnect={async () => {}}- />- );- expect(screen.getByText('1 connecting')).toBeInTheDocument();- });-- it('only shows error count when there are errored servers', () => {- const { rerender } = render(- <McpConnectionHealthToolbar- statuses={[statusFor('a', 'connected')]}- onReconnect={async () => {}}- onDisconnect={async () => {}}- />- );- expect(screen.queryByText(/error/)).not.toBeInTheDocument();- rerender(- <McpConnectionHealthToolbar- statuses={[statusFor('a', 'connected'), statusFor('b', 'error')]}- onReconnect={async () => {}}- onDisconnect={async () => {}}- />- );- expect(screen.getByText('1 error')).toBeInTheDocument();- });-- it('aggregates counts correctly across a mixed status set', () => {- render(- <McpConnectionHealthToolbar- statuses={[- statusFor('a', 'connected'),- statusFor('b', 'connected'),- statusFor('c', 'error'),- statusFor('d', 'connecting'),- statusFor('e', 'disconnected'),- statusFor('f', 'disconnected'),- ]}- onReconnect={async () => {}}- onDisconnect={async () => {}}- />- );- expect(screen.getByText('2 connected')).toBeInTheDocument();- expect(screen.getByText('1 connecting')).toBeInTheDocument();- expect(screen.getByText('1 error')).toBeInTheDocument();- expect(screen.getByText('2 idle')).toBeInTheDocument();- });-- it('hides "Retry all" button when there are no errors', () => {- render(- <McpConnectionHealthToolbar- statuses={[statusFor('a', 'connected'), statusFor('b', 'disconnected')]}- onReconnect={async () => {}}- onDisconnect={async () => {}}- />- );- expect(screen.queryByRole('button', { name: /Retry all/i })).not.toBeInTheDocument();- });-- it('hides "Disconnect all" button when nothing is connected', () => {- render(- <McpConnectionHealthToolbar- statuses={[statusFor('a', 'error'), statusFor('b', 'disconnected')]}- onReconnect={async () => {}}- onDisconnect={async () => {}}- />- );- expect(screen.queryByRole('button', { name: /Disconnect all/i })).not.toBeInTheDocument();- });-- it('shows "Retry all (N)" button with the correct error count when errors exist', () => {- render(- <McpConnectionHealthToolbar- statuses={[statusFor('a', 'error'), statusFor('b', 'error'), statusFor('c', 'connected')]}- onReconnect={async () => {}}- onDisconnect={async () => {}}- />- );- expect(- screen.getByRole('button', { name: 'Retry all 2 errored MCP servers' })- ).toBeInTheDocument();- expect(screen.getByText('Retry all (2)')).toBeInTheDocument();- });-- it('calls onReconnect with the errored server IDs when "Retry all" is clicked', async () => {- const onReconnect = vi.fn().mockResolvedValue(undefined);- render(- <McpConnectionHealthToolbar- statuses={[- statusFor('srv-1', 'error'),- statusFor('srv-2', 'connected'),- statusFor('srv-3', 'error'),- ]}- onReconnect={onReconnect}- onDisconnect={async () => {}}- />- );- await act(async () => {- fireEvent.click(screen.getByRole('button', { name: /Retry all/i }));- });- expect(onReconnect).toHaveBeenCalledTimes(1);- expect(onReconnect).toHaveBeenCalledWith(['srv-1', 'srv-3']);- });-- it('does NOT call onDisconnect directly — opens confirm dialog first', () => {- const onDisconnect = vi.fn();- render(- <McpConnectionHealthToolbar- statuses={[statusFor('a', 'connected')]}- onReconnect={async () => {}}- onDisconnect={onDisconnect}- />- );- fireEvent.click(screen.getByRole('button', { name: /Disconnect all/i }));- expect(onDisconnect).not.toHaveBeenCalled();- // Confirm dialog appears with accessible structure. Migrated onto the- // shared `AlertDialog` (#radix-ui-foundation) per the "use AlertDialog for- // disconnect confirmations" convention — its Radix content carries- // `role="alertdialog"`, not `role="dialog"`, and this build's Radix- // doesn't stamp `aria-modal` (the real focus-trap + inert-background- // behavior is still there).- const dialog = screen.getByRole('alertdialog');- expect(dialog).toBeInTheDocument();- expect(screen.getByText('Disconnect all MCP servers?')).toBeInTheDocument();- });-- it('cancel in the dialog closes it without calling onDisconnect', () => {- const onDisconnect = vi.fn();- render(- <McpConnectionHealthToolbar- statuses={[statusFor('a', 'connected')]}- onReconnect={async () => {}}- onDisconnect={onDisconnect}- />- );- fireEvent.click(- screen.getByRole('button', { name: /Disconnect all \d+ connected MCP servers/i })- );- fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));- expect(onDisconnect).not.toHaveBeenCalled();- expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument();- });-- it('Escape closes the confirm dialog without calling onDisconnect', () => {- const onDisconnect = vi.fn();- render(- <McpConnectionHealthToolbar- statuses={[statusFor('a', 'connected')]}- onReconnect={async () => {}}- onDisconnect={onDisconnect}- />- );- fireEvent.click(- screen.getByRole('button', { name: /Disconnect all \d+ connected MCP servers/i })- );- expect(screen.getByRole('alertdialog')).toBeInTheDocument();- act(() => {- fireEvent.keyDown(document, { key: 'Escape' });- });- expect(onDisconnect).not.toHaveBeenCalled();- expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument();- });-- it('confirm in the dialog fires onDisconnect with connected IDs and closes the dialog', async () => {- const onDisconnect = vi.fn().mockResolvedValue(undefined);- render(- <McpConnectionHealthToolbar- statuses={[- statusFor('srv-1', 'connected'),- statusFor('srv-2', 'error'),- statusFor('srv-3', 'connected'),- ]}- onReconnect={async () => {}}- onDisconnect={onDisconnect}- />- );- fireEvent.click(- screen.getByRole('button', { name: /Disconnect all \d+ connected MCP servers/i })- );- // Confirm button inside dialog- const dialogConfirm = screen.getAllByRole('button', { name: 'Disconnect all' })[0];- await act(async () => {- fireEvent.click(dialogConfirm);- });- expect(onDisconnect).toHaveBeenCalledTimes(1);- expect(onDisconnect).toHaveBeenCalledWith(['srv-1', 'srv-3']);- expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument();- });-- it('disables both action buttons while a bulk operation is pending', async () => {- let resolveOp: (() => void) | undefined;- const onReconnect = vi.fn(- () =>- new Promise<void>(res => {- resolveOp = res;- })- );- render(- <McpConnectionHealthToolbar- statuses={[statusFor('a', 'error'), statusFor('b', 'connected')]}- onReconnect={onReconnect}- onDisconnect={async () => {}}- />- );- fireEvent.click(screen.getByRole('button', { name: /Retry all/i }));- // While the promise is pending, both buttons should be disabled.- expect(screen.getByRole('button', { name: /Retry all/i })).toBeDisabled();- expect(- screen.getByRole('button', { name: /Disconnect all \d+ connected MCP servers/i })- ).toBeDisabled();- // Resolve and re-render — buttons re-enable.- await act(async () => {- resolveOp?.();- });- expect(screen.getByRole('button', { name: /Retry all/i })).not.toBeDisabled();- });-- it('surfaces a thrown error from onReconnect via role="alert"', async () => {- const onReconnect = vi.fn().mockRejectedValue(new Error('upstream RPC died'));- render(- <McpConnectionHealthToolbar- statuses={[statusFor('a', 'error')]}- onReconnect={onReconnect}- onDisconnect={async () => {}}- />- );- await act(async () => {- fireEvent.click(screen.getByRole('button', { name: /Retry all/i }));- });- const alert = screen.getByRole('alert');- expect(alert).toHaveTextContent('upstream RPC died');- });-- it('falls back to a generic error message when the thrown value is not an Error instance', async () => {- const onReconnect = vi.fn().mockRejectedValue('not-an-error-object');- render(- <McpConnectionHealthToolbar- statuses={[statusFor('a', 'error')]}- onReconnect={onReconnect}- onDisconnect={async () => {}}- />- );- await act(async () => {- fireEvent.click(screen.getByRole('button', { name: /Retry all/i }));- });- expect(screen.getByRole('alert')).toHaveTextContent('Bulk operation failed. See logs.');- });-- it('the summary region is a polite live region with an accessible label', () => {- render(- <McpConnectionHealthToolbar- statuses={[statusFor('a', 'connected')]}- onReconnect={async () => {}}- onDisconnect={async () => {}}- />- );- const status = screen.getByRole('status', { name: 'MCP connection health summary' });- expect(status).toHaveAttribute('aria-live', 'polite');- });-- it('confirm dialog body interpolates the connected count', () => {- render(- <McpConnectionHealthToolbar- statuses={[- statusFor('a', 'connected'),- statusFor('b', 'connected'),- statusFor('c', 'connected'),- ]}- onReconnect={async () => {}}- onDisconnect={async () => {}}- />- );- fireEvent.click(- screen.getByRole('button', { name: /Disconnect all \d+ connected MCP servers/i })- );- expect(- screen.getByText(/This will disconnect 3 currently-connected MCP servers/)- ).toBeInTheDocument();- });-});diff --git a/app/src/components/channels/mcp/McpConnectionHealthToolbar.tsx b/app/src/components/channels/mcp/McpConnectionHealthToolbar.tsxdeleted file mode 100644index 71786104d9..0000000000--- a/app/src/components/channels/mcp/McpConnectionHealthToolbar.tsx+++ /dev/null@@ -1,244 +0,0 @@-/**- * Aggregate health summary + bulk actions for the MCP server list.- *- * Lives in the left pane of `McpServersTab` above the list. Reads the- * polled `statuses` array (no extra fetches) and surfaces:- *- * - Live counts per state (connected / connecting / error / disconnected),- * announced through a `role="status" aria-live="polite"` region so- * screen readers hear updates as the polling loop refreshes.- * - `Retry all` button — visible only when there are servers in error- * state; iterates through them and calls `onReconnect` once.- * - `Disconnect all` button — visible only when there are connected- * servers; opens a confirm dialog (`role="dialog" aria-modal`) before- * firing `onDisconnect`.- *- * Parent (`McpServersTab`) owns the actual `mcpClientsApi` calls and the- * subsequent `fetchStatuses()` refresh; this component only orchestrates- * the user intent.- */-import { useMemo, useState } from 'react';--import { useT } from '../../../lib/i18n/I18nContext';-import {- AlertDialogAction,- AlertDialogCancel,- AlertDialogContent,- AlertDialogDescription,- AlertDialogFooter,- AlertDialogRoot,- AlertDialogTitle,-} from '../../ui/AlertDialog';-import Button from '../../ui/Button';-import type { ConnStatus } from './types';--interface McpConnectionHealthToolbarProps {- statuses: ConnStatus[];- /** Reconnect every server in error state. Caller resolves after refresh. */- onReconnect: (serverIds: string[]) => Promise<void>;- /** Disconnect every currently-connected server. Caller resolves after refresh. */- onDisconnect: (serverIds: string[]) => Promise<void>;-}--interface HealthCounts {- connectedIds: string[];- errorIds: string[];- connectedCount: number;- connectingCount: number;- errorCount: number;- disconnectedCount: number;-}--const computeHealthCounts = (statuses: ConnStatus[]): HealthCounts => {- const connectedIds: string[] = [];- const errorIds: string[] = [];- let connectingCount = 0;- let disconnectedCount = 0;- for (const s of statuses) {- switch (s.status) {- case 'connected':- connectedIds.push(s.server_id);- break;- case 'error':- errorIds.push(s.server_id);- break;- case 'connecting':- connectingCount += 1;- break;- // An `unauthorized` server is not connected, but it must NOT join the- // `errorIds` set — "Retry all" blindly reconnects those, which would just- // 401 again. Re-auth is a deliberate per-server action (sign in / token),- // so we surface it under the disconnected tally rather than as an error.- case 'unauthorized':- case 'disconnected':- disconnectedCount += 1;- break;- }- }- return {- connectedIds,- errorIds,- connectedCount: connectedIds.length,- connectingCount,- errorCount: errorIds.length,- disconnectedCount,- };-};--const McpConnectionHealthToolbar = ({- statuses,- onReconnect,- onDisconnect,-}: McpConnectionHealthToolbarProps) => {- const { t } = useT();- const [isOperating, setIsOperating] = useState(false);- const [confirmDisconnect, setConfirmDisconnect] = useState(false);- const [opError, setOpError] = useState<string | null>(null);-- const counts = useMemo(() => computeHealthCounts(statuses), [statuses]);-- // Escape closing the "Disconnect all" confirmation WITHOUT firing the bulk- // RPC is now `AlertDialog` / Radix's own default behavior — no hand-rolled- // listener needed.-- // Nothing to summarise — match the parent's existing "hide chrome when- // there's nothing installed" pattern.- if (statuses.length === 0) return null;-- const runRetryAll = async () => {- if (counts.errorIds.length === 0 || isOperating) return;- setIsOperating(true);- setOpError(null);- try {- await onReconnect(counts.errorIds);- } catch (err) {- setOpError(err instanceof Error ? err.message : t('mcp.health.opErrorGeneric'));- } finally {- setIsOperating(false);- }- };-- const runDisconnectAll = async () => {- if (counts.connectedIds.length === 0 || isOperating) return;- setConfirmDisconnect(false);- setIsOperating(true);- setOpError(null);- try {- await onDisconnect(counts.connectedIds);- } catch (err) {- setOpError(err instanceof Error ? err.message : t('mcp.health.opErrorGeneric'));- } finally {- setIsOperating(false);- }- };-- return (- <div className="mb-2 rounded-lg border border-line bg-surface px-2.5 py-2">- <div className="flex items-center justify-between gap-2 mb-1.5">- <span className="text-[10px] font-semibold text-content-muted uppercase tracking-wide">- {t('mcp.health.title')}- </span>- <div className="flex items-center gap-2">- {counts.errorCount > 0 && (- <Button- variant="tertiary"- size="xs"- onClick={() => void runRetryAll()}- disabled={isOperating}- aria-label={t('mcp.health.retryAllAria').replace(- '{count}',- String(counts.errorCount)- )}- className="h-auto p-0 text-[10px] font-medium text-amber-700 hover:underline disabled:no-underline disabled:opacity-50 dark:text-amber-300">- {t('mcp.health.retryAll').replace('{count}', String(counts.errorCount))}- </Button>- )}- {counts.connectedCount > 0 && (- <Button- variant="tertiary"- size="xs"- onClick={() => setConfirmDisconnect(true)}- disabled={isOperating}- aria-label={t('mcp.health.disconnectAllAria').replace(- '{count}',- String(counts.connectedCount)- )}- className="h-auto p-0 text-[10px] font-medium text-content-secondary hover:underline disabled:no-underline disabled:opacity-50">- {t('mcp.health.disconnectAll').replace('{count}', String(counts.connectedCount))}- </Button>- )}- </div>- </div>- <div- role="status"- aria-live="polite"- aria-label={t('mcp.health.summaryAria')}- className="flex flex-wrap items-center gap-x-2 gap-y-1 text-[10px] text-content-secondary">- <span className="inline-flex items-center gap-1">- <span className="w-1.5 h-1.5 rounded-full bg-sage-500" aria-hidden="true" />- <span>- {t('mcp.health.connectedCount').replace('{count}', String(counts.connectedCount))}- </span>- </span>- {counts.connectingCount > 0 && (- <span className="inline-flex items-center gap-1">- <span className="w-1.5 h-1.5 rounded-full bg-amber-400" aria-hidden="true" />- <span>- {t('mcp.health.connectingCount').replace('{count}', String(counts.connectingCount))}- </span>- </span>- )}- {counts.errorCount > 0 && (- <span className="inline-flex items-center gap-1">- <span className="w-1.5 h-1.5 rounded-full bg-coral-500" aria-hidden="true" />- <span>{t('mcp.health.errorCount').replace('{count}', String(counts.errorCount))}</span>- </span>- )}- <span className="inline-flex items-center gap-1">- <span className="w-1.5 h-1.5 rounded-full bg-surface-strong" aria-hidden="true" />- <span>- {t('mcp.health.disconnectedCount').replace('{count}', String(counts.disconnectedCount))}- </span>- </span>- </div>-- {opError && (- <p- role="alert"- className="mt-1.5 text-[10px] text-coral-700 dark:text-coral-300 wrap-break-word">- {opError}- </p>- )}-- <AlertDialogRoot open={confirmDisconnect} onOpenChange={setConfirmDisconnect}>- <AlertDialogContent>- <AlertDialogTitle>{t('mcp.health.disconnectConfirm.title')}</AlertDialogTitle>- <AlertDialogDescription>- {t('mcp.health.disconnectConfirm.body').replace(- '{count}',- String(counts.connectedCount)- )}- </AlertDialogDescription>- <AlertDialogFooter>- <AlertDialogCancel asChild>- <Button variant="secondary" size="sm">- {t('mcp.health.disconnectConfirm.cancel')}- </Button>- </AlertDialogCancel>- <AlertDialogAction asChild>- <Button- variant="primary"- tone="danger"- size="sm"- onClick={() => void runDisconnectAll()}>- {t('mcp.health.disconnectConfirm.confirm')}- </Button>- </AlertDialogAction>- </AlertDialogFooter>- </AlertDialogContent>- </AlertDialogRoot>- </div>- );-};--export default McpConnectionHealthToolbar;diff --git a/app/src/components/channels/mcp/McpServersTab.tsx b/app/src/components/channels/mcp/McpServersTab.tsxindex 0baf18b45e..df2931fff6 100644--- a/app/src/components/channels/mcp/McpServersTab.tsx+++ b/app/src/components/channels/mcp/McpServersTab.tsx@@ -16,7 +16,6 @@ import { useT } from '../../../lib/i18n/I18nContext';import { mcpClientsApi } from '../../../services/api/mcpClientsApi';import Button from '../../ui/Button';import InstalledServerDetail from './InstalledServerDetail';-import McpConnectionHealthToolbar from './McpConnectionHealthToolbar';import McpJsonEditor from './McpJsonEditor';import McpRegistryBrowser from './McpRegistryBrowser';import McpServerRows from './McpServerRows';@@ -148,34 +147,6 @@ const McpServersTab = ({ tab, onTabChange }: McpServersTabProps) => {await fetchStatuses();}, [loadInstalled, fetchStatuses]);- // Bulk lifecycle actions for the health toolbar. One failure doesn't abort the- // batch (allSettled), and we always refresh status so the dots reflect reality- // — but if any call rejected we then throw so the toolbar can surface the- // failure (otherwise a partial/total failure would look like success).- const handleReconnectAll = useCallback(- async (serverIds: string[]) => {- log('reconnect all: %o', serverIds);- const results = await Promise.allSettled(serverIds.map(id => mcpClientsApi.connect(id)));- await fetchStatuses();- if (results.some(r => r.status === 'rejected')) {- throw new Error(t('mcp.health.opErrorGeneric'));- }- },- [fetchStatuses, t]- );-- const handleDisconnectAll = useCallback(- async (serverIds: string[]) => {- log('disconnect all: %o', serverIds);- const results = await Promise.allSettled(serverIds.map(id => mcpClientsApi.disconnect(id)));- await fetchStatuses();- if (results.some(r => r.status === 'rejected')) {- throw new Error(t('mcp.health.opErrorGeneric'));- }- },- [fetchStatuses, t]- );-const selectedServer =view.mode === 'detail' ? (servers.find(s => s.server_id === view.serverId) ?? null) : null;const selectedConnStatus =@@ -246,16 +217,6 @@ const McpServersTab = ({ tab, onTabChange }: McpServersTabProps) => {</p>)}- {/* Connection health + bulk lifecycle actions. Reads the polled statuses- — no extra fetches. */}- {statuses.length > 0 && (- <McpConnectionHealthToolbar- statuses={statuses}- onReconnect={handleReconnectAll}- onDisconnect={handleDisconnectAll}- />- )}-<McpServerRowsservers={rows}statuses={statuses}