🔬 refactor: Prevent Automatic MCP Server UI Deselection (#10588)

* chore: Add experimental backend server for multi-pod simulation

* Introduced a new backend script (`experimental.js`) to manage a clustered server environment with Redis cache flushing on startup.
* Updated `package.json` to include a new script command for the experimental backend.
* This setup aims to enhance scalability and performance for production environments.

* refactor: Remove server disconnection handling logic from useMCPServerManager
This commit is contained in:
Danny Avila 2025-11-19 17:10:25 -05:00 committed by GitHub
parent 014eb10662
commit 9f2fc25bde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 417 additions and 26 deletions

View file

@ -84,32 +84,6 @@ export function useMCPServerManager({ conversationId }: { conversationId?: strin
enabled: !!startupConfig?.mcpServers && Object.keys(startupConfig.mcpServers).length > 0,
});
/** Filter disconnected servers when values change, but only after initial load
This prevents clearing selections on page refresh when servers haven't connected yet
*/
const hasInitialLoadCompleted = useRef(false);
useEffect(() => {
if (!connectionStatus || Object.keys(connectionStatus).length === 0) {
return;
}
if (!hasInitialLoadCompleted.current) {
hasInitialLoadCompleted.current = true;
return;
}
if (!mcpValues?.length) return;
const connectedSelected = mcpValues.filter(
(serverName) => connectionStatus[serverName]?.connectionState === 'connected',
);
if (connectedSelected.length !== mcpValues.length) {
setMCPValues(connectedSelected);
}
}, [connectionStatus, mcpValues, setMCPValues]);
const updateServerState = useCallback((serverName: string, updates: Partial<ServerState>) => {
setServerStates((prev) => {
const newStates = { ...prev };