Update plug indicator to show enabled vs total counts
- Change indicator format to show enabled/total for both servers and tools - Format: 'X (Y servers) A (B tools)' where: - X = enabled servers, Y = total servers - A = tools from enabled servers, B = total tools from all servers - Track tool counts per server in localStorage (mcpServerToolCounts) - Persist tool counts even when servers are disabled - Examples: - No servers: '0 (0 servers) 0 (0 tools)' - One disabled server with 2 tools: '0 (1 servers) 0 (2 tools)' - One enabled server with 2 tools: '1 (1 servers) 2 (2 tools)' - Clean up tool counts when servers are deleted
This commit is contained in:
parent
d15c88419c
commit
644b3b663d
1 changed files with 39 additions and 3 deletions
|
|
@ -59,6 +59,10 @@ const McpServerModal: React.FC<McpServerModalProps> = ({
|
|||
const [newServerUrl, setNewServerUrl] = useState('')
|
||||
const [showSettings, setShowSettings] = useState(false)
|
||||
const [connectionData, setConnectionData] = useState<Record<string, any>>({})
|
||||
const [serverToolCounts, setServerToolCounts] = useState<Record<string, number>>(() => {
|
||||
const stored = localStorage.getItem('mcpServerToolCounts')
|
||||
return stored ? JSON.parse(stored) : {}
|
||||
})
|
||||
const logRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
// Save servers to localStorage whenever they change
|
||||
|
|
@ -66,6 +70,11 @@ const McpServerModal: React.FC<McpServerModalProps> = ({
|
|||
localStorage.setItem('mcpServers', JSON.stringify(servers))
|
||||
}, [servers])
|
||||
|
||||
// Save tool counts to localStorage whenever they change
|
||||
useEffect(() => {
|
||||
localStorage.setItem('mcpServerToolCounts', JSON.stringify(serverToolCounts))
|
||||
}, [serverToolCounts])
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
document.body.style.overflow = 'hidden'
|
||||
|
|
@ -127,6 +136,11 @@ const McpServerModal: React.FC<McpServerModalProps> = ({
|
|||
delete newData[serverId]
|
||||
return newData
|
||||
})
|
||||
setServerToolCounts(prev => {
|
||||
const newCounts = { ...prev }
|
||||
delete newCounts[serverId]
|
||||
return newCounts
|
||||
})
|
||||
}
|
||||
|
||||
// Handle toggling server enabled state
|
||||
|
|
@ -150,6 +164,14 @@ const McpServerModal: React.FC<McpServerModalProps> = ({
|
|||
...prev,
|
||||
[serverId]: data
|
||||
}))
|
||||
|
||||
// Store tool count for this server (even if it gets disabled later)
|
||||
if (data.tools && Array.isArray(data.tools)) {
|
||||
setServerToolCounts(prev => ({
|
||||
...prev,
|
||||
[serverId]: data.tools.length
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
// Handle authentication for a specific server
|
||||
|
|
|
|||
Loading…
Reference in a new issue