@@ -16,6 +16,7 @@ import { localize, localize2 } from '../../../../nls.js';
1616import { Action2 , IMenuService , MenuId , MenuRegistry , registerAction2 } from '../../../../platform/actions/common/actions.js' ;
1717import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js' ;
1818import { ContextKeyExpr , IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js' ;
19+ import { IRelaxedExtensionDescription } from '../../../../platform/extensions/common/extensions.js' ;
1920import { InstantiationType , registerSingleton } from '../../../../platform/instantiation/common/extensions.js' ;
2021import { ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js' ;
2122import { ILogService } from '../../../../platform/log/common/log.js' ;
@@ -228,8 +229,8 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
228229 readonly _serviceBrand : undefined ;
229230
230231 private readonly _itemsProviders : Map < string , IChatSessionItemProvider > = new Map ( ) ;
232+ private readonly _contributions : Map < /* type */ string , { readonly contribution : IChatSessionsExtensionPoint ; readonly extension : IRelaxedExtensionDescription } > = new Map ( ) ;
231233 private readonly _contentProviders : Map < /* scheme */ string , IChatSessionContentProvider > = new Map ( ) ;
232- private readonly _contributions : Map < /* scheme */ string , IChatSessionsExtensionPoint > = new Map ( ) ;
233234 private readonly _alternativeIdMap : Map < /* alternativeId */ string , /* primaryType */ string > = new Map ( ) ;
234235 private readonly _disposableStores : Map < string , DisposableStore > = new Map ( ) ;
235236 private readonly _contextKeys = new Set < string > ( ) ;
@@ -270,6 +271,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
270271 @IThemeService private readonly _themeService : IThemeService
271272 ) {
272273 super ( ) ;
274+
273275 this . _register ( extensionPoint . setHandler ( extensions => {
274276 for ( const ext of extensions ) {
275277 if ( ! isProposedApiEnabled ( ext . description , 'chatSessionsProvider' ) ) {
@@ -283,24 +285,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
283285 continue ;
284286 }
285287
286- const c : IChatSessionsExtensionPoint = {
287- type : contribution . type ,
288- name : contribution . name ,
289- displayName : contribution . displayName ,
290- description : contribution . description ,
291- when : contribution . when ,
292- icon : contribution . icon ,
293- alternativeIds : contribution . alternativeIds ,
294- welcomeTitle : contribution . welcomeTitle ,
295- welcomeMessage : contribution . welcomeMessage ,
296- welcomeTips : contribution . welcomeTips ,
297- inputPlaceholder : contribution . inputPlaceholder ,
298- order : contribution . order ,
299- capabilities : contribution . capabilities ,
300- extensionDescription : ext . description ,
301- commands : contribution . commands
302- } ;
303- this . _register ( this . registerContribution ( c ) ) ;
288+ this . _register ( this . registerContribution ( contribution , ext . description ) ) ;
304289 }
305290 }
306291 } ) ) ;
@@ -323,7 +308,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
323308 if ( chatSessionType === 'local' ) {
324309 displayName = 'Local Chat Agent' ;
325310 } else {
326- displayName = this . _contributions . get ( chatSessionType ) ?. displayName ;
311+ displayName = this . _contributions . get ( chatSessionType ) ?. contribution . displayName ;
327312 }
328313
329314 if ( displayName ) {
@@ -346,7 +331,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
346331 }
347332 }
348333
349- private registerContribution ( contribution : IChatSessionsExtensionPoint ) : IDisposable {
334+ private registerContribution ( contribution : IChatSessionsExtensionPoint , ext : IRelaxedExtensionDescription ) : IDisposable {
350335 if ( this . _contributions . has ( contribution . type ) ) {
351336 this . _logService . warn ( `Chat session contribution with id '${ contribution . type } ' is already registered.` ) ;
352337 return { dispose : ( ) => { } } ;
@@ -362,7 +347,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
362347 }
363348 }
364349
365- this . _contributions . set ( contribution . type , contribution ) ;
350+ this . _contributions . set ( contribution . type , { contribution, extension : ext } ) ;
366351
367352 // Register alternative IDs if provided
368353 if ( contribution . alternativeIds ) {
@@ -385,8 +370,8 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
385370 : ThemeIcon . fromId ( contribution . icon ) ;
386371 } else {
387372 icon = {
388- dark : resources . joinPath ( contribution . extensionDescription . extensionLocation , contribution . icon . dark ) ,
389- light : resources . joinPath ( contribution . extensionDescription . extensionLocation , contribution . icon . light )
373+ dark : resources . joinPath ( ext . extensionLocation , contribution . icon . dark ) ,
374+ light : resources . joinPath ( ext . extensionLocation , contribution . icon . light )
390375 } ;
391376 }
392377 }
@@ -451,7 +436,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
451436 */
452437 private _resolveToPrimaryType ( sessionType : string ) : string | undefined {
453438 // Try to find the primary type first
454- const contribution = this . _contributions . get ( sessionType ) ;
439+ const contribution = this . _contributions . get ( sessionType ) ?. contribution ;
455440 if ( contribution ) {
456441 // If the contribution is available, use it
457442 if ( this . _isContributionAvailable ( contribution ) ) {
@@ -463,7 +448,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
463448 // Check if this is an alternative ID, or if the primary type is not available
464449 const primaryType = this . _alternativeIdMap . get ( sessionType ) ;
465450 if ( primaryType ) {
466- const altContribution = this . _contributions . get ( primaryType ) ;
451+ const altContribution = this . _contributions . get ( primaryType ) ?. contribution ;
467452 if ( altContribution && this . _isContributionAvailable ( altContribution ) ) {
468453 this . _logService . info ( `Resolving chat session type '${ sessionType } ' to alternative type '${ primaryType } '` ) ;
469454 return primaryType ;
@@ -473,7 +458,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
473458 return undefined ;
474459 }
475460
476- private _registerMenuItems ( contribution : IChatSessionsExtensionPoint ) : IDisposable {
461+ private _registerMenuItems ( contribution : IChatSessionsExtensionPoint , extensionDescription : IRelaxedExtensionDescription ) : IDisposable {
477462 // If provider registers anything for the create submenu, let it fully control the creation
478463 const contextKeyService = this . _contextKeyService . createOverlay ( [
479464 [ 'chatSessionType' , contribution . type ]
@@ -500,8 +485,8 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
500485 title : localize ( 'interactiveSession.openNewSessionEditor' , "New {0}" , contribution . displayName ) ,
501486 icon : Codicon . plus ,
502487 source : {
503- id : contribution . extensionDescription . identifier . value ,
504- title : contribution . extensionDescription . displayName || contribution . extensionDescription . name ,
488+ id : extensionDescription . identifier . value ,
489+ title : extensionDescription . displayName || extensionDescription . name ,
505490 }
506491 } ,
507492 group : 'navigation' ,
@@ -554,7 +539,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
554539
555540 private _evaluateAvailability ( ) : void {
556541 let hasChanges = false ;
557- for ( const contribution of this . _contributions . values ( ) ) {
542+ for ( const { contribution, extension } of this . _contributions . values ( ) ) {
558543 const isCurrentlyRegistered = this . _disposableStores . has ( contribution . type ) ;
559544 const shouldBeRegistered = this . _isContributionAvailable ( contribution ) ;
560545 if ( isCurrentlyRegistered && ! shouldBeRegistered ) {
@@ -569,7 +554,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
569554 hasChanges = true ;
570555 } else if ( ! isCurrentlyRegistered && shouldBeRegistered ) {
571556 // Enable the contribution by registering it
572- this . _enableContribution ( contribution ) ;
557+ this . _enableContribution ( contribution , extension ) ;
573558 hasChanges = true ;
574559 }
575560 }
@@ -578,19 +563,19 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
578563 for ( const provider of this . _itemsProviders . values ( ) ) {
579564 this . _onDidChangeItemsProviders . fire ( provider ) ;
580565 }
581- for ( const contribution of this . _contributions . values ( ) ) {
566+ for ( const { contribution } of this . _contributions . values ( ) ) {
582567 this . _onDidChangeSessionItems . fire ( contribution . type ) ;
583568 }
584569 }
585570 }
586571
587- private _enableContribution ( contribution : IChatSessionsExtensionPoint ) : void {
572+ private _enableContribution ( contribution : IChatSessionsExtensionPoint , ext : IRelaxedExtensionDescription ) : void {
588573 const disposableStore = new DisposableStore ( ) ;
589574 this . _disposableStores . set ( contribution . type , disposableStore ) ;
590575
591- disposableStore . add ( this . _registerAgent ( contribution ) ) ;
576+ disposableStore . add ( this . _registerAgent ( contribution , ext ) ) ;
592577 disposableStore . add ( this . _registerCommands ( contribution ) ) ;
593- disposableStore . add ( this . _registerMenuItems ( contribution ) ) ;
578+ disposableStore . add ( this . _registerMenuItems ( contribution , ext ) ) ;
594579 }
595580
596581 private _disposeSessionsForContribution ( contributionId : string ) : void {
@@ -614,9 +599,8 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
614599 }
615600 }
616601
617- private _registerAgent ( contribution : IChatSessionsExtensionPoint ) : IDisposable {
618- const { type : id , name, displayName, description, extensionDescription } = contribution ;
619- const { identifier : extensionId , name : extensionName , displayName : extensionDisplayName , publisher : extensionPublisherId } = extensionDescription ;
602+ private _registerAgent ( contribution : IChatSessionsExtensionPoint , ext : IRelaxedExtensionDescription ) : IDisposable {
603+ const { type : id , name, displayName, description } = contribution ;
620604 const agentData : IChatAgentData = {
621605 id,
622606 name,
@@ -634,25 +618,24 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
634618 isSticky : false ,
635619 } ,
636620 capabilities : contribution . capabilities ,
637- extensionId,
638- extensionVersion : extensionDescription . version ,
639- extensionDisplayName : extensionDisplayName || extensionName ,
640- extensionPublisherId,
621+ extensionId : ext . identifier ,
622+ extensionVersion : ext . version ,
623+ extensionDisplayName : ext . displayName || ext . name ,
624+ extensionPublisherId : ext . publisher ,
641625 } ;
642626
643627 return this . _chatAgentService . registerAgent ( id , agentData ) ;
644628 }
645629
646630 getAllChatSessionContributions ( ) : IChatSessionsExtensionPoint [ ] {
647- return Array . from ( this . _contributions . values ( ) ) . filter ( contribution =>
648- this . _isContributionAvailable ( contribution )
649- ) ;
631+ return Array . from ( this . _contributions . values ( ) , x => x . contribution )
632+ . filter ( contribution => this . _isContributionAvailable ( contribution ) ) ;
650633 }
651634
652635 getAllChatSessionItemProviders ( ) : IChatSessionItemProvider [ ] {
653636 return [ ...this . _itemsProviders . values ( ) ] . filter ( provider => {
654637 // Check if the provider's corresponding contribution is available
655- const contribution = this . _contributions . get ( provider . chatSessionType ) ;
638+ const contribution = this . _contributions . get ( provider . chatSessionType ) ?. contribution ;
656639 return ! contribution || this . _isContributionAvailable ( contribution ) ;
657640 } ) ;
658641 }
@@ -664,7 +647,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
664647 chatViewType = resolvedType ;
665648 }
666649
667- const contribution = this . _contributions . get ( chatViewType ) ;
650+ const contribution = this . _contributions . get ( chatViewType ) ?. contribution ;
668651 if ( contribution && ! this . _isContributionAvailable ( contribution ) ) {
669652 return false ;
670653 }
@@ -681,7 +664,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
681664 async canResolveChatSession ( chatSessionResource : URI ) {
682665 await this . _extensionService . whenInstalledExtensionsRegistered ( ) ;
683666 const resolvedType = this . _resolveToPrimaryType ( chatSessionResource . scheme ) || chatSessionResource . scheme ;
684- const contribution = this . _contributions . get ( resolvedType ) ;
667+ const contribution = this . _contributions . get ( resolvedType ) ?. contribution ;
685668 if ( contribution && ! this . _isContributionAvailable ( contribution ) ) {
686669 return false ;
687670 }
@@ -944,7 +927,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
944927 * Get the capabilities for a specific session type
945928 */
946929 public getCapabilitiesForSessionType ( chatSessionType : string ) : IChatAgentAttachmentCapabilities | undefined {
947- const contribution = this . _contributions . get ( chatSessionType ) ;
930+ const contribution = this . _contributions . get ( chatSessionType ) ?. contribution ;
948931 return contribution ?. capabilities ;
949932 }
950933
0 commit comments