@@ -22,14 +22,12 @@ import { localize } from '../../../../nls.js';
22
22
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js' ;
23
23
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js' ;
24
24
import { ILogService } from '../../../../platform/log/common/log.js' ;
25
- import { mcpAutoStartConfig , McpAutoStartValue } from '../../../../platform/mcp/common/mcpManagement.js' ;
26
25
import { Progress } from '../../../../platform/progress/common/progress.js' ;
27
26
import { IStorageService , StorageScope , StorageTarget } from '../../../../platform/storage/common/storage.js' ;
28
27
import { ITelemetryService } from '../../../../platform/telemetry/common/telemetry.js' ;
29
28
import { IWorkspaceContextService } from '../../../../platform/workspace/common/workspace.js' ;
30
29
import { IExtensionService } from '../../../services/extensions/common/extensions.js' ;
31
- import { IMcpServer , IMcpService , McpConnectionState , McpServerCacheState , McpStartServerInteraction } from '../../mcp/common/mcpTypes.js' ;
32
- import { startServerAndWaitForLiveTools } from '../../mcp/common/mcpTypesUtils.js' ;
30
+ import { IMcpService } from '../../mcp/common/mcpTypes.js' ;
33
31
import { IChatAgent , IChatAgentCommand , IChatAgentData , IChatAgentHistoryEntry , IChatAgentRequest , IChatAgentResult , IChatAgentService } from './chatAgents.js' ;
34
32
import { ChatModel , ChatRequestModel , ChatRequestRemovalReason , IChatModel , IChatRequestModel , IChatRequestVariableData , IChatResponseModel , IExportableChatData , ISerializableChatData , ISerializableChatDataIn , ISerializableChatsData , normalizeSerializableChatData , toChatHistoryContent , updateRanges } from './chatModel.js' ;
35
33
import { chatAgentLeader , ChatRequestAgentPart , ChatRequestAgentSubcommandPart , ChatRequestSlashCommandPart , ChatRequestTextPart , chatSubcommandLeader , getPromptText , IParsedChatRequest } from './chatParserTypes.js' ;
@@ -774,31 +772,6 @@ export class ChatService extends Disposable implements IChatService {
774
772
return newTokenSource . token ;
775
773
}
776
774
777
- private async _checkForMcpAutostart ( token : CancellationToken ) {
778
- let todo : IMcpServer [ ] = [ ] ;
779
-
780
- const autoStartConfig = this . configurationService . getValue < McpAutoStartValue > ( mcpAutoStartConfig ) ;
781
-
782
- // don't try re-running errored servers, let the user choose if they want that
783
- const candidates = this . mcpService . servers . get ( ) . filter ( s => s . connectionState . get ( ) . state !== McpConnectionState . Kind . Error ) ;
784
-
785
- if ( autoStartConfig === McpAutoStartValue . OnlyNew ) {
786
- todo = candidates . filter ( s => s . cacheState . get ( ) === McpServerCacheState . Unknown ) ;
787
- } else if ( autoStartConfig === McpAutoStartValue . NewAndOutdated ) {
788
- todo = candidates . filter ( s => {
789
- const c = s . cacheState . get ( ) ;
790
- return c === McpServerCacheState . Unknown || c === McpServerCacheState . Outdated ;
791
- } ) ;
792
- }
793
-
794
- if ( ! todo . length ) {
795
- return ;
796
- }
797
-
798
- const interaction = new McpStartServerInteraction ( ) ;
799
- await Promise . all ( todo . map ( server => startServerAndWaitForLiveTools ( server , { interaction } , token ) ) ) ;
800
- }
801
-
802
775
private _sendRequestAsync ( model : ChatModel , sessionId : string , parsedRequest : IParsedChatRequest , attempt : number , enableCommandDetection : boolean , defaultAgent : IChatAgent , location : ChatAgentLocation , options ?: IChatSendRequestOptions ) : IChatSendRequestResponseState {
803
776
const followupsCancelToken = this . refreshFollowupsCancellationToken ( sessionId ) ;
804
777
let request : ChatRequestModel ;
@@ -851,6 +824,10 @@ export class ChatService extends Disposable implements IChatService {
851
824
const stopWatch = new StopWatch ( false ) ;
852
825
store . add ( token . onCancellationRequested ( ( ) => {
853
826
this . trace ( 'sendRequest' , `Request for session ${ model . sessionId } was cancelled` ) ;
827
+ if ( ! request ) {
828
+ return ;
829
+ }
830
+
854
831
this . telemetryService . publicLog2 < ChatProviderInvokedEvent , ChatProviderInvokedClassification > ( 'interactiveSessionProviderInvoked' , {
855
832
timeToFirstProgress : undefined ,
856
833
// Normally timings happen inside the EH around the actual provider. For cancellation we can measure how long the user waited before cancelling
@@ -952,7 +929,7 @@ export class ChatService extends Disposable implements IChatService {
952
929
const command = detectedCommand ?? agentSlashCommandPart ?. command ;
953
930
await Promise . all ( [
954
931
this . extensionService . activateByEvent ( `onChatParticipant:${ agent . id } ` ) ,
955
- this . _checkForMcpAutostart ( token ) ,
932
+ this . mcpService . autostart ( token ) ,
956
933
] ) ;
957
934
958
935
// Recompute history in case the agent or command changed
0 commit comments