55
66import { h } from '../../../../base/browser/dom.js' ;
77import { assertNever } from '../../../../base/common/assert.js' ;
8- import { raceTimeout } from '../../../../base/common/async.js' ;
98import { Codicon } from '../../../../base/common/codicons.js' ;
109import { groupBy } from '../../../../base/common/collections.js' ;
1110import { Event } from '../../../../base/common/event.js' ;
@@ -34,9 +33,9 @@ import { ActiveEditorContext, ResourceContextKey } from '../../../common/context
3433import { IWorkbenchContribution } from '../../../common/contributions.js' ;
3534import { IEditorService } from '../../../services/editor/common/editorService.js' ;
3635import { IViewsService } from '../../../services/views/common/viewsService.js' ;
37- import { ChatViewId , IChatWidget , IChatWidgetService } from '../../chat/browser/chat.js' ;
36+ import { IChatWidgetService } from '../../chat/browser/chat.js' ;
3837import { ChatContextKeys } from '../../chat/common/chatContextKeys.js' ;
39- import { ChatAgentLocation , ChatMode } from '../../chat/common/constants.js' ;
38+ import { ChatMode } from '../../chat/common/constants.js' ;
4039import { ILanguageModelsService } from '../../chat/common/languageModels.js' ;
4140import { extensionsFilterSubMenu , IExtensionsWorkbenchService } from '../../extensions/common/extensions.js' ;
4241import { TEXT_FILE_EDITOR_ID } from '../../files/common/files.js' ;
@@ -47,6 +46,7 @@ import { IMcpSamplingService, IMcpServer, IMcpServerStartOpts, IMcpService, IMcp
4746import { McpAddConfigurationCommand } from './mcpCommandsAddConfiguration.js' ;
4847import { McpResourceQuickAccess , McpResourceQuickPick } from './mcpResourceQuickAccess.js' ;
4948import { McpUrlHandler } from './mcpUrlHandler.js' ;
49+ import { openPanelChatAndGetWidget } from './openPanelChatAndGetWidget.js' ;
5050
5151// acroynms do not get localized
5252const category : ILocalizedString = {
@@ -745,18 +745,4 @@ export class McpStartPromptingServerCommand extends Action2 {
745745 }
746746}
747747
748- export async function openPanelChatAndGetWidget ( viewsService : IViewsService , chatService : IChatWidgetService ) : Promise < IChatWidget | undefined > {
749- await viewsService . openView ( ChatViewId , true ) ;
750- const widgets = chatService . getWidgetsByLocations ( ChatAgentLocation . Panel ) ;
751- if ( widgets . length ) {
752- return widgets [ 0 ] ;
753- }
754-
755- const eventPromise = Event . toPromise ( Event . filter ( chatService . onDidAddWidget , e => e . location === ChatAgentLocation . Panel ) ) ;
756748
757- return await raceTimeout (
758- eventPromise ,
759- 10_000 , // should be enough time for chat to initialize...
760- ( ) => eventPromise . cancel ( ) ,
761- ) ;
762- }
0 commit comments