@@ -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' ;
@@ -227,6 +227,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
227227 @IChatAgentService private readonly _chatAgentService : IChatAgentService ,
228228 @IExtensionService private readonly _extensionService : IExtensionService ,
229229 @IContextKeyService private readonly _contextKeyService : IContextKeyService ,
230+ @IMenuService private readonly _menuService : IMenuService ,
230231 ) {
231232 super ( ) ;
232233 this . _register ( extensionPoint . setHandler ( extensions => {
@@ -374,22 +375,43 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
374375 }
375376
376377 private _registerMenuItems ( contribution : IChatSessionsExtensionPoint ) : IDisposable {
377- return MenuRegistry . appendMenuItem ( MenuId . ViewTitle , {
378- command : {
379- id : `${ NEW_CHAT_SESSION_ACTION_ID } .${ contribution . type } ` ,
380- title : localize ( 'interactiveSession.openNewSessionEditor' , "New {0}" , contribution . displayName ) ,
378+ // If provider registers anything for the create submenu, let it fully control the creation
379+ const contextKeyService = this . _contextKeyService . createOverlay ( [
380+ [ 'chatSessionType' , contribution . type ]
381+ ] ) ;
382+
383+ const menuActions = this . _menuService . getMenuActions ( MenuId . ChatSessionsCreateSubMenu , contextKeyService ) ;
384+ if ( menuActions ?. length ) {
385+ return MenuRegistry . appendMenuItem ( MenuId . ViewTitle , {
386+ group : 'navigation' ,
387+ title : localize ( 'interactiveSession.chatSessionSubMenuTitle' , "Create chat session" ) ,
381388 icon : Codicon . plus ,
382- source : {
383- id : contribution . extensionDescription . identifier . value ,
384- title : contribution . extensionDescription . displayName || contribution . extensionDescription . name ,
385- }
386- } ,
387- group : 'navigation' ,
388- order : 1 ,
389- when : ContextKeyExpr . and (
390- ContextKeyExpr . equals ( 'view' , `${ AGENT_SESSIONS_VIEWLET_ID } .${ contribution . type } ` )
391- ) ,
392- } ) ;
389+ order : 1 ,
390+ when : ContextKeyExpr . and (
391+ ContextKeyExpr . equals ( 'view' , `${ AGENT_SESSIONS_VIEWLET_ID } .${ contribution . type } ` )
392+ ) ,
393+ submenu : MenuId . ChatSessionsCreateSubMenu ,
394+ isSplitButton : true
395+ } ) ;
396+ } else {
397+ // We control creation instead
398+ return MenuRegistry . appendMenuItem ( MenuId . ViewTitle , {
399+ command : {
400+ id : `${ NEW_CHAT_SESSION_ACTION_ID } .${ contribution . type } ` ,
401+ title : localize ( 'interactiveSession.openNewSessionEditor' , "New {0}" , contribution . displayName ) ,
402+ icon : Codicon . plus ,
403+ source : {
404+ id : contribution . extensionDescription . identifier . value ,
405+ title : contribution . extensionDescription . displayName || contribution . extensionDescription . name ,
406+ }
407+ } ,
408+ group : 'navigation' ,
409+ order : 1 ,
410+ when : ContextKeyExpr . and (
411+ ContextKeyExpr . equals ( 'view' , `${ AGENT_SESSIONS_VIEWLET_ID } .${ contribution . type } ` )
412+ ) ,
413+ } ) ;
414+ }
393415 }
394416
395417 private _registerCommands ( contribution : IChatSessionsExtensionPoint ) : IDisposable {
0 commit comments