Remember last selected transport and SSE URL
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React from "react";
|
||||||
import { useDraggablePane } from "./lib/hooks/useDraggablePane";
|
import { useDraggablePane } from "./lib/hooks/useDraggablePane";
|
||||||
import { useConnection } from "./lib/hooks/useConnection";
|
import { useConnection } from "./lib/hooks/useConnection";
|
||||||
import {
|
import {
|
||||||
@@ -51,8 +51,10 @@ const PROXY_SERVER_URL = `http://localhost:${PROXY_PORT}`;
|
|||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
// Handle OAuth callback route
|
// Handle OAuth callback route
|
||||||
if (window.location.pathname === '/oauth/callback') {
|
if (window.location.pathname === "/oauth/callback") {
|
||||||
const OAuthCallback = React.lazy(() => import('./components/OAuthCallback'));
|
const OAuthCallback = React.lazy(
|
||||||
|
() => import("./components/OAuthCallback"),
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<Suspense fallback={<div>Loading...</div>}>
|
<Suspense fallback={<div>Loading...</div>}>
|
||||||
<OAuthCallback />
|
<OAuthCallback />
|
||||||
@@ -81,8 +83,14 @@ const App = () => {
|
|||||||
return localStorage.getItem("lastArgs") || "";
|
return localStorage.getItem("lastArgs") || "";
|
||||||
});
|
});
|
||||||
|
|
||||||
const [sseUrl, setSseUrl] = useState<string>("http://localhost:3001/sse");
|
const [sseUrl, setSseUrl] = useState<string>(() => {
|
||||||
const [transportType, setTransportType] = useState<"stdio" | "sse">("stdio");
|
return localStorage.getItem("lastSseUrl") || "http://localhost:3001/sse";
|
||||||
|
});
|
||||||
|
const [transportType, setTransportType] = useState<"stdio" | "sse">(() => {
|
||||||
|
return (
|
||||||
|
(localStorage.getItem("lastTransportType") as "stdio" | "sse") || "stdio"
|
||||||
|
);
|
||||||
|
});
|
||||||
const [notifications, setNotifications] = useState<ServerNotification[]>([]);
|
const [notifications, setNotifications] = useState<ServerNotification[]>([]);
|
||||||
const [stdErrNotifications, setStdErrNotifications] = useState<
|
const [stdErrNotifications, setStdErrNotifications] = useState<
|
||||||
StdErrNotification[]
|
StdErrNotification[]
|
||||||
@@ -200,6 +208,14 @@ const App = () => {
|
|||||||
localStorage.setItem("lastArgs", args);
|
localStorage.setItem("lastArgs", args);
|
||||||
}, [args]);
|
}, [args]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
localStorage.setItem("lastSseUrl", sseUrl);
|
||||||
|
}, [sseUrl]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
localStorage.setItem("lastTransportType", transportType);
|
||||||
|
}, [transportType]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch(`${PROXY_SERVER_URL}/config`)
|
fetch(`${PROXY_SERVER_URL}/config`)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
|
|||||||
Reference in New Issue
Block a user