Skip to content

Commit c54ad6e

Browse files
committed
Adding actions to chat sessions toolbar
1 parent 7ca850c commit c54ad6e

File tree

2 files changed

+113
-1
lines changed

2 files changed

+113
-1
lines changed

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

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { ActiveEditorContext, IsCompactTitleBarContext } from '../../../../commo
4545
import { IWorkbenchContribution } from '../../../../common/contributions.js';
4646
import { IViewDescriptorService, ViewContainerLocation } from '../../../../common/views.js';
4747
import { IEditorGroupsService } from '../../../../services/editor/common/editorGroupsService.js';
48-
import { ACTIVE_GROUP, IEditorService } from '../../../../services/editor/common/editorService.js';
48+
import { ACTIVE_GROUP, AUX_WINDOW_GROUP, IEditorService } from '../../../../services/editor/common/editorService.js';
4949
import { IHostService } from '../../../../services/host/browser/host.js';
5050
import { IWorkbenchLayoutService, Parts } from '../../../../services/layout/browser/layoutService.js';
5151
import { IViewsService } from '../../../../services/views/common/viewsService.js';
@@ -903,6 +903,82 @@ export function registerChatActions() {
903903
}
904904
});
905905

906+
registerAction2(class OpenChatEditorInNewWindowAction extends Action2 {
907+
constructor() {
908+
super({
909+
id: `workbench.action.chat.newChatInNewWindow`,
910+
title: localize2('chatSessions.openNewChatInNewWindow', 'Open New Chat in New Window'),
911+
f1: true,
912+
category: CHAT_CATEGORY,
913+
precondition: ChatContextKeys.enabled
914+
});
915+
}
916+
917+
async run(accessor: ServicesAccessor) {
918+
const editorService = accessor.get(IEditorService);
919+
await editorService.openEditor({
920+
resource: ChatEditorInput.getNewEditorUri(),
921+
options: {
922+
pinned: true,
923+
auxiliary: { compact: true, bounds: { width: 640, height: 640 } }
924+
} satisfies IChatEditorOptions
925+
}, AUX_WINDOW_GROUP);
926+
}
927+
});
928+
929+
registerAction2(class OpenChatEditorInNewMaximizedWindowAction extends Action2 {
930+
constructor() {
931+
super({
932+
id: `workbench.action.chat.newChatInNewMaximizedWindow`,
933+
title: localize2('chatSessions.openNewChatInNewMaximizedWindow', 'Open New Chat in Maximized Window'),
934+
f1: true,
935+
category: CHAT_CATEGORY,
936+
precondition: ChatContextKeys.enabled
937+
});
938+
}
939+
940+
async run(accessor: ServicesAccessor) {
941+
const editorService = accessor.get(IEditorService);
942+
await editorService.openEditor({
943+
resource: ChatEditorInput.getNewEditorUri(),
944+
options: {
945+
pinned: true,
946+
auxiliary: { compact: false }
947+
} satisfies IChatEditorOptions
948+
}, AUX_WINDOW_GROUP);
949+
}
950+
});
951+
952+
registerAction2(class NewChatInSideBarAction extends Action2 {
953+
constructor() {
954+
super({
955+
id: `workbench.action.chat.newChatInSideBar`,
956+
title: localize2('chatSessions.openNewChatInSideBar', 'Open New Chat in Side Bar'),
957+
f1: true,
958+
category: CHAT_CATEGORY,
959+
precondition: ChatContextKeys.enabled
960+
});
961+
}
962+
963+
async run(accessor: ServicesAccessor) {
964+
const viewsService = accessor.get(IViewsService);
965+
966+
// Open the chat view in the sidebar and get the widget
967+
const chatWidget = await showChatView(viewsService);
968+
969+
if (chatWidget) {
970+
// Clear the current chat to start a new one
971+
chatWidget.clear();
972+
await chatWidget.waitForReady();
973+
chatWidget.attachmentModel.clear(true);
974+
chatWidget.input.relatedFiles?.clear();
975+
976+
// Focus the input area
977+
chatWidget.focusInput();
978+
}
979+
}
980+
});
981+
906982
registerAction2(class ChatAddAction extends Action2 {
907983
constructor() {
908984
super({

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,3 +962,39 @@ MenuRegistry.appendMenuItem(MenuId.ViewTitle, {
962962
when: ContextKeyExpr.equals('view', `${VIEWLET_ID}.local`),
963963
});
964964

965+
MenuRegistry.appendMenuItem(MenuId.ViewTitle, {
966+
command: {
967+
id: 'workbench.action.chat.newChatInNewWindow',
968+
title: nls.localize2('chatSessions.openNewChatInNewWindow', 'Open New Chat in New Window')
969+
},
970+
group: 'submenu',
971+
order: 1,
972+
});
973+
974+
MenuRegistry.appendMenuItem(MenuId.ViewTitle, {
975+
command: {
976+
id: 'workbench.action.chat.newChatInSideBar',
977+
title: nls.localize2('chatSessions.openNewChatInSideBar', 'Open New Chat in Side Bar'),
978+
},
979+
group: 'submenu',
980+
order: 1,
981+
});
982+
983+
984+
MenuRegistry.appendMenuItem(MenuId.ViewTitle, {
985+
command: {
986+
id: 'workbench.action.chat.newChatInNewMaximizedWindow',
987+
title: nls.localize2('chatSessions.openNewChatInNewMaximizedWindow', 'Open New Chat in Maximized Window')
988+
},
989+
group: 'submenu',
990+
order: 1,
991+
});
992+
993+
MenuRegistry.appendMenuItem(MenuId.ViewTitle, {
994+
command: {
995+
id: 'workbench.action.chat.openInNewEditorGroup',
996+
title: nls.localize2('chatSessions.openNewChatInNewEditorGroup', 'Open New Chat in Editor Group'),
997+
},
998+
group: 'submenu',
999+
order: 1,
1000+
});

0 commit comments

Comments
 (0)