Skip to content

Commit bc0129d

Browse files
authored
chat - use proper icon to move chat back into view (microsoft#250263)
1 parent 8020398 commit bc0129d

File tree

5 files changed

+37
-17
lines changed

5 files changed

+37
-17
lines changed

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

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { Codicon } from '../../../../../base/common/codicons.js';
7-
import { localize2 } from '../../../../../nls.js';
8-
import { Action2, MenuId, registerAction2 } from '../../../../../platform/actions/common/actions.js';
9-
import { ContextKeyExpr } from '../../../../../platform/contextkey/common/contextkey.js';
7+
import { ThemeIcon } from '../../../../../base/common/themables.js';
8+
import { localize, localize2 } from '../../../../../nls.js';
9+
import { Action2, MenuId, MenuRegistry, registerAction2 } from '../../../../../platform/actions/common/actions.js';
10+
import { ContextKeyExpr, ContextKeyExpression } from '../../../../../platform/contextkey/common/contextkey.js';
1011
import { ServicesAccessor } from '../../../../../platform/instantiation/common/instantiation.js';
1112
import { ActiveEditorContext } from '../../../../common/contextkeys.js';
13+
import { ViewContainerLocation } from '../../../../common/views.js';
1214
import { IEditorGroupsService } from '../../../../services/editor/common/editorGroupsService.js';
1315
import { ACTIVE_GROUP, AUX_WINDOW_GROUP, IEditorService } from '../../../../services/editor/common/editorService.js';
1416
import { IViewsService } from '../../../../services/views/common/viewsService.js';
@@ -30,7 +32,7 @@ export function registerMoveActions() {
3032
registerAction2(class GlobalMoveToEditorAction extends Action2 {
3133
constructor() {
3234
super({
33-
id: `workbench.action.chat.openInEditor`,
35+
id: 'workbench.action.chat.openInEditor',
3436
title: localize2('chat.openInEditor.label', "Open Chat in Editor"),
3537
category: CHAT_CATEGORY,
3638
precondition: ChatContextKeys.enabled,
@@ -53,7 +55,7 @@ export function registerMoveActions() {
5355
registerAction2(class GlobalMoveToNewWindowAction extends Action2 {
5456
constructor() {
5557
super({
56-
id: `workbench.action.chat.openInNewWindow`,
58+
id: 'workbench.action.chat.openInNewWindow',
5759
title: localize2('chat.openInNewWindow.label', "Open Chat in New Window"),
5860
category: CHAT_CATEGORY,
5961
precondition: ChatContextKeys.enabled,
@@ -76,25 +78,36 @@ export function registerMoveActions() {
7678
registerAction2(class GlobalMoveToSidebarAction extends Action2 {
7779
constructor() {
7880
super({
79-
id: `workbench.action.chat.openInSidebar`,
81+
id: 'workbench.action.chat.openInSidebar',
8082
title: localize2('interactiveSession.openInSidebar.label', "Open Chat in Side Bar"),
8183
category: CHAT_CATEGORY,
82-
icon: Codicon.layoutSidebarRight,
8384
precondition: ChatContextKeys.enabled,
84-
f1: true,
85-
menu: [MenuId.EditorTitle, MenuId.CompactWindowEditorTitle].map(id => ({
86-
id,
87-
group: id === MenuId.CompactWindowEditorTitle ? 'navigation' : undefined,
88-
when: ActiveEditorContext.isEqualTo(ChatEditorInput.EditorID),
89-
order: 0
90-
}))
85+
f1: true
9186
});
9287
}
9388

9489
async run(accessor: ServicesAccessor, ...args: any[]) {
9590
return moveToSidebar(accessor);
9691
}
9792
});
93+
94+
function appendOpenChatInViewMenuItem(menuId: MenuId, title: string, icon: ThemeIcon, locationContextKey: ContextKeyExpression) {
95+
MenuRegistry.appendMenuItem(menuId, {
96+
command: { id: 'workbench.action.chat.openInSidebar', title, icon },
97+
when: ContextKeyExpr.and(
98+
ActiveEditorContext.isEqualTo(ChatEditorInput.EditorID),
99+
locationContextKey
100+
),
101+
group: menuId === MenuId.CompactWindowEditorTitle ? 'navigation' : undefined,
102+
order: 0
103+
});
104+
}
105+
106+
[MenuId.EditorTitle, MenuId.CompactWindowEditorTitle].forEach(id => {
107+
appendOpenChatInViewMenuItem(id, localize('interactiveSession.openInSecondarySidebar.label', "Open Chat in Secondary Side Bar"), Codicon.layoutSidebarRightDock, ChatContextKeys.panelLocation.isEqualTo(ViewContainerLocation.AuxiliaryBar));
108+
appendOpenChatInViewMenuItem(id, localize('interactiveSession.openInPrimarySidebar.label', "Open Chat in Primary Side Bar"), Codicon.layoutSidebarLeftDock, ChatContextKeys.panelLocation.isEqualTo(ViewContainerLocation.Sidebar));
109+
appendOpenChatInViewMenuItem(id, localize('interactiveSession.openInPanel.label', "Open Chat in Panel"), Codicon.layoutPanelDock, ChatContextKeys.panelLocation.isEqualTo(ViewContainerLocation.Panel));
110+
});
98111
}
99112

100113
async function executeMoveToAction(accessor: ServicesAccessor, moveTo: MoveToNewLocation, _sessionId?: string) {

src/vs/workbench/contrib/chat/browser/actions/promptActions/chatAttachInstructionsAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class ManageInstructionsFilesAction extends Action2 {
167167

168168
when: ContextKeyExpr.equals('view', ChatViewId),
169169
order: 11,
170-
group: '1_open'
170+
group: '2_manage'
171171
},
172172

173173
});

src/vs/workbench/contrib/chat/browser/actions/promptActions/chatRunPromptAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ class ManagePromptFilesAction extends Action2 {
251251
id: MenuId.ViewTitle,
252252
when: ContextKeyExpr.equals('view', ChatViewId),
253253
order: 10,
254-
group: '1_open'
254+
group: '2_manage'
255255
},
256256

257257
});

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ import { IThemeService } from '../../../../platform/theme/common/themeService.js
2323
import { IViewPaneOptions, ViewPane } from '../../../browser/parts/views/viewPane.js';
2424
import { Memento } from '../../../common/memento.js';
2525
import { SIDE_BAR_FOREGROUND } from '../../../common/theme.js';
26-
import { IViewDescriptorService } from '../../../common/views.js';
26+
import { IViewDescriptorService, ViewContainerLocation } from '../../../common/views.js';
2727
import { IChatViewTitleActionContext } from '../common/chatActions.js';
2828
import { IChatAgentService } from '../common/chatAgents.js';
29+
import { ChatContextKeys } from '../common/chatContextKeys.js';
2930
import { IChatModel } from '../common/chatModel.js';
3031
import { CHAT_PROVIDER_ID } from '../common/chatParticipantContribTypes.js';
3132
import { IChatService } from '../common/chatService.js';
@@ -120,6 +121,9 @@ export class ChatViewPane extends ViewPane implements IViewWelcomeDelegate {
120121

121122
this._onDidChangeViewWelcomeState.fire();
122123
}));
124+
125+
// Location context key
126+
ChatContextKeys.panelLocation.bindTo(contextKeyService).set(viewDescriptorService.getViewLocationById(options.id) ?? ViewContainerLocation.AuxiliaryBar);
123127
}
124128

125129
override getActionsContext(): IChatViewTitleActionContext | undefined {

src/vs/workbench/contrib/chat/common/chatContextKeys.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { localize } from '../../../../nls.js';
77
import { ContextKeyExpr, RawContextKey } from '../../../../platform/contextkey/common/contextkey.js';
88
import { IsWebContext } from '../../../../platform/contextkey/common/contextkeys.js';
99
import { RemoteNameContext } from '../../../common/contextkeys.js';
10+
import { ViewContainerLocation } from '../../../common/views.js';
1011
import { ChatAgentLocation, ChatMode } from './constants.js';
1112

1213
export namespace ChatContextKeys {
@@ -81,6 +82,8 @@ export namespace ChatContextKeys {
8182
export const Modes = {
8283
hasCustomChatModes: new RawContextKey<boolean>('chatHasCustomChatModes', false, { type: 'boolean', description: localize('chatHasCustomChatModes', "True when the chat has custom chat modes available.") }),
8384
};
85+
86+
export const panelLocation = new RawContextKey<ViewContainerLocation>('chatPanelLocation', undefined, { type: 'number', description: localize('chatPanelLocation', "The location of the chat panel.") });
8487
}
8588

8689
export namespace ChatContextKeyExprs {

0 commit comments

Comments
 (0)