Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
Merge remote-tracking branch 'origin/dev' into feat/ux-improvements-28
Miguelon Peluchon84264f8b81df
diff --cc control-ui/app/mcp-servers/page.tsxindex 609eca96e,78daef225..0a193682c--- a/control-ui/app/mcp-servers/page.tsx+++ b/control-ui/app/mcp-servers/page.tsx@@@ -1,10 -1,8 +1,8 @@@'use client'-import React, { useEffect, useState } from 'react'+import React, { useEffect, useMemo, useState } from 'react'import { useRouter } from 'next/navigation'- import { LoadingScreen } from '@components/LoadingScreen'import { CONTROL_ROUTES } from '@constants/routes'- import { useAuth } from '../../components/AuthContext'import { useConfirmDialog } from '../../components/ConfirmDialog'import { DashboardLayout } from '../../components/DashboardLayout'import { McpServerTable } from '../../components/McpServerTable'@@@ -23,10 -19,8 +21,9 @@@ importgetHosts,getMcpServers,isSilentApiError,+ updateContext,} from '../../lib/api'-import type { HostResource, McpServerResource } from '../../lib/api'+import type { ContextResource, ContextSpec, HostResource, McpServerResource } from '../../lib/api'- import { buildControlUiLoginPath, getCurrentControlUiPath } from '../../lib/authRedirect'function resourceName(resource: { metadata?: { name?: string } }): string {return resource.metadata?.name || 'unknown'@@@ -118,23 -99,14 +115,22 @@@ async function loadContextAccess}export default function McpServersPage() {- const { authState } = useAuth()const router = useRouter()const { showToast } = useToast()- const [loading, setLoading] = useState(false)+ const [loading, setLoading] = useState(true)const [error, setError] = useState('')const [mcpServers, setMcpServers] = useState<McpServerResource[]>([])+ const [contexts, setContexts] = useState<ContextResource[]>([])+ const [hosts, setHosts] = useState<HostResource[]>([])const [accessByConnectorKey, setAccessByConnectorKey] = useState<ConnectorAccessSummaryMap>({})+ const [accessByContextName, setAccessByContextName] = useState<+ Record<string, ConnectorAccessSummary>+ >({})const [accessWarning, setAccessWarning] = useState('')const [deletingKey, setDeletingKey] = useState<string | null>(null)+ const [updatingContextMembershipKey, setUpdatingContextMembershipKey] = useState<string | null>(+ null+ )const { confirm, confirmDialog } = useConfirmDialog()async function loadAll() {@@@ -240,158 -187,9 +236,142 @@@router.push(CONTROL_ROUTES.contexts.connectors(trimmed))}+ function contextName(context: ContextResource): string {+ return String(context.metadata?.name || context.spec?.contextId || '').trim()+ }++ function contextSpec(context: ContextResource): ContextSpec {+ const name = contextName(context)+ return {+ contextId: context.spec?.contextId || name,+ description: context.spec?.description,+ mcpServers: Array.isArray(context.spec?.mcpServers) ? context.spec.mcpServers : [],+ sharedFileSystems: context.spec?.sharedFileSystems ?? [],+ }+ }++ const shareTargets = useMemo<ConnectorContextShareTargets>(() => {+ const agentCountByContext = new Map<string, number>()+ for (const host of hosts) {+ const contextName = getContextRef(host)+ if (contextName) {+ agentCountByContext.set(contextName, (agentCountByContext.get(contextName) ?? 0) + 1)+ }+ }+ const affectedAgentCount = (contextName: string) => agentCountByContext.get(contextName) ?? 0++ return {+ agents: hosts+ .map(host => {+ const name = resourceName(host)+ const contextName = getContextRef(host)+ return contextName+ ? {+ id: name,+ label: name,+ contextName,+ affectedAgentCount: affectedAgentCount(contextName),+ }+ : null+ })+ .filter(+ (target): target is ConnectorContextShareTargets['agents'][number] => target !== null+ )+ .sort((a, b) => a.label.localeCompare(b.label)),+ teams: Object.entries(accessByContextName).flatMap(([contextName, access]) =>+ access.teams.map(team => ({+ id: `${team.id}:${contextName}`,+ label: team.label,+ contextName,+ affectedAgentCount: affectedAgentCount(contextName),+ }))+ ),+ members: Object.entries(accessByContextName).flatMap(([contextName, access]) =>+ access.users.map(user => ({+ id: `${user.id}:${contextName}`,+ label: user.label,+ contextName,+ affectedAgentCount: affectedAgentCount(contextName),+ }))+ ),+ }+ }, [accessByContextName, hosts])++ async function addConnectorToContexts(+ server: { name: string; namespace: string },+ contextNames: string[]+ ) {+ const key = `${server.namespace}/${server.name}`+ const targets = contexts.filter(context => contextNames.includes(contextName(context)))+ if (targets.length !== contextNames.length) {+ setError('One or more selected contexts could not be loaded. Please refresh and try again.')+ return+ }++ setUpdatingContextMembershipKey(key)+ setError('')+ try {+ await Promise.all(+ targets.map(context => {+ const name = contextName(context)+ const spec = contextSpec(context)+ return updateContext(name, {+ spec: {+ ...spec,+ mcpServers: Array.from(new Set([...spec.mcpServers, server.name])),+ },+ })+ })+ )+ await loadAll()+ showToast(+ contextNames.length === 1+ ? `Connector ${server.name} added to context.`+ : `Connector ${server.name} added to ${contextNames.length} contexts.`,+ { tone: 'success' }+ )+ } catch (e) {+ if (isSilentApiError(e)) return+ setError(e instanceof Error ? e.message : `Failed to add ${server.name} to contexts`)+ } finally {+ setUpdatingContextMembershipKey(null)+ }+ }++ async function removeConnectorFromContext(+ server: { name: string; namespace: string },+ targetContextName: string+ ) {+ const key = `${server.namespace}/${server.name}`+ const target = contexts.find(context => contextName(context) === targetContextName)+ if (!target) {+ setError('Context could not be loaded. Please refresh and try again.')+ return+ }++ setUpdatingContextMembershipKey(key)+ setError('')+ try {+ const spec = contextSpec(target)+ await updateContext(targetContextName, {+ spec: {+ ...spec,+ mcpServers: spec.mcpServers.filter(name => name !== server.name),+ },+ })+ await loadAll()+ showToast(`Connector ${server.name} removed from ${targetContextName}.`, { tone: 'success' })+ } catch (e) {+ if (isSilentApiError(e)) return+ setError(e instanceof Error ? e.message : `Failed to remove ${server.name} from context`)+ } finally {+ setUpdatingContextMembershipKey(null)+ }+ }+useEffect(() => {- if (authState.isLoggedIn && !authState.isLoading) {- void loadAll()- }- }, [authState.isLoggedIn, authState.isLoading])-- useEffect(() => {- if (!authState.isLoading && !authState.isLoggedIn) {- router.replace(buildControlUiLoginPath(getCurrentControlUiPath()))- }- }, [authState.isLoading, authState.isLoggedIn, router])-- if (authState.isLoading) {- return <LoadingScreen />- }-- if (!authState.isLoggedIn) {- return null- }+ void loadAll()+ }, [])return (<DashboardLayout>