fix: prevent phantom "Unnamed Server" view after deleting MCP server

- Reset selectedServerId and editServer state when deleting the currently
  viewed MCP server to return user to the server list
- Avoids the detail view remaining mounted with an empty stub server after deletion
This commit is contained in:
mateo-berri 2026-05-20 19:04:16 -07:00
parent b2e25b3915
commit 5d57c6bfa3

View file

@ -267,6 +267,14 @@ const MCPServers: React.FC<MCPServerProps> = ({ accessToken, userRole, userID })
setIsDeletingServer(true);
await deleteMCPServer(accessToken, serverIdToDelete);
NotificationsManager.success("Deleted MCP Server successfully");
// If the user is currently viewing the detail page of the server they
// just deleted, return them to the All Servers list. Otherwise the
// detail view would stay mounted, fall back to an empty stub server,
// and show a phantom "Unnamed Server" page.
if (selectedServerId === serverIdToDelete) {
setEditServer(false);
setSelectedServerId(null);
}
refetch();
} catch (error) {
console.error("Error deleting the mcp server:", error);