diff --git a/src/vs/workbench/contrib/chat/browser/actions/chatSessionActions.ts b/src/vs/workbench/contrib/chat/browser/actions/chatSessionActions.ts index 3beb481833c1..c3b1f8195f6e 100644 --- a/src/vs/workbench/contrib/chat/browser/actions/chatSessionActions.ts +++ b/src/vs/workbench/contrib/chat/browser/actions/chatSessionActions.ts @@ -441,7 +441,10 @@ MenuRegistry.appendMenuItem(MenuId.ChatSessionsMenu, { }, group: 'inline', order: 1, - when: ChatContextKeys.sessionType.isEqualTo(localChatSessionType) + when: ContextKeyExpr.and( + ChatContextKeys.sessionType.isEqualTo(localChatSessionType), + ChatContextKeys.isCombinedSessionViewer.negate() + ) }); // Register delete menu item - only show for non-active sessions (history items) diff --git a/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsView.ts b/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsView.ts index 766335bd7f48..913bd2a6a7db 100644 --- a/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsView.ts +++ b/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsView.ts @@ -44,13 +44,14 @@ import { Event } from '../../../../../base/common/event.js'; import { MutableDisposable } from '../../../../../base/common/lifecycle.js'; import { ITreeContextMenuEvent } from '../../../../../base/browser/ui/tree/tree.js'; import { MarshalledId } from '../../../../../base/common/marshallingIds.js'; -import { getActionBarActions } from '../../../../../platform/actions/browser/menuEntryActionViewItem.js'; +import { getActionBarActions, getFlatActionBarActions } from '../../../../../platform/actions/browser/menuEntryActionViewItem.js'; import { IChatService } from '../../common/chatService.js'; import { IChatWidgetService } from '../chat.js'; import { AGENT_SESSIONS_VIEW_ID, AGENT_SESSIONS_VIEW_CONTAINER_ID, AgentSessionProviders } from './agentSessions.js'; import { TreeFindMode } from '../../../../../base/browser/ui/tree/abstractTree.js'; import { SIDE_GROUP } from '../../../../services/editor/common/editorService.js'; import { IMarshalledChatSessionContext } from '../actions/chatSessionActions.js'; +import { distinct } from '../../../../../base/common/arrays.js'; export class AgentSessionsView extends ViewPane { @@ -158,18 +159,13 @@ export class AgentSessionsView extends ViewPane { } const provider = await this.chatSessionsService.activateChatSessionItemProvider(session.providerType); - - const menu = this.menuService.createMenu(MenuId.ChatSessionsMenu, this.contextKeyService.createOverlay(getSessionItemContextOverlay( - session, - provider, - this.chatWidgetService, - this.chatService, - this.editorGroupsService - ))); + const contextOverlay = getSessionItemContextOverlay(session, provider, this.chatWidgetService, this.chatService, this.editorGroupsService); + contextOverlay.push([ChatContextKeys.isCombinedSessionViewer.key, true]); + const menu = this.menuService.createMenu(MenuId.ChatSessionsMenu, this.contextKeyService.createOverlay(contextOverlay)); const marshalledSession: IMarshalledChatSessionContext = { session, $mid: MarshalledId.ChatSessionContext }; - const { secondary } = getActionBarActions(menu.getActions({ arg: marshalledSession, shouldForwardArgs: true }), 'inline'); this.contextMenuService.showContextMenu({ - getActions: () => secondary, + this.contextMenuService.showContextMenu({ + getActions: () => distinct(getFlatActionBarActions(menu.getActions({ arg: marshalledSession, shouldForwardArgs: true })), action => action.id), getAnchor: () => anchor, getActionsContext: () => marshalledSession, }); diff --git a/src/vs/workbench/contrib/chat/browser/chatSessions/view/sessionsViewPane.ts b/src/vs/workbench/contrib/chat/browser/chatSessions/view/sessionsViewPane.ts index 34c92c5682ce..f8dd87df0669 100644 --- a/src/vs/workbench/contrib/chat/browser/chatSessions/view/sessionsViewPane.ts +++ b/src/vs/workbench/contrib/chat/browser/chatSessions/view/sessionsViewPane.ts @@ -512,7 +512,8 @@ export class SessionsViewPane extends ViewPane { // Get actions and filter for context menu (all actions that are NOT inline) const actions = menu.getActions({ arg: marshalledSession, shouldForwardArgs: true }); - const { secondary } = getActionBarActions(actions, 'inline'); this.contextMenuService.showContextMenu({ + const { secondary } = getActionBarActions(actions, 'inline'); + this.contextMenuService.showContextMenu({ getActions: () => secondary, getAnchor: () => e.anchor, getActionsContext: () => marshalledSession, diff --git a/src/vs/workbench/contrib/chat/common/chatContextKeys.ts b/src/vs/workbench/contrib/chat/common/chatContextKeys.ts index d5ab4e32dda5..68b89136a212 100644 --- a/src/vs/workbench/contrib/chat/common/chatContextKeys.ts +++ b/src/vs/workbench/contrib/chat/common/chatContextKeys.ts @@ -93,6 +93,7 @@ export namespace ChatContextKeys { export const sessionType = new RawContextKey('chatSessionType', '', { type: 'string', description: localize('chatSessionType', "The type of the current chat session item.") }); export const isArchivedItem = new RawContextKey('chatIsArchivedItem', false, { type: 'boolean', description: localize('chatIsArchivedItem', "True when the chat session item is archived.") }); + export const isCombinedSessionViewer = new RawContextKey('chatIsCombinedSessionViewer', false, { type: 'boolean', description: localize('chatIsCombinedSessionViewer', "True when the chat session viewer uses the new combined style.") }); // TODO@bpasero eventually retire this context key export const isActiveSession = new RawContextKey('chatIsActiveSession', false, { type: 'boolean', description: localize('chatIsActiveSession', "True when the chat session is currently active (not deletable).") }); export const isKatexMathElement = new RawContextKey('chatIsKatexMathElement', false, { type: 'boolean', description: localize('chatIsKatexMathElement', "True when focusing a KaTeX math element.") }); }