mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-27 19:08:21 +01:00
agent sessions - support more actions from context menu (#278787)
* agent sessions - support more actions from context menu * distinct
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -93,6 +93,7 @@ export namespace ChatContextKeys {
|
||||
|
||||
export const sessionType = new RawContextKey<string>('chatSessionType', '', { type: 'string', description: localize('chatSessionType', "The type of the current chat session item.") });
|
||||
export const isArchivedItem = new RawContextKey<boolean>('chatIsArchivedItem', false, { type: 'boolean', description: localize('chatIsArchivedItem', "True when the chat session item is archived.") });
|
||||
export const isCombinedSessionViewer = new RawContextKey<boolean>('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<boolean>('chatIsActiveSession', false, { type: 'boolean', description: localize('chatIsActiveSession', "True when the chat session is currently active (not deletable).") });
|
||||
export const isKatexMathElement = new RawContextKey<boolean>('chatIsKatexMathElement', false, { type: 'boolean', description: localize('chatIsKatexMathElement', "True when focusing a KaTeX math element.") });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user