@codingame/monaco-vscode-chat-service-override 4.5.1 → 5.0.0

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 (26) hide show
  1. package/chat.js +6 -6
  2. package/package.json +2 -2
  3. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClear.js +2 -2
  4. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +36 -60
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +78 -51
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +5 -12
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +6 -13
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +10 -27
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +39 -95
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.js +102 -40
  11. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +57 -70
  12. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +3 -23
  13. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +4 -3
  14. package/vscode/src/vs/workbench/contrib/chat/browser/{chatContributionServiceImpl.js → chatParticipantContributions.js} +63 -202
  15. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +35 -28
  16. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +1 -1
  17. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +49 -41
  18. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +71 -74
  19. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +142 -185
  20. package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +3 -3
  21. package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +5 -4
  22. package/vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js +131 -0
  23. package/vscode/src/vs/workbench/contrib/chat/common/languageModels.js +11 -2
  24. package/vscode/src/vs/workbench/contrib/chat/common/voiceChat.js +4 -4
  25. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +1 -4
  26. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +35 -34
package/chat.js CHANGED
@@ -1,15 +1,12 @@
1
1
  import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
2
- import './vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js';
3
2
  import { IChatWidgetService, IQuickChatService, IChatAccessibilityService, IChatCodeBlockContextProviderService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
4
3
  import { ChatAccessibilityService } from './vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js';
5
- import { ChatContributionService } from './vscode/src/vs/workbench/contrib/chat/browser/chatContributionServiceImpl.js';
6
4
  import { QuickChatService } from './vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js';
7
5
  import { ChatVariablesService } from './vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js';
8
6
  import { ChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatWidget';
9
7
  import { ChatCodeBlockContextProviderService } from './vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.js';
10
8
  import { ChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
11
9
  import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
12
- import { IChatContributionService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContributionService.service';
13
10
  import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService.service';
14
11
  import { ChatService } from './vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js';
15
12
  import { ChatSlashCommandService } from './vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js';
@@ -17,20 +14,22 @@ import { IChatSlashCommandService } from 'vscode/vscode/vs/workbench/contrib/cha
17
14
  import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatVariables.service';
18
15
  import { ChatWidgetHistoryService } from './vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js';
19
16
  import { IChatWidgetHistoryService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatWidgetHistoryService.service';
17
+ import { ILanguageModelStatsService } from 'vscode/vscode/vs/workbench/contrib/chat/common/languageModelStats.service';
20
18
  import { LanguageModelsService } from './vscode/src/vs/workbench/contrib/chat/common/languageModels.js';
21
19
  import { ILanguageModelsService } from 'vscode/vscode/vs/workbench/contrib/chat/common/languageModels.service';
22
- import './vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js';
23
20
  import { IInlineChatSavingService } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSavingService.service';
24
21
  import { InlineChatSavingServiceImpl } from './vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js';
25
22
  import { IInlineChatSessionService } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService.service';
26
23
  import { InlineChatSessionServiceImpl } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl';
27
24
  import { IInlineChatService } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat.service';
28
25
  import { InlineChatServiceImpl } from './vscode/src/vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl.js';
26
+ import { LanguageModelStatsService } from './vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js';
27
+ import './vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js';
28
+ import './vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js';
29
29
 
30
30
  function getServiceOverride() {
31
31
  return {
32
32
  [( IChatService.toString())]: new SyncDescriptor(ChatService, [], true),
33
- [( IChatContributionService.toString())]: new SyncDescriptor(ChatContributionService, [], true),
34
33
  [( IChatWidgetService.toString())]: new SyncDescriptor(ChatWidgetService, [], true),
35
34
  [( IQuickChatService.toString())]: new SyncDescriptor(QuickChatService, [], true),
36
35
  [( IChatAccessibilityService.toString())]: new SyncDescriptor(ChatAccessibilityService, [], true),
@@ -42,7 +41,8 @@ function getServiceOverride() {
42
41
  [( IInlineChatService.toString())]: new SyncDescriptor(InlineChatServiceImpl, [], true),
43
42
  [( IInlineChatSessionService.toString())]: new SyncDescriptor(InlineChatSessionServiceImpl, [], true),
44
43
  [( IInlineChatSavingService.toString())]: new SyncDescriptor(InlineChatSavingServiceImpl, [], true),
45
- [( IChatCodeBlockContextProviderService.toString())]: new SyncDescriptor(ChatCodeBlockContextProviderService, [], true)
44
+ [( IChatCodeBlockContextProviderService.toString())]: new SyncDescriptor(ChatCodeBlockContextProviderService, [], true),
45
+ [( ILanguageModelStatsService.toString())]: new SyncDescriptor(LanguageModelStatsService, [], true)
46
46
  };
47
47
  }
48
48
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-chat-service-override",
3
- "version": "4.5.1",
3
+ "version": "5.0.0",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -26,6 +26,6 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "vscode": "npm:@codingame/monaco-vscode-api@4.5.1"
29
+ "vscode": "npm:@codingame/monaco-vscode-api@5.0.0"
30
30
  }
31
31
  }
@@ -6,10 +6,10 @@ async function clearChatEditor(accessor) {
6
6
  const editorService = accessor.get(IEditorService);
7
7
  const editorGroupsService = accessor.get(IEditorGroupsService);
8
8
  const chatEditorInput = editorService.activeEditor;
9
- if (chatEditorInput instanceof ChatEditorInput && chatEditorInput.providerId) {
9
+ if (chatEditorInput instanceof ChatEditorInput) {
10
10
  await editorService.replaceEditors([{
11
11
  editor: chatEditorInput,
12
- replacement: { resource: ChatEditorInput.getNewEditorUri(), options: { target: { providerId: chatEditorInput.providerId, pinned: true } } }
12
+ replacement: { resource: ChatEditorInput.getNewEditorUri(), options: { pinned: true } }
13
13
  }], editorGroupsService.activeGroup);
14
14
  }
15
15
  }
@@ -1,36 +1,33 @@
1
1
  import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
2
2
  import { localize2WithPath } from 'vscode/vscode/vs/nls';
3
- import { registerAction2, Action2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
4
3
  import { AccessibilitySignal } from 'vscode/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService';
5
4
  import { IAccessibilitySignalService } from 'vscode/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService.service';
5
+ import { registerAction2, Action2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
6
6
  import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
7
- import { ViewAction } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPane';
8
7
  import { ActiveEditorContext } from 'vscode/vscode/vs/workbench/common/contextkeys';
9
- import { CHAT_CATEGORY } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
8
+ import { CHAT_CATEGORY, isChatViewTitleActionContext } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
10
9
  import { clearChatEditor } from './chatClear.js';
10
+ import { CHAT_VIEW_ID } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
11
11
  import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
12
12
  import { ChatEditorInput } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatEditorInput';
13
- import { CONTEXT_PROVIDER_EXISTS, CONTEXT_IN_CHAT_SESSION } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
13
+ import { CONTEXT_CHAT_ENABLED, CONTEXT_IN_CHAT_SESSION } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
14
14
 
15
+ const _moduleId = "vs/workbench/contrib/chat/browser/actions/chatClearActions";
15
16
  const ACTION_ID_NEW_CHAT = `workbench.action.chat.newChat`;
16
17
  function registerNewChatActions() {
17
18
  registerAction2(class NewChatEditorAction extends Action2 {
18
19
  constructor() {
19
20
  super({
20
21
  id: 'workbench.action.chatEditor.newChat',
21
- title: ( localize2WithPath(
22
- 'vs/workbench/contrib/chat/browser/actions/chatClearActions',
23
- 'chat.newChat.label',
24
- "New Chat"
25
- )),
22
+ title: ( localize2WithPath(_moduleId, 0, "New Chat")),
26
23
  icon: Codicon.plus,
27
24
  f1: false,
28
- precondition: CONTEXT_PROVIDER_EXISTS,
25
+ precondition: CONTEXT_CHAT_ENABLED,
29
26
  menu: [{
30
27
  id: MenuId.EditorTitle,
31
28
  group: 'navigation',
32
29
  order: 0,
33
- when: ( ActiveEditorContext.isEqualTo(ChatEditorInput.EditorID)),
30
+ when: ( (ActiveEditorContext.isEqualTo(ChatEditorInput.EditorID))),
34
31
  }]
35
32
  });
36
33
  }
@@ -43,14 +40,10 @@ function registerNewChatActions() {
43
40
  constructor() {
44
41
  super({
45
42
  id: ACTION_ID_NEW_CHAT,
46
- title: ( localize2WithPath(
47
- 'vs/workbench/contrib/chat/browser/actions/chatClearActions',
48
- 'chat.newChat.label',
49
- "New Chat"
50
- )),
43
+ title: ( localize2WithPath(_moduleId, 0, "New Chat")),
51
44
  category: CHAT_CATEGORY,
52
45
  icon: Codicon.plus,
53
- precondition: CONTEXT_PROVIDER_EXISTS,
46
+ precondition: CONTEXT_CHAT_ENABLED,
54
47
  f1: true,
55
48
  keybinding: {
56
49
  weight: 200 ,
@@ -60,57 +53,40 @@ function registerNewChatActions() {
60
53
  },
61
54
  when: CONTEXT_IN_CHAT_SESSION
62
55
  },
63
- menu: {
64
- id: MenuId.ChatContext,
65
- group: 'z_clear'
66
- }
56
+ menu: [{
57
+ id: MenuId.ChatContext,
58
+ group: 'z_clear'
59
+ },
60
+ {
61
+ id: MenuId.ViewTitle,
62
+ when: ( (ContextKeyExpr.equals('view', CHAT_VIEW_ID))),
63
+ group: 'navigation',
64
+ order: -1
65
+ }]
67
66
  });
68
67
  }
69
68
  run(accessor, ...args) {
70
- const widgetService = accessor.get(IChatWidgetService);
71
- const widget = widgetService.lastFocusedWidget;
72
- if (!widget) {
73
- return;
69
+ const context = args[0];
70
+ if (isChatViewTitleActionContext(context)) {
71
+ announceChatCleared(accessor);
72
+ context.chatView.clear();
73
+ context.chatView.widget.focusInput();
74
+ }
75
+ else {
76
+ const widgetService = accessor.get(IChatWidgetService);
77
+ const widget = widgetService.lastFocusedWidget;
78
+ if (!widget) {
79
+ return;
80
+ }
81
+ announceChatCleared(accessor);
82
+ widget.clear();
83
+ widget.focusInput();
74
84
  }
75
- announceChatCleared(accessor);
76
- widget.clear();
77
- widget.focusInput();
78
85
  }
79
86
  });
80
87
  }
81
- const getNewChatActionDescriptorForViewTitle = (viewId, providerId) => ({
82
- viewId,
83
- id: `workbench.action.chat.${providerId}.newChat`,
84
- title: ( localize2WithPath(
85
- 'vs/workbench/contrib/chat/browser/actions/chatClearActions',
86
- 'chat.newChat.label',
87
- "New Chat"
88
- )),
89
- menu: {
90
- id: MenuId.ViewTitle,
91
- when: ( ContextKeyExpr.equals('view', viewId)),
92
- group: 'navigation',
93
- order: -1
94
- },
95
- precondition: CONTEXT_PROVIDER_EXISTS,
96
- category: CHAT_CATEGORY,
97
- icon: Codicon.plus,
98
- f1: false
99
- });
100
- function getNewChatAction(viewId, providerId) {
101
- return class NewChatAction extends ViewAction {
102
- constructor() {
103
- super(getNewChatActionDescriptorForViewTitle(viewId, providerId));
104
- }
105
- async runInView(accessor, view) {
106
- announceChatCleared(accessor);
107
- await view.clear();
108
- view.widget.focusInput();
109
- }
110
- };
111
- }
112
88
  function announceChatCleared(accessor) {
113
89
  accessor.get(IAccessibilitySignalService).playSignal(AccessibilitySignal.clear);
114
90
  }
115
91
 
116
- export { ACTION_ID_NEW_CHAT, getNewChatAction, registerNewChatActions };
92
+ export { ACTION_ID_NEW_CHAT, registerNewChatActions };
@@ -12,11 +12,13 @@ import { localize2WithPath } from 'vscode/vscode/vs/nls';
12
12
  import { Action2, registerAction2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
13
13
  import { IClipboardService } from 'vscode/vscode/vs/platform/clipboard/common/clipboardService.service';
14
14
  import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
15
+ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
15
16
  import { TerminalLocation } from 'vscode/vscode/vs/platform/terminal/common/terminal';
16
17
  import { accessibleViewInCodeBlock } from 'vscode/vscode/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration';
17
18
  import { CHAT_CATEGORY } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
18
19
  import { IChatWidgetService, IChatCodeBlockContextProviderService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
19
- import { CONTEXT_PROVIDER_EXISTS, CONTEXT_IN_CHAT_SESSION, CONTEXT_IN_CHAT_INPUT } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
20
+ import { DefaultChatTextEditor } from 'vscode/vscode/vs/workbench/contrib/chat/browser/codeBlockPart';
21
+ import { CONTEXT_CHAT_ENABLED, CONTEXT_IN_CHAT_SESSION, CONTEXT_IN_CHAT_INPUT, CONTEXT_CHAT_EDIT_APPLIED } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
20
22
  import { ChatCopyKind } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
21
23
  import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService.service';
22
24
  import { isResponseVM } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatViewModel';
@@ -26,9 +28,13 @@ import { ITerminalService, ITerminalEditorService, ITerminalGroupService } from
26
28
  import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
27
29
  import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles.service';
28
30
 
31
+ const _moduleId = "vs/workbench/contrib/chat/browser/actions/chatCodeblockActions";
29
32
  function isCodeBlockActionContext(thing) {
30
33
  return typeof thing === 'object' && thing !== null && 'code' in thing && 'element' in thing;
31
34
  }
35
+ function isCodeCompareBlockActionContext(thing) {
36
+ return typeof thing === 'object' && thing !== null && 'element' in thing;
37
+ }
32
38
  function isResponseFiltered(context) {
33
39
  return isResponseVM(context.element) && context.element.errorDetails?.responseIsFiltered;
34
40
  }
@@ -57,11 +63,7 @@ function registerChatCodeBlockActions() {
57
63
  constructor() {
58
64
  super({
59
65
  id: 'workbench.action.chat.copyCodeBlock',
60
- title: ( localize2WithPath(
61
- 'vs/workbench/contrib/chat/browser/actions/chatCodeblockActions',
62
- 'interactive.copyCodeBlock.label',
63
- "Copy"
64
- )),
66
+ title: ( localize2WithPath(_moduleId, 0, "Copy")),
65
67
  f1: false,
66
68
  category: CHAT_CATEGORY,
67
69
  icon: Codicon.copy,
@@ -81,7 +83,6 @@ function registerChatCodeBlockActions() {
81
83
  if (isResponseVM(context.element)) {
82
84
  const chatService = accessor.get(IChatService);
83
85
  chatService.notifyUserAction({
84
- providerId: context.element.providerId,
85
86
  agentId: context.element.agent?.id,
86
87
  sessionId: context.element.sessionId,
87
88
  requestId: context.element.requestId,
@@ -120,7 +121,6 @@ function registerChatCodeBlockActions() {
120
121
  const element = context.element;
121
122
  if (element) {
122
123
  chatService.notifyUserAction({
123
- providerId: element.providerId,
124
124
  agentId: element.agent?.id,
125
125
  sessionId: element.sessionId,
126
126
  requestId: element.requestId,
@@ -145,12 +145,8 @@ function registerChatCodeBlockActions() {
145
145
  constructor() {
146
146
  super({
147
147
  id: 'workbench.action.chat.insertCodeBlock',
148
- title: ( localize2WithPath(
149
- 'vs/workbench/contrib/chat/browser/actions/chatCodeblockActions',
150
- 'interactive.insertCodeBlock.label',
151
- "Insert at Cursor"
152
- )),
153
- precondition: CONTEXT_PROVIDER_EXISTS,
148
+ title: ( localize2WithPath(_moduleId, 1, "Insert at Cursor")),
149
+ precondition: CONTEXT_CHAT_ENABLED,
154
150
  f1: true,
155
151
  category: CHAT_CATEGORY,
156
152
  icon: Codicon.insert,
@@ -160,7 +156,10 @@ function registerChatCodeBlockActions() {
160
156
  when: CONTEXT_IN_CHAT_SESSION
161
157
  },
162
158
  keybinding: {
163
- when: ( ContextKeyExpr.or(( ContextKeyExpr.and(CONTEXT_IN_CHAT_SESSION, ( CONTEXT_IN_CHAT_INPUT.negate()))), accessibleViewInCodeBlock)),
159
+ when: ( (ContextKeyExpr.or(
160
+ (ContextKeyExpr.and(CONTEXT_IN_CHAT_SESSION, (CONTEXT_IN_CHAT_INPUT.negate()))),
161
+ accessibleViewInCodeBlock
162
+ ))),
164
163
  primary: 2048 | 3 ,
165
164
  mac: { primary: 256 | 3 },
166
165
  weight: 400 + 1
@@ -241,28 +240,27 @@ function registerChatCodeBlockActions() {
241
240
  if (usedDocuments) {
242
241
  docRefs.push(usedDocuments);
243
242
  }
244
- const cancellationTokenSource = ( new CancellationTokenSource());
243
+ const cancellationTokenSource = ( (new CancellationTokenSource()));
245
244
  mappedEdits = await mostRelevantProvider.provideMappedEdits(activeModel, [codeBlockActionContext.code], { documents: docRefs }, cancellationTokenSource.token);
246
245
  }
247
246
  if (mappedEdits) {
248
247
  await bulkEditService.apply(mappedEdits);
249
248
  }
250
249
  else {
251
- const activeSelection = codeEditor.getSelection() ?? ( new Range(activeModel.getLineCount(), 1, activeModel.getLineCount(), 1));
250
+ const activeSelection = codeEditor.getSelection() ?? ( (new Range(activeModel.getLineCount(), 1, activeModel.getLineCount(), 1)));
252
251
  await bulkEditService.apply([
253
- ( new ResourceTextEdit(activeModel.uri, {
252
+ ( (new ResourceTextEdit(activeModel.uri, {
254
253
  range: activeSelection,
255
254
  text: codeBlockActionContext.code,
256
- })),
255
+ }))),
257
256
  ]);
258
257
  }
259
- codeEditorService.listCodeEditors().find(editor => editor.getModel()?.uri.toString() === ( activeModel.uri.toString()))?.focus();
258
+ codeEditorService.listCodeEditors().find(editor => editor.getModel()?.uri.toString() === ( (activeModel.uri.toString())))?.focus();
260
259
  }
261
260
  notifyUserAction(accessor, context) {
262
261
  if (isResponseVM(context.element)) {
263
262
  const chatService = accessor.get(IChatService);
264
263
  chatService.notifyUserAction({
265
- providerId: context.element.providerId,
266
264
  agentId: context.element.agent?.id,
267
265
  sessionId: context.element.sessionId,
268
266
  requestId: context.element.requestId,
@@ -280,12 +278,8 @@ function registerChatCodeBlockActions() {
280
278
  constructor() {
281
279
  super({
282
280
  id: 'workbench.action.chat.insertIntoNewFile',
283
- title: ( localize2WithPath(
284
- 'vs/workbench/contrib/chat/browser/actions/chatCodeblockActions',
285
- 'interactive.insertIntoNewFile.label',
286
- "Insert into New File"
287
- )),
288
- precondition: CONTEXT_PROVIDER_EXISTS,
281
+ title: ( localize2WithPath(_moduleId, 2, "Insert into New File")),
282
+ precondition: CONTEXT_CHAT_ENABLED,
289
283
  f1: true,
290
284
  category: CHAT_CATEGORY,
291
285
  icon: Codicon.newFile,
@@ -305,7 +299,6 @@ function registerChatCodeBlockActions() {
305
299
  editorService.openEditor({ contents: context.code, languageId: context.languageId, resource: undefined });
306
300
  if (isResponseVM(context.element)) {
307
301
  chatService.notifyUserAction({
308
- providerId: context.element.providerId,
309
302
  agentId: context.element.agent?.id,
310
303
  sessionId: context.element.sessionId,
311
304
  requestId: context.element.requestId,
@@ -333,25 +326,28 @@ function registerChatCodeBlockActions() {
333
326
  constructor() {
334
327
  super({
335
328
  id: 'workbench.action.chat.runInTerminal',
336
- title: ( localize2WithPath(
337
- 'vs/workbench/contrib/chat/browser/actions/chatCodeblockActions',
338
- 'interactive.runInTerminal.label',
339
- "Insert into Terminal"
340
- )),
341
- precondition: CONTEXT_PROVIDER_EXISTS,
329
+ title: ( localize2WithPath(_moduleId, 3, "Insert into Terminal")),
330
+ precondition: CONTEXT_CHAT_ENABLED,
342
331
  f1: true,
343
332
  category: CHAT_CATEGORY,
344
333
  icon: Codicon.terminal,
345
334
  menu: [{
346
335
  id: MenuId.ChatCodeBlock,
347
336
  group: 'navigation',
348
- when: ( ContextKeyExpr.and(CONTEXT_IN_CHAT_SESSION, ( ContextKeyExpr.or(...( shellLangIds.map(e => ( ContextKeyExpr.equals(EditorContextKeys.languageId.key, e)))))))),
337
+ when: ( (ContextKeyExpr.and(
338
+ CONTEXT_IN_CHAT_SESSION,
339
+ (ContextKeyExpr.or(...( (shellLangIds.map(
340
+ e => ( (ContextKeyExpr.equals(EditorContextKeys.languageId.key, e)))
341
+ )))))
342
+ ))),
349
343
  },
350
344
  {
351
345
  id: MenuId.ChatCodeBlock,
352
346
  group: 'navigation',
353
347
  isHiddenByDefault: true,
354
- when: ( ContextKeyExpr.and(CONTEXT_IN_CHAT_SESSION, ...( shellLangIds.map(e => ( ContextKeyExpr.notEquals(EditorContextKeys.languageId.key, e))))))
348
+ when: ( (ContextKeyExpr.and(CONTEXT_IN_CHAT_SESSION, ...( (shellLangIds.map(
349
+ e => ( (ContextKeyExpr.notEquals(EditorContextKeys.languageId.key, e)))
350
+ ))))))
355
351
  }],
356
352
  keybinding: [{
357
353
  primary: 2048 | 512 | 3 ,
@@ -359,7 +355,7 @@ function registerChatCodeBlockActions() {
359
355
  primary: 256 | 512 | 3
360
356
  },
361
357
  weight: 100 ,
362
- when: ( ContextKeyExpr.or(CONTEXT_IN_CHAT_SESSION, accessibleViewInCodeBlock)),
358
+ when: ( (ContextKeyExpr.or(CONTEXT_IN_CHAT_SESSION, accessibleViewInCodeBlock))),
363
359
  }]
364
360
  });
365
361
  }
@@ -387,7 +383,6 @@ function registerChatCodeBlockActions() {
387
383
  terminal.runCommand(context.code, false);
388
384
  if (isResponseVM(context.element)) {
389
385
  chatService.notifyUserAction({
390
- providerId: context.element.providerId,
391
386
  agentId: context.element.agent?.id,
392
387
  sessionId: context.element.sessionId,
393
388
  requestId: context.element.requestId,
@@ -430,18 +425,14 @@ function registerChatCodeBlockActions() {
430
425
  constructor() {
431
426
  super({
432
427
  id: 'workbench.action.chat.nextCodeBlock',
433
- title: ( localize2WithPath(
434
- 'vs/workbench/contrib/chat/browser/actions/chatCodeblockActions',
435
- 'interactive.nextCodeBlock.label',
436
- "Next Code Block"
437
- )),
428
+ title: ( localize2WithPath(_moduleId, 4, "Next Code Block")),
438
429
  keybinding: {
439
430
  primary: 2048 | 512 | 12 ,
440
431
  mac: { primary: 2048 | 512 | 12 , },
441
432
  weight: 200 ,
442
433
  when: CONTEXT_IN_CHAT_SESSION,
443
434
  },
444
- precondition: CONTEXT_PROVIDER_EXISTS,
435
+ precondition: CONTEXT_CHAT_ENABLED,
445
436
  f1: true,
446
437
  category: CHAT_CATEGORY,
447
438
  });
@@ -454,18 +445,14 @@ function registerChatCodeBlockActions() {
454
445
  constructor() {
455
446
  super({
456
447
  id: 'workbench.action.chat.previousCodeBlock',
457
- title: ( localize2WithPath(
458
- 'vs/workbench/contrib/chat/browser/actions/chatCodeblockActions',
459
- 'interactive.previousCodeBlock.label',
460
- "Previous Code Block"
461
- )),
448
+ title: ( localize2WithPath(_moduleId, 5, "Previous Code Block")),
462
449
  keybinding: {
463
450
  primary: 2048 | 512 | 11 ,
464
451
  mac: { primary: 2048 | 512 | 11 , },
465
452
  weight: 200 ,
466
453
  when: CONTEXT_IN_CHAT_SESSION,
467
454
  },
468
- precondition: CONTEXT_PROVIDER_EXISTS,
455
+ precondition: CONTEXT_CHAT_ENABLED,
469
456
  f1: true,
470
457
  category: CHAT_CATEGORY,
471
458
  });
@@ -500,5 +487,45 @@ function getContextFromEditor(editor, accessor) {
500
487
  languageId: editor.getModel().getLanguageId(),
501
488
  };
502
489
  }
490
+ function registerChatCodeCompareBlockActions() {
491
+ class ChatCompareCodeBlockAction extends Action2 {
492
+ run(accessor, ...args) {
493
+ const context = args[0];
494
+ if (!isCodeCompareBlockActionContext(context)) {
495
+ return;
496
+ }
497
+ return this.runWithContext(accessor, context);
498
+ }
499
+ }
500
+ registerAction2(class ApplyEditsCompareBlockAction extends ChatCompareCodeBlockAction {
501
+ constructor() {
502
+ super({
503
+ id: 'workbench.action.chat.applyCompareEdits',
504
+ title: ( localize2WithPath(_moduleId, 6, "Apply Edits")),
505
+ f1: false,
506
+ category: CHAT_CATEGORY,
507
+ icon: Codicon.check,
508
+ precondition: ( (ContextKeyExpr.and(
509
+ EditorContextKeys.hasChanges,
510
+ (CONTEXT_CHAT_EDIT_APPLIED.negate())
511
+ ))),
512
+ menu: {
513
+ id: MenuId.ChatCompareBlock,
514
+ group: 'navigation'
515
+ }
516
+ });
517
+ }
518
+ async runWithContext(accessor, context) {
519
+ const editorService = accessor.get(IEditorService);
520
+ const instaService = accessor.get(IInstantiationService);
521
+ const editor = instaService.createInstance(DefaultChatTextEditor);
522
+ await editor.apply(context.element, context.edit);
523
+ await editorService.openEditor({
524
+ resource: context.edit.uri,
525
+ options: { revealIfVisible: true },
526
+ });
527
+ }
528
+ });
529
+ }
503
530
 
504
- export { isCodeBlockActionContext, registerChatCodeBlockActions };
531
+ export { isCodeBlockActionContext, isCodeCompareBlockActionContext, registerChatCodeBlockActions, registerChatCodeCompareBlockActions };
@@ -6,21 +6,18 @@ import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/brow
6
6
  import { CONTEXT_RESPONSE_FILTERED } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
7
7
  import { isRequestVM, isResponseVM } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatViewModel';
8
8
 
9
+ const _moduleId = "vs/workbench/contrib/chat/browser/actions/chatCopyActions";
9
10
  function registerChatCopyActions() {
10
11
  registerAction2(class CopyAllAction extends Action2 {
11
12
  constructor() {
12
13
  super({
13
14
  id: 'workbench.action.chat.copyAll',
14
- title: ( localize2WithPath(
15
- 'vs/workbench/contrib/chat/browser/actions/chatCopyActions',
16
- 'interactive.copyAll.label',
17
- "Copy All"
18
- )),
15
+ title: ( localize2WithPath(_moduleId, 0, "Copy All")),
19
16
  f1: false,
20
17
  category: CHAT_CATEGORY,
21
18
  menu: {
22
19
  id: MenuId.ChatContext,
23
- when: ( CONTEXT_RESPONSE_FILTERED.toNegated()),
20
+ when: ( (CONTEXT_RESPONSE_FILTERED.toNegated())),
24
21
  group: 'copy',
25
22
  }
26
23
  });
@@ -45,16 +42,12 @@ function registerChatCopyActions() {
45
42
  constructor() {
46
43
  super({
47
44
  id: 'workbench.action.chat.copyItem',
48
- title: ( localize2WithPath(
49
- 'vs/workbench/contrib/chat/browser/actions/chatCopyActions',
50
- 'interactive.copyItem.label',
51
- "Copy"
52
- )),
45
+ title: ( localize2WithPath(_moduleId, 1, "Copy")),
53
46
  f1: false,
54
47
  category: CHAT_CATEGORY,
55
48
  menu: {
56
49
  id: MenuId.ChatContext,
57
- when: ( CONTEXT_RESPONSE_FILTERED.toNegated()),
50
+ when: ( (CONTEXT_RESPONSE_FILTERED.toNegated())),
58
51
  group: 'copy',
59
52
  }
60
53
  });
@@ -2,25 +2,22 @@ import { localize2WithPath } from 'vscode/vscode/vs/nls';
2
2
  import { registerAction2, Action2 } from 'vscode/vscode/vs/platform/actions/common/actions';
3
3
  import { CHAT_CATEGORY } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
4
4
  import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
5
- import { CONTEXT_IN_CHAT_SESSION, CONTEXT_PROVIDER_EXISTS } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
5
+ import { CONTEXT_IN_CHAT_SESSION, CONTEXT_CHAT_ENABLED } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
6
6
  import { isResponseVM } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatViewModel';
7
7
 
8
+ const _moduleId = "vs/workbench/contrib/chat/browser/actions/chatFileTreeActions";
8
9
  function registerChatFileTreeActions() {
9
10
  registerAction2(class NextFileTreeAction extends Action2 {
10
11
  constructor() {
11
12
  super({
12
13
  id: 'workbench.action.chat.nextFileTree',
13
- title: ( localize2WithPath(
14
- 'vs/workbench/contrib/chat/browser/actions/chatFileTreeActions',
15
- 'interactive.nextFileTree.label',
16
- "Next File Tree"
17
- )),
14
+ title: ( localize2WithPath(_moduleId, 0, "Next File Tree")),
18
15
  keybinding: {
19
16
  primary: 2048 | 67 ,
20
17
  weight: 200 ,
21
18
  when: CONTEXT_IN_CHAT_SESSION,
22
19
  },
23
- precondition: CONTEXT_PROVIDER_EXISTS,
20
+ precondition: CONTEXT_CHAT_ENABLED,
24
21
  f1: true,
25
22
  category: CHAT_CATEGORY,
26
23
  });
@@ -33,17 +30,13 @@ function registerChatFileTreeActions() {
33
30
  constructor() {
34
31
  super({
35
32
  id: 'workbench.action.chat.previousFileTree',
36
- title: ( localize2WithPath(
37
- 'vs/workbench/contrib/chat/browser/actions/chatFileTreeActions',
38
- 'interactive.previousFileTree.label',
39
- "Previous File Tree"
40
- )),
33
+ title: ( localize2WithPath(_moduleId, 1, "Previous File Tree")),
41
34
  keybinding: {
42
35
  primary: 2048 | 1024 | 67 ,
43
36
  weight: 200 ,
44
37
  when: CONTEXT_IN_CHAT_SESSION,
45
38
  },
46
- precondition: CONTEXT_PROVIDER_EXISTS,
39
+ precondition: CONTEXT_CHAT_ENABLED,
47
40
  f1: true,
48
41
  category: CHAT_CATEGORY,
49
42
  });