@@ -11,7 +11,7 @@ import { ThemeIcon } from '../../../../base/common/themables.js';
1111import { URI } from '../../../../base/common/uri.js' ;
1212import { generateUuid } from '../../../../base/common/uuid.js' ;
1313import { localize , localize2 } from '../../../../nls.js' ;
14- import { Action2 , MenuId , MenuRegistry , registerAction2 } from '../../../../platform/actions/common/actions.js' ;
14+ import { Action2 , IMenuService , MenuId , MenuRegistry , registerAction2 } from '../../../../platform/actions/common/actions.js' ;
1515import { ContextKeyExpr , IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js' ;
1616import { InstantiationType , registerSingleton } from '../../../../platform/instantiation/common/extensions.js' ;
1717import { ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js' ;
@@ -222,6 +222,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
222222 @IChatAgentService private readonly _chatAgentService : IChatAgentService ,
223223 @IExtensionService private readonly _extensionService : IExtensionService ,
224224 @IContextKeyService private readonly _contextKeyService : IContextKeyService ,
225+ @IMenuService private readonly _menuService : IMenuService ,
225226 ) {
226227 super ( ) ;
227228 this . _register ( extensionPoint . setHandler ( extensions => {
@@ -368,22 +369,43 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
368369 }
369370
370371 private _registerMenuItems ( contribution : IChatSessionsExtensionPoint ) : IDisposable {
371- return MenuRegistry . appendMenuItem ( MenuId . ViewTitle , {
372- command : {
373- id : `${ NEW_CHAT_SESSION_ACTION_ID } .${ contribution . type } ` ,
374- title : localize ( 'interactiveSession.openNewSessionEditor' , "New {0}" , contribution . displayName ) ,
372+ // If provider registers anything for the create submenu, let it fully control the creation
373+ const contextKeyService = this . _contextKeyService . createOverlay ( [
374+ [ 'chatSessionType' , contribution . type ]
375+ ] ) ;
376+
377+ const menuActions = this . _menuService . getMenuActions ( MenuId . ChatSessionsCreateSubMenu , contextKeyService ) ;
378+ if ( menuActions ?. length ) {
379+ return MenuRegistry . appendMenuItem ( MenuId . ViewTitle , {
380+ group : 'navigation' ,
381+ title : localize ( 'interactiveSession.chatSessionSubMenuTitle' , "Create chat session" ) ,
375382 icon : Codicon . plus ,
376- source : {
377- id : contribution . extensionDescription . identifier . value ,
378- title : contribution . extensionDescription . displayName || contribution . extensionDescription . name ,
379- }
380- } ,
381- group : 'navigation' ,
382- order : 1 ,
383- when : ContextKeyExpr . and (
384- ContextKeyExpr . equals ( 'view' , `${ VIEWLET_ID } .${ contribution . type } ` )
385- ) ,
386- } ) ;
383+ order : 1 ,
384+ when : ContextKeyExpr . and (
385+ ContextKeyExpr . equals ( 'view' , `${ VIEWLET_ID } .${ contribution . type } ` )
386+ ) ,
387+ submenu : MenuId . ChatSessionsCreateSubMenu ,
388+ isSplitButton : true
389+ } ) ;
390+ } else {
391+ // We control creation instead
392+ return MenuRegistry . appendMenuItem ( MenuId . ViewTitle , {
393+ command : {
394+ id : `${ NEW_CHAT_SESSION_ACTION_ID } .${ contribution . type } ` ,
395+ title : localize ( 'interactiveSession.openNewSessionEditor' , "New {0}" , contribution . displayName ) ,
396+ icon : Codicon . plus ,
397+ source : {
398+ id : contribution . extensionDescription . identifier . value ,
399+ title : contribution . extensionDescription . displayName || contribution . extensionDescription . name ,
400+ }
401+ } ,
402+ group : 'navigation' ,
403+ order : 1 ,
404+ when : ContextKeyExpr . and (
405+ ContextKeyExpr . equals ( 'view' , `${ VIEWLET_ID } .${ contribution . type } ` )
406+ ) ,
407+ } ) ;
408+ }
387409 }
388410
389411 private _registerCommands ( contribution : IChatSessionsExtensionPoint ) : IDisposable {
0 commit comments