@@ -13,12 +13,9 @@ import { ContextKeyExpr, IContextKeyService } from '../../../../platform/context
1313import { InstantiationType , registerSingleton } from '../../../../platform/instantiation/common/extensions.js' ;
1414import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js' ;
1515import { ILogService } from '../../../../platform/log/common/log.js' ;
16- import { Registry } from '../../../../platform/registry/common/platform.js' ;
17- import { IWorkbenchContribution , IWorkbenchContributionsRegistry , Extensions as WorkbenchExtensions } from '../../../common/contributions.js' ;
1816import { IEditorGroupsService } from '../../../services/editor/common/editorGroupsService.js' ;
1917import { IExtensionService , isProposedApiEnabled } from '../../../services/extensions/common/extensions.js' ;
2018import { ExtensionsRegistry } from '../../../services/extensions/common/extensionsRegistry.js' ;
21- import { LifecyclePhase } from '../../../services/lifecycle/common/lifecycle.js' ;
2219import { IChatWidgetService } from '../browser/chat.js' ;
2320import { ChatEditorInput } from '../browser/chatEditorInput.js' ;
2421import { IChatAgentData , IChatAgentImplementation , IChatAgentRequest , IChatAgentResult , IChatAgentService } from '../common/chatAgents.js' ;
@@ -68,42 +65,6 @@ const extensionPoint = ExtensionsRegistry.registerExtensionPoint<IChatSessionsEx
6865 }
6966} ) ;
7067
71- export class ChatSessionsContribution extends Disposable implements IWorkbenchContribution {
72- constructor (
73- @ILogService private readonly logService : ILogService ,
74- @IChatSessionsService private readonly chatSessionsService : IChatSessionsService ,
75- ) {
76- super ( ) ;
77-
78- extensionPoint . setHandler ( extensions => {
79- for ( const ext of extensions ) {
80- if ( ! isProposedApiEnabled ( ext . description , 'chatSessionsProvider' ) ) {
81- continue ;
82- }
83- if ( ! Array . isArray ( ext . value ) ) {
84- continue ;
85- }
86- for ( const contribution of ext . value ) {
87- const c : IChatSessionsExtensionPoint = {
88- id : contribution . id ,
89- type : contribution . type ,
90- name : contribution . name ,
91- displayName : contribution . displayName ,
92- description : contribution . description ,
93- when : contribution . when ,
94- extensionDescription : ext . description ,
95- } ;
96- this . logService . info ( `Registering chat session from extension contribution: ${ c . displayName } (id='${ c . type } ' name='${ c . name } ')` ) ;
97- this . _register ( this . chatSessionsService . registerContribution ( c ) ) ; // TODO: Is it for contribution to own this? I think not
98- }
99- }
100- } ) ;
101- }
102- }
103-
104- const workbenchRegistry = Registry . as < IWorkbenchContributionsRegistry > ( WorkbenchExtensions . Workbench ) ;
105- workbenchRegistry . registerWorkbenchContribution ( ChatSessionsContribution , LifecyclePhase . Restored ) ;
106-
10768class ContributedChatSessionData implements IDisposable {
10869 private readonly _disposableStore : DisposableStore ;
10970
@@ -148,6 +109,29 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
148109 @IContextKeyService private readonly _contextKeyService : IContextKeyService ,
149110 ) {
150111 super ( ) ;
112+ this . _register ( extensionPoint . setHandler ( extensions => {
113+ for ( const ext of extensions ) {
114+ if ( ! isProposedApiEnabled ( ext . description , 'chatSessionsProvider' ) ) {
115+ continue ;
116+ }
117+ if ( ! Array . isArray ( ext . value ) ) {
118+ continue ;
119+ }
120+ for ( const contribution of ext . value ) {
121+ const c : IChatSessionsExtensionPoint = {
122+ id : contribution . id ,
123+ type : contribution . type ,
124+ name : contribution . name ,
125+ displayName : contribution . displayName ,
126+ description : contribution . description ,
127+ when : contribution . when ,
128+ extensionDescription : ext . description ,
129+ } ;
130+ this . _logService . info ( `Registering chat session from extension contribution: ${ c . displayName } (id='${ c . type } ' name='${ c . name } ')` ) ;
131+ this . _register ( this . registerContribution ( c ) ) ;
132+ }
133+ }
134+ } ) ) ;
151135
152136 // Listen for context changes and re-evaluate contributions
153137 this . _register ( Event . filter ( this . _contextKeyService . onDidChangeContext , e => e . affectsSome ( this . _contextKeys ) ) ( ( ) => {
@@ -295,11 +279,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
295279 return disposable ;
296280 }
297281
298- async getChatSessionContributions ( waitForActivation ?: string [ ] ) : Promise < IChatSessionsExtensionPoint [ ] > {
299- await this . _extensionService . whenInstalledExtensionsRegistered ( ) ;
300- if ( waitForActivation ) {
301- await Promise . all ( waitForActivation . map ( id => this . _extensionService . activateByEvent ( `onChatSession:${ id } ` ) ) ) ;
302- }
282+ getChatSessionContributions ( ) : IChatSessionsExtensionPoint [ ] {
303283 return Array . from ( this . _contributions . values ( ) ) . filter ( contribution =>
304284 this . _isContributionAvailable ( contribution )
305285 ) ;
@@ -314,7 +294,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
314294 }
315295
316296 async canResolveItemProvider ( chatViewType : string ) {
317- // First check if the contribution is available based on its when clause
297+ await this . _extensionService . whenInstalledExtensionsRegistered ( ) ;
318298 const contribution = this . _contributions . get ( chatViewType ) ;
319299 if ( contribution && ! this . _isContributionAvailable ( contribution ) ) {
320300 return false ;
@@ -324,7 +304,6 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
324304 return true ;
325305 }
326306
327- await this . _extensionService . whenInstalledExtensionsRegistered ( ) ;
328307 await this . _extensionService . activateByEvent ( `onChatSession:${ chatViewType } ` ) ;
329308
330309 return this . _itemsProviders . has ( chatViewType ) ;
@@ -335,7 +314,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
335314 }
336315
337316 async canResolveContentProvider ( chatViewType : string ) {
338- // First check if the contribution is available based on its when clause
317+ await this . _extensionService . whenInstalledExtensionsRegistered ( ) ;
339318 const contribution = this . _contributions . get ( chatViewType ) ;
340319 if ( contribution && ! this . _isContributionAvailable ( contribution ) ) {
341320 return false ;
@@ -345,7 +324,6 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
345324 return true ;
346325 }
347326
348- await this . _extensionService . whenInstalledExtensionsRegistered ( ) ;
349327 await this . _extensionService . activateByEvent ( `onChatSession:${ chatViewType } ` ) ;
350328
351329 return this . _contentProviders . has ( chatViewType ) ;
0 commit comments