@codingame/monaco-vscode-chat-service-override 5.2.0 → 6.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 (30) hide show
  1. package/chat.js +5 -7
  2. package/package.json +2 -2
  3. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +160 -0
  4. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +17 -11
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +15 -13
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +215 -0
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +1 -9
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +6 -4
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.js +15 -93
  10. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +27 -106
  11. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +5 -2
  12. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +6 -1
  13. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.js +95 -51
  14. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +4 -4
  15. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +94 -0
  16. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +64 -8
  17. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +2 -1
  18. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatContextAttachments.js +50 -0
  19. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputCompletions.js +370 -0
  20. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +19 -366
  21. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +122 -63
  22. package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +12 -5
  23. package/vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js +6 -5
  24. package/vscode/src/vs/workbench/contrib/chat/common/{voiceChat.js → voiceChatService.js} +58 -21
  25. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +15 -14
  26. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +33 -32
  27. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +6 -3
  28. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatHistoryVariables.js +0 -26
  29. package/vscode/src/vs/workbench/contrib/chat/common/languageModels.js +0 -50
  30. package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl.js +0 -33
package/chat.js CHANGED
@@ -5,8 +5,8 @@ import { QuickChatService } from './vscode/src/vs/workbench/contrib/chat/browser
5
5
  import { ChatVariablesService } from './vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js';
6
6
  import { ChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatWidget';
7
7
  import { ChatCodeBlockContextProviderService } from './vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.js';
8
- import { ChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
9
- import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
8
+ import { ChatAgentService, ChatAgentNameService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
9
+ import { IChatAgentService, IChatAgentNameService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
10
10
  import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService.service';
11
11
  import { ChatService } from './vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js';
12
12
  import { ChatSlashCommandService } from './vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js';
@@ -15,14 +15,12 @@ import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/c
15
15
  import { ChatWidgetHistoryService } from './vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js';
16
16
  import { IChatWidgetHistoryService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatWidgetHistoryService.service';
17
17
  import { ILanguageModelStatsService } from 'vscode/vscode/vs/workbench/contrib/chat/common/languageModelStats.service';
18
- import { LanguageModelsService } from './vscode/src/vs/workbench/contrib/chat/common/languageModels.js';
18
+ import { LanguageModelsService } from 'vscode/vscode/vs/workbench/contrib/chat/common/languageModels';
19
19
  import { ILanguageModelsService } from 'vscode/vscode/vs/workbench/contrib/chat/common/languageModels.service';
20
20
  import { IInlineChatSavingService } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSavingService.service';
21
21
  import { InlineChatSavingServiceImpl } from './vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js';
22
22
  import { IInlineChatSessionService } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService.service';
23
23
  import { InlineChatSessionServiceImpl } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl';
24
- import { IInlineChatService } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat.service';
25
- import { InlineChatServiceImpl } from './vscode/src/vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl.js';
26
24
  import { LanguageModelStatsService } from './vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js';
27
25
  import './vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js';
28
26
  import './vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js';
@@ -38,11 +36,11 @@ function getServiceOverride() {
38
36
  [( IChatSlashCommandService.toString())]: new SyncDescriptor(ChatSlashCommandService, [], true),
39
37
  [( IChatAgentService.toString())]: new SyncDescriptor(ChatAgentService, [], true),
40
38
  [( IChatVariablesService.toString())]: new SyncDescriptor(ChatVariablesService, [], true),
41
- [( IInlineChatService.toString())]: new SyncDescriptor(InlineChatServiceImpl, [], true),
42
39
  [( IInlineChatSessionService.toString())]: new SyncDescriptor(InlineChatSessionServiceImpl, [], true),
43
40
  [( IInlineChatSavingService.toString())]: new SyncDescriptor(InlineChatSavingServiceImpl, [], true),
44
41
  [( IChatCodeBlockContextProviderService.toString())]: new SyncDescriptor(ChatCodeBlockContextProviderService, [], true),
45
- [( ILanguageModelStatsService.toString())]: new SyncDescriptor(LanguageModelStatsService, [], true)
42
+ [( ILanguageModelStatsService.toString())]: new SyncDescriptor(LanguageModelStatsService, [], true),
43
+ [( IChatAgentNameService.toString())]: new SyncDescriptor(ChatAgentNameService, [], true)
46
44
  };
47
45
  }
48
46
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-chat-service-override",
3
- "version": "5.2.0",
3
+ "version": "6.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@5.2.0"
29
+ "vscode": "npm:@codingame/monaco-vscode-api@6.0.0"
30
30
  }
31
31
  }
@@ -0,0 +1,160 @@
1
+ import { localizeWithPath } from 'vscode/vscode/vs/nls';
2
+ import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
3
+ import { AccessibleViewType, AccessibleViewProviderId } from 'vscode/vscode/vs/platform/accessibility/browser/accessibleView';
4
+ import { AccessibilityVerbositySettingId } from 'vscode/vscode/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration';
5
+ import { AccessibleDiffViewerNext } from 'vscode/vscode/vs/editor/browser/widget/diffEditor/commands';
6
+ import { INLINE_CHAT_ID } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
7
+ import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
8
+ import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
9
+ import { CONTEXT_IN_CHAT_SESSION, CONTEXT_RESPONSE, CONTEXT_REQUEST } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
10
+
11
+ const _moduleId = "vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp";
12
+ class ChatAccessibilityHelp {
13
+ constructor() {
14
+ this.priority = 105;
15
+ this.name = 'panelChat';
16
+ this.type = AccessibleViewType.Help;
17
+ this.when = ( (ContextKeyExpr.or(CONTEXT_IN_CHAT_SESSION, CONTEXT_RESPONSE, CONTEXT_REQUEST)));
18
+ }
19
+ getProvider(accessor) {
20
+ const codeEditor = accessor.get(ICodeEditorService).getActiveCodeEditor() || accessor.get(ICodeEditorService).getFocusedCodeEditor();
21
+ return getChatAccessibilityHelpProvider(accessor, codeEditor ?? undefined, 'panelChat');
22
+ }
23
+ dispose() { }
24
+ }
25
+ function getAccessibilityHelpText(type) {
26
+ const content = [];
27
+ if (type === 'panelChat') {
28
+ content.push(( localizeWithPath(
29
+ _moduleId,
30
+ 0,
31
+ 'The chat view is comprised of an input box and a request/response list. The input box is used to make requests and the list is used to display responses.'
32
+ )));
33
+ content.push(( localizeWithPath(
34
+ _moduleId,
35
+ 1,
36
+ 'In the input box, use up and down arrows to navigate your request history. Edit input and use enter or the submit button to run a new request.'
37
+ )));
38
+ content.push(( localizeWithPath(
39
+ _moduleId,
40
+ 2,
41
+ 'In the input box, inspect the last response in the accessible view<keybinding:editor.action.accessibleView>'
42
+ )));
43
+ content.push(( localizeWithPath(
44
+ _moduleId,
45
+ 3,
46
+ 'In the input box, navigate to the suggested follow up question (Shift+Tab) and press Enter to run it.'
47
+ )));
48
+ content.push(( localizeWithPath(
49
+ _moduleId,
50
+ 4,
51
+ 'Chat responses will be announced as they come in. A response will indicate the number of code blocks, if any, and then the rest of the response.'
52
+ )));
53
+ content.push(( localizeWithPath(
54
+ _moduleId,
55
+ 5,
56
+ 'To focus the chat request/response list, which can be navigated with up and down arrows, invoke the Focus Chat command<keybinding:chat.action.focus>.'
57
+ )));
58
+ content.push(( localizeWithPath(
59
+ _moduleId,
60
+ 6,
61
+ 'To focus the input box for chat requests, invoke the Focus Chat Input command<keybinding:workbench.action.chat.focusInput>.'
62
+ )));
63
+ content.push(( localizeWithPath(
64
+ _moduleId,
65
+ 7,
66
+ 'To focus the next code block within a response, invoke the Chat: Next Code Block command<keybinding:workbench.action.chat.nextCodeBlock>.'
67
+ )));
68
+ content.push(( localizeWithPath(
69
+ _moduleId,
70
+ 8,
71
+ 'To focus the next file tree within a response, invoke the Chat: Next File Tree command<keybinding:workbench.action.chat.nextFileTree>.'
72
+ )));
73
+ content.push(( localizeWithPath(
74
+ _moduleId,
75
+ 9,
76
+ 'To clear the request/response list, invoke the Chat Clear command<keybinding:workbench.action.chat.clear>.'
77
+ )));
78
+ }
79
+ else {
80
+ content.push(( localizeWithPath(
81
+ _moduleId,
82
+ 10,
83
+ "Inline chat occurs within a code editor and takes into account the current selection. It is useful for making changes to the current editor. For example, fixing diagnostics, documenting or refactoring code. Keep in mind that AI generated code may be incorrect."
84
+ )));
85
+ content.push(( localizeWithPath(
86
+ _moduleId,
87
+ 11,
88
+ "It can be activated via code actions or directly using the command: Inline Chat: Start Inline Chat<keybinding:inlineChat.start>."
89
+ )));
90
+ content.push(( localizeWithPath(
91
+ _moduleId,
92
+ 12,
93
+ 'In the input box, use<keybinding:inlineChat.previousFromHistory> and<keybinding:inlineChat.nextFromHistory> to navigate your request history. Edit input and use enter or the submit button to run a new request.'
94
+ )));
95
+ content.push(( localizeWithPath(
96
+ _moduleId,
97
+ 13,
98
+ 'In the input box, inspect the response in the accessible viewview<keybinding:editor.action.accessibleView>'
99
+ )));
100
+ content.push(( localizeWithPath(
101
+ _moduleId,
102
+ 14,
103
+ "Context menu actions may run a request prefixed with a /. Type / to discover such ready-made commands."
104
+ )));
105
+ content.push(( localizeWithPath(
106
+ _moduleId,
107
+ 15,
108
+ "If a fix action is invoked, a response will indicate the problem with the current code. A diff editor will be rendered and can be reached by tabbing."
109
+ )));
110
+ content.push(( localizeWithPath(
111
+ _moduleId,
112
+ 16,
113
+ "Once in the diff editor, enter review mode with<keybinding:{0}>. Use up and down arrows to navigate lines with the proposed changes.",
114
+ AccessibleDiffViewerNext.id
115
+ )));
116
+ content.push(( localizeWithPath(
117
+ _moduleId,
118
+ 17,
119
+ "Use tab to reach conditional parts like commands, status, message responses and more."
120
+ )));
121
+ }
122
+ content.push(( localizeWithPath(
123
+ _moduleId,
124
+ 18,
125
+ "Accessibility Signals can be changed via settings with a prefix of signals.chat. By default, if a request takes more than 4 seconds, you will hear a sound indicating that progress is still occurring."
126
+ )));
127
+ return content.join('\n\n');
128
+ }
129
+ function getChatAccessibilityHelpProvider(accessor, editor, type) {
130
+ const widgetService = accessor.get(IChatWidgetService);
131
+ const inputEditor = type === 'panelChat' ? widgetService.lastFocusedWidget?.inputEditor : editor;
132
+ if (!inputEditor) {
133
+ return;
134
+ }
135
+ const domNode = inputEditor.getDomNode() ?? undefined;
136
+ if (!domNode) {
137
+ return;
138
+ }
139
+ const cachedPosition = inputEditor.getPosition();
140
+ inputEditor.getSupportedActions();
141
+ const helpText = getAccessibilityHelpText(type);
142
+ return {
143
+ id: type === 'panelChat' ? AccessibleViewProviderId.Chat : AccessibleViewProviderId.InlineChat,
144
+ verbositySettingKey: type === 'panelChat' ? AccessibilityVerbositySettingId.Chat : AccessibilityVerbositySettingId.InlineChat,
145
+ provideContent: () => helpText,
146
+ onClose: () => {
147
+ if (type === 'panelChat' && cachedPosition) {
148
+ inputEditor.setPosition(cachedPosition);
149
+ inputEditor.focus();
150
+ }
151
+ else if (type === 'inlineChat') {
152
+ const ctrl = editor?.getContribution(INLINE_CHAT_ID);
153
+ ctrl?.focus();
154
+ }
155
+ },
156
+ options: { type: AccessibleViewType.Help }
157
+ };
158
+ }
159
+
160
+ export { ChatAccessibilityHelp, getAccessibilityHelpText, getChatAccessibilityHelpProvider };
@@ -1,9 +1,11 @@
1
1
  import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
2
+ import { KeyMod, KeyCode } from 'vscode/vscode/vs/base/common/keyCodes';
2
3
  import { localize2WithPath } from 'vscode/vscode/vs/nls';
3
4
  import { AccessibilitySignal } from 'vscode/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService';
4
5
  import { IAccessibilitySignalService } from 'vscode/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService.service';
5
6
  import { registerAction2, Action2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
6
7
  import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
8
+ import { KeybindingWeight } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
7
9
  import { ActiveEditorContext } from 'vscode/vscode/vs/workbench/common/contextkeys';
8
10
  import { CHAT_CATEGORY, isChatViewTitleActionContext } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
9
11
  import { clearChatEditor } from './chatClear.js';
@@ -11,6 +13,7 @@ import { CHAT_VIEW_ID } from 'vscode/vscode/vs/workbench/contrib/chat/browser/ch
11
13
  import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
12
14
  import { ChatEditorInput } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatEditorInput';
13
15
  import { CONTEXT_CHAT_ENABLED, CONTEXT_IN_CHAT_SESSION } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
16
+ import { IViewsService } from 'vscode/vscode/vs/workbench/services/views/common/viewsService.service';
14
17
 
15
18
  const _moduleId = "vs/workbench/contrib/chat/browser/actions/chatClearActions";
16
19
  const ACTION_ID_NEW_CHAT = `workbench.action.chat.newChat`;
@@ -32,7 +35,7 @@ function registerNewChatActions() {
32
35
  });
33
36
  }
34
37
  async run(accessor, ...args) {
35
- announceChatCleared(accessor);
38
+ announceChatCleared(accessor.get(IAccessibilitySignalService));
36
39
  await clearChatEditor(accessor);
37
40
  }
38
41
  });
@@ -46,10 +49,10 @@ function registerNewChatActions() {
46
49
  precondition: CONTEXT_CHAT_ENABLED,
47
50
  f1: true,
48
51
  keybinding: {
49
- weight: 200 ,
50
- primary: 2048 | 42 ,
52
+ weight: KeybindingWeight.WorkbenchContrib,
53
+ primary: KeyMod.CtrlCmd | KeyCode.KeyL,
51
54
  mac: {
52
- primary: 256 | 42
55
+ primary: KeyMod.WinCtrl | KeyCode.KeyL
53
56
  },
54
57
  when: CONTEXT_IN_CHAT_SESSION
55
58
  },
@@ -65,28 +68,31 @@ function registerNewChatActions() {
65
68
  }]
66
69
  });
67
70
  }
68
- run(accessor, ...args) {
71
+ async run(accessor, ...args) {
69
72
  const context = args[0];
73
+ const accessibilitySignalService = accessor.get(IAccessibilitySignalService);
70
74
  if (isChatViewTitleActionContext(context)) {
71
- announceChatCleared(accessor);
75
+ announceChatCleared(accessibilitySignalService);
72
76
  context.chatView.clear();
73
77
  context.chatView.widget.focusInput();
74
78
  }
75
79
  else {
76
80
  const widgetService = accessor.get(IChatWidgetService);
77
- const widget = widgetService.lastFocusedWidget;
81
+ const viewsService = accessor.get(IViewsService);
82
+ let widget = widgetService.lastFocusedWidget;
78
83
  if (!widget) {
79
- return;
84
+ const chatView = await viewsService.openView(CHAT_VIEW_ID);
85
+ widget = chatView.widget;
80
86
  }
81
- announceChatCleared(accessor);
87
+ announceChatCleared(accessibilitySignalService);
82
88
  widget.clear();
83
89
  widget.focusInput();
84
90
  }
85
91
  }
86
92
  });
87
93
  }
88
- function announceChatCleared(accessor) {
89
- accessor.get(IAccessibilitySignalService).playSignal(AccessibilitySignal.clear);
94
+ function announceChatCleared(accessibilitySignalService) {
95
+ accessibilitySignalService.playSignal(AccessibilitySignal.clear);
90
96
  }
91
97
 
92
98
  export { ACTION_ID_NEW_CHAT, registerNewChatActions };
@@ -1,5 +1,6 @@
1
1
  import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
2
2
  import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
3
+ import { KeyMod, KeyCode } from 'vscode/vscode/vs/base/common/keyCodes';
3
4
  import { isDiffEditor, isCodeEditor } from 'vscode/vscode/vs/editor/browser/editorBrowser';
4
5
  import { IBulkEditService, ResourceTextEdit } from 'vscode/vscode/vs/editor/browser/services/bulkEditService';
5
6
  import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
@@ -13,6 +14,7 @@ import { Action2, registerAction2, MenuId } from 'vscode/vscode/vs/platform/acti
13
14
  import { IClipboardService } from 'vscode/vscode/vs/platform/clipboard/common/clipboardService.service';
14
15
  import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
15
16
  import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
17
+ import { KeybindingWeight } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
16
18
  import { TerminalLocation } from 'vscode/vscode/vs/platform/terminal/common/terminal';
17
19
  import { accessibleViewInCodeBlock } from 'vscode/vscode/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration';
18
20
  import { CHAT_CATEGORY } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
@@ -160,9 +162,9 @@ function registerChatCodeBlockActions() {
160
162
  (ContextKeyExpr.and(CONTEXT_IN_CHAT_SESSION, (CONTEXT_IN_CHAT_INPUT.negate()))),
161
163
  accessibleViewInCodeBlock
162
164
  ))),
163
- primary: 2048 | 3 ,
164
- mac: { primary: 256 | 3 },
165
- weight: 400 + 1
165
+ primary: KeyMod.CtrlCmd | KeyCode.Enter,
166
+ mac: { primary: KeyMod.WinCtrl | KeyCode.Enter },
167
+ weight: KeybindingWeight.ExternalExtension + 1
166
168
  },
167
169
  });
168
170
  }
@@ -350,11 +352,11 @@ function registerChatCodeBlockActions() {
350
352
  ))))))
351
353
  }],
352
354
  keybinding: [{
353
- primary: 2048 | 512 | 3 ,
355
+ primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.Enter,
354
356
  mac: {
355
- primary: 256 | 512 | 3
357
+ primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.Enter
356
358
  },
357
- weight: 100 ,
359
+ weight: KeybindingWeight.EditorContrib,
358
360
  when: ( (ContextKeyExpr.or(CONTEXT_IN_CHAT_SESSION, accessibleViewInCodeBlock))),
359
361
  }]
360
362
  });
@@ -427,9 +429,9 @@ function registerChatCodeBlockActions() {
427
429
  id: 'workbench.action.chat.nextCodeBlock',
428
430
  title: ( localize2WithPath(_moduleId, 4, "Next Code Block")),
429
431
  keybinding: {
430
- primary: 2048 | 512 | 12 ,
431
- mac: { primary: 2048 | 512 | 12 , },
432
- weight: 200 ,
432
+ primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageDown,
433
+ mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageDown, },
434
+ weight: KeybindingWeight.WorkbenchContrib,
433
435
  when: CONTEXT_IN_CHAT_SESSION,
434
436
  },
435
437
  precondition: CONTEXT_CHAT_ENABLED,
@@ -447,9 +449,9 @@ function registerChatCodeBlockActions() {
447
449
  id: 'workbench.action.chat.previousCodeBlock',
448
450
  title: ( localize2WithPath(_moduleId, 5, "Previous Code Block")),
449
451
  keybinding: {
450
- primary: 2048 | 512 | 11 ,
451
- mac: { primary: 2048 | 512 | 11 , },
452
- weight: 200 ,
452
+ primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageUp,
453
+ mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageUp, },
454
+ weight: KeybindingWeight.WorkbenchContrib,
453
455
  when: CONTEXT_IN_CHAT_SESSION,
454
456
  },
455
457
  precondition: CONTEXT_CHAT_ENABLED,
@@ -519,7 +521,7 @@ function registerChatCodeCompareBlockActions() {
519
521
  const editorService = accessor.get(IEditorService);
520
522
  const instaService = accessor.get(IInstantiationService);
521
523
  const editor = instaService.createInstance(DefaultChatTextEditor);
522
- await editor.apply(context.element, context.edit);
524
+ await editor.apply(context.element, context.edit, context.diffEditor);
523
525
  await editorService.openEditor({
524
526
  resource: context.edit.uri,
525
527
  options: { revealIfVisible: true },
@@ -0,0 +1,215 @@
1
+ import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
2
+ import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
3
+ import { KeyMod, KeyCode } from 'vscode/vscode/vs/base/common/keyCodes';
4
+ import { Schemas } from 'vscode/vscode/vs/base/common/network';
5
+ import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
6
+ import { URI } from 'vscode/vscode/vs/base/common/uri';
7
+ import { AbstractGotoSymbolQuickAccessProvider } from 'vscode/vscode/vs/editor/contrib/quickAccess/browser/gotoSymbolQuickAccess';
8
+ import { localize2WithPath, localizeWithPath } from 'vscode/vscode/vs/nls';
9
+ import { registerAction2, Action2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
10
+ import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands.service';
11
+ import { KeybindingWeight } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
12
+ import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput.service';
13
+ import { CHAT_CATEGORY } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
14
+ import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
15
+ import { ChatContextAttachments } from '../contrib/chatContextAttachments.js';
16
+ import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
17
+ import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
18
+ import { CONTEXT_IN_CHAT_INPUT, CONTEXT_CHAT_LOCATION, CONTEXT_IN_QUICK_CHAT } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
19
+ import { ChatRequestAgentPart } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
20
+ import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatVariables.service';
21
+ import { AnythingQuickAccessProvider } from 'vscode/vscode/vs/workbench/contrib/search/browser/anythingQuickAccess';
22
+ import { SymbolsQuickAccessProvider } from 'vscode/vscode/vs/workbench/contrib/search/browser/symbolsQuickAccess';
23
+ import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
24
+
25
+ const _moduleId = "vs/workbench/contrib/chat/browser/actions/chatContextActions";
26
+ function registerChatContextActions() {
27
+ registerAction2(AttachContextAction);
28
+ }
29
+ class AttachContextAction extends Action2 {
30
+ static { this.ID = 'workbench.action.chat.attachContext'; }
31
+ constructor() {
32
+ super({
33
+ id: AttachContextAction.ID,
34
+ title: ( localize2WithPath(_moduleId, 0, "Attach Context")),
35
+ icon: Codicon.attach,
36
+ category: CHAT_CATEGORY,
37
+ keybinding: {
38
+ when: CONTEXT_IN_CHAT_INPUT,
39
+ primary: KeyMod.CtrlCmd | KeyCode.Slash,
40
+ weight: KeybindingWeight.EditorContrib
41
+ },
42
+ menu: [
43
+ {
44
+ when: ( (ContextKeyExpr.and(
45
+ (CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.Panel)),
46
+ (CONTEXT_IN_QUICK_CHAT.isEqualTo(false))
47
+ ))),
48
+ id: MenuId.ChatExecute,
49
+ group: 'navigation',
50
+ },
51
+ ]
52
+ });
53
+ }
54
+ _getFileContextId(item) {
55
+ if ('resource' in item) {
56
+ return (
57
+ (item.resource.toString())
58
+ );
59
+ }
60
+ return ( (item.uri.toString())) + (item.range.startLineNumber !== item.range.endLineNumber ?
61
+ `:${item.range.startLineNumber}-${item.range.endLineNumber}` :
62
+ `:${item.range.startLineNumber}`);
63
+ }
64
+ async _attachContext(widget, commandService, ...picks) {
65
+ const toAttach = [];
66
+ for (const pick of picks) {
67
+ if (pick && typeof pick === 'object' && 'command' in pick && pick.command) {
68
+ const selection = await commandService.executeCommand(pick.command.id, ...(pick.command.arguments ?? []));
69
+ if (!selection) {
70
+ continue;
71
+ }
72
+ toAttach.push({
73
+ ...pick,
74
+ isDynamic: pick.isDynamic,
75
+ value: pick.value,
76
+ name: `${typeof pick.value === 'string' && pick.value.startsWith('#') ? pick.value.slice(1) : ''}${selection}`,
77
+ fullName: `${pick.icon ? `$(${pick.icon.id}) ` : ''}${selection}`
78
+ });
79
+ }
80
+ else if ('symbol' in pick && pick.symbol) {
81
+ toAttach.push({
82
+ ...pick,
83
+ id: this._getFileContextId(pick.symbol.location),
84
+ value: pick.symbol.location,
85
+ fullName: pick.label,
86
+ name: pick.symbol.name,
87
+ isDynamic: true
88
+ });
89
+ }
90
+ else if (pick && typeof pick === 'object' && 'resource' in pick && pick.resource) {
91
+ toAttach.push({
92
+ ...pick,
93
+ id: this._getFileContextId({ resource: pick.resource }),
94
+ value: pick.resource,
95
+ name: pick.label,
96
+ isFile: true,
97
+ isDynamic: true
98
+ });
99
+ }
100
+ else if ('symbolName' in pick && pick.uri && pick.range) {
101
+ toAttach.push({
102
+ ...pick,
103
+ range: undefined,
104
+ id: this._getFileContextId({ uri: pick.uri, range: pick.range.decoration }),
105
+ value: { uri: pick.uri, range: pick.range.decoration },
106
+ fullName: pick.label,
107
+ name: pick.symbolName,
108
+ isDynamic: true
109
+ });
110
+ }
111
+ else {
112
+ toAttach.push({
113
+ ...pick,
114
+ range: undefined,
115
+ id: pick.id ?? '',
116
+ value: 'value' in pick ? pick.value : undefined,
117
+ fullName: pick.label,
118
+ name: 'name' in pick && typeof pick.name === 'string' ? pick.name : pick.label,
119
+ icon: 'icon' in pick && ThemeIcon.isThemeIcon(pick.icon) ? pick.icon : undefined
120
+ });
121
+ }
122
+ }
123
+ widget.getContrib(ChatContextAttachments.ID)?.setContext(false, ...toAttach);
124
+ }
125
+ async run(accessor, ...args) {
126
+ const quickInputService = accessor.get(IQuickInputService);
127
+ const chatAgentService = accessor.get(IChatAgentService);
128
+ const chatVariablesService = accessor.get(IChatVariablesService);
129
+ const commandService = accessor.get(ICommandService);
130
+ const widgetService = accessor.get(IChatWidgetService);
131
+ const context = args[0];
132
+ const widget = context?.widget ?? widgetService.lastFocusedWidget;
133
+ if (!widget) {
134
+ return;
135
+ }
136
+ const usedAgent = widget.parsedInput.parts.find(p => p instanceof ChatRequestAgentPart);
137
+ const slowSupported = usedAgent ? usedAgent.agent.metadata.supportsSlowVariables : true;
138
+ const quickPickItems = [];
139
+ for (const variable of chatVariablesService.getVariables()) {
140
+ if (variable.fullName && (!variable.isSlow || slowSupported)) {
141
+ quickPickItems.push({
142
+ label: `${variable.icon ? `$(${variable.icon.id}) ` : ''}${variable.fullName}`,
143
+ name: variable.name,
144
+ id: variable.id,
145
+ icon: variable.icon
146
+ });
147
+ }
148
+ }
149
+ if (widget.viewModel?.sessionId) {
150
+ const agentPart = widget.parsedInput.parts.find((part) => part instanceof ChatRequestAgentPart);
151
+ if (agentPart) {
152
+ const completions = await chatAgentService.getAgentCompletionItems(agentPart.agent.id, '', CancellationToken.None);
153
+ for (const variable of completions) {
154
+ if (variable.fullName) {
155
+ quickPickItems.push({
156
+ label: `${variable.icon ? `$(${variable.icon.id}) ` : ''}${variable.fullName}`,
157
+ id: variable.id,
158
+ command: variable.command,
159
+ icon: variable.icon,
160
+ value: variable.value,
161
+ isDynamic: true,
162
+ name: variable.name
163
+ });
164
+ }
165
+ }
166
+ }
167
+ }
168
+ quickPickItems.push({
169
+ label: ( localizeWithPath(_moduleId, 1, '{0} Symbol...', `$(${Codicon.symbolField.id})`)),
170
+ icon: ThemeIcon.fromId(Codicon.symbolField.id),
171
+ prefix: SymbolsQuickAccessProvider.PREFIX
172
+ });
173
+ this._show(quickInputService, commandService, widget, quickPickItems);
174
+ }
175
+ _show(quickInputService, commandService, widget, quickPickItems, query = '') {
176
+ quickInputService.quickAccess.show(query, {
177
+ enabledProviderPrefixes: [
178
+ AnythingQuickAccessProvider.PREFIX,
179
+ SymbolsQuickAccessProvider.PREFIX,
180
+ AbstractGotoSymbolQuickAccessProvider.PREFIX
181
+ ],
182
+ placeholder: ( localizeWithPath(_moduleId, 2, 'Search attachments')),
183
+ providerOptions: {
184
+ handleAccept: (item) => {
185
+ if ('prefix' in item) {
186
+ this._show(quickInputService, commandService, widget, quickPickItems, item.prefix);
187
+ }
188
+ else {
189
+ this._attachContext(widget, commandService, item);
190
+ }
191
+ },
192
+ additionPicks: quickPickItems,
193
+ filter: (item) => {
194
+ const attachedContext = widget.getContrib(ChatContextAttachments.ID)?.getContext() ?? ( (new Set()));
195
+ if ('symbol' in item && item.symbol) {
196
+ return !( (attachedContext.has(this._getFileContextId(item.symbol.location))));
197
+ }
198
+ if (item && typeof item === 'object' && 'resource' in item && URI.isUri(item.resource)) {
199
+ return [Schemas.file, Schemas.vscodeRemote].includes(item.resource.scheme)
200
+ && !( (attachedContext.has(this._getFileContextId({ resource: item.resource }))));
201
+ }
202
+ if (item && typeof item === 'object' && 'uri' in item && item.uri && item.range) {
203
+ return !( (attachedContext.has(this._getFileContextId({ uri: item.uri, range: item.range.decoration }))));
204
+ }
205
+ if (!('command' in item) && item.id) {
206
+ return !( (attachedContext.has(item.id)));
207
+ }
208
+ return true;
209
+ }
210
+ }
211
+ });
212
+ }
213
+ }
214
+
215
+ export { registerChatContextActions };
@@ -1,7 +1,7 @@
1
1
  import { localize2WithPath } from 'vscode/vscode/vs/nls';
2
2
  import { registerAction2, Action2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
3
3
  import { IClipboardService } from 'vscode/vscode/vs/platform/clipboard/common/clipboardService.service';
4
- import { CHAT_CATEGORY } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
4
+ import { CHAT_CATEGORY, stringifyItem } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
5
5
  import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
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';
@@ -63,13 +63,5 @@ function registerChatCopyActions() {
63
63
  }
64
64
  });
65
65
  }
66
- function stringifyItem(item, includeName = true) {
67
- if (isRequestVM(item)) {
68
- return (includeName ? `${item.username}: ` : '') + item.messageText;
69
- }
70
- else {
71
- return (includeName ? `${item.username}: ` : '') + item.response.asString();
72
- }
73
- }
74
66
 
75
67
  export { registerChatCopyActions };
@@ -1,5 +1,7 @@
1
+ import { KeyMod, KeyCode } from 'vscode/vscode/vs/base/common/keyCodes';
1
2
  import { localize2WithPath } from 'vscode/vscode/vs/nls';
2
3
  import { registerAction2, Action2 } from 'vscode/vscode/vs/platform/actions/common/actions';
4
+ import { KeybindingWeight } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
3
5
  import { CHAT_CATEGORY } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
4
6
  import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
5
7
  import { CONTEXT_IN_CHAT_SESSION, CONTEXT_CHAT_ENABLED } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
@@ -13,8 +15,8 @@ function registerChatFileTreeActions() {
13
15
  id: 'workbench.action.chat.nextFileTree',
14
16
  title: ( localize2WithPath(_moduleId, 0, "Next File Tree")),
15
17
  keybinding: {
16
- primary: 2048 | 67 ,
17
- weight: 200 ,
18
+ primary: KeyMod.CtrlCmd | KeyCode.F9,
19
+ weight: KeybindingWeight.WorkbenchContrib,
18
20
  when: CONTEXT_IN_CHAT_SESSION,
19
21
  },
20
22
  precondition: CONTEXT_CHAT_ENABLED,
@@ -32,8 +34,8 @@ function registerChatFileTreeActions() {
32
34
  id: 'workbench.action.chat.previousFileTree',
33
35
  title: ( localize2WithPath(_moduleId, 1, "Previous File Tree")),
34
36
  keybinding: {
35
- primary: 2048 | 1024 | 67 ,
36
- weight: 200 ,
37
+ primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.F9,
38
+ weight: KeybindingWeight.WorkbenchContrib,
37
39
  when: CONTEXT_IN_CHAT_SESSION,
38
40
  },
39
41
  precondition: CONTEXT_CHAT_ENABLED,