Add restart capability to servers

This commit is contained in:
Saoud Rizwan
2024-12-07 22:11:22 -08:00
parent ede6a40405
commit 6c5db4135e
7 changed files with 45 additions and 23 deletions

View File

@@ -820,12 +820,12 @@ export const ChatRowContent = ({
}}
/>
{useMcpServer.arguments && (
<div style={{ marginTop: "6px" }}>
<div style={{ marginTop: "8px" }}>
<div
style={{
marginBottom: "4px",
opacity: 0.8,
fontSize: "11px",
fontSize: "12px",
textTransform: "uppercase",
}}>
Arguments

View File

@@ -12,7 +12,7 @@ const McpResourceRow = ({ item }: McpResourceRowProps) => {
<div
key={uri}
style={{
padding: "3px 0 8px 0",
padding: "3px 0",
}}>
<div
style={{

View File

@@ -9,7 +9,7 @@ const McpToolRow = ({ tool }: McpToolRowProps) => {
<div
key={tool.name}
style={{
padding: "3px 0 8px 0",
padding: "3px 0",
}}>
<div style={{ display: "flex" }}>
<span className="codicon codicon-symbol-method" style={{ marginRight: "6px" }}></span>

View File

@@ -150,9 +150,9 @@ const ServerRow = ({ server }: { server: McpServer }) => {
}
}
const handleRetry = () => {
const handleRestart = () => {
vscode.postMessage({
type: "retryMcpServer",
type: "restartMcpServer",
text: server.name,
})
}
@@ -196,9 +196,11 @@ const ServerRow = ({ server }: { server: McpServer }) => {
borderRadius: "0 0 4px 4px",
}}>
<div style={{ color: "var(--vscode-testing-iconFailed)", marginBottom: "8px" }}>{server.error}</div>
<VSCodeButton appearance="secondary" onClick={handleRetry}>
<span className="codicon codicon-debug-restart" style={{ marginRight: "6px" }}></span>
Retry Connection
<VSCodeButton
appearance="secondary"
onClick={handleRestart}
disabled={server.status === "connecting"}>
{server.status === "connecting" ? "Retrying..." : "Retry Connection"}
</VSCodeButton>
</div>
) : (
@@ -206,7 +208,7 @@ const ServerRow = ({ server }: { server: McpServer }) => {
<div
style={{
background: "var(--vscode-textCodeBlock-background)",
padding: "0 12px 0 12px",
padding: "0 12px 12px 12px",
fontSize: "13px",
borderRadius: "0 0 4px 4px",
}}>
@@ -217,7 +219,7 @@ const ServerRow = ({ server }: { server: McpServer }) => {
<VSCodePanelView id="tools-view">
{server.tools && server.tools.length > 0 ? (
<div
style={{ display: "flex", flexDirection: "column", gap: "6px", width: "100%" }}>
style={{ display: "flex", flexDirection: "column", gap: "8px", width: "100%" }}>
{server.tools.map((tool) => (
<McpToolRow key={tool.name} tool={tool} />
))}
@@ -233,7 +235,7 @@ const ServerRow = ({ server }: { server: McpServer }) => {
{(server.resources && server.resources.length > 0) ||
(server.resourceTemplates && server.resourceTemplates.length > 0) ? (
<div
style={{ display: "flex", flexDirection: "column", gap: "3px", width: "100%" }}>
style={{ display: "flex", flexDirection: "column", gap: "8px", width: "100%" }}>
{[...(server.resourceTemplates || []), ...(server.resources || [])].map(
(item) => (
<McpResourceRow
@@ -250,6 +252,14 @@ const ServerRow = ({ server }: { server: McpServer }) => {
)}
</VSCodePanelView>
</VSCodePanels>
<VSCodeButton
appearance="secondary"
onClick={handleRestart}
disabled={server.status === "connecting"}
style={{ width: "calc(100% - 14px)", margin: "0 7px 3px 7px" }}>
{server.status === "connecting" ? "Restarting..." : "Restart Server"}
</VSCodeButton>
</div>
)
)}