@codingame/monaco-vscode-chat-service-override 4.1.0 → 4.1.2
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.
- package/chat.js +9 -9
- package/external/tslib/tslib.es6.js +11 -0
- package/external/vscode-marked/lib/marked.esm.js +2200 -0
- package/override/vs/platform/dialogs/common/dialogs.js +10 -0
- package/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClear.js +17 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +115 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +503 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +82 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +77 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +110 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +171 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.js +271 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +317 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +60 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatContributionServiceImpl.js +423 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +98 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +285 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +90 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +185 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatHistoryVariables.js +26 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +618 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +600 -0
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChat.js +141 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +40 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +41 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +72 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +236 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl.js +33 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
2
|
+
import marked_1 from '../../../../../../../../external/vscode-marked/lib/marked.esm.js';
|
|
3
|
+
import { IBulkEditService } from 'vscode/vscode/vs/editor/browser/services/bulkEditService';
|
|
4
|
+
import { localize2WithPath } from 'vscode/vscode/vs/nls';
|
|
5
|
+
import { registerAction2, Action2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
6
|
+
import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
7
|
+
import { ResourceNotebookCellEdit } from 'vscode/vscode/vs/workbench/contrib/bulkEdit/browser/bulkCellEdits';
|
|
8
|
+
import { CHAT_CATEGORY } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
|
|
9
|
+
import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
|
|
10
|
+
import { CONTEXT_RESPONSE_VOTE, CONTEXT_RESPONSE, CONTEXT_CHAT_RESPONSE_SUPPORT_ISSUE_REPORTING, CONTEXT_RESPONSE_FILTERED, CONTEXT_IN_CHAT_SESSION, CONTEXT_IN_CHAT_INPUT, CONTEXT_REQUEST } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
|
|
11
|
+
import { IChatService, InteractiveSessionVoteDirection } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
|
|
12
|
+
import { isResponseVM, isRequestVM } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatViewModel';
|
|
13
|
+
import { NOTEBOOK_EDITOR_ID, CellKind } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
14
|
+
import { NOTEBOOK_IS_ACTIVE_EDITOR } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
|
|
15
|
+
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
16
|
+
|
|
17
|
+
function registerChatTitleActions() {
|
|
18
|
+
registerAction2(class MarkHelpfulAction extends Action2 {
|
|
19
|
+
constructor() {
|
|
20
|
+
super({
|
|
21
|
+
id: 'workbench.action.chat.markHelpful',
|
|
22
|
+
title: ( localize2WithPath(
|
|
23
|
+
'vs/workbench/contrib/chat/browser/actions/chatTitleActions',
|
|
24
|
+
'interactive.helpful.label',
|
|
25
|
+
"Helpful"
|
|
26
|
+
)),
|
|
27
|
+
f1: false,
|
|
28
|
+
category: CHAT_CATEGORY,
|
|
29
|
+
icon: Codicon.thumbsup,
|
|
30
|
+
toggled: ( CONTEXT_RESPONSE_VOTE.isEqualTo('up')),
|
|
31
|
+
menu: {
|
|
32
|
+
id: MenuId.ChatMessageTitle,
|
|
33
|
+
group: 'navigation',
|
|
34
|
+
order: 1,
|
|
35
|
+
when: CONTEXT_RESPONSE
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
run(accessor, ...args) {
|
|
40
|
+
const item = args[0];
|
|
41
|
+
if (!isResponseVM(item)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const chatService = accessor.get(IChatService);
|
|
45
|
+
chatService.notifyUserAction({
|
|
46
|
+
providerId: item.providerId,
|
|
47
|
+
agentId: item.agent?.id,
|
|
48
|
+
sessionId: item.sessionId,
|
|
49
|
+
requestId: item.requestId,
|
|
50
|
+
result: item.result,
|
|
51
|
+
action: {
|
|
52
|
+
kind: 'vote',
|
|
53
|
+
direction: InteractiveSessionVoteDirection.Up,
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
item.setVote(InteractiveSessionVoteDirection.Up);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
registerAction2(class MarkUnhelpfulAction extends Action2 {
|
|
60
|
+
constructor() {
|
|
61
|
+
super({
|
|
62
|
+
id: 'workbench.action.chat.markUnhelpful',
|
|
63
|
+
title: ( localize2WithPath(
|
|
64
|
+
'vs/workbench/contrib/chat/browser/actions/chatTitleActions',
|
|
65
|
+
'interactive.unhelpful.label',
|
|
66
|
+
"Unhelpful"
|
|
67
|
+
)),
|
|
68
|
+
f1: false,
|
|
69
|
+
category: CHAT_CATEGORY,
|
|
70
|
+
icon: Codicon.thumbsdown,
|
|
71
|
+
toggled: ( CONTEXT_RESPONSE_VOTE.isEqualTo('down')),
|
|
72
|
+
menu: {
|
|
73
|
+
id: MenuId.ChatMessageTitle,
|
|
74
|
+
group: 'navigation',
|
|
75
|
+
order: 2,
|
|
76
|
+
when: CONTEXT_RESPONSE
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
run(accessor, ...args) {
|
|
81
|
+
const item = args[0];
|
|
82
|
+
if (!isResponseVM(item)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const chatService = accessor.get(IChatService);
|
|
86
|
+
chatService.notifyUserAction({
|
|
87
|
+
providerId: item.providerId,
|
|
88
|
+
agentId: item.agent?.id,
|
|
89
|
+
sessionId: item.sessionId,
|
|
90
|
+
requestId: item.requestId,
|
|
91
|
+
result: item.result,
|
|
92
|
+
action: {
|
|
93
|
+
kind: 'vote',
|
|
94
|
+
direction: InteractiveSessionVoteDirection.Down,
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
item.setVote(InteractiveSessionVoteDirection.Down);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
registerAction2(class ReportIssueForBugAction extends Action2 {
|
|
101
|
+
constructor() {
|
|
102
|
+
super({
|
|
103
|
+
id: 'workbench.action.chat.reportIssueForBug',
|
|
104
|
+
title: ( localize2WithPath(
|
|
105
|
+
'vs/workbench/contrib/chat/browser/actions/chatTitleActions',
|
|
106
|
+
'interactive.reportIssueForBug.label',
|
|
107
|
+
"Report Issue"
|
|
108
|
+
)),
|
|
109
|
+
f1: false,
|
|
110
|
+
category: CHAT_CATEGORY,
|
|
111
|
+
icon: Codicon.report,
|
|
112
|
+
menu: {
|
|
113
|
+
id: MenuId.ChatMessageTitle,
|
|
114
|
+
group: 'navigation',
|
|
115
|
+
order: 3,
|
|
116
|
+
when: ( ContextKeyExpr.and(CONTEXT_CHAT_RESPONSE_SUPPORT_ISSUE_REPORTING, CONTEXT_RESPONSE))
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
run(accessor, ...args) {
|
|
121
|
+
const item = args[0];
|
|
122
|
+
if (!isResponseVM(item)) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const chatService = accessor.get(IChatService);
|
|
126
|
+
chatService.notifyUserAction({
|
|
127
|
+
providerId: item.providerId,
|
|
128
|
+
agentId: item.agent?.id,
|
|
129
|
+
sessionId: item.sessionId,
|
|
130
|
+
requestId: item.requestId,
|
|
131
|
+
result: item.result,
|
|
132
|
+
action: {
|
|
133
|
+
kind: 'bug'
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
registerAction2(class InsertToNotebookAction extends Action2 {
|
|
139
|
+
constructor() {
|
|
140
|
+
super({
|
|
141
|
+
id: 'workbench.action.chat.insertIntoNotebook',
|
|
142
|
+
title: ( localize2WithPath(
|
|
143
|
+
'vs/workbench/contrib/chat/browser/actions/chatTitleActions',
|
|
144
|
+
'interactive.insertIntoNotebook.label',
|
|
145
|
+
"Insert into Notebook"
|
|
146
|
+
)),
|
|
147
|
+
f1: false,
|
|
148
|
+
category: CHAT_CATEGORY,
|
|
149
|
+
icon: Codicon.insert,
|
|
150
|
+
menu: {
|
|
151
|
+
id: MenuId.ChatMessageTitle,
|
|
152
|
+
group: 'navigation',
|
|
153
|
+
isHiddenByDefault: true,
|
|
154
|
+
when: ( ContextKeyExpr.and(NOTEBOOK_IS_ACTIVE_EDITOR, CONTEXT_RESPONSE, ( CONTEXT_RESPONSE_FILTERED.negate())))
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
async run(accessor, ...args) {
|
|
159
|
+
const item = args[0];
|
|
160
|
+
if (!isResponseVM(item)) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const editorService = accessor.get(IEditorService);
|
|
164
|
+
if (editorService.activeEditorPane?.getId() === NOTEBOOK_EDITOR_ID) {
|
|
165
|
+
const notebookEditor = editorService.activeEditorPane.getControl();
|
|
166
|
+
if (!notebookEditor.hasModel()) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (notebookEditor.isReadOnly) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const value = item.response.asString();
|
|
173
|
+
const splitContents = splitMarkdownAndCodeBlocks(value);
|
|
174
|
+
const focusRange = notebookEditor.getFocus();
|
|
175
|
+
const index = Math.max(focusRange.end, 0);
|
|
176
|
+
const bulkEditService = accessor.get(IBulkEditService);
|
|
177
|
+
await bulkEditService.apply([
|
|
178
|
+
( new ResourceNotebookCellEdit(notebookEditor.textModel.uri, {
|
|
179
|
+
editType: 1 ,
|
|
180
|
+
index: index,
|
|
181
|
+
count: 0,
|
|
182
|
+
cells: ( splitContents.map(content => {
|
|
183
|
+
const kind = content.type === 'markdown' ? CellKind.Markup : CellKind.Code;
|
|
184
|
+
const language = content.type === 'markdown' ? 'markdown' : content.language;
|
|
185
|
+
const mime = content.type === 'markdown' ? 'text/markdown' : `text/x-${content.language}`;
|
|
186
|
+
return {
|
|
187
|
+
cellKind: kind,
|
|
188
|
+
language,
|
|
189
|
+
mime,
|
|
190
|
+
source: content.content,
|
|
191
|
+
outputs: [],
|
|
192
|
+
metadata: {}
|
|
193
|
+
};
|
|
194
|
+
}))
|
|
195
|
+
}))
|
|
196
|
+
], { quotableLabel: 'Insert into Notebook' });
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
registerAction2(class RemoveAction extends Action2 {
|
|
201
|
+
constructor() {
|
|
202
|
+
super({
|
|
203
|
+
id: 'workbench.action.chat.remove',
|
|
204
|
+
title: ( localize2WithPath(
|
|
205
|
+
'vs/workbench/contrib/chat/browser/actions/chatTitleActions',
|
|
206
|
+
'chat.remove.label',
|
|
207
|
+
"Remove Request and Response"
|
|
208
|
+
)),
|
|
209
|
+
f1: false,
|
|
210
|
+
category: CHAT_CATEGORY,
|
|
211
|
+
icon: Codicon.x,
|
|
212
|
+
keybinding: {
|
|
213
|
+
primary: 20 ,
|
|
214
|
+
mac: {
|
|
215
|
+
primary: 2048 | 1 ,
|
|
216
|
+
},
|
|
217
|
+
when: ( ContextKeyExpr.and(CONTEXT_IN_CHAT_SESSION, ( CONTEXT_IN_CHAT_INPUT.negate()))),
|
|
218
|
+
weight: 200 ,
|
|
219
|
+
},
|
|
220
|
+
menu: {
|
|
221
|
+
id: MenuId.ChatMessageTitle,
|
|
222
|
+
group: 'navigation',
|
|
223
|
+
order: 2,
|
|
224
|
+
when: CONTEXT_REQUEST
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
run(accessor, ...args) {
|
|
229
|
+
let item = args[0];
|
|
230
|
+
if (!isRequestVM(item)) {
|
|
231
|
+
const chatWidgetService = accessor.get(IChatWidgetService);
|
|
232
|
+
const widget = chatWidgetService.lastFocusedWidget;
|
|
233
|
+
item = widget?.getFocus();
|
|
234
|
+
}
|
|
235
|
+
const requestId = isRequestVM(item) ? item.id :
|
|
236
|
+
isResponseVM(item) ? item.requestId : undefined;
|
|
237
|
+
if (requestId) {
|
|
238
|
+
const chatService = accessor.get(IChatService);
|
|
239
|
+
chatService.removeRequest(item.sessionId, requestId);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
function splitMarkdownAndCodeBlocks(markdown) {
|
|
245
|
+
const lexer = new marked_1.Lexer();
|
|
246
|
+
const tokens = lexer.lex(markdown);
|
|
247
|
+
const splitContent = [];
|
|
248
|
+
let markdownPart = '';
|
|
249
|
+
tokens.forEach((token) => {
|
|
250
|
+
if (token.type === 'code') {
|
|
251
|
+
if (markdownPart.trim()) {
|
|
252
|
+
splitContent.push({ type: 'markdown', content: markdownPart });
|
|
253
|
+
markdownPart = '';
|
|
254
|
+
}
|
|
255
|
+
splitContent.push({
|
|
256
|
+
type: 'code',
|
|
257
|
+
language: token.lang || '',
|
|
258
|
+
content: token.text,
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
markdownPart += token.raw;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
if (markdownPart.trim()) {
|
|
266
|
+
splitContent.push({ type: 'markdown', content: markdownPart });
|
|
267
|
+
}
|
|
268
|
+
return splitContent;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export { registerChatTitleActions };
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { isMarkdownString, MarkdownString } from 'vscode/vscode/vs/base/common/htmlContent';
|
|
3
|
+
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
|
+
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
5
|
+
import { isMacintosh } from 'vscode/vscode/vs/base/common/platform';
|
|
6
|
+
import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
|
|
7
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
8
|
+
import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
|
|
9
|
+
import { Extensions } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
|
|
10
|
+
import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
|
|
11
|
+
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
12
|
+
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
13
|
+
import { EditorPaneDescriptor } from 'vscode/vscode/vs/workbench/browser/editor';
|
|
14
|
+
import { Extensions as Extensions$1, registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
15
|
+
import { EditorExtensions } from 'vscode/vscode/vs/workbench/common/editor';
|
|
16
|
+
import { alertFocusChange } from 'vscode/vscode/vs/workbench/contrib/accessibility/browser/accessibilityContributions';
|
|
17
|
+
import { IAccessibleViewService } from 'vscode/vscode/vs/workbench/contrib/accessibility/browser/accessibleView';
|
|
18
|
+
import { AccessibleViewAction } from 'vscode/vscode/vs/workbench/contrib/accessibility/browser/accessibleViewActions';
|
|
19
|
+
import { registerChatActions } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
|
|
20
|
+
import { registerNewChatActions, ACTION_ID_NEW_CHAT } from './actions/chatClearActions.js';
|
|
21
|
+
import { registerChatCodeBlockActions } from './actions/chatCodeblockActions.js';
|
|
22
|
+
import { registerChatCopyActions } from './actions/chatCopyActions.js';
|
|
23
|
+
import { registerChatExecuteActions, SubmitAction } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatExecuteActions';
|
|
24
|
+
import { registerChatFileTreeActions } from './actions/chatFileTreeActions.js';
|
|
25
|
+
import { registerChatExportActions } from './actions/chatImportExport.js';
|
|
26
|
+
import { registerMoveActions } from './actions/chatMoveActions.js';
|
|
27
|
+
import { registerQuickChatActions } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions';
|
|
28
|
+
import { registerChatTitleActions } from './actions/chatTitleActions.js';
|
|
29
|
+
import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
|
|
30
|
+
import './chatAccessibilityService.js';
|
|
31
|
+
import './chatContributionServiceImpl.js';
|
|
32
|
+
import { ChatEditor } from './chatEditor.js';
|
|
33
|
+
import { ChatEditorInput, ChatEditorInputSerializer } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatEditorInput';
|
|
34
|
+
import './chatQuick.js';
|
|
35
|
+
import './chatVariables.js';
|
|
36
|
+
import 'vscode/vscode/vs/workbench/contrib/chat/browser/chatWidget';
|
|
37
|
+
import './contrib/chatHistoryVariables.js';
|
|
38
|
+
import './contrib/chatInputEditorContrib.js';
|
|
39
|
+
import { ChatAgentLocation, IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
|
|
40
|
+
import { CONTEXT_IN_CHAT_SESSION } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
|
|
41
|
+
import { ChatWelcomeMessageModel } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatModel';
|
|
42
|
+
import { chatAgentLeader, chatSubcommandLeader, chatVariableLeader } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
|
|
43
|
+
import 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
|
|
44
|
+
import '../common/chatServiceImpl.js';
|
|
45
|
+
import { IChatSlashCommandService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatSlashCommands';
|
|
46
|
+
import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatVariables';
|
|
47
|
+
import { isResponseVM } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatViewModel';
|
|
48
|
+
import 'vscode/vscode/vs/workbench/contrib/chat/common/chatWidgetHistoryService';
|
|
49
|
+
import 'vscode/vscode/vs/base/common/event';
|
|
50
|
+
import '../common/voiceChat.js';
|
|
51
|
+
import { RegisteredEditorPriority, IEditorResolverService } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService';
|
|
52
|
+
import 'vscode/vscode/vs/workbench/contrib/chat/common/chatColors';
|
|
53
|
+
|
|
54
|
+
const configurationRegistry = ( Registry.as(Extensions.Configuration));
|
|
55
|
+
configurationRegistry.registerConfiguration({
|
|
56
|
+
id: 'chatSidebar',
|
|
57
|
+
title: ( localizeWithPath(
|
|
58
|
+
'vs/workbench/contrib/chat/browser/chat.contribution',
|
|
59
|
+
'interactiveSessionConfigurationTitle',
|
|
60
|
+
"Chat"
|
|
61
|
+
)),
|
|
62
|
+
type: 'object',
|
|
63
|
+
properties: {
|
|
64
|
+
'chat.editor.fontSize': {
|
|
65
|
+
type: 'number',
|
|
66
|
+
description: ( localizeWithPath(
|
|
67
|
+
'vs/workbench/contrib/chat/browser/chat.contribution',
|
|
68
|
+
'interactiveSession.editor.fontSize',
|
|
69
|
+
"Controls the font size in pixels in chat codeblocks."
|
|
70
|
+
)),
|
|
71
|
+
default: isMacintosh ? 12 : 14,
|
|
72
|
+
},
|
|
73
|
+
'chat.editor.fontFamily': {
|
|
74
|
+
type: 'string',
|
|
75
|
+
description: ( localizeWithPath(
|
|
76
|
+
'vs/workbench/contrib/chat/browser/chat.contribution',
|
|
77
|
+
'interactiveSession.editor.fontFamily',
|
|
78
|
+
"Controls the font family in chat codeblocks."
|
|
79
|
+
)),
|
|
80
|
+
default: 'default'
|
|
81
|
+
},
|
|
82
|
+
'chat.editor.fontWeight': {
|
|
83
|
+
type: 'string',
|
|
84
|
+
description: ( localizeWithPath(
|
|
85
|
+
'vs/workbench/contrib/chat/browser/chat.contribution',
|
|
86
|
+
'interactiveSession.editor.fontWeight',
|
|
87
|
+
"Controls the font weight in chat codeblocks."
|
|
88
|
+
)),
|
|
89
|
+
default: 'default'
|
|
90
|
+
},
|
|
91
|
+
'chat.editor.wordWrap': {
|
|
92
|
+
type: 'string',
|
|
93
|
+
description: ( localizeWithPath(
|
|
94
|
+
'vs/workbench/contrib/chat/browser/chat.contribution',
|
|
95
|
+
'interactiveSession.editor.wordWrap',
|
|
96
|
+
"Controls whether lines should wrap in chat codeblocks."
|
|
97
|
+
)),
|
|
98
|
+
default: 'off',
|
|
99
|
+
enum: ['on', 'off']
|
|
100
|
+
},
|
|
101
|
+
'chat.editor.lineHeight': {
|
|
102
|
+
type: 'number',
|
|
103
|
+
description: ( localizeWithPath(
|
|
104
|
+
'vs/workbench/contrib/chat/browser/chat.contribution',
|
|
105
|
+
'interactiveSession.editor.lineHeight',
|
|
106
|
+
"Controls the line height in pixels in chat codeblocks. Use 0 to compute the line height from the font size."
|
|
107
|
+
)),
|
|
108
|
+
default: 0
|
|
109
|
+
},
|
|
110
|
+
'chat.experimental.implicitContext': {
|
|
111
|
+
type: 'boolean',
|
|
112
|
+
description: ( localizeWithPath(
|
|
113
|
+
'vs/workbench/contrib/chat/browser/chat.contribution',
|
|
114
|
+
'chat.experimental.implicitContext',
|
|
115
|
+
"Controls whether a checkbox is shown to allow the user to determine which implicit context is included with a chat participant's prompt."
|
|
116
|
+
)),
|
|
117
|
+
default: false
|
|
118
|
+
},
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
( Registry.as(EditorExtensions.EditorPane)).registerEditorPane(EditorPaneDescriptor.create(ChatEditor, ChatEditorInput.EditorID, ( localizeWithPath('vs/workbench/contrib/chat/browser/chat.contribution', 'chat', "Chat"))), [
|
|
122
|
+
( new SyncDescriptor(ChatEditorInput))
|
|
123
|
+
]);
|
|
124
|
+
let ChatResolverContribution = class ChatResolverContribution extends Disposable {
|
|
125
|
+
static { this.ID = 'workbench.contrib.chatResolver'; }
|
|
126
|
+
constructor(editorResolverService, instantiationService) {
|
|
127
|
+
super();
|
|
128
|
+
this._register(editorResolverService.registerEditor(`${Schemas.vscodeChatSesssion}:**/**`, {
|
|
129
|
+
id: ChatEditorInput.EditorID,
|
|
130
|
+
label: ( localizeWithPath('vs/workbench/contrib/chat/browser/chat.contribution', 'chat', "Chat")),
|
|
131
|
+
priority: RegisteredEditorPriority.builtin
|
|
132
|
+
}, {
|
|
133
|
+
singlePerResource: true,
|
|
134
|
+
canSupportResource: resource => resource.scheme === Schemas.vscodeChatSesssion
|
|
135
|
+
}, {
|
|
136
|
+
createEditorInput: ({ resource, options }) => {
|
|
137
|
+
return { editor: instantiationService.createInstance(ChatEditorInput, resource, options), options };
|
|
138
|
+
}
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
ChatResolverContribution = ( __decorate([
|
|
143
|
+
( __param(0, IEditorResolverService)),
|
|
144
|
+
( __param(1, IInstantiationService))
|
|
145
|
+
], ChatResolverContribution));
|
|
146
|
+
class ChatAccessibleViewContribution extends Disposable {
|
|
147
|
+
constructor() {
|
|
148
|
+
super();
|
|
149
|
+
this._register(AccessibleViewAction.addImplementation(100, 'panelChat', accessor => {
|
|
150
|
+
const accessibleViewService = accessor.get(IAccessibleViewService);
|
|
151
|
+
const widgetService = accessor.get(IChatWidgetService);
|
|
152
|
+
const codeEditorService = accessor.get(ICodeEditorService);
|
|
153
|
+
return renderAccessibleView(accessibleViewService, widgetService, codeEditorService, true);
|
|
154
|
+
function renderAccessibleView(accessibleViewService, widgetService, codeEditorService, initialRender) {
|
|
155
|
+
const widget = widgetService.lastFocusedWidget;
|
|
156
|
+
if (!widget) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
const chatInputFocused = initialRender && !!codeEditorService.getFocusedCodeEditor();
|
|
160
|
+
if (initialRender && chatInputFocused) {
|
|
161
|
+
widget.focusLastMessage();
|
|
162
|
+
}
|
|
163
|
+
if (!widget) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
const verifiedWidget = widget;
|
|
167
|
+
const focusedItem = verifiedWidget.getFocus();
|
|
168
|
+
if (!focusedItem) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
widget.focus(focusedItem);
|
|
172
|
+
const isWelcome = focusedItem instanceof ChatWelcomeMessageModel;
|
|
173
|
+
let responseContent = isResponseVM(focusedItem) ? focusedItem.response.asString() : undefined;
|
|
174
|
+
if (isWelcome) {
|
|
175
|
+
const welcomeReplyContents = [];
|
|
176
|
+
for (const content of focusedItem.content) {
|
|
177
|
+
if (Array.isArray(content)) {
|
|
178
|
+
welcomeReplyContents.push(...( content.map(m => m.message)));
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
welcomeReplyContents.push(content.value);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
responseContent = welcomeReplyContents.join('\n');
|
|
185
|
+
}
|
|
186
|
+
if (!responseContent && 'errorDetails' in focusedItem && focusedItem.errorDetails) {
|
|
187
|
+
responseContent = focusedItem.errorDetails.message;
|
|
188
|
+
}
|
|
189
|
+
if (!responseContent) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
const responses = verifiedWidget.viewModel?.getItems().filter(i => isResponseVM(i));
|
|
193
|
+
const length = responses?.length;
|
|
194
|
+
const responseIndex = responses?.findIndex(i => i === focusedItem);
|
|
195
|
+
accessibleViewService.show({
|
|
196
|
+
id: "panelChat" ,
|
|
197
|
+
verbositySettingKey: "accessibility.verbosity.panelChat" ,
|
|
198
|
+
provideContent() { return responseContent; },
|
|
199
|
+
onClose() {
|
|
200
|
+
verifiedWidget.reveal(focusedItem);
|
|
201
|
+
if (chatInputFocused) {
|
|
202
|
+
verifiedWidget.focusInput();
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
verifiedWidget.focus(focusedItem);
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
next() {
|
|
209
|
+
verifiedWidget.moveFocus(focusedItem, 'next');
|
|
210
|
+
alertFocusChange(responseIndex, length, 'next');
|
|
211
|
+
renderAccessibleView(accessibleViewService, widgetService, codeEditorService);
|
|
212
|
+
},
|
|
213
|
+
previous() {
|
|
214
|
+
verifiedWidget.moveFocus(focusedItem, 'previous');
|
|
215
|
+
alertFocusChange(responseIndex, length, 'previous');
|
|
216
|
+
renderAccessibleView(accessibleViewService, widgetService, codeEditorService);
|
|
217
|
+
},
|
|
218
|
+
options: { type: "view" }
|
|
219
|
+
});
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
}, CONTEXT_IN_CHAT_SESSION));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
let ChatSlashStaticSlashCommandsContribution = class ChatSlashStaticSlashCommandsContribution extends Disposable {
|
|
226
|
+
constructor(slashCommandService, commandService, chatAgentService, chatVariablesService) {
|
|
227
|
+
super();
|
|
228
|
+
this._store.add(slashCommandService.registerSlashCommand({
|
|
229
|
+
command: 'clear',
|
|
230
|
+
detail: ( localizeWithPath(
|
|
231
|
+
'vs/workbench/contrib/chat/browser/chat.contribution',
|
|
232
|
+
'clear',
|
|
233
|
+
"Start a new chat"
|
|
234
|
+
)),
|
|
235
|
+
sortText: 'z2_clear',
|
|
236
|
+
executeImmediately: true
|
|
237
|
+
}, async () => {
|
|
238
|
+
commandService.executeCommand(ACTION_ID_NEW_CHAT);
|
|
239
|
+
}));
|
|
240
|
+
this._store.add(slashCommandService.registerSlashCommand({
|
|
241
|
+
command: 'help',
|
|
242
|
+
detail: '',
|
|
243
|
+
sortText: 'z1_help',
|
|
244
|
+
executeImmediately: true
|
|
245
|
+
}, async (prompt, progress) => {
|
|
246
|
+
const defaultAgent = chatAgentService.getDefaultAgent(ChatAgentLocation.Panel);
|
|
247
|
+
const agents = chatAgentService.getAgents();
|
|
248
|
+
if (defaultAgent?.metadata.helpTextPrefix) {
|
|
249
|
+
if (isMarkdownString(defaultAgent.metadata.helpTextPrefix)) {
|
|
250
|
+
progress.report({ content: defaultAgent.metadata.helpTextPrefix, kind: 'markdownContent' });
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
progress.report({ content: defaultAgent.metadata.helpTextPrefix, kind: 'content' });
|
|
254
|
+
}
|
|
255
|
+
progress.report({ content: '\n\n', kind: 'content' });
|
|
256
|
+
}
|
|
257
|
+
const agentText = (await Promise.all(( agents
|
|
258
|
+
.filter(a => a.id !== defaultAgent?.id)
|
|
259
|
+
.map(async (a) => {
|
|
260
|
+
const agentWithLeader = `${chatAgentLeader}${a.name}`;
|
|
261
|
+
const actionArg = { inputValue: `${agentWithLeader} ${a.metadata.sampleRequest}` };
|
|
262
|
+
const urlSafeArg = encodeURIComponent(JSON.stringify(actionArg));
|
|
263
|
+
const agentLine = `* [\`${agentWithLeader}\`](command:${SubmitAction.ID}?${urlSafeArg}) - ${a.description}`;
|
|
264
|
+
const commandText = ( a.slashCommands.map(c => {
|
|
265
|
+
const actionArg = { inputValue: `${agentWithLeader} ${chatSubcommandLeader}${c.name} ${c.sampleRequest ?? ''}` };
|
|
266
|
+
const urlSafeArg = encodeURIComponent(JSON.stringify(actionArg));
|
|
267
|
+
return `\t* [\`${chatSubcommandLeader}${c.name}\`](command:${SubmitAction.ID}?${urlSafeArg}) - ${c.description}`;
|
|
268
|
+
})).join('\n');
|
|
269
|
+
return (agentLine + '\n' + commandText).trim();
|
|
270
|
+
})))).join('\n');
|
|
271
|
+
progress.report({ content: ( new MarkdownString(agentText, { isTrusted: { enabledCommands: [SubmitAction.ID] } })), kind: 'markdownContent' });
|
|
272
|
+
if (defaultAgent?.metadata.helpTextVariablesPrefix) {
|
|
273
|
+
progress.report({ content: '\n\n', kind: 'content' });
|
|
274
|
+
if (isMarkdownString(defaultAgent.metadata.helpTextVariablesPrefix)) {
|
|
275
|
+
progress.report({ content: defaultAgent.metadata.helpTextVariablesPrefix, kind: 'markdownContent' });
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
progress.report({ content: defaultAgent.metadata.helpTextVariablesPrefix, kind: 'content' });
|
|
279
|
+
}
|
|
280
|
+
const variableText = ( Array.from(chatVariablesService.getVariables())
|
|
281
|
+
.map(v => `* \`${chatVariableLeader}${v.name}\` - ${v.description}`))
|
|
282
|
+
.join('\n');
|
|
283
|
+
progress.report({ content: '\n' + variableText, kind: 'content' });
|
|
284
|
+
}
|
|
285
|
+
if (defaultAgent?.metadata.helpTextPostfix) {
|
|
286
|
+
progress.report({ content: '\n\n', kind: 'content' });
|
|
287
|
+
if (isMarkdownString(defaultAgent.metadata.helpTextPostfix)) {
|
|
288
|
+
progress.report({ content: defaultAgent.metadata.helpTextPostfix, kind: 'markdownContent' });
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
progress.report({ content: defaultAgent.metadata.helpTextPostfix, kind: 'content' });
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}));
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
ChatSlashStaticSlashCommandsContribution = ( __decorate([
|
|
298
|
+
( __param(0, IChatSlashCommandService)),
|
|
299
|
+
( __param(1, ICommandService)),
|
|
300
|
+
( __param(2, IChatAgentService)),
|
|
301
|
+
( __param(3, IChatVariablesService))
|
|
302
|
+
], ChatSlashStaticSlashCommandsContribution));
|
|
303
|
+
const workbenchContributionsRegistry = ( Registry.as(Extensions$1.Workbench));
|
|
304
|
+
registerWorkbenchContribution2(ChatResolverContribution.ID, ChatResolverContribution, 1 );
|
|
305
|
+
workbenchContributionsRegistry.registerWorkbenchContribution(ChatAccessibleViewContribution, 4 );
|
|
306
|
+
workbenchContributionsRegistry.registerWorkbenchContribution(ChatSlashStaticSlashCommandsContribution, 4 );
|
|
307
|
+
( Registry.as(EditorExtensions.EditorFactory)).registerEditorSerializer(ChatEditorInput.TypeID, ChatEditorInputSerializer);
|
|
308
|
+
registerChatActions();
|
|
309
|
+
registerChatCopyActions();
|
|
310
|
+
registerChatCodeBlockActions();
|
|
311
|
+
registerChatFileTreeActions();
|
|
312
|
+
registerChatTitleActions();
|
|
313
|
+
registerChatExecuteActions();
|
|
314
|
+
registerQuickChatActions();
|
|
315
|
+
registerChatExportActions();
|
|
316
|
+
registerMoveActions();
|
|
317
|
+
registerNewChatActions();
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { status } from 'vscode/vscode/vs/base/browser/ui/aria/aria';
|
|
3
|
+
import { RunOnceScheduler } from 'vscode/vscode/vs/base/common/async';
|
|
4
|
+
import { Disposable, DisposableMap } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
5
|
+
import { AccessibilitySignal, IAccessibilitySignalService } from 'vscode/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService';
|
|
6
|
+
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
7
|
+
|
|
8
|
+
let ChatAccessibilityService = class ChatAccessibilityService extends Disposable {
|
|
9
|
+
constructor(_accessibilitySignalService, _instantiationService) {
|
|
10
|
+
super();
|
|
11
|
+
this._accessibilitySignalService = _accessibilitySignalService;
|
|
12
|
+
this._instantiationService = _instantiationService;
|
|
13
|
+
this._pendingSignalMap = this._register(( new DisposableMap()));
|
|
14
|
+
this._requestId = 0;
|
|
15
|
+
}
|
|
16
|
+
acceptRequest() {
|
|
17
|
+
this._requestId++;
|
|
18
|
+
this._accessibilitySignalService.playSignal(AccessibilitySignal.chatRequestSent, { allowManyInParallel: true });
|
|
19
|
+
this._pendingSignalMap.set(this._requestId, this._instantiationService.createInstance(AccessibilitySignalScheduler));
|
|
20
|
+
return this._requestId;
|
|
21
|
+
}
|
|
22
|
+
acceptResponse(response, requestId) {
|
|
23
|
+
this._pendingSignalMap.deleteAndDispose(requestId);
|
|
24
|
+
const isPanelChat = typeof response !== 'string';
|
|
25
|
+
const responseContent = typeof response === 'string' ? response : response?.response.asString();
|
|
26
|
+
this._accessibilitySignalService.playSignal(AccessibilitySignal.chatResponseReceived, { allowManyInParallel: true });
|
|
27
|
+
if (!response) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const errorDetails = isPanelChat && response.errorDetails ? ` ${response.errorDetails.message}` : '';
|
|
31
|
+
status(responseContent + errorDetails);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
ChatAccessibilityService = ( __decorate([
|
|
35
|
+
( __param(0, IAccessibilitySignalService)),
|
|
36
|
+
( __param(1, IInstantiationService))
|
|
37
|
+
], ChatAccessibilityService));
|
|
38
|
+
const CHAT_RESPONSE_PENDING_AUDIO_CUE_LOOP_MS = 5000;
|
|
39
|
+
const CHAT_RESPONSE_PENDING_ALLOWANCE_MS = 4000;
|
|
40
|
+
let AccessibilitySignalScheduler = class AccessibilitySignalScheduler extends Disposable {
|
|
41
|
+
constructor(_accessibilitySignalService) {
|
|
42
|
+
super();
|
|
43
|
+
this._accessibilitySignalService = _accessibilitySignalService;
|
|
44
|
+
this._scheduler = ( new RunOnceScheduler(() => {
|
|
45
|
+
this._signalLoop = this._accessibilitySignalService.playSignalLoop(AccessibilitySignal.chatResponsePending, CHAT_RESPONSE_PENDING_AUDIO_CUE_LOOP_MS);
|
|
46
|
+
}, CHAT_RESPONSE_PENDING_ALLOWANCE_MS));
|
|
47
|
+
this._scheduler.schedule();
|
|
48
|
+
}
|
|
49
|
+
dispose() {
|
|
50
|
+
super.dispose();
|
|
51
|
+
this._signalLoop?.dispose();
|
|
52
|
+
this._scheduler.cancel();
|
|
53
|
+
this._scheduler.dispose();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
AccessibilitySignalScheduler = ( __decorate([
|
|
57
|
+
( __param(0, IAccessibilitySignalService))
|
|
58
|
+
], AccessibilitySignalScheduler));
|
|
59
|
+
|
|
60
|
+
export { ChatAccessibilityService };
|