|
6 | 6 | VSCodePanelView, |
7 | 7 | VSCodeDropdown, |
8 | 8 | VSCodeOption, |
| 9 | + VSCodeCheckbox, |
9 | 10 | } from "@vscode/webview-ui-toolkit/react" |
10 | 11 | import { useEffect, useState } from "react" |
11 | 12 | import styled from "styled-components" |
@@ -204,7 +205,7 @@ export const TabButton = ({ |
204 | 205 |
|
205 | 206 | // Server Row Component |
206 | 207 | const ServerRow = ({ server }: { server: McpServer }) => { |
207 | | - const { mcpMarketplaceCatalog } = useExtensionState() |
| 208 | + const { mcpMarketplaceCatalog, autoApprovalSettings } = useExtensionState() |
208 | 209 |
|
209 | 210 | const [isExpanded, setIsExpanded] = useState(false) |
210 | 211 | const [isDeleting, setIsDeleting] = useState(false) |
@@ -271,6 +272,17 @@ const ServerRow = ({ server }: { server: McpServer }) => { |
271 | 272 | }) |
272 | 273 | } |
273 | 274 |
|
| 275 | + const handleAutoApproveChange = () => { |
| 276 | + if (!server.name) return |
| 277 | + |
| 278 | + vscode.postMessage({ |
| 279 | + type: "toggleToolAutoApprove", |
| 280 | + serverName: server.name, |
| 281 | + toolNames: server.tools?.map((tool) => tool.name) || [], |
| 282 | + autoApprove: !server.tools?.every((tool) => tool.autoApprove), |
| 283 | + }) |
| 284 | + } |
| 285 | + |
274 | 286 | return ( |
275 | 287 | <div style={{ marginBottom: "10px" }}> |
276 | 288 | <div |
@@ -299,7 +311,33 @@ const ServerRow = ({ server }: { server: McpServer }) => { |
299 | 311 | }}> |
300 | 312 | {getMcpServerDisplayName(server.name, mcpMarketplaceCatalog)} |
301 | 313 | </span> |
302 | | - <div style={{ display: "flex", alignItems: "center", marginRight: "8px" }} onClick={(e) => e.stopPropagation()}> |
| 314 | + {/* Collapsed view controls */} |
| 315 | + {!server.error && ( |
| 316 | + <div style={{ display: "flex", alignItems: "center", gap: "4px", marginLeft: "8px" }}> |
| 317 | + <VSCodeButton |
| 318 | + appearance="icon" |
| 319 | + title="Restart Server" |
| 320 | + onClick={(e) => { |
| 321 | + e.stopPropagation() |
| 322 | + handleRestart() |
| 323 | + }} |
| 324 | + disabled={server.status === "connecting"}> |
| 325 | + <span className="codicon codicon-sync"></span> |
| 326 | + </VSCodeButton> |
| 327 | + <VSCodeButton |
| 328 | + appearance="icon" |
| 329 | + title="Delete Server" |
| 330 | + onClick={(e) => { |
| 331 | + e.stopPropagation() |
| 332 | + handleDelete() |
| 333 | + }} |
| 334 | + disabled={isDeleting}> |
| 335 | + <span className="codicon codicon-trash"></span> |
| 336 | + </VSCodeButton> |
| 337 | + </div> |
| 338 | + )} |
| 339 | + {/* Toggle Switch */} |
| 340 | + <div style={{ display: "flex", alignItems: "center", marginLeft: "8px" }} onClick={(e) => e.stopPropagation()}> |
303 | 341 | <div |
304 | 342 | role="switch" |
305 | 343 | aria-checked={!server.disabled} |
@@ -422,6 +460,15 @@ const ServerRow = ({ server }: { server: McpServer }) => { |
422 | 460 | {server.tools.map((tool) => ( |
423 | 461 | <McpToolRow key={tool.name} tool={tool} serverName={server.name} /> |
424 | 462 | ))} |
| 463 | + {server.name && autoApprovalSettings.enabled && autoApprovalSettings.actions.useMcp && ( |
| 464 | + <VSCodeCheckbox |
| 465 | + style={{ marginBottom: -10 }} |
| 466 | + checked={server.tools.every((tool) => tool.autoApprove)} |
| 467 | + onChange={handleAutoApproveChange} |
| 468 | + data-tool="all-tools"> |
| 469 | + Auto-approve all tools |
| 470 | + </VSCodeCheckbox> |
| 471 | + )} |
425 | 472 | </div> |
426 | 473 | ) : ( |
427 | 474 | <div |
|
0 commit comments