From 446248aa791e845effbd1012bc43b2e15c0fb548 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Wed, 21 May 2025 22:02:24 -0700 Subject: [PATCH] loading --- .../contrib/void/common/mcpService.ts | 37 +++++++------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/src/vs/workbench/contrib/void/common/mcpService.ts b/src/vs/workbench/contrib/void/common/mcpService.ts index cdba9da2..3b73af87 100644 --- a/src/vs/workbench/contrib/void/common/mcpService.ts +++ b/src/vs/workbench/contrib/void/common/mcpService.ts @@ -24,7 +24,6 @@ import { MCPServerStateOfName } from './voidSettingsTypes.js'; type MCPState = { mcpServerOfName: MCPServerOfName, error: string | undefined, - isLoading: boolean, // TODO!!!!!! userSpecifiedMCPServerNames: string[], } @@ -78,7 +77,6 @@ class MCPService extends Disposable implements IMCPService { state: MCPState = { mcpServerOfName: {}, error: undefined, - isLoading: false, userSpecifiedMCPServerNames: [], } @@ -122,12 +120,8 @@ class MCPService extends Disposable implements IMCPService { await this._createMCPConfigFile(mcpConfigUri); console.log('MCP Config file created:', mcpConfigUri.toString()); } - - await this._refreshMCPServers(); - - // Add a watcher to the MCP config file await this._addMCPConfigFileWatcher(); - + await this._refreshMCPServers(); } catch (error) { console.error('Error initializing MCPService:', error); } @@ -156,22 +150,6 @@ class MCPService extends Disposable implements IMCPService { } this._onDidChangeState.fire(); } - private readonly _setUserSpecifiedServerNames = async (names: string[]) => { - this.state = { - ...this.state, - userSpecifiedMCPServerNames: names, - } - this._onDidChangeState.fire(); - } - // private readonly _setIsLoading = async (isLoading: boolean) => { - // this.state = { - // ...this.state, - // isLoading: isLoading, - // } - // this._onDidChangeState.fire(); - // } - - // Create the file/directory if it doesn't exist private async _createMCPConfigFile(mcpConfigUri: URI): Promise { @@ -289,7 +267,18 @@ class MCPService extends Disposable implements IMCPService { if (!mcpConfigFile) { console.log(`Not setting state: MCP config file not found`); return } if (!mcpConfigFile?.mcpServers) { console.log(`Not setting state: MCP config file did not have an 'mcpServers' field`); return } - this._setUserSpecifiedServerNames(Object.keys(mcpConfigFile.mcpServers)) + // set state to loading if it's the first time we're seeing it + const mcpConfigOfName = mcpConfigFile.mcpServers + for (const serverName in mcpConfigOfName) { + if (serverName in this.state.mcpServerOfName) continue + this._setMCPServer(serverName, { + isOn: false, + status: 'loading', + error: undefined, + command: undefined, + tools: [], + }) + } const currMCPStateOfName = this.voidSettingsService.state.mcpServerStateOfName; const availableServers = Object.keys(mcpConfigFile.mcpServers);