@codingame/monaco-vscode-chat-service-override 10.1.4 → 11.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 (50) hide show
  1. package/chat.js +6 -3
  2. package/package.json +6 -2
  3. package/vscode/src/vs/editor/common/diff/documentDiffProvider.js +8 -0
  4. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +84 -38
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +265 -20
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +20 -39
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +373 -216
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +4 -5
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +1 -1
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +4 -5
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +54 -0
  12. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +6 -7
  13. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +12 -11
  14. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +14 -42
  15. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +82 -50
  16. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.js +326 -0
  17. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.js +448 -0
  18. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +507 -0
  19. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.js +76 -0
  20. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +4 -4
  21. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorActions.js +109 -0
  22. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorController.js +284 -0
  23. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.js +116 -77
  24. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +100 -9
  25. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +3 -3
  26. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +1 -1
  27. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +7 -9
  28. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +61 -42
  29. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +5 -5
  30. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +3 -3
  31. package/vscode/src/vs/workbench/contrib/chat/{common → browser}/languageModelToolsService.js +28 -31
  32. package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeContributions.js +75 -0
  33. package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.js +120 -1
  34. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +10 -8
  35. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +33 -18
  36. package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +1 -1
  37. package/vscode/src/vs/workbench/contrib/chat/common/ignoredFiles.js +21 -0
  38. package/vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js +2 -2
  39. package/vscode/src/vs/workbench/contrib/chat/common/languageModels.js +6 -6
  40. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +68 -47
  41. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsParametersSchema.js +250 -0
  42. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +2 -2
  43. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +7 -8
  44. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.js +1 -1
  45. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +1 -1
  46. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +3 -3
  47. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +2 -2
  48. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +65 -128
  49. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +0 -170
  50. package/vscode/src/vs/workbench/contrib/chat/browser/chatGettingStarted.js +0 -131
package/chat.js CHANGED
@@ -3,7 +3,7 @@ import { IChatWidgetService, IQuickChatService, IChatAccessibilityService, IChat
3
3
  import { ChatAccessibilityService } from './vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js';
4
4
  import { QuickChatService } from './vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js';
5
5
  import { ChatVariablesService } from './vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js';
6
- import { ChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatWidget';
6
+ import { ChatWidgetService } from '@codingame/monaco-vscode-chat-extensions-notebook-common/vscode/vs/workbench/contrib/chat/browser/chatWidget';
7
7
  import { ChatCodeBlockContextProviderService } from './vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.js';
8
8
  import { ChatAgentService, ChatAgentNameService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
9
9
  import { IChatAgentService, IChatAgentNameService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
@@ -25,11 +25,13 @@ import { LanguageModelStatsService } from './vscode/src/vs/workbench/contrib/cha
25
25
  import './vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js';
26
26
  import './vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js';
27
27
  import { ILanguageModelToolsService } from 'vscode/vscode/vs/workbench/contrib/chat/common/languageModelToolsService.service';
28
- import { LanguageModelToolsService } from './vscode/src/vs/workbench/contrib/chat/common/languageModelToolsService.js';
28
+ import { LanguageModelToolsService } from './vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js';
29
29
  import { ICodeMapperService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatCodeMapperService.service';
30
30
  import { CodeMapperService } from './vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.js';
31
31
  import { IChatEditingService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatEditingService.service';
32
- import { ChatEditingService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatEditingService';
32
+ import { ChatEditingService } from './vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.js';
33
+ import { LanguageModelIgnoredFilesService } from './vscode/src/vs/workbench/contrib/chat/common/ignoredFiles.js';
34
+ import { ILanguageModelIgnoredFilesService } from 'vscode/vscode/vs/workbench/contrib/chat/common/ignoredFiles.service';
33
35
 
34
36
  function getServiceOverride() {
35
37
  return {
@@ -46,6 +48,7 @@ function getServiceOverride() {
46
48
  [( IInlineChatSavingService.toString())]: new SyncDescriptor(InlineChatSavingServiceImpl, [], true),
47
49
  [( IChatCodeBlockContextProviderService.toString())]: new SyncDescriptor(ChatCodeBlockContextProviderService, [], true),
48
50
  [( ILanguageModelStatsService.toString())]: new SyncDescriptor(LanguageModelStatsService, [], true),
51
+ [( ILanguageModelIgnoredFilesService.toString())]: new SyncDescriptor(LanguageModelIgnoredFilesService, [], true),
49
52
  [( IChatAgentNameService.toString())]: new SyncDescriptor(ChatAgentNameService, [], true),
50
53
  [( ILanguageModelToolsService.toString())]: new SyncDescriptor(LanguageModelToolsService, [], true),
51
54
  [( ICodeMapperService.toString())]: new SyncDescriptor(CodeMapperService, [], true),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-chat-service-override",
3
- "version": "10.1.4",
3
+ "version": "11.0.0",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -26,6 +26,10 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "vscode": "npm:@codingame/monaco-vscode-api@10.1.4"
29
+ "vscode": "npm:@codingame/monaco-vscode-api@11.0.0",
30
+ "@codingame/monaco-vscode-chat-extensions-notebook-common": "11.0.0",
31
+ "@codingame/monaco-vscode-chat-extensions-interactive-notebook-quickaccess-search-terminal-common": "11.0.0",
32
+ "@codingame/monaco-vscode-chat-notebook-common": "11.0.0",
33
+ "@codingame/monaco-vscode-chat-interactive-notebook-search-common": "11.0.0"
30
34
  }
31
35
  }
@@ -0,0 +1,8 @@
1
+ const nullDocumentDiff = ( Object.freeze({
2
+ identical: true,
3
+ quitEarly: false,
4
+ changes: ( Object.freeze([])),
5
+ moves: ( Object.freeze([]))
6
+ }));
7
+
8
+ export { nullDocumentDiff };
@@ -2,19 +2,21 @@ import { localize } from 'vscode/vscode/vs/nls';
2
2
  import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
3
3
  import { AccessibleContentProvider } from 'vscode/vscode/vs/platform/accessibility/browser/accessibleView';
4
4
  import { AccessibleDiffViewerNext } from 'vscode/vscode/vs/editor/browser/widget/diffEditor/commands';
5
- import { INLINE_CHAT_ID } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
5
+ import { INLINE_CHAT_ID } from '@codingame/monaco-vscode-chat-extensions-interactive-notebook-quickaccess-search-terminal-common/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
6
6
  import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
7
7
  import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
8
- import { CONTEXT_CHAT_LOCATION, CONTEXT_IN_CHAT_SESSION, CONTEXT_RESPONSE, CONTEXT_REQUEST } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
8
+ import { CONTEXT_CHAT_LOCATION, CONTEXT_IN_QUICK_CHAT, CONTEXT_IN_CHAT_SESSION, CONTEXT_RESPONSE, CONTEXT_REQUEST } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
9
9
  import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
10
+ import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding.service';
10
11
 
11
- class ChatAccessibilityHelp {
12
+ class PanelChatAccessibilityHelp {
12
13
  constructor() {
13
14
  this.priority = 107;
14
15
  this.name = 'panelChat';
15
16
  this.type = "help" ;
16
17
  this.when = ( (ContextKeyExpr.and(
17
18
  (CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.Panel)),
19
+ (CONTEXT_IN_QUICK_CHAT.negate()),
18
20
  (ContextKeyExpr.or(CONTEXT_IN_CHAT_SESSION, CONTEXT_RESPONSE, CONTEXT_REQUEST))
19
21
  )));
20
22
  }
@@ -23,104 +25,117 @@ class ChatAccessibilityHelp {
23
25
  return getChatAccessibilityHelpProvider(accessor, codeEditor ?? undefined, 'panelChat');
24
26
  }
25
27
  }
26
- function getAccessibilityHelpText(type) {
28
+ class QuickChatAccessibilityHelp {
29
+ constructor() {
30
+ this.priority = 107;
31
+ this.name = 'quickChat';
32
+ this.type = "help" ;
33
+ this.when = ( (ContextKeyExpr.and(
34
+ CONTEXT_IN_QUICK_CHAT,
35
+ (ContextKeyExpr.or(CONTEXT_IN_CHAT_SESSION, CONTEXT_RESPONSE, CONTEXT_REQUEST))
36
+ )));
37
+ }
38
+ getProvider(accessor) {
39
+ const codeEditor = accessor.get(ICodeEditorService).getActiveCodeEditor() || accessor.get(ICodeEditorService).getFocusedCodeEditor();
40
+ return getChatAccessibilityHelpProvider(accessor, codeEditor ?? undefined, 'quickChat');
41
+ }
42
+ }
43
+ function getAccessibilityHelpText(type, keybindingService) {
27
44
  const content = [];
28
- if (type === 'panelChat') {
45
+ if (type === 'panelChat' || type === 'quickChat') {
29
46
  content.push(( localize(
30
- 7266,
47
+ 7494,
31
48
  '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
49
  )));
33
50
  content.push(( localize(
34
- 7267,
51
+ 7495,
35
52
  '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.'
36
53
  )));
37
54
  content.push(( localize(
38
- 7268,
55
+ 7496,
39
56
  'In the input box, inspect the last response in the accessible view{0}.',
40
57
  '<keybinding:editor.action.accessibleView>'
41
58
  )));
42
59
  content.push(( localize(
43
- 7269,
60
+ 7497,
44
61
  'In the input box, navigate to the suggested follow up question (Shift+Tab) and press Enter to run it.'
45
62
  )));
46
63
  content.push(( localize(
47
- 7270,
64
+ 7498,
48
65
  '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.'
49
66
  )));
50
67
  content.push(( localize(
51
- 7271,
68
+ 7499,
52
69
  'To focus the chat request/response list, which can be navigated with up and down arrows, invoke the Focus Chat command{0}.',
53
- '<keybinding:chat.action.focus>'
70
+ getChatFocusKeybindingLabel(keybindingService, type, false)
54
71
  )));
55
72
  content.push(( localize(
56
- 7272,
73
+ 7500,
57
74
  'To focus the input box for chat requests, invoke the Focus Chat Input command{0}.',
58
- '<keybinding:workbench.action.chat.focusInput>'
75
+ getChatFocusKeybindingLabel(keybindingService, type, true)
59
76
  )));
60
77
  content.push(( localize(
61
- 7273,
78
+ 7501,
62
79
  'To focus the next code block within a response, invoke the Chat: Next Code Block command{0}.',
63
80
  '<keybinding:workbench.action.chat.nextCodeBlock>'
64
81
  )));
65
- content.push(( localize(
66
- 7274,
67
- 'To focus the next file tree within a response, invoke the Chat: Next File Tree command{0}.',
68
- '<keybinding:workbench.action.chat.nextFileTree>'
69
- )));
70
- content.push(( localize(
71
- 7275,
72
- 'To create a new chat session, invoke the New Chat command{0}.',
73
- '<keybinding:workbench.action.chat.new>'
74
- )));
82
+ if (type === 'panelChat') {
83
+ content.push(( localize(
84
+ 7502,
85
+ 'To create a new chat session, invoke the New Chat command{0}.',
86
+ '<keybinding:workbench.action.chat.new>'
87
+ )));
88
+ }
75
89
  }
76
90
  else {
77
91
  content.push(( localize(
78
- 7276,
92
+ 7503,
79
93
  "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."
80
94
  )));
81
95
  content.push(( localize(
82
- 7277,
96
+ 7504,
83
97
  "It can be activated via code actions or directly using the command: Inline Chat: Start Inline Chat{0}.",
84
98
  '<keybinding:inlineChat.start>'
85
99
  )));
86
100
  content.push(( localize(
87
- 7278,
101
+ 7505,
88
102
  'In the input box, use Show Previous{0} and Show Next{1} to navigate your request history. Edit input and use enter or the submit button to run a new request.',
89
103
  '<keybinding:history.showPrevious>',
90
104
  '<keybinding:history.showNext>'
91
105
  )));
92
106
  content.push(( localize(
93
- 7279,
107
+ 7506,
94
108
  'In the input box, inspect the response in the accessible view{0}.',
95
109
  '<keybinding:editor.action.accessibleView>'
96
110
  )));
97
111
  content.push(( localize(
98
- 7280,
112
+ 7507,
99
113
  "Context menu actions may run a request prefixed with a /. Type / to discover such ready-made commands."
100
114
  )));
101
115
  content.push(( localize(
102
- 7281,
116
+ 7508,
103
117
  "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."
104
118
  )));
105
119
  content.push(( localize(
106
- 7282,
120
+ 7509,
107
121
  "Once in the diff editor, enter review mode with{0}. Use up and down arrows to navigate lines with the proposed changes.",
108
122
  AccessibleDiffViewerNext.id
109
123
  )));
110
124
  content.push(( localize(
111
- 7283,
125
+ 7510,
112
126
  "Use tab to reach conditional parts like commands, status, message responses and more."
113
127
  )));
114
128
  }
115
129
  content.push(( localize(
116
- 7284,
130
+ 7511,
117
131
  "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."
118
132
  )));
119
133
  return content.join('\n');
120
134
  }
121
135
  function getChatAccessibilityHelpProvider(accessor, editor, type) {
122
136
  const widgetService = accessor.get(IChatWidgetService);
123
- const inputEditor = type === 'panelChat' ? widgetService.lastFocusedWidget?.inputEditor : editor;
137
+ const keybindingService = accessor.get(IKeybindingService);
138
+ const inputEditor = type === 'panelChat' || type === 'quickChat' ? widgetService.lastFocusedWidget?.inputEditor : editor;
124
139
  if (!inputEditor) {
125
140
  return;
126
141
  }
@@ -130,10 +145,10 @@ function getChatAccessibilityHelpProvider(accessor, editor, type) {
130
145
  }
131
146
  const cachedPosition = inputEditor.getPosition();
132
147
  inputEditor.getSupportedActions();
133
- const helpText = getAccessibilityHelpText(type);
148
+ const helpText = getAccessibilityHelpText(type, keybindingService);
134
149
  return (
135
150
  (new AccessibleContentProvider(
136
- type === 'panelChat' ? "panelChat" : "inlineChat" ,
151
+ type === 'panelChat' ? "panelChat" : type === 'inlineChat' ? "inlineChat" : "quickChat" ,
137
152
  { type: "help" },
138
153
  () => helpText,
139
154
  () => {
@@ -150,5 +165,36 @@ function getChatAccessibilityHelpProvider(accessor, editor, type) {
150
165
  ))
151
166
  );
152
167
  }
168
+ function getChatFocusKeybindingLabel(keybindingService, type, focusInput) {
169
+ let kbs;
170
+ const fallback = ' (unassigned keybinding)';
171
+ if (focusInput) {
172
+ kbs = keybindingService.lookupKeybindings('workbench.action.chat.focusInput');
173
+ }
174
+ else {
175
+ kbs = keybindingService.lookupKeybindings('chat.action.focus');
176
+ }
177
+ if (!kbs?.length) {
178
+ return fallback;
179
+ }
180
+ let kb;
181
+ if (type === 'panelChat') {
182
+ if (focusInput) {
183
+ kb = kbs.find(kb => kb.getAriaLabel()?.includes('DownArrow'))?.getAriaLabel();
184
+ }
185
+ else {
186
+ kb = kbs.find(kb => kb.getAriaLabel()?.includes('UpArrow'))?.getAriaLabel();
187
+ }
188
+ }
189
+ else {
190
+ if (focusInput) {
191
+ kb = kbs.find(kb => kb.getAriaLabel()?.includes('UpArrow'))?.getAriaLabel();
192
+ }
193
+ else {
194
+ kb = kbs.find(kb => kb.getAriaLabel()?.includes('DownArrow'))?.getAriaLabel();
195
+ }
196
+ }
197
+ return !!kb ? ` (${kb})` : fallback;
198
+ }
153
199
 
154
- export { ChatAccessibilityHelp, getAccessibilityHelpText, getChatAccessibilityHelpProvider };
200
+ export { PanelChatAccessibilityHelp, QuickChatAccessibilityHelp, getAccessibilityHelpText, getChatAccessibilityHelpProvider };
@@ -1,26 +1,31 @@
1
1
  import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
2
- import { localize2 } from 'vscode/vscode/vs/nls';
2
+ import { localize2, localize } from 'vscode/vscode/vs/nls';
3
3
  import { AccessibilitySignal } from 'vscode/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService';
4
4
  import { IAccessibilitySignalService } from 'vscode/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService.service';
5
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 { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs.service';
7
8
  import { ActiveEditorContext } from 'vscode/vscode/vs/workbench/common/contextkeys';
8
- import { isChatViewTitleActionContext } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
9
- import { clearChatEditor } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatClear';
10
- import { CHAT_VIEW_ID } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
11
- import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
12
- import { ChatEditorInput } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatEditorInput';
13
- import { CONTEXT_CHAT_ENABLED, CONTEXT_IN_CHAT_SESSION } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
14
9
  import { IViewsService } from 'vscode/vscode/vs/workbench/services/views/common/viewsService.service';
15
- import { CHAT_CATEGORY } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatConstants';
10
+ import { isChatViewTitleActionContext } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatActions';
11
+ import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
12
+ import { CONTEXT_CHAT_ENABLED, CONTEXT_CHAT_LOCATION, CONTEXT_IN_CHAT_SESSION, CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED, CONTEXT_CHAT_EDITING_CAN_UNDO, CONTEXT_CHAT_EDITING_CAN_REDO } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
13
+ import { hasUndecidedChatEditingResourceContextKey, hasAppliedChatEditsContextKey } from '@codingame/monaco-vscode-chat-extensions-interactive-notebook-quickaccess-search-terminal-common/vscode/vs/workbench/contrib/chat/common/chatEditingService';
14
+ import { IChatEditingService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatEditingService.service';
15
+ import { CHAT_VIEW_ID, EDITS_VIEW_ID } from '@codingame/monaco-vscode-chat-extensions-interactive-notebook-quickaccess-search-terminal-common/vscode/vs/workbench/contrib/chat/browser/chat';
16
+ import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
17
+ import { ChatEditorInput } from '@codingame/monaco-vscode-chat-extensions-interactive-notebook-quickaccess-search-terminal-common/vscode/vs/workbench/contrib/chat/browser/chatEditorInput';
18
+ import { CHAT_CATEGORY } from '@codingame/monaco-vscode-chat-extensions-interactive-notebook-quickaccess-search-terminal-common/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
19
+ import { clearChatEditor } from '@codingame/monaco-vscode-chat-extensions-interactive-notebook-quickaccess-search-terminal-common/vscode/vs/workbench/contrib/chat/browser/actions/chatClear';
16
20
 
17
21
  const ACTION_ID_NEW_CHAT = `workbench.action.chat.newChat`;
22
+ const ACTION_ID_NEW_EDIT_SESSION = `workbench.action.chat.newEditSession`;
18
23
  function registerNewChatActions() {
19
24
  registerAction2(class NewChatEditorAction extends Action2 {
20
25
  constructor() {
21
26
  super({
22
27
  id: 'workbench.action.chatEditor.newChat',
23
- title: ( localize2(7301, "New Chat")),
28
+ title: ( localize2(7512, "New Chat")),
24
29
  icon: Codicon.plus,
25
30
  f1: false,
26
31
  precondition: CONTEXT_CHAT_ENABLED,
@@ -41,10 +46,13 @@ function registerNewChatActions() {
41
46
  constructor() {
42
47
  super({
43
48
  id: ACTION_ID_NEW_CHAT,
44
- title: ( localize2(7301, "New Chat")),
49
+ title: ( localize2(7512, "New Chat")),
45
50
  category: CHAT_CATEGORY,
46
51
  icon: Codicon.plus,
47
- precondition: CONTEXT_CHAT_ENABLED,
52
+ precondition: ( (ContextKeyExpr.and(
53
+ CONTEXT_CHAT_ENABLED,
54
+ (CONTEXT_CHAT_LOCATION.notEqualsTo(ChatAgentLocation.EditingSession))
55
+ ))),
48
56
  f1: true,
49
57
  keybinding: {
50
58
  weight: 200 ,
@@ -69,28 +77,265 @@ function registerNewChatActions() {
69
77
  async run(accessor, ...args) {
70
78
  const context = args[0];
71
79
  const accessibilitySignalService = accessor.get(IAccessibilitySignalService);
80
+ const widgetService = accessor.get(IChatWidgetService);
81
+ let widget = widgetService.lastFocusedWidget;
82
+ if (isChatViewTitleActionContext(context)) {
83
+ widget = widgetService.getWidgetBySessionId(context.sessionId);
84
+ }
85
+ if (widget) {
86
+ announceChatCleared(accessibilitySignalService);
87
+ widget.clear();
88
+ widget.focusInput();
89
+ }
90
+ }
91
+ });
92
+ registerAction2(class NewEditSessionAction extends Action2 {
93
+ constructor() {
94
+ super({
95
+ id: ACTION_ID_NEW_EDIT_SESSION,
96
+ title: ( localize2(7513, "New Edit Session")),
97
+ category: CHAT_CATEGORY,
98
+ icon: Codicon.plus,
99
+ precondition: ( (ContextKeyExpr.and(CONTEXT_CHAT_ENABLED, CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED))),
100
+ f1: true,
101
+ menu: [{
102
+ id: MenuId.ChatContext,
103
+ group: 'z_clear'
104
+ },
105
+ {
106
+ id: MenuId.ViewTitle,
107
+ when: ( (ContextKeyExpr.equals('view', EDITS_VIEW_ID))),
108
+ group: 'navigation',
109
+ order: -1
110
+ },
111
+ ]
112
+ });
113
+ }
114
+ async _handleCurrentEditingSession(chatEditingService, dialogService) {
115
+ const currentEditingSession = chatEditingService.currentEditingSessionObs.get();
116
+ const currentEdits = currentEditingSession?.entries.get();
117
+ const currentEditCount = currentEdits?.length;
118
+ if (currentEditingSession && currentEditCount) {
119
+ const undecidedEdits = currentEdits.filter((edit) => edit.state.get() === 0 );
120
+ if (undecidedEdits.length) {
121
+ const { result } = await dialogService.prompt({
122
+ title: ( localize(7514, "Start new editing session?")),
123
+ message: ( localize(
124
+ 7515,
125
+ "Starting a new editing session will end your current session. Do you want to discard pending edits to {0} files?",
126
+ undecidedEdits.length
127
+ )),
128
+ type: 'info',
129
+ cancelButton: true,
130
+ buttons: [
131
+ {
132
+ label: ( localize(7516, "Discard & Continue")),
133
+ run: async () => {
134
+ await currentEditingSession.reject();
135
+ return true;
136
+ }
137
+ },
138
+ {
139
+ label: ( localize(7517, "Accept & Continue")),
140
+ run: async () => {
141
+ await currentEditingSession.accept();
142
+ return true;
143
+ }
144
+ }
145
+ ],
146
+ });
147
+ return Boolean(result);
148
+ }
149
+ }
150
+ return true;
151
+ }
152
+ async run(accessor, ...args) {
153
+ const context = args[0];
154
+ const accessibilitySignalService = accessor.get(IAccessibilitySignalService);
155
+ const widgetService = accessor.get(IChatWidgetService);
156
+ const chatEditingService = accessor.get(IChatEditingService);
157
+ const dialogService = accessor.get(IDialogService);
158
+ const viewsService = accessor.get(IViewsService);
159
+ if (!(await this._handleCurrentEditingSession(chatEditingService, dialogService))) {
160
+ return;
161
+ }
72
162
  if (isChatViewTitleActionContext(context)) {
73
163
  announceChatCleared(accessibilitySignalService);
74
- context.chatView.widget.clear();
75
- context.chatView.widget.focusInput();
164
+ const widget = widgetService.getWidgetBySessionId(context.sessionId);
165
+ if (widget) {
166
+ chatEditingService.currentEditingSessionObs.get()?.stop();
167
+ widget.clear();
168
+ widget.attachmentModel.clear();
169
+ widget.focusInput();
170
+ }
76
171
  }
77
172
  else {
78
- const widgetService = accessor.get(IChatWidgetService);
79
- const viewsService = accessor.get(IViewsService);
80
- let widget = widgetService.lastFocusedWidget;
81
- if (!widget) {
82
- const chatView = await viewsService.openView(CHAT_VIEW_ID);
83
- widget = chatView.widget;
173
+ const chatView = await viewsService.openView(EDITS_VIEW_ID);
174
+ const widget = chatView.widget;
175
+ announceChatCleared(accessibilitySignalService);
176
+ chatEditingService.currentEditingSessionObs.get()?.stop();
177
+ widget.clear();
178
+ widget.attachmentModel.clear();
179
+ widget.focusInput();
180
+ }
181
+ }
182
+ });
183
+ registerAction2(class GlobalEditsDoneAction extends Action2 {
184
+ constructor() {
185
+ super({
186
+ id: 'workbench.action.chat.done',
187
+ title: ( localize2(7518, "Done")),
188
+ category: CHAT_CATEGORY,
189
+ precondition: ( (ContextKeyExpr.and(CONTEXT_CHAT_ENABLED, CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED))),
190
+ f1: false,
191
+ menu: [{
192
+ id: MenuId.ChatEditingWidgetToolbar,
193
+ when: ( (ContextKeyExpr.and(
194
+ (hasUndecidedChatEditingResourceContextKey.negate()),
195
+ hasAppliedChatEditsContextKey,
196
+ CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED,
197
+ (CONTEXT_CHAT_LOCATION.isEqualTo(ChatAgentLocation.EditingSession))
198
+ ))),
199
+ group: 'navigation',
200
+ order: 0
201
+ }]
202
+ });
203
+ }
204
+ async run(accessor, ...args) {
205
+ const context = args[0];
206
+ const accessibilitySignalService = accessor.get(IAccessibilitySignalService);
207
+ const widgetService = accessor.get(IChatWidgetService);
208
+ if (isChatViewTitleActionContext(context)) {
209
+ announceChatCleared(accessibilitySignalService);
210
+ const widget = widgetService.getWidgetBySessionId(context.sessionId);
211
+ if (widget) {
212
+ widget.clear();
213
+ widget.attachmentModel.clear();
214
+ widget.focusInput();
84
215
  }
216
+ }
217
+ else {
218
+ const viewsService = accessor.get(IViewsService);
219
+ const chatView = await viewsService.openView(EDITS_VIEW_ID);
220
+ const widget = chatView.widget;
85
221
  announceChatCleared(accessibilitySignalService);
86
222
  widget.clear();
223
+ widget.attachmentModel.clear();
87
224
  widget.focusInput();
88
225
  }
89
226
  }
90
227
  });
228
+ registerAction2(class UndoChatEditInteractionAction extends Action2 {
229
+ constructor() {
230
+ super({
231
+ id: 'workbench.action.chat.undoEdit',
232
+ title: ( localize2(7519, "Undo Last Edit")),
233
+ category: CHAT_CATEGORY,
234
+ icon: Codicon.discard,
235
+ precondition: ( (ContextKeyExpr.and(
236
+ CONTEXT_CHAT_EDITING_CAN_UNDO,
237
+ CONTEXT_CHAT_ENABLED,
238
+ CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED
239
+ ))),
240
+ f1: true,
241
+ menu: [{
242
+ id: MenuId.ViewTitle,
243
+ when: ( (ContextKeyExpr.equals('view', EDITS_VIEW_ID))),
244
+ group: 'navigation',
245
+ order: -3
246
+ }]
247
+ });
248
+ }
249
+ async run(accessor, ...args) {
250
+ const chatEditingService = accessor.get(IChatEditingService);
251
+ const chatWidgetService = accessor.get(IChatWidgetService);
252
+ const currentEditingSession = chatEditingService.currentEditingSession;
253
+ if (!currentEditingSession) {
254
+ return;
255
+ }
256
+ const widget = chatWidgetService.getWidgetBySessionId(currentEditingSession.chatSessionId);
257
+ await currentEditingSession.undoInteraction();
258
+ widget?.viewModel?.model.disableRequests(currentEditingSession.hiddenRequestIds.get());
259
+ }
260
+ });
261
+ registerAction2(class RedoChatEditInteractionAction extends Action2 {
262
+ constructor() {
263
+ super({
264
+ id: 'workbench.action.chat.redoEdit',
265
+ title: ( localize2(7520, "Redo Last Edit")),
266
+ category: CHAT_CATEGORY,
267
+ icon: Codicon.redo,
268
+ precondition: ( (ContextKeyExpr.and(
269
+ CONTEXT_CHAT_EDITING_CAN_REDO,
270
+ CONTEXT_CHAT_ENABLED,
271
+ CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED
272
+ ))),
273
+ f1: true,
274
+ menu: [{
275
+ id: MenuId.ViewTitle,
276
+ when: ( (ContextKeyExpr.equals('view', EDITS_VIEW_ID))),
277
+ group: 'navigation',
278
+ order: -2
279
+ }]
280
+ });
281
+ }
282
+ async run(accessor, ...args) {
283
+ const chatEditingService = accessor.get(IChatEditingService);
284
+ const chatWidgetService = accessor.get(IChatWidgetService);
285
+ const currentEditingSession = chatEditingService.currentEditingSession;
286
+ if (!currentEditingSession) {
287
+ return;
288
+ }
289
+ const widget = chatWidgetService.getWidgetBySessionId(currentEditingSession.chatSessionId);
290
+ await chatEditingService.currentEditingSession?.redoInteraction();
291
+ widget?.viewModel?.model.disableRequests(currentEditingSession.hiddenRequestIds.get());
292
+ }
293
+ });
294
+ registerAction2(class GlobalOpenEditsAction extends Action2 {
295
+ constructor() {
296
+ super({
297
+ id: 'workbench.action.chat.openEditSession',
298
+ title: ( localize2(7521, "Open {0}", 'Copilot Edits')),
299
+ category: CHAT_CATEGORY,
300
+ icon: Codicon.goToEditingSession,
301
+ precondition: ( (ContextKeyExpr.and(CONTEXT_CHAT_ENABLED, CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED))),
302
+ f1: true,
303
+ menu: [{
304
+ id: MenuId.ViewTitle,
305
+ when: ( (ContextKeyExpr.and(
306
+ (ContextKeyExpr.equals('view', CHAT_VIEW_ID)),
307
+ CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED
308
+ ))),
309
+ group: 'navigation',
310
+ order: 1
311
+ }, {
312
+ id: MenuId.ChatCommandCenter,
313
+ when: CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED,
314
+ group: 'a_chatEdit',
315
+ order: 1
316
+ }],
317
+ keybinding: {
318
+ weight: 200 ,
319
+ primary: 2048 | 1024 | 39 ,
320
+ linux: {
321
+ primary: 2048 | 512 | 1024 | 39
322
+ },
323
+ when: ( (ContextKeyExpr.and(
324
+ (ContextKeyExpr.notEquals('view', EDITS_VIEW_ID)),
325
+ CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED
326
+ )))
327
+ }
328
+ });
329
+ }
330
+ async run(accessor, ...args) {
331
+ const viewsService = accessor.get(IViewsService);
332
+ const chatView = await viewsService.openView(EDITS_VIEW_ID);
333
+ chatView.widget.focusInput();
334
+ }
335
+ });
91
336
  }
92
337
  function announceChatCleared(accessibilitySignalService) {
93
338
  accessibilitySignalService.playSignal(AccessibilitySignal.clear);
94
339
  }
95
340
 
96
- export { ACTION_ID_NEW_CHAT, registerNewChatActions };
341
+ export { ACTION_ID_NEW_CHAT, ACTION_ID_NEW_EDIT_SESSION, registerNewChatActions };