diff --git a/frontend/src/components/settings/McpManager.tsx b/frontend/src/components/settings/McpManager.tsx index 54256377..2c980473 100644 --- a/frontend/src/components/settings/McpManager.tsx +++ b/frontend/src/components/settings/McpManager.tsx @@ -1,15 +1,13 @@ import { useState } from 'react' import { Button } from '@/components/ui/button' -import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' +import { Card, CardContent } from '@/components/ui/card' import { Dialog, DialogTrigger } from '@/components/ui/dialog' -import { Badge } from '@/components/ui/badge' -import { Switch } from '@/components/ui/switch' -import { Plus, Trash2, Globe, Terminal, Loader2, AlertCircle, RefreshCw, Key, XCircle } from 'lucide-react' +import { Plus, Loader2, RefreshCw } from 'lucide-react' import { DeleteDialog } from '@/components/ui/delete-dialog' import { AddMcpServerDialog } from './AddMcpServerDialog' +import { McpServerCard } from './McpServerCard' import { useMcpServers } from '@/hooks/useMcpServers' import { useMutation, useQueryClient } from '@tanstack/react-query' -import type { McpStatus } from '@/api/mcp' interface McpServerConfig { type: 'local' | 'remote' @@ -29,37 +27,7 @@ interface McpManagerProps { onConfigUpdate?: (configName: string, content: Record) => Promise } -function getStatusBadge(status: McpStatus) { - switch (status.status) { - case 'connected': - return Connected - case 'disabled': - return Disabled - case 'failed': - return ( - - - Failed - - ) - case 'needs_auth': - return ( - - - Auth Required - - ) - case 'needs_client_registration': - return ( - - - Registration Required - - ) - default: - return Unknown - } -} + export function McpManager({ config, onUpdate, onConfigUpdate }: McpManagerProps) { const [isAddDialogOpen, setIsAddDialogOpen] = useState(false) @@ -130,30 +98,7 @@ export function McpManager({ config, onUpdate, onConfigUpdate }: McpManagerProps } } - const getServerDisplayName = (serverId: string): string => { - const name = serverId.replace(/[-_]/g, ' ') - return name.charAt(0).toUpperCase() + name.slice(1) - } - - const getServerDescription = (serverConfig: McpServerConfig): string => { - if (serverConfig.type === 'local' && serverConfig.command) { - const command = serverConfig.command.join(' ') - if (command.includes('filesystem')) return 'File system access' - if (command.includes('git')) return 'Git repository operations' - if (command.includes('sqlite')) return 'SQLite database access' - if (command.includes('postgres')) return 'PostgreSQL database access' - if (command.includes('brave-search')) return 'Web search via Brave' - if (command.includes('github')) return 'GitHub repository access' - if (command.includes('slack')) return 'Slack integration' - if (command.includes('puppeteer')) return 'Web automation' - if (command.includes('fetch')) return 'HTTP requests' - if (command.includes('memory')) return 'Persistent memory' - return `Local command: ${command}` - } else if (serverConfig.type === 'remote' && serverConfig.url) { - return `Remote server: ${serverConfig.url}` - } - return 'MCP server' - } + const getErrorMessage = (serverId: string): string | null => { const status = mcpStatus?.[serverId] @@ -232,62 +177,18 @@ export function McpManager({ config, onUpdate, onConfigUpdate }: McpManagerProps const errorMessage = getErrorMessage(serverId) return ( - - -
-
-
- {serverConfig.type === 'local' ? ( - - ) : ( - - )} - {getServerDisplayName(serverId)} -
-
- {status ? getStatusBadge(status) : ( - Loading... - )} - - {serverConfig.type} - -
-
-
- handleToggleServer(serverId)} - disabled={isAnyOperationPending || togglingServerId === serverId} - /> - -
-
-
- -
-

{getServerDescription(serverConfig)}

- {serverConfig.timeout && ( -

Timeout: {serverConfig.timeout}ms

- )} - {serverConfig.environment && Object.keys(serverConfig.environment).length > 0 && ( -

Environment variables: {Object.keys(serverConfig.environment).length} configured

- )} - {errorMessage && ( -
- - {errorMessage} -
- )} -
-
-
+ setDeleteConfirmServer({ id, name })} + /> ) })} diff --git a/frontend/src/components/settings/OpenCodeConfigManager.tsx b/frontend/src/components/settings/OpenCodeConfigManager.tsx index 75902659..b2a8e6da 100644 --- a/frontend/src/components/settings/OpenCodeConfigManager.tsx +++ b/frontend/src/components/settings/OpenCodeConfigManager.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from 'react' +import { useState, useEffect, useRef } from 'react' import { Loader2, Plus, Trash2, Edit, Star, StarOff, Download, RotateCcw } from 'lucide-react' import { Button } from '@/components/ui/button' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' @@ -16,6 +16,35 @@ import { useMutation, useQueryClient } from '@tanstack/react-query' import { parseJsonc, hasJsoncComments } from '@/lib/jsonc' import type { OpenCodeConfig } from '@/api/types/settings' +interface Command { + template: string + description?: string + agent?: string + model?: string + subtask?: boolean + topP?: number +} + +interface Agent { + prompt?: string + description?: string + mode?: 'subagent' | 'primary' | 'all' + temperature?: number + topP?: number + model?: { + modelID: string + providerID: string + } + tools?: Record + permission?: { + edit?: 'ask' | 'allow' | 'deny' + bash?: 'ask' | 'allow' | 'deny' | Record + webfetch?: 'ask' | 'allow' | 'deny' + } + disable?: boolean + [key: string]: unknown +} + export function OpenCodeConfigManager() { const queryClient = useQueryClient() const [configs, setConfigs] = useState([]) @@ -32,6 +61,31 @@ export function OpenCodeConfigManager() { const [isEditDialogOpen, setIsEditDialogOpen] = useState(false) const [deleteConfirmConfig, setDeleteConfirmConfig] = useState(null) + const commandsRef = useRef(null) + const agentsRef = useRef(null) + const mcpRef = useRef(null) + + const scrollToSection = (ref: React.RefObject) => { + if (ref.current) { + const rect = ref.current.getBoundingClientRect() + + console.log('Scroll check:', { + section: ref.current.textContent?.trim(), + rectTop: rect.top, + rectBottom: rect.bottom, + viewportHeight: window.innerHeight + }) + + // Always scroll to ensure the section is at the top when expanded + console.log('Scrolling to section:', ref.current.textContent?.trim()) + ref.current.scrollIntoView({ + behavior: 'smooth', + block: 'start', + inline: 'nearest' + }) + } + } + const restartServerMutation = useMutation({ mutationFn: async () => { return await settingsApi.restartOpenCodeServer() @@ -343,13 +397,23 @@ export function OpenCodeConfigManager() { <>