Merge branch 'main' into main

This commit is contained in:
Cliff Hall
2025-04-01 15:35:12 -04:00
committed by GitHub
4 changed files with 31 additions and 11 deletions

View File

@@ -145,6 +145,7 @@ const App = () => {
handleCompletion, handleCompletion,
completionsSupported, completionsSupported,
connect: connectMcpServer, connect: connectMcpServer,
disconnect: disconnectMcpServer,
} = useConnection({ } = useConnection({
transportType, transportType,
command, command,
@@ -458,6 +459,7 @@ const App = () => {
bearerToken={bearerToken} bearerToken={bearerToken}
setBearerToken={setBearerToken} setBearerToken={setBearerToken}
onConnect={connectMcpServer} onConnect={connectMcpServer}
onDisconnect={disconnectMcpServer}
stdErrNotifications={stdErrNotifications} stdErrNotifications={stdErrNotifications}
logLevel={logLevel} logLevel={logLevel}
sendLogLevelRequest={sendLogLevelRequest} sendLogLevelRequest={sendLogLevelRequest}

View File

@@ -10,6 +10,7 @@ import {
EyeOff, EyeOff,
RotateCcw, RotateCcw,
Settings, Settings,
RefreshCwOff,
} from "lucide-react"; } from "lucide-react";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
@@ -45,6 +46,7 @@ interface SidebarProps {
bearerToken: string; bearerToken: string;
setBearerToken: (token: string) => void; setBearerToken: (token: string) => void;
onConnect: () => void; onConnect: () => void;
onDisconnect: () => void;
stdErrNotifications: StdErrNotification[]; stdErrNotifications: StdErrNotification[];
logLevel: LoggingLevel; logLevel: LoggingLevel;
sendLogLevelRequest: (level: LoggingLevel) => void; sendLogLevelRequest: (level: LoggingLevel) => void;
@@ -68,6 +70,7 @@ const Sidebar = ({
bearerToken, bearerToken,
setBearerToken, setBearerToken,
onConnect, onConnect,
onDisconnect,
stdErrNotifications, stdErrNotifications,
logLevel, logLevel,
sendLogLevelRequest, sendLogLevelRequest,
@@ -375,19 +378,24 @@ const Sidebar = ({
</div> </div>
<div className="space-y-2"> <div className="space-y-2">
<Button className="w-full" onClick={onConnect}> {connectionStatus === "connected" && (
{connectionStatus === "connected" ? ( <div className="grid grid-cols-2 gap-4">
<> <Button onClick={onConnect}>
<RotateCcw className="w-4 h-4 mr-2" /> <RotateCcw className="w-4 h-4 mr-2" />
{transportType === "stdio" ? "Restart" : "Reconnect"} {transportType === "stdio" ? "Restart" : "Reconnect"}
</> </Button>
) : ( <Button onClick={onDisconnect}>
<> <RefreshCwOff className="w-4 h-4 mr-2" />
<Play className="w-4 h-4 mr-2" /> Disconnect
Connect </Button>
</> </div>
)} )}
</Button> {connectionStatus !== "connected" && (
<Button className="w-full" onClick={onConnect}>
<Play className="w-4 h-4 mr-2" />
Connect
</Button>
)}
<div className="flex items-center justify-center space-x-2 mb-4"> <div className="flex items-center justify-center space-x-2 mb-4">
<div <div

View File

@@ -26,6 +26,7 @@ describe("Sidebar Environment Variables", () => {
bearerToken: "", bearerToken: "",
setBearerToken: jest.fn(), setBearerToken: jest.fn(),
onConnect: jest.fn(), onConnect: jest.fn(),
onDisconnect: jest.fn(),
stdErrNotifications: [], stdErrNotifications: [],
logLevel: "info" as const, logLevel: "info" as const,
sendLogLevelRequest: jest.fn(), sendLogLevelRequest: jest.fn(),

View File

@@ -321,6 +321,14 @@ export function useConnection({
} }
}; };
const disconnect = async () => {
await mcpClient?.close();
setMcpClient(null);
setConnectionStatus("disconnected");
setCompletionsSupported(false);
setServerCapabilities(null);
};
return { return {
connectionStatus, connectionStatus,
serverCapabilities, serverCapabilities,
@@ -331,5 +339,6 @@ export function useConnection({
handleCompletion, handleCompletion,
completionsSupported, completionsSupported,
connect, connect,
disconnect,
}; };
} }