@codingame/monaco-vscode-extensions-service-override 1.83.16 → 1.85.0-next.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 (71) hide show
  1. package/extensions.js +2 -2
  2. package/localExtensionHost.d.ts +1 -0
  3. package/package.json +4 -4
  4. package/vscode/src/vs/workbench/api/browser/mainThreadAuthentication.js +4 -2
  5. package/vscode/src/vs/workbench/api/browser/mainThreadChat.js +9 -88
  6. package/vscode/src/vs/workbench/api/browser/mainThreadChatAgents2.js +216 -0
  7. package/vscode/src/vs/workbench/api/browser/mainThreadChatProvider.js +3 -0
  8. package/vscode/src/vs/workbench/api/browser/mainThreadChatVariables.js +7 -6
  9. package/vscode/src/vs/workbench/api/browser/mainThreadCommands.js +8 -4
  10. package/vscode/src/vs/workbench/api/browser/mainThreadComments.js +4 -4
  11. package/vscode/src/vs/workbench/api/browser/mainThreadDocuments.js +6 -2
  12. package/vscode/src/vs/workbench/api/browser/mainThreadEditorTabs.js +16 -9
  13. package/vscode/src/vs/workbench/api/browser/mainThreadFileSystem.js +3 -75
  14. package/vscode/src/vs/workbench/api/browser/mainThreadFileSystemEventService.js +102 -11
  15. package/vscode/src/vs/workbench/api/browser/mainThreadInlineChat.js +6 -2
  16. package/vscode/src/vs/workbench/api/browser/mainThreadIssueReporter.js +16 -0
  17. package/vscode/src/vs/workbench/api/browser/mainThreadLanguageFeatures.js +25 -0
  18. package/vscode/src/vs/workbench/api/browser/mainThreadNotebook.js +36 -0
  19. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookKernels.js +34 -1
  20. package/vscode/src/vs/workbench/api/browser/mainThreadQuickDiff.js +4 -11
  21. package/vscode/src/vs/workbench/api/browser/mainThreadSCM.js +136 -28
  22. package/vscode/src/vs/workbench/api/browser/mainThreadSearch.js +2 -4
  23. package/vscode/src/vs/workbench/api/browser/mainThreadSpeech.js +67 -0
  24. package/vscode/src/vs/workbench/api/browser/mainThreadTerminalService.js +8 -10
  25. package/vscode/src/vs/workbench/api/browser/mainThreadTesting.js +25 -10
  26. package/vscode/src/vs/workbench/api/browser/mainThreadTreeViews.js +8 -13
  27. package/vscode/src/vs/workbench/api/browser/mainThreadTunnelService.js +1 -1
  28. package/vscode/src/vs/workbench/api/browser/mainThreadWorkspace.js +3 -0
  29. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.js +40 -0
  30. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorInput.js +141 -0
  31. package/vscode/src/vs/workbench/contrib/chat/browser/chatFollowups.js +37 -0
  32. package/vscode/src/vs/workbench/contrib/chat/browser/chatInputPart.js +342 -0
  33. package/vscode/src/vs/workbench/contrib/chat/browser/chatListRenderer.js +1197 -0
  34. package/vscode/src/vs/workbench/contrib/chat/browser/chatMarkdownDecorationsRenderer.js +117 -0
  35. package/vscode/src/vs/workbench/contrib/chat/browser/chatOptions.js +83 -0
  36. package/vscode/src/vs/workbench/contrib/chat/browser/chatWidget.js +543 -0
  37. package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockPart.css.js +6 -0
  38. package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockPart.js +292 -0
  39. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables.js +169 -0
  40. package/vscode/src/vs/workbench/contrib/chat/browser/media/chat.css.js +6 -0
  41. package/vscode/src/vs/workbench/contrib/chat/common/chatModel.js +111 -73
  42. package/vscode/src/vs/workbench/contrib/chat/common/chatRequestParser.js +195 -0
  43. package/vscode/src/vs/workbench/contrib/chat/common/chatViewModel.js +260 -0
  44. package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +5 -0
  45. package/vscode/src/vs/workbench/contrib/chat/common/chatWordCounter.js +26 -0
  46. package/vscode/src/vs/workbench/contrib/comments/browser/commentColors.js +6 -0
  47. package/vscode/src/vs/workbench/contrib/comments/browser/commentNode.js +6 -5
  48. package/vscode/src/vs/workbench/contrib/comments/browser/commentReply.js +8 -3
  49. package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadBody.js +6 -4
  50. package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadHeader.js +1 -1
  51. package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadWidget.js +6 -2
  52. package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.js +24 -10
  53. package/vscode/src/vs/workbench/contrib/comments/browser/commentsController.js +113 -34
  54. package/vscode/src/vs/workbench/contrib/comments/browser/commentsTreeViewer.js +17 -8
  55. package/vscode/src/vs/workbench/contrib/comments/browser/commentsView.js +5 -3
  56. package/vscode/src/vs/workbench/contrib/comments/browser/media/panel.css.js +1 -1
  57. package/vscode/src/vs/workbench/contrib/comments/browser/media/review.css.js +1 -1
  58. package/vscode/src/vs/workbench/contrib/comments/common/commentModel.js +18 -8
  59. package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveEditorInput.js +2 -1
  60. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/diffComputer.js +7 -0
  61. package/vscode/src/vs/workbench/contrib/tasks/common/tasks.js +5 -5
  62. package/vscode/src/vs/workbench/services/extensions/browser/extensionService.js +2 -1
  63. package/vscode/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.js +7 -4
  64. package/vscode/src/vs/workbench/services/extensions/common/abstractExtensionService.js +17 -12
  65. package/vscode/src/vs/workbench/services/extensions/common/extensionHostManager.js +17 -148
  66. package/vscode/src/vs/workbench/services/extensions/common/lazyCreateExtensionHostManager.js +161 -0
  67. package/vscode/src/vs/workbench/services/extensions/common/remoteExtensionHost.js +2 -0
  68. package/vscode/src/vs/platform/files/common/watcher.js +0 -71
  69. package/vscode/src/vs/workbench/api/browser/mainThreadChatAgents.js +0 -52
  70. package/vscode/src/vs/workbench/api/browser/mainThreadChatSlashCommands.js +0 -49
  71. package/vscode/src/vs/workbench/contrib/testing/common/testCoverage.js +0 -25
@@ -0,0 +1,543 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import * as dom from 'monaco-editor/esm/vs/base/browser/dom.js';
3
+ import { disposableTimeout } from 'monaco-editor/esm/vs/base/common/async.js';
4
+ import { toErrorMessage } from 'monaco-editor/esm/vs/base/common/errorMessage.js';
5
+ import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
6
+ import { Disposable, DisposableStore, MutableDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
7
+ import { isDefined } from 'monaco-editor/esm/vs/base/common/types.js';
8
+ import './media/chat.css.js';
9
+ import { MenuId } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
10
+ import { IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
11
+ import { IContextMenuService } from 'monaco-editor/esm/vs/platform/contextview/browser/contextView.js';
12
+ import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
13
+ import { ServiceCollection } from 'monaco-editor/esm/vs/platform/instantiation/common/serviceCollection.js';
14
+ import { WorkbenchObjectTree } from 'monaco-editor/esm/vs/platform/list/browser/listService.js';
15
+ import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
16
+ import { IChatWidgetService, IChatAccessibilityService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
17
+ import { ChatInputPart } from './chatInputPart.js';
18
+ import { ChatListDelegate, ChatListItemRenderer, ChatAccessibilityProvider } from './chatListRenderer.js';
19
+ import { ChatEditorOptions } from './chatOptions.js';
20
+ import { CONTEXT_IN_CHAT_SESSION, CONTEXT_CHAT_REQUEST_IN_PROGRESS, CONTEXT_RESPONSE_FILTERED } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
21
+ import { ChatModelInitState } from '../common/chatModel.js';
22
+ import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
23
+ import { isResponseVM, isRequestVM, isWelcomeVM, ChatViewModel } from '../common/chatViewModel.js';
24
+
25
+ var ChatWidget_1;
26
+ const $ = dom.$;
27
+ function revealLastElement(list) {
28
+ list.scrollTop = list.scrollHeight - list.renderHeight;
29
+ }
30
+ let ChatWidget = class ChatWidget extends Disposable {
31
+ static { ChatWidget_1 = this; }
32
+ static { this.CONTRIBS = []; }
33
+ get visible() {
34
+ return this._visible;
35
+ }
36
+ set viewModel(viewModel) {
37
+ if (this._viewModel === viewModel) {
38
+ return;
39
+ }
40
+ this.viewModelDisposables.clear();
41
+ this._viewModel = viewModel;
42
+ if (viewModel) {
43
+ this.viewModelDisposables.add(viewModel);
44
+ }
45
+ this._onDidChangeViewModel.fire();
46
+ }
47
+ get viewModel() {
48
+ return this._viewModel;
49
+ }
50
+ constructor(viewContext, viewOptions, styles, contextKeyService, instantiationService, chatService, chatWidgetService, contextMenuService, _chatAccessibilityService, _instantiationService, _logService) {
51
+ super();
52
+ this.viewContext = viewContext;
53
+ this.viewOptions = viewOptions;
54
+ this.styles = styles;
55
+ this.contextKeyService = contextKeyService;
56
+ this.instantiationService = instantiationService;
57
+ this.chatService = chatService;
58
+ this.contextMenuService = contextMenuService;
59
+ this._chatAccessibilityService = _chatAccessibilityService;
60
+ this._instantiationService = _instantiationService;
61
+ this._logService = _logService;
62
+ this._onDidFocus = this._register(( new Emitter()));
63
+ this.onDidFocus = this._onDidFocus.event;
64
+ this._onDidChangeViewModel = this._register(( new Emitter()));
65
+ this.onDidChangeViewModel = this._onDidChangeViewModel.event;
66
+ this._onDidClear = this._register(( new Emitter()));
67
+ this.onDidClear = this._onDidClear.event;
68
+ this._onDidAcceptInput = this._register(( new Emitter()));
69
+ this.onDidAcceptInput = this._onDidAcceptInput.event;
70
+ this._onDidChangeHeight = this._register(( new Emitter()));
71
+ this.onDidChangeHeight = this._onDidChangeHeight.event;
72
+ this.contribs = [];
73
+ this.visibleChangeCount = 0;
74
+ this._visible = false;
75
+ this.previousTreeScrollHeight = 0;
76
+ this.viewModelDisposables = this._register(( new DisposableStore()));
77
+ CONTEXT_IN_CHAT_SESSION.bindTo(contextKeyService).set(true);
78
+ this.requestInProgress = CONTEXT_CHAT_REQUEST_IN_PROGRESS.bindTo(contextKeyService);
79
+ this._register(chatWidgetService.register(this));
80
+ }
81
+ get supportsFileReferences() {
82
+ return !!this.viewOptions.supportsFileReferences;
83
+ }
84
+ get providerId() {
85
+ return this.viewModel?.providerId || '';
86
+ }
87
+ get inputEditor() {
88
+ return this.inputPart.inputEditor;
89
+ }
90
+ get inputUri() {
91
+ return this.inputPart.inputUri;
92
+ }
93
+ render(parent) {
94
+ const viewId = 'viewId' in this.viewContext ? this.viewContext.viewId : undefined;
95
+ this.editorOptions = this._register(this.instantiationService.createInstance(ChatEditorOptions, viewId, this.styles.listForeground, this.styles.inputEditorBackground, this.styles.resultEditorBackground));
96
+ const renderInputOnTop = this.viewOptions.renderInputOnTop ?? false;
97
+ const renderStyle = this.viewOptions.renderStyle;
98
+ this.container = dom.append(parent, $('.interactive-session'));
99
+ if (renderInputOnTop) {
100
+ this.createInput(this.container, { renderFollowups: false, renderStyle });
101
+ this.listContainer = dom.append(this.container, $(`.interactive-list`));
102
+ }
103
+ else {
104
+ this.listContainer = dom.append(this.container, $(`.interactive-list`));
105
+ this.createInput(this.container);
106
+ }
107
+ this.createList(this.listContainer, { renderStyle });
108
+ this._register(this.editorOptions.onDidChange(() => this.onDidStyleChange()));
109
+ this.onDidStyleChange();
110
+ if (this.viewModel) {
111
+ this.onDidChangeItems();
112
+ revealLastElement(this.tree);
113
+ }
114
+ this.contribs = ( ChatWidget_1.CONTRIBS.map(contrib => {
115
+ try {
116
+ return this._register(this.instantiationService.createInstance(contrib, this));
117
+ }
118
+ catch (err) {
119
+ this._logService.error('Failed to instantiate chat widget contrib', toErrorMessage(err));
120
+ return undefined;
121
+ }
122
+ })).filter(isDefined);
123
+ }
124
+ getContrib(id) {
125
+ return this.contribs.find(c => c.id === id);
126
+ }
127
+ focusInput() {
128
+ this.inputPart.focus();
129
+ }
130
+ hasInputFocus() {
131
+ return this.inputPart.hasFocus();
132
+ }
133
+ moveFocus(item, type) {
134
+ const items = this.viewModel?.getItems();
135
+ if (!items) {
136
+ return;
137
+ }
138
+ const responseItems = items.filter(i => isResponseVM(i));
139
+ const targetIndex = responseItems.indexOf(item);
140
+ if (targetIndex === undefined) {
141
+ return;
142
+ }
143
+ const indexToFocus = type === 'next' ? targetIndex + 1 : targetIndex - 1;
144
+ if (indexToFocus < 0 || indexToFocus > responseItems.length - 1) {
145
+ return;
146
+ }
147
+ this.focus(responseItems[indexToFocus]);
148
+ }
149
+ clear() {
150
+ if (this._dynamicMessageLayoutData) {
151
+ this._dynamicMessageLayoutData.enabled = true;
152
+ }
153
+ this._onDidClear.fire();
154
+ }
155
+ onDidChangeItems(skipDynamicLayout) {
156
+ if (this.tree && this._visible) {
157
+ const treeItems = ( (this.viewModel?.getItems() ?? [])
158
+ .map(item => {
159
+ return {
160
+ element: item,
161
+ collapsed: false,
162
+ collapsible: false
163
+ };
164
+ }));
165
+ this.tree.setChildren(null, treeItems, {
166
+ diffIdentityProvider: {
167
+ getId: (element) => {
168
+ return ((isResponseVM(element) || isRequestVM(element)) ? element.dataId : element.id) +
169
+ ((isWelcomeVM(element) && this.viewModel) ? `_${ChatModelInitState[this.viewModel.initState]}` : '') +
170
+ `${(isRequestVM(element) || isWelcomeVM(element)) }` +
171
+ `${isResponseVM(element) && element.renderData ? `_${this.visibleChangeCount}` : ''}` +
172
+ (isResponseVM(element) ? `_${element.contentReferences.length}` : '');
173
+ },
174
+ }
175
+ });
176
+ if (!skipDynamicLayout && this._dynamicMessageLayoutData) {
177
+ this.layoutDynamicChatTreeItemMode();
178
+ }
179
+ const lastItem = treeItems[treeItems.length - 1]?.element;
180
+ if (lastItem && isResponseVM(lastItem) && lastItem.isComplete) {
181
+ this.renderFollowups(lastItem.replyFollowups, lastItem);
182
+ }
183
+ else if (lastItem && isWelcomeVM(lastItem)) {
184
+ this.renderFollowups(lastItem.sampleQuestions);
185
+ }
186
+ else {
187
+ this.renderFollowups(undefined);
188
+ }
189
+ }
190
+ }
191
+ async renderFollowups(items, response) {
192
+ this.inputPart.renderFollowups(items, response);
193
+ if (this.bodyDimension) {
194
+ this.layout(this.bodyDimension.height, this.bodyDimension.width);
195
+ }
196
+ }
197
+ setVisible(visible) {
198
+ this._visible = visible;
199
+ this.visibleChangeCount++;
200
+ this.renderer.setVisible(visible);
201
+ if (visible) {
202
+ this._register(disposableTimeout(() => {
203
+ if (this._visible) {
204
+ this.onDidChangeItems(true);
205
+ }
206
+ }, 0));
207
+ }
208
+ }
209
+ createList(listContainer, options) {
210
+ const scopedInstantiationService = this.instantiationService.createChild(( new ServiceCollection([IContextKeyService, this.contextKeyService])));
211
+ const delegate = scopedInstantiationService.createInstance(ChatListDelegate);
212
+ const rendererDelegate = {
213
+ getListLength: () => this.tree.getNode(null).visibleChildrenCount,
214
+ };
215
+ this.renderer = this._register(scopedInstantiationService.createInstance(ChatListItemRenderer, this.editorOptions, options, rendererDelegate));
216
+ this._register(this.renderer.onDidClickFollowup(item => {
217
+ this.acceptInput(item.message);
218
+ }));
219
+ this.tree = scopedInstantiationService.createInstance(WorkbenchObjectTree, 'Chat', listContainer, delegate, [this.renderer], {
220
+ identityProvider: { getId: (e) => e.id },
221
+ horizontalScrolling: false,
222
+ supportDynamicHeights: true,
223
+ hideTwistiesOfChildlessElements: true,
224
+ accessibilityProvider: this._instantiationService.createInstance(ChatAccessibilityProvider),
225
+ keyboardNavigationLabelProvider: { getKeyboardNavigationLabel: (e) => isRequestVM(e) ? e.message : isResponseVM(e) ? e.response.value : '' },
226
+ setRowLineHeight: false,
227
+ overrideStyles: {
228
+ listFocusBackground: this.styles.listBackground,
229
+ listInactiveFocusBackground: this.styles.listBackground,
230
+ listActiveSelectionBackground: this.styles.listBackground,
231
+ listFocusAndSelectionBackground: this.styles.listBackground,
232
+ listInactiveSelectionBackground: this.styles.listBackground,
233
+ listHoverBackground: this.styles.listBackground,
234
+ listBackground: this.styles.listBackground,
235
+ listFocusForeground: this.styles.listForeground,
236
+ listHoverForeground: this.styles.listForeground,
237
+ listInactiveFocusForeground: this.styles.listForeground,
238
+ listInactiveSelectionForeground: this.styles.listForeground,
239
+ listActiveSelectionForeground: this.styles.listForeground,
240
+ listFocusAndSelectionForeground: this.styles.listForeground,
241
+ }
242
+ });
243
+ this.tree.onContextMenu(e => this.onContextMenu(e));
244
+ this._register(this.tree.onDidChangeContentHeight(() => {
245
+ this.onDidChangeTreeContentHeight();
246
+ }));
247
+ this._register(this.renderer.onDidChangeItemHeight(e => {
248
+ this.tree.updateElementHeight(e.element, e.height);
249
+ }));
250
+ this._register(this.tree.onDidFocus(() => {
251
+ this._onDidFocus.fire();
252
+ }));
253
+ }
254
+ onContextMenu(e) {
255
+ e.browserEvent.preventDefault();
256
+ e.browserEvent.stopPropagation();
257
+ const selected = e.element;
258
+ const scopedContextKeyService = this.contextKeyService.createOverlay([
259
+ [CONTEXT_RESPONSE_FILTERED.key, isResponseVM(selected) && !!selected.errorDetails?.responseIsFiltered]
260
+ ]);
261
+ this.contextMenuService.showContextMenu({
262
+ menuId: MenuId.ChatContext,
263
+ menuActionOptions: { shouldForwardArgs: true },
264
+ contextKeyService: scopedContextKeyService,
265
+ getAnchor: () => e.anchor,
266
+ getActionsContext: () => selected,
267
+ });
268
+ }
269
+ onDidChangeTreeContentHeight() {
270
+ if (this.tree.scrollHeight !== this.previousTreeScrollHeight) {
271
+ const lastElementWasVisible = this.tree.scrollTop + this.tree.renderHeight >= this.previousTreeScrollHeight - 2;
272
+ if (lastElementWasVisible) {
273
+ dom.scheduleAtNextAnimationFrame(dom.getWindow(this.listContainer), () => {
274
+ revealLastElement(this.tree);
275
+ }, 0);
276
+ }
277
+ }
278
+ this.previousTreeScrollHeight = this.tree.scrollHeight;
279
+ }
280
+ createInput(container, options) {
281
+ this.inputPart = this._register(this.instantiationService.createInstance(ChatInputPart, {
282
+ renderFollowups: options?.renderFollowups ?? true,
283
+ renderStyle: options?.renderStyle,
284
+ }));
285
+ this.inputPart.render(container, '', this);
286
+ this._register(this.inputPart.onDidLoadInputState(state => {
287
+ this.contribs.forEach(c => {
288
+ if (c.setInputState && typeof state === 'object' && state?.[c.id]) {
289
+ c.setInputState(state[c.id]);
290
+ }
291
+ });
292
+ }));
293
+ this._register(this.inputPart.onDidFocus(() => this._onDidFocus.fire()));
294
+ this._register(this.inputPart.onDidAcceptFollowup(e => {
295
+ if (!this.viewModel) {
296
+ return;
297
+ }
298
+ this.acceptInput(e.followup.message);
299
+ if (!e.response) {
300
+ return;
301
+ }
302
+ this.chatService.notifyUserAction({
303
+ providerId: this.viewModel.providerId,
304
+ sessionId: this.viewModel.sessionId,
305
+ requestId: e.response.requestId,
306
+ agentId: e.response?.agent?.id,
307
+ action: {
308
+ kind: 'followUp',
309
+ followup: e.followup
310
+ },
311
+ });
312
+ }));
313
+ this._register(this.inputPart.onDidChangeHeight(() => this.bodyDimension && this.layout(this.bodyDimension.height, this.bodyDimension.width)));
314
+ }
315
+ onDidStyleChange() {
316
+ this.container.style.setProperty('--vscode-interactive-result-editor-background-color', this.editorOptions.configuration.resultEditor.backgroundColor?.toString() ?? '');
317
+ this.container.style.setProperty('--vscode-interactive-session-foreground', this.editorOptions.configuration.foreground?.toString() ?? '');
318
+ }
319
+ setModel(model, viewState) {
320
+ if (!this.container) {
321
+ throw new Error('Call render() before setModel()');
322
+ }
323
+ this.container.setAttribute('data-session-id', model.sessionId);
324
+ this.viewModel = this.instantiationService.createInstance(ChatViewModel, model);
325
+ this.viewModelDisposables.add(this.viewModel.onDidChange(e => {
326
+ this.requestInProgress.set(this.viewModel.requestInProgress);
327
+ this.onDidChangeItems();
328
+ if (e?.kind === 'addRequest') {
329
+ revealLastElement(this.tree);
330
+ this.focusInput();
331
+ }
332
+ }));
333
+ this.viewModelDisposables.add(this.viewModel.onDidDisposeModel(() => {
334
+ this.inputPart.saveState();
335
+ this.viewModel = undefined;
336
+ this.onDidChangeItems();
337
+ }));
338
+ this.inputPart.setState(model.providerId, viewState.inputValue);
339
+ this.contribs.forEach(c => {
340
+ if (c.setInputState && viewState.inputState?.[c.id]) {
341
+ c.setInputState(viewState.inputState?.[c.id]);
342
+ }
343
+ });
344
+ if (this.tree) {
345
+ this.onDidChangeItems();
346
+ revealLastElement(this.tree);
347
+ }
348
+ }
349
+ getFocus() {
350
+ return this.tree.getFocus()[0] ?? undefined;
351
+ }
352
+ reveal(item) {
353
+ this.tree.reveal(item);
354
+ }
355
+ focus(item) {
356
+ const items = this.tree.getNode(null).children;
357
+ const node = items.find(i => i.element?.id === item.id);
358
+ if (!node) {
359
+ return;
360
+ }
361
+ this.tree.setFocus([node.element]);
362
+ this.tree.domFocus();
363
+ }
364
+ setInputPlaceholder(placeholder) {
365
+ this.viewModel?.setInputPlaceholder(placeholder);
366
+ }
367
+ resetInputPlaceholder() {
368
+ this.viewModel?.resetInputPlaceholder();
369
+ }
370
+ updateInput(value = '') {
371
+ this.inputPart.setValue(value);
372
+ }
373
+ getInput() {
374
+ return this.inputPart.inputEditor.getValue();
375
+ }
376
+ async acceptInput(query) {
377
+ this._acceptInput(query ? { query } : undefined);
378
+ }
379
+ async acceptInputWithPrefix(prefix) {
380
+ this._acceptInput({ prefix });
381
+ }
382
+ collectInputState() {
383
+ const inputState = {};
384
+ this.contribs.forEach(c => {
385
+ if (c.getInputState) {
386
+ inputState[c.id] = c.getInputState();
387
+ }
388
+ });
389
+ return inputState;
390
+ }
391
+ async _acceptInput(opts) {
392
+ if (this.viewModel) {
393
+ this._onDidAcceptInput.fire();
394
+ const editorValue = this.getInput();
395
+ const requestId = this._chatAccessibilityService.acceptRequest();
396
+ const input = !opts ? editorValue :
397
+ 'query' in opts ? opts.query :
398
+ `${opts.prefix} ${editorValue}`;
399
+ const isUserQuery = !opts || 'query' in opts;
400
+ const result = await this.chatService.sendRequest(this.viewModel.sessionId, input);
401
+ if (result) {
402
+ const inputState = this.collectInputState();
403
+ this.inputPart.acceptInput(isUserQuery ? input : undefined, isUserQuery ? inputState : undefined);
404
+ result.responseCompletePromise.then(async () => {
405
+ const responses = this.viewModel?.getItems().filter(isResponseVM);
406
+ const lastResponse = responses?.[responses.length - 1];
407
+ this._chatAccessibilityService.acceptResponse(lastResponse, requestId);
408
+ });
409
+ }
410
+ else {
411
+ this._chatAccessibilityService.acceptResponse(undefined, requestId);
412
+ }
413
+ }
414
+ }
415
+ getCodeBlockInfosForResponse(response) {
416
+ return this.renderer.getCodeBlockInfosForResponse(response);
417
+ }
418
+ getCodeBlockInfoForEditor(uri) {
419
+ return this.renderer.getCodeBlockInfoForEditor(uri);
420
+ }
421
+ getFileTreeInfosForResponse(response) {
422
+ return this.renderer.getFileTreeInfosForResponse(response);
423
+ }
424
+ getLastFocusedFileTreeForResponse(response) {
425
+ return this.renderer.getLastFocusedFileTreeForResponse(response);
426
+ }
427
+ focusLastMessage() {
428
+ if (!this.viewModel) {
429
+ return;
430
+ }
431
+ const items = this.tree.getNode(null).children;
432
+ const lastItem = items[items.length - 1];
433
+ if (!lastItem) {
434
+ return;
435
+ }
436
+ this.tree.setFocus([lastItem.element]);
437
+ this.tree.domFocus();
438
+ }
439
+ layout(height, width) {
440
+ width = Math.min(width, 850);
441
+ this.bodyDimension = new dom.Dimension(width, height);
442
+ const inputPartHeight = this.inputPart.layout(height, width);
443
+ const lastElementVisible = this.tree.scrollTop + this.tree.renderHeight >= this.tree.scrollHeight;
444
+ const listHeight = height - inputPartHeight;
445
+ this.tree.layout(listHeight, width);
446
+ this.tree.getHTMLElement().style.height = `${listHeight}px`;
447
+ this.renderer.layout(width);
448
+ if (lastElementVisible) {
449
+ revealLastElement(this.tree);
450
+ }
451
+ this.listContainer.style.height = `${height - inputPartHeight}px`;
452
+ this._onDidChangeHeight.fire(height);
453
+ }
454
+ setDynamicChatTreeItemLayout(numOfChatTreeItems, maxHeight) {
455
+ this._dynamicMessageLayoutData = { numOfMessages: numOfChatTreeItems, maxHeight, enabled: true };
456
+ this._register(this.renderer.onDidChangeItemHeight(() => this.layoutDynamicChatTreeItemMode()));
457
+ const mutableDisposable = this._register(( new MutableDisposable()));
458
+ this._register(this.tree.onDidScroll((e) => {
459
+ if (!this._dynamicMessageLayoutData?.enabled) {
460
+ return;
461
+ }
462
+ mutableDisposable.value = dom.scheduleAtNextAnimationFrame(dom.getWindow(this.listContainer), () => {
463
+ if (!e.scrollTopChanged || e.heightChanged || e.scrollHeightChanged) {
464
+ return;
465
+ }
466
+ const renderHeight = e.height;
467
+ const diff = e.scrollHeight - renderHeight - e.scrollTop;
468
+ if (diff === 0) {
469
+ return;
470
+ }
471
+ const possibleMaxHeight = (this._dynamicMessageLayoutData?.maxHeight ?? maxHeight);
472
+ const width = this.bodyDimension?.width ?? this.container.offsetWidth;
473
+ const inputPartHeight = this.inputPart.layout(possibleMaxHeight, width);
474
+ const newHeight = Math.min(renderHeight + diff, possibleMaxHeight - inputPartHeight);
475
+ this.layout(newHeight + inputPartHeight, width);
476
+ });
477
+ }));
478
+ }
479
+ updateDynamicChatTreeItemLayout(numOfChatTreeItems, maxHeight) {
480
+ this._dynamicMessageLayoutData = { numOfMessages: numOfChatTreeItems, maxHeight, enabled: true };
481
+ let hasChanged = false;
482
+ let height = this.bodyDimension.height;
483
+ let width = this.bodyDimension.width;
484
+ if (maxHeight < this.bodyDimension.height) {
485
+ height = maxHeight;
486
+ hasChanged = true;
487
+ }
488
+ const containerWidth = this.container.offsetWidth;
489
+ if (this.bodyDimension?.width !== containerWidth) {
490
+ width = containerWidth;
491
+ hasChanged = true;
492
+ }
493
+ if (hasChanged) {
494
+ this.layout(height, width);
495
+ }
496
+ }
497
+ get isDynamicChatTreeItemLayoutEnabled() {
498
+ return this._dynamicMessageLayoutData?.enabled ?? false;
499
+ }
500
+ set isDynamicChatTreeItemLayoutEnabled(value) {
501
+ if (!this._dynamicMessageLayoutData) {
502
+ return;
503
+ }
504
+ this._dynamicMessageLayoutData.enabled = value;
505
+ }
506
+ layoutDynamicChatTreeItemMode() {
507
+ if (!this.viewModel || !this._dynamicMessageLayoutData?.enabled) {
508
+ return;
509
+ }
510
+ const width = this.bodyDimension?.width ?? this.container.offsetWidth;
511
+ const inputHeight = this.inputPart.layout(this._dynamicMessageLayoutData.maxHeight, width);
512
+ const totalMessages = this.viewModel.getItems();
513
+ const messages = totalMessages.slice(-this._dynamicMessageLayoutData.numOfMessages);
514
+ const needsRerender = ( messages.some(m => m.currentRenderedHeight === undefined));
515
+ const listHeight = needsRerender
516
+ ? this._dynamicMessageLayoutData.maxHeight
517
+ : messages.reduce((acc, message) => acc + message.currentRenderedHeight, 0);
518
+ this.layout(Math.min(
519
+ inputHeight + listHeight + (totalMessages.length > 2 ? 18 : 0), this._dynamicMessageLayoutData.maxHeight), width);
520
+ if (needsRerender || !listHeight) {
521
+ revealLastElement(this.tree);
522
+ }
523
+ }
524
+ saveState() {
525
+ this.inputPart.saveState();
526
+ }
527
+ getViewState() {
528
+ this.inputPart.saveState();
529
+ return { inputValue: this.getInput(), inputState: this.collectInputState() };
530
+ }
531
+ };
532
+ ChatWidget = ChatWidget_1 = ( __decorate([
533
+ ( __param(3, IContextKeyService)),
534
+ ( __param(4, IInstantiationService)),
535
+ ( __param(5, IChatService)),
536
+ ( __param(6, IChatWidgetService)),
537
+ ( __param(7, IContextMenuService)),
538
+ ( __param(8, IChatAccessibilityService)),
539
+ ( __param(9, IInstantiationService)),
540
+ ( __param(10, ILogService))
541
+ ], ChatWidget));
542
+
543
+ export { ChatWidget };
@@ -0,0 +1,6 @@
1
+ import n from '../../../../../../../external/rollup-plugin-styles/dist/runtime/inject-css.js';
2
+
3
+ var css = ".interactive-result-code-block{position:relative}.interactive-result-code-block .monaco-toolbar{background-color:var(--vscode-interactive-result-editor-background-color,var(--vscode-editor-background));border:1px solid var(--vscode-chat-requestBorder);display:none;height:26px;position:absolute;right:10px;top:-13px;z-index:100}.interactive-result-code-block .monaco-toolbar .action-item{height:24px;margin:1px 2px;width:24px}.interactive-result-code-block .monaco-toolbar .action-item .codicon{margin:1px}.interactive-result-code-block .monaco-toolbar:focus-within,.interactive-result-code-block.focused .monaco-toolbar,.interactive-result-code-block:hover .monaco-toolbar{border-radius:2px;display:initial}.interactive-result-code-block .interactive-result-code-block-toolbar.force-visibility .monaco-toolbar{display:initial!important}.interactive-result-code-block{background-color:var(--vscode-interactive-result-editor-background-color);border:1px solid var(--vscode-input-border,transparent);margin:16px 0}.interactive-result-code-block:has(.monaco-editor.focused){border-color:var(--vscode-focusBorder,transparent)}.interactive-result-code-block,.interactive-result-code-block .monaco-editor,.interactive-result-code-block .monaco-editor .overflow-guard{border-radius:4px}.interactive-result-code-block .interactive-result-vulns{font-size:.9em;padding:0 8px 2px}.interactive-result-code-block .interactive-result-vulns-header{display:flex;height:22px}.interactive-result-code-block .interactive-result-vulns-header,.interactive-result-code-block .interactive-result-vulns-list{opacity:.8}.interactive-result-code-block .interactive-result-vulns-list{margin:0;padding-bottom:3px;padding-left:16px!important}.interactive-result-code-block.chat-vulnerabilities-collapsed .interactive-result-vulns-list{display:none}.interactive-result-code-block .interactive-result-vulns-list .chat-vuln-title{font-weight:700}.interactive-result-code-block.no-vulns .interactive-result-vulns{display:none}.interactive-result-code-block .interactive-result-vulns-header .monaco-button{border:none;color:var(--vscode-foreground)!important;display:inline-flex;justify-content:normal;padding:0;text-align:initial;user-select:none;width:100%}.interactive-result-code-block .interactive-result-vulns-header .monaco-text-button:focus{outline:none}.interactive-result-code-block .interactive-result-vulns-header .monaco-text-button:focus-visible{outline:1px solid var(--vscode-focusBorder)}";
4
+ n(css,{});
5
+
6
+ export { css, css as default };