( host: SlashCommandHost, id: string, options?: ShowPluginMcpPickerOptions, )
| 218 | } |
| 219 | |
| 220 | async function showPluginMcpPicker( |
| 221 | host: SlashCommandHost, |
| 222 | id: string, |
| 223 | options?: ShowPluginMcpPickerOptions, |
| 224 | ): Promise<void> { |
| 225 | let info: PluginInfo; |
| 226 | try { |
| 227 | info = await host.requireSession().getPluginInfo(id); |
| 228 | } catch (error) { |
| 229 | host.showError(`Failed to load plugin MCP servers: ${formatErrorMessage(error)}`); |
| 230 | return; |
| 231 | } |
| 232 | |
| 233 | host.mountEditorReplacement( |
| 234 | new PluginMcpSelectorComponent({ |
| 235 | info, |
| 236 | selectedServer: options?.selectedServer, |
| 237 | serverHint: options?.serverHint, |
| 238 | onSelect: (selection) => { |
| 239 | // Every MCP action re-mounts a picker, so let the handler do the |
| 240 | // mounting — pre-restoring the editor here would flash on toggle. |
| 241 | void handlePluginMcpSelection(host, selection).catch((error: unknown) => { |
| 242 | host.showError(`/plugins mcp failed: ${formatErrorMessage(error)}`); |
| 243 | }); |
| 244 | }, |
| 245 | onCancel: () => { |
| 246 | host.restoreEditor(); |
| 247 | void showPluginsPicker(host, { selectedId: id }); |
| 248 | }, |
| 249 | }), |
| 250 | ); |
| 251 | } |
| 252 | |
| 253 | async function confirmRemovePlugin(host: SlashCommandHost, id: string): Promise<boolean> { |
| 254 | let displayName = id; |
no test coverage detected