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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/chat.d.ts +5 -0
  2. package/chat.js +39 -0
  3. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
  4. package/external/tslib/tslib.es6.js +11 -0
  5. package/index.d.ts +1 -0
  6. package/index.js +1 -0
  7. package/override/vs/platform/dialogs/common/dialogs.js +8 -0
  8. package/package.json +24 -0
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClear.js +17 -0
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +115 -0
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +509 -0
  12. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +88 -0
  13. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +83 -0
  14. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +110 -0
  15. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +223 -0
  16. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.js +283 -0
  17. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +283 -0
  18. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +61 -0
  19. package/vscode/src/vs/workbench/contrib/chat/browser/chatContributionServiceImpl.js +179 -0
  20. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +88 -0
  21. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +271 -0
  22. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +91 -0
  23. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +165 -0
  24. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatHistoryVariables.js +26 -0
  25. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +626 -0
  26. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditor.css.js +6 -0
  27. package/vscode/src/vs/workbench/contrib/chat/common/chatColors.js +31 -0
  28. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +564 -0
  29. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +41 -0
  30. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +41 -0
  31. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.js +748 -0
  32. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatDecorations.js +250 -0
  33. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +62 -0
  34. package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl.js +35 -0
@@ -0,0 +1,283 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
3
+ import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
4
+ import { isMacintosh } from 'monaco-editor/esm/vs/base/common/platform.js';
5
+ import * as nls from 'monaco-editor/esm/vs/nls.js';
6
+ import { Extensions } from 'monaco-editor/esm/vs/platform/configuration/common/configurationRegistry.js';
7
+ import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
8
+ import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
9
+ import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
10
+ import { EditorPaneDescriptor } from 'vscode/vscode/vs/workbench/browser/editor';
11
+ import { Extensions as Extensions$1 } from 'vscode/vscode/vs/workbench/common/contributions';
12
+ import { EditorExtensions } from 'vscode/vscode/vs/workbench/common/editor';
13
+ import { registerChatActions } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
14
+ import { registerChatCodeBlockActions } from './actions/chatCodeblockActions.js';
15
+ import { registerChatCopyActions } from './actions/chatCopyActions.js';
16
+ import { registerChatExecuteActions, SubmitAction } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatExecuteActions';
17
+ import { registerQuickChatActions } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions';
18
+ import { registerChatTitleActions } from './actions/chatTitleActions.js';
19
+ import { registerChatExportActions } from './actions/chatImportExport.js';
20
+ import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
21
+ import { ChatEditor } from './chatEditor.js';
22
+ import { ChatEditorInput, ChatEditorInputSerializer } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatEditorInput';
23
+ import './contrib/chatInputEditorContrib.js';
24
+ import './contrib/chatHistoryVariables.js';
25
+ import { RegisteredEditorPriority, IEditorResolverService } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService';
26
+ import { registerMoveActions } from './actions/chatMoveActions.js';
27
+ import { registerClearActions, ACTION_ID_CLEAR_CHAT } from './actions/chatClearActions.js';
28
+ import { IAccessibleViewService } from 'vscode/vscode/vs/workbench/contrib/accessibility/browser/accessibleView';
29
+ import { isResponseVM } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatViewModel';
30
+ import { CONTEXT_IN_CHAT_SESSION } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
31
+ import { ICodeEditorService } from 'monaco-editor/esm/vs/editor/browser/services/codeEditorService.js';
32
+ import { ChatWelcomeMessageModel } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatModel';
33
+ import { isMarkdownString, MarkdownString } from 'monaco-editor/esm/vs/base/common/htmlContent.js';
34
+ import { IChatSlashCommandService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatSlashCommands';
35
+ import { alertFocusChange } from 'vscode/vscode/vs/workbench/contrib/accessibility/browser/accessibilityContributions';
36
+ import { AccessibleViewAction } from 'vscode/vscode/vs/workbench/contrib/accessibility/browser/accessibleViewActions';
37
+ import { ICommandService } from 'monaco-editor/esm/vs/platform/commands/common/commands.js';
38
+ import { registerChatFileTreeActions } from './actions/chatFileTreeActions.js';
39
+ import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
40
+ import { chatAgentLeader, chatSubcommandLeader } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
41
+ import { CancellationToken } from 'monaco-editor/esm/vs/base/common/cancellation.js';
42
+
43
+ const configurationRegistry = ( Registry.as(Extensions.Configuration));
44
+ configurationRegistry.registerConfiguration({
45
+ id: 'chatSidebar',
46
+ title: ( nls.localizeWithPath(
47
+ 'vs/workbench/contrib/chat/browser/chat.contribution',
48
+ 'interactiveSessionConfigurationTitle',
49
+ "Chat"
50
+ )),
51
+ type: 'object',
52
+ properties: {
53
+ 'chat.editor.fontSize': {
54
+ type: 'number',
55
+ description: ( nls.localizeWithPath(
56
+ 'vs/workbench/contrib/chat/browser/chat.contribution',
57
+ 'interactiveSession.editor.fontSize',
58
+ "Controls the font size in pixels in chat codeblocks."
59
+ )),
60
+ default: isMacintosh ? 12 : 14,
61
+ },
62
+ 'chat.editor.fontFamily': {
63
+ type: 'string',
64
+ description: ( nls.localizeWithPath(
65
+ 'vs/workbench/contrib/chat/browser/chat.contribution',
66
+ 'interactiveSession.editor.fontFamily',
67
+ "Controls the font family in chat codeblocks."
68
+ )),
69
+ default: 'default'
70
+ },
71
+ 'chat.editor.fontWeight': {
72
+ type: 'string',
73
+ description: ( nls.localizeWithPath(
74
+ 'vs/workbench/contrib/chat/browser/chat.contribution',
75
+ 'interactiveSession.editor.fontWeight',
76
+ "Controls the font weight in chat codeblocks."
77
+ )),
78
+ default: 'default'
79
+ },
80
+ 'chat.editor.wordWrap': {
81
+ type: 'string',
82
+ description: ( nls.localizeWithPath(
83
+ 'vs/workbench/contrib/chat/browser/chat.contribution',
84
+ 'interactiveSession.editor.wordWrap',
85
+ "Controls whether lines should wrap in chat codeblocks."
86
+ )),
87
+ default: 'off',
88
+ enum: ['on', 'off']
89
+ },
90
+ 'chat.editor.lineHeight': {
91
+ type: 'number',
92
+ description: ( nls.localizeWithPath(
93
+ 'vs/workbench/contrib/chat/browser/chat.contribution',
94
+ 'interactiveSession.editor.lineHeight',
95
+ "Controls the line height in pixels in chat codeblocks. Use 0 to compute the line height from the font size."
96
+ )),
97
+ default: 0
98
+ }
99
+ }
100
+ });
101
+ ( Registry.as(EditorExtensions.EditorPane)).registerEditorPane(EditorPaneDescriptor.create(ChatEditor, ChatEditorInput.EditorID, ( nls.localizeWithPath('vs/workbench/contrib/chat/browser/chat.contribution', 'chat', "Chat"))), [
102
+ ( new SyncDescriptor(ChatEditorInput))
103
+ ]);
104
+ let ChatResolverContribution = class ChatResolverContribution extends Disposable {
105
+ constructor(editorResolverService, instantiationService) {
106
+ super();
107
+ this._register(editorResolverService.registerEditor(`${Schemas.vscodeChatSesssion}:**/**`, {
108
+ id: ChatEditorInput.EditorID,
109
+ label: ( nls.localizeWithPath('vs/workbench/contrib/chat/browser/chat.contribution', 'chat', "Chat")),
110
+ priority: RegisteredEditorPriority.builtin
111
+ }, {
112
+ singlePerResource: true,
113
+ canSupportResource: resource => resource.scheme === Schemas.vscodeChatSesssion
114
+ }, {
115
+ createEditorInput: ({ resource, options }) => {
116
+ return { editor: instantiationService.createInstance(ChatEditorInput, resource, options), options };
117
+ }
118
+ }));
119
+ }
120
+ };
121
+ ChatResolverContribution = ( __decorate([
122
+ ( __param(0, IEditorResolverService)),
123
+ ( __param(1, IInstantiationService))
124
+ ], ChatResolverContribution));
125
+ class ChatAccessibleViewContribution extends Disposable {
126
+ constructor() {
127
+ super();
128
+ this._register(AccessibleViewAction.addImplementation(100, 'panelChat', accessor => {
129
+ const accessibleViewService = accessor.get(IAccessibleViewService);
130
+ const widgetService = accessor.get(IChatWidgetService);
131
+ const codeEditorService = accessor.get(ICodeEditorService);
132
+ return renderAccessibleView(accessibleViewService, widgetService, codeEditorService, true);
133
+ function renderAccessibleView(accessibleViewService, widgetService, codeEditorService, initialRender) {
134
+ const widget = widgetService.lastFocusedWidget;
135
+ if (!widget) {
136
+ return false;
137
+ }
138
+ const chatInputFocused = initialRender && !!codeEditorService.getFocusedCodeEditor();
139
+ if (initialRender && chatInputFocused) {
140
+ widget.focusLastMessage();
141
+ }
142
+ if (!widget) {
143
+ return false;
144
+ }
145
+ const verifiedWidget = widget;
146
+ const focusedItem = verifiedWidget.getFocus();
147
+ if (!focusedItem) {
148
+ return false;
149
+ }
150
+ widget.focus(focusedItem);
151
+ const isWelcome = focusedItem instanceof ChatWelcomeMessageModel;
152
+ let responseContent = isResponseVM(focusedItem) ? focusedItem.response.asString() : undefined;
153
+ if (isWelcome) {
154
+ const welcomeReplyContents = [];
155
+ for (const content of focusedItem.content) {
156
+ if (Array.isArray(content)) {
157
+ welcomeReplyContents.push(...( content.map(m => m.message)));
158
+ }
159
+ else {
160
+ welcomeReplyContents.push(content.value);
161
+ }
162
+ }
163
+ responseContent = welcomeReplyContents.join('\n');
164
+ }
165
+ if (!responseContent && 'errorDetails' in focusedItem && focusedItem.errorDetails) {
166
+ responseContent = focusedItem.errorDetails.message;
167
+ }
168
+ if (!responseContent) {
169
+ return false;
170
+ }
171
+ const responses = verifiedWidget.viewModel?.getItems().filter(i => isResponseVM(i));
172
+ const length = responses?.length;
173
+ const responseIndex = responses?.findIndex(i => i === focusedItem);
174
+ accessibleViewService.show({
175
+ id: "panelChat" ,
176
+ verbositySettingKey: "accessibility.verbosity.panelChat" ,
177
+ provideContent() { return responseContent; },
178
+ onClose() {
179
+ verifiedWidget.reveal(focusedItem);
180
+ if (chatInputFocused) {
181
+ verifiedWidget.focusInput();
182
+ }
183
+ else {
184
+ verifiedWidget.focus(focusedItem);
185
+ }
186
+ },
187
+ next() {
188
+ verifiedWidget.moveFocus(focusedItem, 'next');
189
+ alertFocusChange(responseIndex, length, 'next');
190
+ renderAccessibleView(accessibleViewService, widgetService, codeEditorService);
191
+ },
192
+ previous() {
193
+ verifiedWidget.moveFocus(focusedItem, 'previous');
194
+ alertFocusChange(responseIndex, length, 'previous');
195
+ renderAccessibleView(accessibleViewService, widgetService, codeEditorService);
196
+ },
197
+ options: { type: "view" }
198
+ });
199
+ return true;
200
+ }
201
+ }, CONTEXT_IN_CHAT_SESSION));
202
+ }
203
+ }
204
+ let ChatSlashStaticSlashCommandsContribution = class ChatSlashStaticSlashCommandsContribution extends Disposable {
205
+ constructor(slashCommandService, commandService, chatAgentService) {
206
+ super();
207
+ this._store.add(slashCommandService.registerSlashCommand({
208
+ command: 'clear',
209
+ detail: ( nls.localizeWithPath(
210
+ 'vs/workbench/contrib/chat/browser/chat.contribution',
211
+ 'clear',
212
+ "Clear the session"
213
+ )),
214
+ sortText: 'z2_clear',
215
+ executeImmediately: true
216
+ }, async () => {
217
+ commandService.executeCommand(ACTION_ID_CLEAR_CHAT);
218
+ }));
219
+ this._store.add(slashCommandService.registerSlashCommand({
220
+ command: 'help',
221
+ detail: '',
222
+ sortText: 'z1_help',
223
+ executeImmediately: true
224
+ }, async (prompt, progress) => {
225
+ const defaultAgent = chatAgentService.getDefaultAgent();
226
+ const agents = chatAgentService.getAgents();
227
+ if (defaultAgent?.metadata.helpTextPrefix) {
228
+ if (isMarkdownString(defaultAgent.metadata.helpTextPrefix)) {
229
+ progress.report({ content: defaultAgent.metadata.helpTextPrefix, kind: 'markdownContent' });
230
+ }
231
+ else {
232
+ progress.report({ content: defaultAgent.metadata.helpTextPrefix, kind: 'content' });
233
+ }
234
+ progress.report({ content: '\n\n', kind: 'content' });
235
+ }
236
+ const agentText = (await Promise.all(( agents
237
+ .filter(a => a.id !== defaultAgent?.id)
238
+ .map(async (a) => {
239
+ const agentWithLeader = `${chatAgentLeader}${a.id}`;
240
+ const actionArg = { inputValue: `${agentWithLeader} ${a.metadata.sampleRequest}` };
241
+ const urlSafeArg = encodeURIComponent(JSON.stringify(actionArg));
242
+ const agentLine = `* [\`${agentWithLeader}\`](command:${SubmitAction.ID}?${urlSafeArg}) - ${a.metadata.description}`;
243
+ const commands = await a.provideSlashCommands(CancellationToken.None);
244
+ const commandText = ( commands.map(c => {
245
+ const actionArg = { inputValue: `${agentWithLeader} ${chatSubcommandLeader}${c.name} ${c.sampleRequest ?? ''}` };
246
+ const urlSafeArg = encodeURIComponent(JSON.stringify(actionArg));
247
+ return `\t* [\`${chatSubcommandLeader}${c.name}\`](command:${SubmitAction.ID}?${urlSafeArg}) - ${c.description}`;
248
+ })).join('\n');
249
+ return agentLine + '\n' + commandText;
250
+ })))).join('\n');
251
+ progress.report({ content: ( new MarkdownString(agentText, { isTrusted: { enabledCommands: [SubmitAction.ID] } })), kind: 'markdownContent' });
252
+ if (defaultAgent?.metadata.helpTextPostfix) {
253
+ progress.report({ content: '\n\n', kind: 'content' });
254
+ if (isMarkdownString(defaultAgent.metadata.helpTextPostfix)) {
255
+ progress.report({ content: defaultAgent.metadata.helpTextPostfix, kind: 'markdownContent' });
256
+ }
257
+ else {
258
+ progress.report({ content: defaultAgent.metadata.helpTextPostfix, kind: 'content' });
259
+ }
260
+ }
261
+ }));
262
+ }
263
+ };
264
+ ChatSlashStaticSlashCommandsContribution = ( __decorate([
265
+ ( __param(0, IChatSlashCommandService)),
266
+ ( __param(1, ICommandService)),
267
+ ( __param(2, IChatAgentService))
268
+ ], ChatSlashStaticSlashCommandsContribution));
269
+ const workbenchContributionsRegistry = ( Registry.as(Extensions$1.Workbench));
270
+ workbenchContributionsRegistry.registerWorkbenchContribution(ChatResolverContribution, 1 );
271
+ workbenchContributionsRegistry.registerWorkbenchContribution(ChatAccessibleViewContribution, 4 );
272
+ workbenchContributionsRegistry.registerWorkbenchContribution(ChatSlashStaticSlashCommandsContribution, 4 );
273
+ ( Registry.as(EditorExtensions.EditorFactory)).registerEditorSerializer(ChatEditorInput.TypeID, ChatEditorInputSerializer);
274
+ registerChatActions();
275
+ registerChatCopyActions();
276
+ registerChatCodeBlockActions();
277
+ registerChatFileTreeActions();
278
+ registerChatTitleActions();
279
+ registerChatExecuteActions();
280
+ registerQuickChatActions();
281
+ registerChatExportActions();
282
+ registerMoveActions();
283
+ registerClearActions();
@@ -0,0 +1,61 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { status } from 'monaco-editor/esm/vs/base/browser/ui/aria/aria.js';
3
+ import { RunOnceScheduler } from 'monaco-editor/esm/vs/base/common/async.js';
4
+ import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
5
+ import { AudioCue, IAudioCueService } from 'monaco-editor/esm/vs/platform/audioCues/browser/audioCueService.js';
6
+ import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
7
+
8
+ let ChatAccessibilityService = class ChatAccessibilityService extends Disposable {
9
+ constructor(_audioCueService, _instantiationService) {
10
+ super();
11
+ this._audioCueService = _audioCueService;
12
+ this._instantiationService = _instantiationService;
13
+ this._pendingCueMap = ( new Map());
14
+ this._requestId = 0;
15
+ }
16
+ acceptRequest() {
17
+ this._requestId++;
18
+ this._audioCueService.playAudioCue(AudioCue.chatRequestSent, { allowManyInParallel: true });
19
+ this._pendingCueMap.set(this._requestId, this._register(this._instantiationService.createInstance(AudioCueScheduler)));
20
+ return this._requestId;
21
+ }
22
+ acceptResponse(response, requestId) {
23
+ this._pendingCueMap.get(requestId)?.dispose();
24
+ this._pendingCueMap.delete(requestId);
25
+ const isPanelChat = typeof response !== 'string';
26
+ const responseContent = typeof response === 'string' ? response : response?.response.asString();
27
+ this._audioCueService.playAudioCue(AudioCue.chatResponseReceived, { allowManyInParallel: true });
28
+ if (!response) {
29
+ return;
30
+ }
31
+ const errorDetails = isPanelChat && response.errorDetails ? ` ${response.errorDetails.message}` : '';
32
+ status(responseContent + errorDetails);
33
+ }
34
+ };
35
+ ChatAccessibilityService = ( __decorate([
36
+ ( __param(0, IAudioCueService)),
37
+ ( __param(1, IInstantiationService))
38
+ ], ChatAccessibilityService));
39
+ const CHAT_RESPONSE_PENDING_AUDIO_CUE_LOOP_MS = 5000;
40
+ const CHAT_RESPONSE_PENDING_ALLOWANCE_MS = 4000;
41
+ let AudioCueScheduler = class AudioCueScheduler extends Disposable {
42
+ constructor(_audioCueService) {
43
+ super();
44
+ this._audioCueService = _audioCueService;
45
+ this._scheduler = ( new RunOnceScheduler(() => {
46
+ this._audioCueLoop = this._audioCueService.playAudioCueLoop(AudioCue.chatResponsePending, CHAT_RESPONSE_PENDING_AUDIO_CUE_LOOP_MS);
47
+ }, CHAT_RESPONSE_PENDING_ALLOWANCE_MS));
48
+ this._scheduler.schedule();
49
+ }
50
+ dispose() {
51
+ super.dispose();
52
+ this._audioCueLoop?.dispose();
53
+ this._scheduler.cancel();
54
+ this._scheduler.dispose();
55
+ }
56
+ };
57
+ AudioCueScheduler = ( __decorate([
58
+ ( __param(0, IAudioCueService))
59
+ ], AudioCueScheduler));
60
+
61
+ export { ChatAccessibilityService };
@@ -0,0 +1,179 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { Codicon } from 'monaco-editor/esm/vs/base/common/codicons.js';
3
+ import { DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
4
+ import { localizeWithPath, localize2WithPath } from 'monaco-editor/esm/vs/nls.js';
5
+ import { registerAction2 } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
6
+ import { ContextKeyExpr } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
7
+ import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
8
+ import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
9
+ import { ViewPaneContainer } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPaneContainer';
10
+ import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
11
+ import { Extensions as Extensions$1 } from 'vscode/vscode/vs/workbench/common/views';
12
+ import { getHistoryAction, getOpenChatEditorAction } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
13
+ import { getClearAction } from './actions/chatClearActions.js';
14
+ import { getMoveToEditorAction, getMoveToNewWindowAction } from './actions/chatMoveActions.js';
15
+ import { getQuickChatActionForProvider } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions';
16
+ import { ChatViewPane, CHAT_SIDEBAR_PANEL_ID } from './chatViewPane.js';
17
+ import { IChatContributionService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContributionService';
18
+ import { ExtensionsRegistry } from 'vscode/vscode/vs/workbench/services/extensions/common/extensionsRegistry';
19
+
20
+ const chatExtensionPoint = ( ExtensionsRegistry.registerExtensionPoint({
21
+ extensionPoint: 'interactiveSession',
22
+ jsonSchema: {
23
+ description: ( localizeWithPath(
24
+ 'vs/workbench/contrib/chat/browser/chatContributionServiceImpl',
25
+ 'vscode.extension.contributes.interactiveSession',
26
+ 'Contributes an Interactive Session provider'
27
+ )),
28
+ type: 'array',
29
+ items: {
30
+ additionalProperties: false,
31
+ type: 'object',
32
+ defaultSnippets: [{ body: { id: '', program: '', runtime: '' } }],
33
+ required: ['id', 'label'],
34
+ properties: {
35
+ id: {
36
+ description: ( localizeWithPath(
37
+ 'vs/workbench/contrib/chat/browser/chatContributionServiceImpl',
38
+ 'vscode.extension.contributes.interactiveSession.id',
39
+ "Unique identifier for this Interactive Session provider."
40
+ )),
41
+ type: 'string'
42
+ },
43
+ label: {
44
+ description: ( localizeWithPath(
45
+ 'vs/workbench/contrib/chat/browser/chatContributionServiceImpl',
46
+ 'vscode.extension.contributes.interactiveSession.label',
47
+ "Display name for this Interactive Session provider."
48
+ )),
49
+ type: 'string'
50
+ },
51
+ icon: {
52
+ description: ( localizeWithPath(
53
+ 'vs/workbench/contrib/chat/browser/chatContributionServiceImpl',
54
+ 'vscode.extension.contributes.interactiveSession.icon',
55
+ "An icon for this Interactive Session provider."
56
+ )),
57
+ type: 'string'
58
+ },
59
+ when: {
60
+ description: ( localizeWithPath(
61
+ 'vs/workbench/contrib/chat/browser/chatContributionServiceImpl',
62
+ 'vscode.extension.contributes.interactiveSession.when',
63
+ "A condition which must be true to enable this Interactive Session provider."
64
+ )),
65
+ type: 'string'
66
+ },
67
+ }
68
+ }
69
+ },
70
+ activationEventsGenerator: (contributions, result) => {
71
+ for (const contrib of contributions) {
72
+ result.push(`onInteractiveSession:${contrib.id}`);
73
+ }
74
+ },
75
+ }));
76
+ let ChatExtensionPointHandler = class ChatExtensionPointHandler {
77
+ constructor(_chatContributionService) {
78
+ this._chatContributionService = _chatContributionService;
79
+ this._registrationDisposables = ( new Map());
80
+ this._viewContainer = this.registerViewContainer();
81
+ this.handleAndRegisterChatExtensions();
82
+ }
83
+ handleAndRegisterChatExtensions() {
84
+ chatExtensionPoint.setHandler((extensions, delta) => {
85
+ for (const extension of delta.added) {
86
+ const extensionDisposable = ( new DisposableStore());
87
+ for (const providerDescriptor of extension.value) {
88
+ this.registerChatProvider(providerDescriptor);
89
+ this._chatContributionService.registerChatProvider(providerDescriptor);
90
+ }
91
+ this._registrationDisposables.set(extension.description.identifier.value, extensionDisposable);
92
+ }
93
+ for (const extension of delta.removed) {
94
+ const registration = this._registrationDisposables.get(extension.description.identifier.value);
95
+ if (registration) {
96
+ registration.dispose();
97
+ this._registrationDisposables.delete(extension.description.identifier.value);
98
+ }
99
+ for (const providerDescriptor of extension.value) {
100
+ this._chatContributionService.deregisterChatProvider(providerDescriptor.id);
101
+ }
102
+ }
103
+ });
104
+ }
105
+ registerViewContainer() {
106
+ const title = ( localize2WithPath(
107
+ 'vs/workbench/contrib/chat/browser/chatContributionServiceImpl',
108
+ 'chat.viewContainer.label',
109
+ "Chat"
110
+ ));
111
+ const icon = Codicon.commentDiscussion;
112
+ const viewContainerId = CHAT_SIDEBAR_PANEL_ID;
113
+ const viewContainer = ( Registry.as(Extensions$1.ViewContainersRegistry)).registerViewContainer({
114
+ id: viewContainerId,
115
+ title,
116
+ icon,
117
+ ctorDescriptor: ( new SyncDescriptor(
118
+ ViewPaneContainer,
119
+ [viewContainerId, { mergeViewWithContainerWhenSingleView: true }]
120
+ )),
121
+ storageId: viewContainerId,
122
+ hideIfEmpty: true,
123
+ order: 100,
124
+ }, 0 );
125
+ return viewContainer;
126
+ }
127
+ registerChatProvider(providerDescriptor) {
128
+ const viewId = this._chatContributionService.getViewIdForProvider(providerDescriptor.id);
129
+ const viewDescriptor = [{
130
+ id: viewId,
131
+ containerIcon: this._viewContainer.icon,
132
+ containerTitle: this._viewContainer.title.value,
133
+ name: { value: providerDescriptor.label, original: providerDescriptor.label },
134
+ canToggleVisibility: false,
135
+ canMoveView: true,
136
+ ctorDescriptor: ( new SyncDescriptor(ChatViewPane, [{ providerId: providerDescriptor.id }])),
137
+ when: ContextKeyExpr.deserialize(providerDescriptor.when)
138
+ }];
139
+ ( Registry.as(Extensions$1.ViewsRegistry)).registerViews(viewDescriptor, this._viewContainer);
140
+ const disposables = ( new DisposableStore());
141
+ disposables.add(registerAction2(getHistoryAction(viewId, providerDescriptor.id)));
142
+ disposables.add(registerAction2(getClearAction(viewId, providerDescriptor.id)));
143
+ disposables.add(registerAction2(getMoveToEditorAction(viewId, providerDescriptor.id)));
144
+ disposables.add(registerAction2(getMoveToNewWindowAction(viewId, providerDescriptor.id)));
145
+ disposables.add(registerAction2(getOpenChatEditorAction(providerDescriptor.id, providerDescriptor.label, providerDescriptor.when)));
146
+ disposables.add(registerAction2(getQuickChatActionForProvider(providerDescriptor.id, providerDescriptor.label)));
147
+ return {
148
+ dispose: () => {
149
+ ( Registry.as(Extensions$1.ViewsRegistry)).deregisterViews(viewDescriptor, this._viewContainer);
150
+ ( Registry.as(Extensions$1.ViewContainersRegistry)).deregisterViewContainer(this._viewContainer);
151
+ disposables.dispose();
152
+ }
153
+ };
154
+ }
155
+ };
156
+ ChatExtensionPointHandler = ( __decorate([
157
+ ( __param(0, IChatContributionService))
158
+ ], ChatExtensionPointHandler));
159
+ const workbenchRegistry = ( Registry.as(Extensions.Workbench));
160
+ workbenchRegistry.registerWorkbenchContribution(ChatExtensionPointHandler, 1 );
161
+ class ChatContributionService {
162
+ constructor() {
163
+ this._registeredProviders = ( new Map());
164
+ }
165
+ getViewIdForProvider(providerId) {
166
+ return ChatViewPane.ID + '.' + providerId;
167
+ }
168
+ registerChatProvider(provider) {
169
+ this._registeredProviders.set(provider.id, provider);
170
+ }
171
+ deregisterChatProvider(providerId) {
172
+ this._registeredProviders.delete(providerId);
173
+ }
174
+ get registeredProviders() {
175
+ return Array.from(( this._registeredProviders.values()));
176
+ }
177
+ }
178
+
179
+ export { ChatContributionService, ChatExtensionPointHandler };
@@ -0,0 +1,88 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import './media/chatEditor.css.js';
3
+ import { IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
4
+ import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
5
+ import { ServiceCollection } from 'monaco-editor/esm/vs/platform/instantiation/common/serviceCollection.js';
6
+ import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
7
+ import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
8
+ import { editorForeground, editorBackground, inputBackground } from 'monaco-editor/esm/vs/platform/theme/common/colorRegistry.js';
9
+ import { IThemeService } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
10
+ import { EditorPane } from 'vscode/vscode/vs/workbench/browser/parts/editor/editorPane';
11
+ import { Memento } from 'vscode/vscode/vs/workbench/common/memento';
12
+ import { ChatEditorInput } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatEditorInput';
13
+ import { ChatWidget } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatWidget';
14
+ import { clearChatEditor } from './actions/chatClear.js';
15
+
16
+ let ChatEditor = class ChatEditor extends EditorPane {
17
+ get scopedContextKeyService() {
18
+ return this._scopedContextKeyService;
19
+ }
20
+ constructor(telemetryService, themeService, instantiationService, storageService, contextKeyService) {
21
+ super(ChatEditorInput.EditorID, telemetryService, themeService, storageService);
22
+ this.instantiationService = instantiationService;
23
+ this.storageService = storageService;
24
+ this.contextKeyService = contextKeyService;
25
+ }
26
+ async clear() {
27
+ return this.instantiationService.invokeFunction(clearChatEditor);
28
+ }
29
+ createEditor(parent) {
30
+ this._scopedContextKeyService = this._register(this.contextKeyService.createScoped(parent));
31
+ const scopedInstantiationService = this.instantiationService.createChild(( new ServiceCollection([IContextKeyService, this.scopedContextKeyService])));
32
+ this.widget = this._register(scopedInstantiationService.createInstance(ChatWidget, { resource: true }, { supportsFileReferences: true }, {
33
+ listForeground: editorForeground,
34
+ listBackground: editorBackground,
35
+ inputEditorBackground: inputBackground,
36
+ resultEditorBackground: editorBackground
37
+ }));
38
+ this._register(this.widget.onDidClear(() => this.clear()));
39
+ this.widget.render(parent);
40
+ this.widget.setVisible(true);
41
+ }
42
+ focus() {
43
+ super.focus();
44
+ this.widget?.focusInput();
45
+ }
46
+ clearInput() {
47
+ this.saveState();
48
+ super.clearInput();
49
+ }
50
+ async setInput(input, options, context, token) {
51
+ super.setInput(input, options, context, token);
52
+ const editorModel = await input.resolve();
53
+ if (!editorModel) {
54
+ throw new Error(`Failed to get model for chat editor. id: ${input.sessionId}`);
55
+ }
56
+ if (!this.widget) {
57
+ throw new Error('ChatEditor lifecycle issue: no editor widget');
58
+ }
59
+ this.updateModel(editorModel.model);
60
+ }
61
+ updateModel(model) {
62
+ this._memento = ( new Memento('interactive-session-editor-' + model.sessionId, this.storageService));
63
+ this._viewState = this._memento.getMemento(1 , 1 );
64
+ this.widget.setModel(model, { ...this._viewState });
65
+ }
66
+ saveState() {
67
+ this.widget?.saveState();
68
+ if (this._memento && this._viewState) {
69
+ const widgetViewState = this.widget.getViewState();
70
+ this._viewState.inputValue = widgetViewState.inputValue;
71
+ this._memento.saveMemento();
72
+ }
73
+ }
74
+ layout(dimension, position) {
75
+ if (this.widget) {
76
+ this.widget.layout(dimension.height, dimension.width);
77
+ }
78
+ }
79
+ };
80
+ ChatEditor = ( __decorate([
81
+ ( __param(0, ITelemetryService)),
82
+ ( __param(1, IThemeService)),
83
+ ( __param(2, IInstantiationService)),
84
+ ( __param(3, IStorageService)),
85
+ ( __param(4, IContextKeyService))
86
+ ], ChatEditor));
87
+
88
+ export { ChatEditor };