|
1 | 1 | 'use client' |
2 | 2 |
|
3 | | -import { useEffect, useMemo, useRef, useState } from 'react' |
| 3 | +import { useEffect, useRef, useState } from 'react' |
4 | 4 | import { createLogger } from '@sim/logger' |
5 | 5 | import { toError } from '@sim/utils/errors' |
6 | 6 | import { useQueryClient } from '@tanstack/react-query' |
@@ -105,7 +105,10 @@ function ServerListItem({ |
105 | 105 | <span className='text-[var(--text-secondary)] text-sm'>({transportLabel})</span> |
106 | 106 | </div> |
107 | 107 | <p |
108 | | - className={`truncate text-sm ${isError ? 'text-red-500 dark:text-red-400' : 'text-[var(--text-muted)]'}`} |
| 108 | + className={cn( |
| 109 | + 'truncate text-sm', |
| 110 | + isError ? 'text-[var(--text-error)]' : 'text-[var(--text-muted)]' |
| 111 | + )} |
109 | 112 | > |
110 | 113 | {isRefreshing |
111 | 114 | ? 'Refreshing...' |
@@ -300,19 +303,17 @@ export function MCP({ initialServerId }: MCPProps) { |
300 | 303 | } |
301 | 304 | } |
302 | 305 |
|
303 | | - const toolsByServer = useMemo(() => { |
304 | | - return (mcpToolsData || []).reduce( |
305 | | - (acc, tool) => { |
306 | | - if (!tool?.serverId) return acc |
307 | | - if (!acc[tool.serverId]) { |
308 | | - acc[tool.serverId] = [] |
309 | | - } |
310 | | - acc[tool.serverId].push(tool) |
311 | | - return acc |
312 | | - }, |
313 | | - {} as Record<string, typeof mcpToolsData> |
314 | | - ) |
315 | | - }, [mcpToolsData]) |
| 306 | + const toolsByServer = (mcpToolsData || []).reduce( |
| 307 | + (acc, tool) => { |
| 308 | + if (!tool?.serverId) return acc |
| 309 | + if (!acc[tool.serverId]) { |
| 310 | + acc[tool.serverId] = [] |
| 311 | + } |
| 312 | + acc[tool.serverId].push(tool) |
| 313 | + return acc |
| 314 | + }, |
| 315 | + {} as Record<string, typeof mcpToolsData> |
| 316 | + ) |
316 | 317 |
|
317 | 318 | const filteredServers = (servers || []).filter((server) => |
318 | 319 | server.name?.toLowerCase().includes(searchTerm.toLowerCase()) |
@@ -413,13 +414,13 @@ export function MCP({ initialServerId }: MCPProps) { |
413 | 414 | setShowEditModal(true) |
414 | 415 | } |
415 | 416 |
|
416 | | - const selectedServer = useMemo(() => { |
| 417 | + const selectedServer = (() => { |
417 | 418 | if (!selectedServerId) return null |
418 | 419 | const server = servers.find((s) => s.id === selectedServerId) as McpServer | undefined |
419 | 420 | if (!server) return null |
420 | 421 | const serverTools = (toolsByServer[selectedServerId] || []) as McpTool[] |
421 | 422 | return { server, tools: serverTools } |
422 | | - }, [selectedServerId, servers, toolsByServer]) |
| 423 | + })() |
423 | 424 |
|
424 | 425 | const getStoredToolIssues = ( |
425 | 426 | serverId: string, |
@@ -498,7 +499,7 @@ export function MCP({ initialServerId }: MCPProps) { |
498 | 499 | {server.connectionStatus === 'error' && ( |
499 | 500 | <div className='flex flex-col gap-2'> |
500 | 501 | <span className='font-medium text-[var(--text-primary)] text-sm'>Status</span> |
501 | | - <p className='text-base text-red-500 dark:text-red-400'> |
| 502 | + <p className='text-[var(--text-error)] text-base'> |
502 | 503 | {server.lastError || 'Unable to connect'} |
503 | 504 | </p> |
504 | 505 | </div> |
@@ -716,7 +717,7 @@ export function MCP({ initialServerId }: MCPProps) { |
716 | 717 | /> |
717 | 718 | </div> |
718 | 719 | <Button onClick={() => setShowAddModal(true)} variant='primary' disabled={serversLoading}> |
719 | | - <Plus className='mr-1.5 h-[13px] w-[13px]' /> |
| 720 | + <Plus className='mr-1.5 h-[14px] w-[14px]' /> |
720 | 721 | Add |
721 | 722 | </Button> |
722 | 723 | </div> |
|
0 commit comments