@codingame/monaco-vscode-chat-service-override 1.85.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/chat.d.ts +5 -0
  2. package/chat.js +39 -0
  3. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
  4. package/external/tslib/tslib.es6.js +11 -0
  5. package/index.d.ts +1 -0
  6. package/index.js +1 -0
  7. package/override/vs/platform/dialogs/common/dialogs.js +8 -0
  8. package/package.json +24 -0
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClear.js +17 -0
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +115 -0
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +509 -0
  12. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +88 -0
  13. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +83 -0
  14. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +110 -0
  15. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +223 -0
  16. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.js +283 -0
  17. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +283 -0
  18. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +61 -0
  19. package/vscode/src/vs/workbench/contrib/chat/browser/chatContributionServiceImpl.js +179 -0
  20. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +88 -0
  21. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +271 -0
  22. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +91 -0
  23. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +165 -0
  24. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatHistoryVariables.js +26 -0
  25. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +626 -0
  26. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditor.css.js +6 -0
  27. package/vscode/src/vs/workbench/contrib/chat/common/chatColors.js +31 -0
  28. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +564 -0
  29. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +41 -0
  30. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +41 -0
  31. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.js +748 -0
  32. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatDecorations.js +250 -0
  33. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +62 -0
  34. package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl.js +35 -0
@@ -0,0 +1,110 @@
1
+ import { VSBuffer } from 'monaco-editor/esm/vs/base/common/buffer.js';
2
+ import { joinPath } from 'monaco-editor/esm/vs/base/common/resources.js';
3
+ import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
4
+ import { registerAction2, Action2 } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
5
+ import '../../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
6
+ import { IFileService } from 'monaco-editor/esm/vs/platform/files/common/files.js';
7
+ import { CHAT_CATEGORY } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
8
+ import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
9
+ import { ChatEditorInput } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatEditorInput';
10
+ import { CONTEXT_PROVIDER_EXISTS } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
11
+ import { isExportableSessionData } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatModel';
12
+ import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
13
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
14
+ import { IFileDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
15
+
16
+ const defaultFileName = 'chat.json';
17
+ const filters = [{ name: ( localizeWithPath(
18
+ 'vs/workbench/contrib/chat/browser/actions/chatImportExport',
19
+ 'chat.file.label',
20
+ "Chat Session"
21
+ )), extensions: ['json'] }];
22
+ function registerChatExportActions() {
23
+ registerAction2(class ExportChatAction extends Action2 {
24
+ constructor() {
25
+ super({
26
+ id: 'workbench.action.chat.export',
27
+ category: CHAT_CATEGORY,
28
+ title: {
29
+ value: ( localizeWithPath(
30
+ 'vs/workbench/contrib/chat/browser/actions/chatImportExport',
31
+ 'chat.export.label',
32
+ "Export Session"
33
+ )) + '...',
34
+ original: 'Export Session...'
35
+ },
36
+ precondition: CONTEXT_PROVIDER_EXISTS,
37
+ f1: true,
38
+ });
39
+ }
40
+ async run(accessor, ...args) {
41
+ const widgetService = accessor.get(IChatWidgetService);
42
+ const fileDialogService = accessor.get(IFileDialogService);
43
+ const fileService = accessor.get(IFileService);
44
+ const chatService = accessor.get(IChatService);
45
+ const widget = widgetService.lastFocusedWidget;
46
+ if (!widget || !widget.viewModel) {
47
+ return;
48
+ }
49
+ const defaultUri = joinPath(await fileDialogService.defaultFilePath(), defaultFileName);
50
+ const result = await fileDialogService.showSaveDialog({
51
+ defaultUri,
52
+ filters
53
+ });
54
+ if (!result) {
55
+ return;
56
+ }
57
+ const model = chatService.getSession(widget.viewModel.sessionId);
58
+ if (!model) {
59
+ return;
60
+ }
61
+ const content = VSBuffer.fromString(JSON.stringify(model.toExport(), undefined, 2));
62
+ await fileService.writeFile(result, content);
63
+ }
64
+ });
65
+ registerAction2(class ImportChatAction extends Action2 {
66
+ constructor() {
67
+ super({
68
+ id: 'workbench.action.chat.import',
69
+ title: {
70
+ value: ( localizeWithPath(
71
+ 'vs/workbench/contrib/chat/browser/actions/chatImportExport',
72
+ 'chat.import.label',
73
+ "Import Session"
74
+ )) + '...',
75
+ original: 'Import Session...'
76
+ },
77
+ category: CHAT_CATEGORY,
78
+ precondition: CONTEXT_PROVIDER_EXISTS,
79
+ f1: true,
80
+ });
81
+ }
82
+ async run(accessor, ...args) {
83
+ const fileDialogService = accessor.get(IFileDialogService);
84
+ const fileService = accessor.get(IFileService);
85
+ const editorService = accessor.get(IEditorService);
86
+ const defaultUri = joinPath(await fileDialogService.defaultFilePath(), defaultFileName);
87
+ const result = await fileDialogService.showOpenDialog({
88
+ defaultUri,
89
+ canSelectFiles: true,
90
+ filters
91
+ });
92
+ if (!result) {
93
+ return;
94
+ }
95
+ const content = await fileService.readFile(result[0]);
96
+ try {
97
+ const data = JSON.parse(( content.value.toString()));
98
+ if (!isExportableSessionData(data)) {
99
+ throw new Error('Invalid chat session data');
100
+ }
101
+ await editorService.openEditor({ resource: ChatEditorInput.getNewEditorUri(), options: { target: { data }, pinned: true } });
102
+ }
103
+ catch (err) {
104
+ throw err;
105
+ }
106
+ }
107
+ });
108
+ }
109
+
110
+ export { registerChatExportActions };
@@ -0,0 +1,223 @@
1
+ import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
2
+ import { registerAction2, Action2, MenuId } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
3
+ import { ContextKeyExpr } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
4
+ import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
5
+ import { ViewAction } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPane';
6
+ import { ActiveEditorContext } from 'vscode/vscode/vs/workbench/common/contextkeys';
7
+ import { IViewsService } from 'vscode/vscode/vs/workbench/common/views';
8
+ import { CHAT_CATEGORY } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
9
+ import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
10
+ import { ChatEditorInput } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatEditorInput';
11
+ import { CONTEXT_PROVIDER_EXISTS } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
12
+ import { IChatContributionService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContributionService';
13
+ import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
14
+ import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
15
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
16
+
17
+ var MoveToNewLocation;
18
+ ( (function(MoveToNewLocation) {
19
+ MoveToNewLocation["Editor"] = "Editor";
20
+ MoveToNewLocation["Window"] = "Window";
21
+ })(MoveToNewLocation || (MoveToNewLocation = {})));
22
+ const getMoveToChatActionDescriptorForViewTitle = (viewId, providerId, moveTo) => ({
23
+ id: `workbench.action.chat.${providerId}.openIn${moveTo}`,
24
+ title: {
25
+ value: moveTo === MoveToNewLocation.Editor ? ( localizeWithPath(
26
+ 'vs/workbench/contrib/chat/browser/actions/chatMoveActions',
27
+ 'chat.openInEditor.label',
28
+ "Open Session in Editor"
29
+ )) : ( localizeWithPath(
30
+ 'vs/workbench/contrib/chat/browser/actions/chatMoveActions',
31
+ 'chat.openInNewWindow.label',
32
+ "Open Session in New Window"
33
+ )),
34
+ original: moveTo === MoveToNewLocation.Editor ? 'Open Session in Editor' : 'Open Session in New Window',
35
+ },
36
+ category: CHAT_CATEGORY,
37
+ precondition: CONTEXT_PROVIDER_EXISTS,
38
+ f1: false,
39
+ viewId,
40
+ menu: {
41
+ id: MenuId.ViewTitle,
42
+ when: ( ContextKeyExpr.equals('view', viewId)),
43
+ order: 0
44
+ },
45
+ });
46
+ function getMoveToEditorAction(viewId, providerId) {
47
+ return getMoveToAction(viewId, providerId, MoveToNewLocation.Editor);
48
+ }
49
+ function getMoveToNewWindowAction(viewId, providerId) {
50
+ return getMoveToAction(viewId, providerId, MoveToNewLocation.Window);
51
+ }
52
+ function getMoveToAction(viewId, providerId, moveTo) {
53
+ return class MoveToAction extends ViewAction {
54
+ constructor() {
55
+ super(getMoveToChatActionDescriptorForViewTitle(viewId, providerId, moveTo));
56
+ }
57
+ async runInView(accessor, view) {
58
+ const viewModel = view.widget.viewModel;
59
+ if (!viewModel) {
60
+ return;
61
+ }
62
+ const editorGroupService = accessor.get(IEditorGroupsService);
63
+ const instantiationService = accessor.get(IInstantiationService);
64
+ const editorService = accessor.get(IEditorService);
65
+ const sessionId = viewModel.sessionId;
66
+ view.clear();
67
+ switch (moveTo) {
68
+ case (MoveToNewLocation.Editor): {
69
+ await editorService.openEditor({ resource: ChatEditorInput.getNewEditorUri(), options: { target: { sessionId: viewModel.sessionId }, pinned: true } });
70
+ break;
71
+ }
72
+ case (MoveToNewLocation.Window): {
73
+ await openInNewWindow(instantiationService, editorGroupService, { target: { sessionId } });
74
+ break;
75
+ }
76
+ default: {
77
+ throw new Error(`Unexpected move to location : ${moveTo}`);
78
+ }
79
+ }
80
+ }
81
+ };
82
+ }
83
+ function registerMoveActions() {
84
+ registerAction2(class GlobalMoveToEditorAction extends Action2 {
85
+ constructor() {
86
+ super({
87
+ id: `workbench.action.chat.openInEditor`,
88
+ title: {
89
+ value: ( localizeWithPath(
90
+ 'vs/workbench/contrib/chat/browser/actions/chatMoveActions',
91
+ 'interactiveSession.openInEditor.label',
92
+ "Open Session in Editor"
93
+ )),
94
+ original: 'Open Session in Editor'
95
+ },
96
+ category: CHAT_CATEGORY,
97
+ precondition: CONTEXT_PROVIDER_EXISTS,
98
+ f1: true
99
+ });
100
+ }
101
+ async run(accessor, ...args) {
102
+ executeMoveToAction(accessor, MoveToNewLocation.Editor);
103
+ }
104
+ });
105
+ registerAction2(class GlobalMoveToNewWindowAction extends Action2 {
106
+ constructor() {
107
+ super({
108
+ id: `workbench.action.chat.openInNewWindow`,
109
+ title: {
110
+ value: ( localizeWithPath(
111
+ 'vs/workbench/contrib/chat/browser/actions/chatMoveActions',
112
+ 'interactiveSession.openInNewWindow.label',
113
+ "Open Session in New Window"
114
+ )),
115
+ original: 'Open Session In New Window'
116
+ },
117
+ category: CHAT_CATEGORY,
118
+ precondition: CONTEXT_PROVIDER_EXISTS,
119
+ f1: true
120
+ });
121
+ }
122
+ async run(accessor, ...args) {
123
+ executeMoveToAction(accessor, MoveToNewLocation.Window);
124
+ }
125
+ });
126
+ registerAction2(class GlobalMoveToSidebarAction extends Action2 {
127
+ constructor() {
128
+ super({
129
+ id: `workbench.action.chat.openInSidebar`,
130
+ title: {
131
+ value: ( localizeWithPath(
132
+ 'vs/workbench/contrib/chat/browser/actions/chatMoveActions',
133
+ 'interactiveSession.openInSidebar.label',
134
+ "Open Session in Side Bar"
135
+ )),
136
+ original: 'Open Session in Side Bar'
137
+ },
138
+ category: CHAT_CATEGORY,
139
+ precondition: CONTEXT_PROVIDER_EXISTS,
140
+ f1: true,
141
+ menu: [{
142
+ id: MenuId.EditorTitle,
143
+ order: 0,
144
+ when: ( ActiveEditorContext.isEqualTo(ChatEditorInput.EditorID)),
145
+ }]
146
+ });
147
+ }
148
+ async run(accessor, ...args) {
149
+ return moveToSidebar(accessor);
150
+ }
151
+ });
152
+ }
153
+ async function executeMoveToAction(accessor, moveTo) {
154
+ const widgetService = accessor.get(IChatWidgetService);
155
+ const viewService = accessor.get(IViewsService);
156
+ const chatService = accessor.get(IChatService);
157
+ const editorService = accessor.get(IEditorService);
158
+ const instantiationService = accessor.get(IInstantiationService);
159
+ const editorGroupService = accessor.get(IEditorGroupsService);
160
+ const widget = widgetService.lastFocusedWidget;
161
+ if (!widget || !('viewId' in widget.viewContext)) {
162
+ const providerId = chatService.getProviderInfos()[0].id;
163
+ switch (moveTo) {
164
+ case (MoveToNewLocation.Editor): {
165
+ await editorService.openEditor({ resource: ChatEditorInput.getNewEditorUri(), options: { target: { providerId }, pinned: true } });
166
+ break;
167
+ }
168
+ case (MoveToNewLocation.Window): {
169
+ await openInNewWindow(instantiationService, editorGroupService, { target: { providerId } });
170
+ break;
171
+ }
172
+ default: {
173
+ throw new Error(`Unexpected move to location : ${moveTo}`);
174
+ }
175
+ }
176
+ return;
177
+ }
178
+ const viewModel = widget.viewModel;
179
+ if (!viewModel) {
180
+ return;
181
+ }
182
+ const sessionId = viewModel.sessionId;
183
+ const view = await viewService.openView(widget.viewContext.viewId);
184
+ view.clear();
185
+ switch (moveTo) {
186
+ case (MoveToNewLocation.Editor): {
187
+ await editorService.openEditor({ resource: ChatEditorInput.getNewEditorUri(), options: { target: { sessionId: sessionId }, pinned: true } });
188
+ break;
189
+ }
190
+ case (MoveToNewLocation.Window): {
191
+ await openInNewWindow(instantiationService, editorGroupService, { target: { sessionId } });
192
+ }
193
+ default: {
194
+ throw new Error(`Unexpected move to location : ${moveTo}`);
195
+ }
196
+ }
197
+ }
198
+ async function openInNewWindow(intstantiationService, editorGroupService, options) {
199
+ const auxiliaryEditorPart = await editorGroupService.createAuxiliaryEditorPart();
200
+ const chatEditorInput = intstantiationService.createInstance(ChatEditorInput, ChatEditorInput.getNewEditorUri(), options);
201
+ await auxiliaryEditorPart.activeGroup.openEditor(chatEditorInput, { pinned: true });
202
+ }
203
+ async function moveToSidebar(accessor) {
204
+ const viewsService = accessor.get(IViewsService);
205
+ const editorService = accessor.get(IEditorService);
206
+ const chatContribService = accessor.get(IChatContributionService);
207
+ const editorGroupService = accessor.get(IEditorGroupsService);
208
+ const chatEditorInput = editorService.activeEditor;
209
+ if (chatEditorInput instanceof ChatEditorInput && chatEditorInput.sessionId && chatEditorInput.providerId) {
210
+ await editorService.closeEditor({ editor: chatEditorInput, groupId: editorGroupService.activeGroup.id });
211
+ const viewId = chatContribService.getViewIdForProvider(chatEditorInput.providerId);
212
+ const view = await viewsService.openView(viewId);
213
+ view.loadSession(chatEditorInput.sessionId);
214
+ }
215
+ else {
216
+ const chatService = accessor.get(IChatService);
217
+ const providerId = chatService.getProviderInfos()[0].id;
218
+ const viewId = chatContribService.getViewIdForProvider(providerId);
219
+ await viewsService.openView(viewId);
220
+ }
221
+ }
222
+
223
+ export { getMoveToAction, getMoveToEditorAction, getMoveToNewWindowAction, registerMoveActions };
@@ -0,0 +1,283 @@
1
+ import { Codicon } from 'monaco-editor/esm/vs/base/common/codicons.js';
2
+ import { marked } from 'monaco-editor/esm/vs/base/common/marked/marked.js';
3
+ import { IBulkEditService } from 'monaco-editor/esm/vs/editor/browser/services/bulkEditService.js';
4
+ import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
5
+ import { registerAction2, Action2, MenuId } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
6
+ import { ContextKeyExpr } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
7
+ import { ResourceNotebookCellEdit } from 'vscode/vscode/vs/workbench/contrib/bulkEdit/browser/bulkCellEdits';
8
+ import { CHAT_CATEGORY } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
9
+ import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
10
+ import { CONTEXT_RESPONSE_VOTE, CONTEXT_RESPONSE, CONTEXT_CHAT_RESPONSE_SUPPORT_ISSUE_REPORTING, CONTEXT_RESPONSE_FILTERED, CONTEXT_IN_CHAT_SESSION, CONTEXT_IN_CHAT_INPUT, CONTEXT_REQUEST } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
11
+ import { IChatService, InteractiveSessionVoteDirection } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
12
+ import { isResponseVM, isRequestVM } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatViewModel';
13
+ import { NOTEBOOK_EDITOR_ID, CellKind } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
14
+ import { NOTEBOOK_IS_ACTIVE_EDITOR } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
15
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
16
+
17
+ function registerChatTitleActions() {
18
+ registerAction2(class MarkHelpfulAction extends Action2 {
19
+ constructor() {
20
+ super({
21
+ id: 'workbench.action.chat.markHelpful',
22
+ title: {
23
+ value: ( localizeWithPath(
24
+ 'vs/workbench/contrib/chat/browser/actions/chatTitleActions',
25
+ 'interactive.helpful.label',
26
+ "Helpful"
27
+ )),
28
+ original: 'Helpful'
29
+ },
30
+ f1: false,
31
+ category: CHAT_CATEGORY,
32
+ icon: Codicon.thumbsup,
33
+ toggled: ( CONTEXT_RESPONSE_VOTE.isEqualTo('up')),
34
+ menu: {
35
+ id: MenuId.ChatMessageTitle,
36
+ group: 'navigation',
37
+ order: 1,
38
+ when: CONTEXT_RESPONSE
39
+ }
40
+ });
41
+ }
42
+ run(accessor, ...args) {
43
+ const item = args[0];
44
+ if (!isResponseVM(item)) {
45
+ return;
46
+ }
47
+ const chatService = accessor.get(IChatService);
48
+ chatService.notifyUserAction({
49
+ providerId: item.providerId,
50
+ agentId: item.agent?.id,
51
+ sessionId: item.sessionId,
52
+ requestId: item.requestId,
53
+ action: {
54
+ kind: 'vote',
55
+ direction: InteractiveSessionVoteDirection.Up,
56
+ }
57
+ });
58
+ item.setVote(InteractiveSessionVoteDirection.Up);
59
+ }
60
+ });
61
+ registerAction2(class MarkUnhelpfulAction extends Action2 {
62
+ constructor() {
63
+ super({
64
+ id: 'workbench.action.chat.markUnhelpful',
65
+ title: {
66
+ value: ( localizeWithPath(
67
+ 'vs/workbench/contrib/chat/browser/actions/chatTitleActions',
68
+ 'interactive.unhelpful.label',
69
+ "Unhelpful"
70
+ )),
71
+ original: 'Unhelpful'
72
+ },
73
+ f1: false,
74
+ category: CHAT_CATEGORY,
75
+ icon: Codicon.thumbsdown,
76
+ toggled: ( CONTEXT_RESPONSE_VOTE.isEqualTo('down')),
77
+ menu: {
78
+ id: MenuId.ChatMessageTitle,
79
+ group: 'navigation',
80
+ order: 2,
81
+ when: CONTEXT_RESPONSE
82
+ }
83
+ });
84
+ }
85
+ run(accessor, ...args) {
86
+ const item = args[0];
87
+ if (!isResponseVM(item)) {
88
+ return;
89
+ }
90
+ const chatService = accessor.get(IChatService);
91
+ chatService.notifyUserAction({
92
+ providerId: item.providerId,
93
+ agentId: item.agent?.id,
94
+ sessionId: item.sessionId,
95
+ requestId: item.requestId,
96
+ action: {
97
+ kind: 'vote',
98
+ direction: InteractiveSessionVoteDirection.Down,
99
+ }
100
+ });
101
+ item.setVote(InteractiveSessionVoteDirection.Down);
102
+ }
103
+ });
104
+ registerAction2(class ReportIssueForBugAction extends Action2 {
105
+ constructor() {
106
+ super({
107
+ id: 'workbench.action.chat.reportIssueForBug',
108
+ title: {
109
+ value: ( localizeWithPath(
110
+ 'vs/workbench/contrib/chat/browser/actions/chatTitleActions',
111
+ 'interactive.reportIssueForBug.label',
112
+ "Report Issue"
113
+ )),
114
+ original: 'Report Issue'
115
+ },
116
+ f1: false,
117
+ category: CHAT_CATEGORY,
118
+ icon: Codicon.report,
119
+ menu: {
120
+ id: MenuId.ChatMessageTitle,
121
+ group: 'navigation',
122
+ order: 3,
123
+ when: ( ContextKeyExpr.and(CONTEXT_CHAT_RESPONSE_SUPPORT_ISSUE_REPORTING, CONTEXT_RESPONSE))
124
+ }
125
+ });
126
+ }
127
+ run(accessor, ...args) {
128
+ const item = args[0];
129
+ if (!isResponseVM(item)) {
130
+ return;
131
+ }
132
+ const chatService = accessor.get(IChatService);
133
+ chatService.notifyUserAction({
134
+ providerId: item.providerId,
135
+ agentId: item.agent?.id,
136
+ sessionId: item.sessionId,
137
+ requestId: item.requestId,
138
+ action: {
139
+ kind: 'bug'
140
+ }
141
+ });
142
+ }
143
+ });
144
+ registerAction2(class InsertToNotebookAction extends Action2 {
145
+ constructor() {
146
+ super({
147
+ id: 'workbench.action.chat.insertIntoNotebook',
148
+ title: {
149
+ value: ( localizeWithPath(
150
+ 'vs/workbench/contrib/chat/browser/actions/chatTitleActions',
151
+ 'interactive.insertIntoNotebook.label',
152
+ "Insert into Notebook"
153
+ )),
154
+ original: 'Insert into Notebook'
155
+ },
156
+ f1: false,
157
+ category: CHAT_CATEGORY,
158
+ icon: Codicon.insert,
159
+ menu: {
160
+ id: MenuId.ChatMessageTitle,
161
+ group: 'navigation',
162
+ isHiddenByDefault: true,
163
+ when: ( ContextKeyExpr.and(NOTEBOOK_IS_ACTIVE_EDITOR, CONTEXT_RESPONSE, ( CONTEXT_RESPONSE_FILTERED.negate())))
164
+ }
165
+ });
166
+ }
167
+ async run(accessor, ...args) {
168
+ const item = args[0];
169
+ if (!isResponseVM(item)) {
170
+ return;
171
+ }
172
+ const editorService = accessor.get(IEditorService);
173
+ if (editorService.activeEditorPane?.getId() === NOTEBOOK_EDITOR_ID) {
174
+ const notebookEditor = editorService.activeEditorPane.getControl();
175
+ if (!notebookEditor.hasModel()) {
176
+ return;
177
+ }
178
+ if (notebookEditor.isReadOnly) {
179
+ return;
180
+ }
181
+ const value = item.response.asString();
182
+ const splitContents = splitMarkdownAndCodeBlocks(value);
183
+ const focusRange = notebookEditor.getFocus();
184
+ const index = Math.max(focusRange.end, 0);
185
+ const bulkEditService = accessor.get(IBulkEditService);
186
+ await bulkEditService.apply([
187
+ ( new ResourceNotebookCellEdit(notebookEditor.textModel.uri, {
188
+ editType: 1 ,
189
+ index: index,
190
+ count: 0,
191
+ cells: ( splitContents.map(content => {
192
+ const kind = content.type === 'markdown' ? CellKind.Markup : CellKind.Code;
193
+ const language = content.type === 'markdown' ? 'markdown' : content.language;
194
+ const mime = content.type === 'markdown' ? 'text/markdown' : `text/x-${content.language}`;
195
+ return {
196
+ cellKind: kind,
197
+ language,
198
+ mime,
199
+ source: content.content,
200
+ outputs: [],
201
+ metadata: {}
202
+ };
203
+ }))
204
+ }))
205
+ ], { quotableLabel: 'Insert into Notebook' });
206
+ }
207
+ }
208
+ });
209
+ registerAction2(class RemoveAction extends Action2 {
210
+ constructor() {
211
+ super({
212
+ id: 'workbench.action.chat.remove',
213
+ title: {
214
+ value: ( localizeWithPath(
215
+ 'vs/workbench/contrib/chat/browser/actions/chatTitleActions',
216
+ 'chat.remove.label',
217
+ "Remove Request and Response"
218
+ )),
219
+ original: 'Remove Request and Response'
220
+ },
221
+ f1: false,
222
+ category: CHAT_CATEGORY,
223
+ icon: Codicon.x,
224
+ keybinding: {
225
+ primary: 20 ,
226
+ mac: {
227
+ primary: 2048 | 1 ,
228
+ },
229
+ when: ( ContextKeyExpr.and(CONTEXT_IN_CHAT_SESSION, ( CONTEXT_IN_CHAT_INPUT.negate()))),
230
+ weight: 200 ,
231
+ },
232
+ menu: {
233
+ id: MenuId.ChatMessageTitle,
234
+ group: 'navigation',
235
+ order: 2,
236
+ when: CONTEXT_REQUEST
237
+ }
238
+ });
239
+ }
240
+ run(accessor, ...args) {
241
+ let item = args[0];
242
+ if (!isRequestVM(item)) {
243
+ const chatWidgetService = accessor.get(IChatWidgetService);
244
+ const widget = chatWidgetService.lastFocusedWidget;
245
+ item = widget?.getFocus();
246
+ }
247
+ const requestId = isRequestVM(item) ? item.id :
248
+ isResponseVM(item) ? item.requestId : undefined;
249
+ if (requestId) {
250
+ const chatService = accessor.get(IChatService);
251
+ chatService.removeRequest(item.sessionId, requestId);
252
+ }
253
+ }
254
+ });
255
+ }
256
+ function splitMarkdownAndCodeBlocks(markdown) {
257
+ const lexer = new marked.Lexer();
258
+ const tokens = lexer.lex(markdown);
259
+ const splitContent = [];
260
+ let markdownPart = '';
261
+ tokens.forEach((token) => {
262
+ if (token.type === 'code') {
263
+ if (markdownPart.trim()) {
264
+ splitContent.push({ type: 'markdown', content: markdownPart });
265
+ markdownPart = '';
266
+ }
267
+ splitContent.push({
268
+ type: 'code',
269
+ language: token.lang || '',
270
+ content: token.text,
271
+ });
272
+ }
273
+ else {
274
+ markdownPart += token.raw;
275
+ }
276
+ });
277
+ if (markdownPart.trim()) {
278
+ splitContent.push({ type: 'markdown', content: markdownPart });
279
+ }
280
+ return splitContent;
281
+ }
282
+
283
+ export { registerChatTitleActions };