fix: Do not reconnect on rerender
This commit is contained in:
@@ -47,6 +47,7 @@ import ToolsTab from "./components/ToolsTab";
|
|||||||
import { DEFAULT_INSPECTOR_CONFIG } from "./lib/constants";
|
import { DEFAULT_INSPECTOR_CONFIG } from "./lib/constants";
|
||||||
import { InspectorConfig } from "./lib/configurationTypes";
|
import { InspectorConfig } from "./lib/configurationTypes";
|
||||||
import { useToast } from "@/hooks/use-toast";
|
import { useToast } from "@/hooks/use-toast";
|
||||||
|
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
const PROXY_PORT = params.get("proxyPort") ?? "6277";
|
const PROXY_PORT = params.get("proxyPort") ?? "6277";
|
||||||
const PROXY_SERVER_URL = `http://${window.location.hostname}:${PROXY_PORT}`;
|
const PROXY_SERVER_URL = `http://${window.location.hostname}:${PROXY_PORT}`;
|
||||||
@@ -197,8 +198,13 @@ const App = () => {
|
|||||||
localStorage.setItem(CONFIG_LOCAL_STORAGE_KEY, JSON.stringify(config));
|
localStorage.setItem(CONFIG_LOCAL_STORAGE_KEY, JSON.stringify(config));
|
||||||
}, [config]);
|
}, [config]);
|
||||||
|
|
||||||
|
const hasProcessedRef = useRef(false);
|
||||||
// Auto-connect if serverUrl is provided in URL params (e.g. after OAuth callback)
|
// Auto-connect if serverUrl is provided in URL params (e.g. after OAuth callback)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (hasProcessedRef.current) {
|
||||||
|
// Only try to connect once
|
||||||
|
return;
|
||||||
|
}
|
||||||
const serverUrl = params.get("serverUrl");
|
const serverUrl = params.get("serverUrl");
|
||||||
if (serverUrl) {
|
if (serverUrl) {
|
||||||
setSseUrl(serverUrl);
|
setSseUrl(serverUrl);
|
||||||
@@ -212,6 +218,7 @@ const App = () => {
|
|||||||
title: "Success",
|
title: "Success",
|
||||||
description: "Successfully authenticated with OAuth",
|
description: "Successfully authenticated with OAuth",
|
||||||
});
|
});
|
||||||
|
hasProcessedRef.current = true;
|
||||||
// Connect to the server
|
// Connect to the server
|
||||||
connectMcpServer();
|
connectMcpServer();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user