@@ -65,7 +65,6 @@ import { defaultInputBoxStyles } from '../../../../platform/theme/browser/defaul
6565import { createSingleCallFunction } from '../../../../base/common/functional.js' ;
6666import { StandardKeyboardEvent } from '../../../../base/browser/keyboardEvent.js' ;
6767import { timeout } from '../../../../base/common/async.js' ;
68- import { IChatSessionContext } from './actions/chatSessionActions.js' ;
6968import { KeyCode } from '../../../../base/common/keyCodes.js' ;
7069
7170export const VIEWLET_ID = 'workbench.view.chat.sessions' ;
@@ -954,6 +953,7 @@ class SessionsViewPane extends ViewPane {
954953 @IViewsService private readonly viewsService : IViewsService ,
955954 @ILogService private readonly logService : ILogService ,
956955 @IProgressService private readonly progressService : IProgressService ,
956+ @IMenuService private readonly menuService : IMenuService ,
957957 ) {
958958 super ( options , keybindingService , contextMenuService , configurationService , contextKeyService , viewDescriptorService , instantiationService , openerService , themeService , hoverService ) ;
959959
@@ -1215,46 +1215,48 @@ class SessionsViewPane extends ViewPane {
12151215 }
12161216
12171217 private onContextMenu ( e : ITreeContextMenuEvent < IChatSessionItem | null > ) : void {
1218- if ( ! e . element || ! this . isLocalChatSessionItem ( e . element ) ) {
1218+ if ( ! e . element ) {
12191219 return ;
12201220 }
12211221
1222- const sessionItem = e . element as ILocalChatSessionItem ;
1223- let actualSessionId : string | undefined ;
1222+ const session = e . element ;
1223+ const sessionWithProvider = session as ChatSessionItemWithProvider ;
12241224
1225- // Extract the actual chat session ID based on session type
1226- if ( sessionItem . sessionType === 'editor' && sessionItem . editor instanceof ChatEditorInput ) {
1227- // For editor sessions, use the ChatEditorInput's sessionId
1228- actualSessionId = sessionItem . editor . sessionId ;
1229- } else if ( sessionItem . sessionType === 'widget' && sessionItem . widget ) {
1230- // For widget sessions, get the session ID from the model
1231- actualSessionId = sessionItem . widget . viewModel ?. model . sessionId ;
1232- }
1225+ e . browserEvent . preventDefault ( ) ;
1226+ e . browserEvent . stopPropagation ( ) ;
12331227
1234- if ( ! actualSessionId ) {
1235- return ; // Cannot rename without a valid session ID
1236- }
1228+ // Create context overlay for this specific session item
1229+ const contextOverlay = getSessionItemContextOverlay ( session , sessionWithProvider . provider ) ;
1230+ const contextKeyService = this . contextKeyService . createOverlay ( contextOverlay ) ;
12371231
1238- // Create context for the rename action
1239- const context : IChatSessionContext = {
1240- sessionId : actualSessionId ,
1241- sessionType : sessionItem . sessionType ,
1242- currentTitle : sessionItem . label ,
1243- editorInput : sessionItem . editor ,
1244- editorGroup : sessionItem . group ,
1245- widget : sessionItem . widget
1232+ // Create marshalled context for command execution (same approach as action bar)
1233+ const marshalledSession = {
1234+ session : session ,
1235+ $mid : MarshalledId . ChatSessionContext
12461236 } ;
12471237
1248- e . browserEvent . preventDefault ( ) ;
1249- e . browserEvent . stopPropagation ( ) ;
1238+ // Create menu and get all actions
1239+ const menu = this . menuService . createMenu ( MenuId . ChatSessionsMenu , contextKeyService ) ;
1240+ const actions = menu . getActions ( { arg : marshalledSession , shouldForwardArgs : true } ) ;
12501241
1251- this . contextMenuService . showContextMenu ( {
1252- menuId : MenuId . ChatSessionsMenu ,
1253- menuActionOptions : { shouldForwardArgs : true } ,
1254- contextKeyService : this . contextKeyService ,
1255- getAnchor : ( ) => e . anchor ,
1256- getActionsContext : ( ) => context ,
1257- } ) ;
1242+ // Filter to only show actions from the 'context' group
1243+ const contextActions : any [ ] = [ ] ;
1244+ for ( const [ group , groupActions ] of actions ) {
1245+ if ( group === 'context' ) {
1246+ contextActions . push ( ...groupActions ) ;
1247+ }
1248+ }
1249+
1250+ menu . dispose ( ) ;
1251+
1252+ // Only show context menu if there are context actions
1253+ if ( contextActions . length > 0 ) {
1254+ this . contextMenuService . showContextMenu ( {
1255+ getAnchor : ( ) => e . anchor ,
1256+ getActions : ( ) => contextActions ,
1257+ getActionsContext : ( ) => marshalledSession ,
1258+ } ) ;
1259+ }
12581260 }
12591261
12601262 override focus ( ) : void {
0 commit comments