Skip to content

Commit 45e7451

Browse files
authored
chat - core provided chat submenus in components (microsoft#250851)
1 parent 65bb1d6 commit 45e7451

File tree

3 files changed

+52
-34
lines changed

3 files changed

+52
-34
lines changed

src/vs/workbench/contrib/chat/browser/actions/chatActions.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,3 +1036,33 @@ export function shouldShowClearEditingSessionConfirmation(editingSession: IChatE
10361036

10371037
return false;
10381038
}
1039+
1040+
// --- Chat Submenus in various Components
1041+
1042+
const menuContext = ContextKeyExpr.and(
1043+
ChatContextKeys.Setup.hidden.negate(),
1044+
ChatContextKeys.Setup.disabled.negate()
1045+
);
1046+
1047+
const title = localize('copilot', "Copilot");
1048+
1049+
MenuRegistry.appendMenuItem(MenuId.EditorContext, {
1050+
submenu: MenuId.ChatTextEditorMenu,
1051+
group: '1_copilot',
1052+
title,
1053+
when: menuContext
1054+
});
1055+
1056+
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
1057+
submenu: MenuId.ChatExplorerMenu,
1058+
group: '5_copilot',
1059+
title,
1060+
when: menuContext
1061+
});
1062+
1063+
MenuRegistry.appendMenuItem(MenuId.TerminalInstanceContext, {
1064+
submenu: MenuId.ChatTerminalMenu,
1065+
group: '2_copilot',
1066+
title,
1067+
when: menuContext
1068+
});

src/vs/workbench/contrib/chat/browser/chatSetup.ts

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { URI } from '../../../../base/common/uri.js';
2424
import { ServicesAccessor } from '../../../../editor/browser/editorExtensions.js';
2525
import { MarkdownRenderer } from '../../../../editor/browser/widget/markdownRenderer/browser/markdownRenderer.js';
2626
import { localize, localize2 } from '../../../../nls.js';
27-
import { Action2, MenuId, MenuRegistry, registerAction2 } from '../../../../platform/actions/common/actions.js';
27+
import { Action2, MenuId, registerAction2 } from '../../../../platform/actions/common/actions.js';
2828
import { ICommandService } from '../../../../platform/commands/common/commands.js';
2929
import { ConfigurationTarget, IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
3030
import { Extensions as ConfigurationExtensions, IConfigurationRegistry } from '../../../../platform/configuration/common/configurationRegistry.js';
@@ -988,7 +988,6 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
988988

989989
this.registerSetupAgents(context, controller);
990990
this.registerActions(context, requests, controller);
991-
this.registerMenus();
992991
this.registerUrlLinkHandler();
993992
}
994993

@@ -1294,38 +1293,6 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
12941293
registerAction2(EnableOveragesAction);
12951294
}
12961295

1297-
private registerMenus(): void {
1298-
const menuContext = ContextKeyExpr.and(
1299-
// TODO@bpasero this needs to be revisited when the Copilot
1300-
// extension contributes this OOTB where this menu is also
1301-
// defined.
1302-
ChatContextKeys.Setup.installed.negate(),
1303-
ChatContextKeys.Setup.hidden.negate(),
1304-
ChatContextKeys.Setup.disabled.negate()
1305-
);
1306-
1307-
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
1308-
submenu: MenuId.ChatExplorerMenu,
1309-
group: '5_copilot',
1310-
title: localize('title4', "Copilot"),
1311-
when: menuContext
1312-
});
1313-
1314-
MenuRegistry.appendMenuItem(MenuId.EditorContext, {
1315-
submenu: MenuId.ChatTextEditorMenu,
1316-
group: '1_copilot',
1317-
title: localize('title4', "Copilot"),
1318-
when: menuContext
1319-
});
1320-
1321-
MenuRegistry.appendMenuItem(MenuId.TerminalInstanceContext, {
1322-
submenu: MenuId.ChatTerminalMenu,
1323-
group: '2_copilot',
1324-
title: localize('title4', "Copilot"),
1325-
when: menuContext
1326-
});
1327-
}
1328-
13291296
private registerUrlLinkHandler(): void {
13301297
this._register(ExtensionUrlHandlerOverrideRegistry.registerHandler({
13311298
canHandleURL: url => {

src/vs/workbench/services/actions/common/menusExtensionPoint.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,27 @@ const apiMenus: IAPIMenu[] = [
450450
description: localize('menus.chatModelPicker', "The chat model picker dropdown menu"),
451451
supportsSubmenus: false,
452452
proposed: 'chatParticipantPrivate'
453+
},
454+
{
455+
key: 'explorer/context/chat',
456+
id: MenuId.ChatExplorerMenu,
457+
description: localize('menus.chatExplorer', "The Chat submenu in the explorer context menu."),
458+
supportsSubmenus: false,
459+
proposed: 'chatParticipantPrivate'
460+
},
461+
{
462+
key: 'editor/context/chat',
463+
id: MenuId.ChatTextEditorMenu,
464+
description: localize('menus.chatTextEditor', "The Chat submenu in the text editor context menu."),
465+
supportsSubmenus: false,
466+
proposed: 'chatParticipantPrivate'
467+
},
468+
{
469+
key: 'terminal/context/chat',
470+
id: MenuId.ChatTerminalMenu,
471+
description: localize('menus.chatTerminal', "The Chat submenu in the terminal context menu."),
472+
supportsSubmenus: false,
473+
proposed: 'chatParticipantPrivate'
453474
}
454475
];
455476

0 commit comments

Comments
 (0)