mirror of
https://github.com/voideditor/void
synced 2026-05-23 17:38:23 +00:00
loading
This commit is contained in:
parent
66575b5381
commit
446248aa79
1 changed files with 13 additions and 24 deletions
|
|
@ -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<void> {
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue