@@ -13,12 +13,9 @@ import { ContextKeyExpr, IContextKeyService } from '../../../../platform/context
13
13
import { InstantiationType , registerSingleton } from '../../../../platform/instantiation/common/extensions.js' ;
14
14
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js' ;
15
15
import { 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' ;
18
16
import { IEditorGroupsService } from '../../../services/editor/common/editorGroupsService.js' ;
19
17
import { IExtensionService , isProposedApiEnabled } from '../../../services/extensions/common/extensions.js' ;
20
18
import { ExtensionsRegistry } from '../../../services/extensions/common/extensionsRegistry.js' ;
21
- import { LifecyclePhase } from '../../../services/lifecycle/common/lifecycle.js' ;
22
19
import { IChatWidgetService } from '../browser/chat.js' ;
23
20
import { ChatEditorInput } from '../browser/chatEditorInput.js' ;
24
21
import { IChatAgentData , IChatAgentImplementation , IChatAgentRequest , IChatAgentResult , IChatAgentService } from '../common/chatAgents.js' ;
@@ -68,42 +65,6 @@ const extensionPoint = ExtensionsRegistry.registerExtensionPoint<IChatSessionsEx
68
65
}
69
66
} ) ;
70
67
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
-
107
68
class ContributedChatSessionData implements IDisposable {
108
69
private readonly _disposableStore : DisposableStore ;
109
70
@@ -148,6 +109,29 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
148
109
@IContextKeyService private readonly _contextKeyService : IContextKeyService ,
149
110
) {
150
111
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
+ } ) ) ;
151
135
152
136
// Listen for context changes and re-evaluate contributions
153
137
this . _register ( Event . filter ( this . _contextKeyService . onDidChangeContext , e => e . affectsSome ( this . _contextKeys ) ) ( ( ) => {
@@ -295,11 +279,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
295
279
return disposable ;
296
280
}
297
281
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 [ ] {
303
283
return Array . from ( this . _contributions . values ( ) ) . filter ( contribution =>
304
284
this . _isContributionAvailable ( contribution )
305
285
) ;
@@ -314,7 +294,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
314
294
}
315
295
316
296
async canResolveItemProvider ( chatViewType : string ) {
317
- // First check if the contribution is available based on its when clause
297
+ await this . _extensionService . whenInstalledExtensionsRegistered ( ) ;
318
298
const contribution = this . _contributions . get ( chatViewType ) ;
319
299
if ( contribution && ! this . _isContributionAvailable ( contribution ) ) {
320
300
return false ;
@@ -324,7 +304,6 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
324
304
return true ;
325
305
}
326
306
327
- await this . _extensionService . whenInstalledExtensionsRegistered ( ) ;
328
307
await this . _extensionService . activateByEvent ( `onChatSession:${ chatViewType } ` ) ;
329
308
330
309
return this . _itemsProviders . has ( chatViewType ) ;
@@ -335,7 +314,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
335
314
}
336
315
337
316
async canResolveContentProvider ( chatViewType : string ) {
338
- // First check if the contribution is available based on its when clause
317
+ await this . _extensionService . whenInstalledExtensionsRegistered ( ) ;
339
318
const contribution = this . _contributions . get ( chatViewType ) ;
340
319
if ( contribution && ! this . _isContributionAvailable ( contribution ) ) {
341
320
return false ;
@@ -345,7 +324,6 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
345
324
return true ;
346
325
}
347
326
348
- await this . _extensionService . whenInstalledExtensionsRegistered ( ) ;
349
327
await this . _extensionService . activateByEvent ( `onChatSession:${ chatViewType } ` ) ;
350
328
351
329
return this . _contentProviders . has ( chatViewType ) ;
0 commit comments