refactor: adopt proxychannel for calling INativeMcpDiscoveryHelperService

This commit is contained in:
Connor Peet
2025-03-11 10:53:25 -07:00
parent 67e6e173f8
commit 0e01b1cc94
6 changed files with 69 additions and 41 deletions

View File

@@ -118,8 +118,8 @@ import { IAuxiliaryWindowsMainService } from '../../platform/auxiliaryWindow/ele
import { AuxiliaryWindowsMainService } from '../../platform/auxiliaryWindow/electron-main/auxiliaryWindowsMainService.js';
import { normalizeNFC } from '../../base/common/normalization.js';
import { ICSSDevelopmentService, CSSDevelopmentService } from '../../platform/cssDev/node/cssDevService.js';
import { NativeMcpDiscoveryHelperChannelName } from '../../platform/mcp/common/nativeMcpDiscoveryHelper.js';
import { NativeMcpDiscoveryHelperChannel } from '../../platform/mcp/node/nativeMcpDiscoveryHelperChannel.js';
import { INativeMcpDiscoveryHelperService, NativeMcpDiscoveryHelperChannelName } from '../../platform/mcp/common/nativeMcpDiscoveryHelper.js';
import { NativeMcpDiscoveryHelperService } from '../../platform/mcp/node/nativeMcpDiscoveryHelperService.js';
/**
* The main VS Code application. There will only ever be one instance,
@@ -1121,6 +1121,10 @@ export class CodeApplication extends Disposable {
// Proxy Auth
services.set(IProxyAuthService, new SyncDescriptor(ProxyAuthService));
// MCP
services.set(INativeMcpDiscoveryHelperService, new SyncDescriptor(NativeMcpDiscoveryHelperService));
// Dev Only: CSS service (for ESM)
services.set(ICSSDevelopmentService, new SyncDescriptor(CSSDevelopmentService, undefined, true));
@@ -1225,7 +1229,8 @@ export class CodeApplication extends Disposable {
mainProcessElectronServer.registerChannel('externalTerminal', externalTerminalChannel);
// MCP
mainProcessElectronServer.registerChannel(NativeMcpDiscoveryHelperChannelName, new NativeMcpDiscoveryHelperChannel(undefined));
const mcpDiscoveryChannel = ProxyChannel.fromService(accessor.get(INativeMcpDiscoveryHelperService), disposables);
mainProcessElectronServer.registerChannel(NativeMcpDiscoveryHelperChannelName, mcpDiscoveryChannel);
// Logger
const loggerChannel = new LoggerChannel(accessor.get(ILoggerMainService),);