@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,271 @@
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 { Sash } from 'monaco-editor/esm/vs/base/browser/ui/sash/sash.js';
4
+ import { disposableTimeout } from 'monaco-editor/esm/vs/base/common/async.js';
5
+ import { CancellationToken } from 'monaco-editor/esm/vs/base/common/cancellation.js';
6
+ import { Emitter, Event } from 'monaco-editor/esm/vs/base/common/event.js';
7
+ import { Disposable, MutableDisposable, DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
8
+ import { IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
9
+ import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
10
+ import { ServiceCollection } from 'monaco-editor/esm/vs/platform/instantiation/common/serviceCollection.js';
11
+ import { ILayoutService } from 'monaco-editor/esm/vs/platform/layout/browser/layoutService.js';
12
+ import { IQuickInputService } from 'monaco-editor/esm/vs/platform/quickinput/common/quickInput.js';
13
+ import { quickInputForeground, quickInputBackground, inputBackground, editorBackground } from 'monaco-editor/esm/vs/platform/theme/common/colorRegistry.js';
14
+ import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
15
+ import { ChatWidget } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatWidget';
16
+ import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
17
+
18
+ var QuickChat_1;
19
+ let QuickChatService = class QuickChatService extends Disposable {
20
+ constructor(quickInputService, chatService, instantiationService) {
21
+ super();
22
+ this.quickInputService = quickInputService;
23
+ this.chatService = chatService;
24
+ this.instantiationService = instantiationService;
25
+ this._onDidClose = this._register(( new Emitter()));
26
+ this.onDidClose = this._onDidClose.event;
27
+ }
28
+ get enabled() {
29
+ return this.chatService.getProviderInfos().length > 0;
30
+ }
31
+ get focused() {
32
+ const widget = this._input?.widget;
33
+ if (!widget) {
34
+ return false;
35
+ }
36
+ return dom.isAncestorOfActiveElement(widget);
37
+ }
38
+ toggle(providerId, options) {
39
+ if (this.focused && !options?.query) {
40
+ this.close();
41
+ }
42
+ else {
43
+ this.open(providerId, options);
44
+ if (options?.isPartialQuery) {
45
+ const disposable = this._store.add(Event.once(this.onDidClose)(() => {
46
+ this._currentChat?.clearValue();
47
+ this._store.delete(disposable);
48
+ }));
49
+ }
50
+ }
51
+ }
52
+ open(providerId, options) {
53
+ if (this._input) {
54
+ if (this._currentChat && options?.query) {
55
+ this._currentChat.setValue(options.query, options.selection);
56
+ if (!options.isPartialQuery) {
57
+ this._currentChat.acceptInput();
58
+ }
59
+ }
60
+ return this.focus();
61
+ }
62
+ const providerInfo = providerId
63
+ ? this.chatService.getProviderInfos().find(info => info.id === providerId)
64
+ : this.chatService.getProviderInfos()[0];
65
+ if (!providerInfo) {
66
+ return;
67
+ }
68
+ const disposableStore = ( new DisposableStore());
69
+ this._input = this.quickInputService.createQuickWidget();
70
+ this._input.contextKey = 'chatInputVisible';
71
+ this._input.ignoreFocusOut = true;
72
+ disposableStore.add(this._input);
73
+ this._container ??= dom.$('.interactive-session');
74
+ this._input.widget = this._container;
75
+ this._input.show();
76
+ if (!this._currentChat) {
77
+ this._currentChat = this.instantiationService.createInstance(QuickChat, {
78
+ providerId: providerInfo.id,
79
+ });
80
+ this._currentChat.render(this._container);
81
+ }
82
+ else {
83
+ this._currentChat.show();
84
+ }
85
+ disposableStore.add(this._input.onDidHide(() => {
86
+ disposableStore.dispose();
87
+ this._currentChat.hide();
88
+ this._input = undefined;
89
+ this._onDidClose.fire();
90
+ }));
91
+ this._currentChat.focus();
92
+ if (options?.query) {
93
+ this._currentChat.setValue(options.query, options.selection);
94
+ if (!options.isPartialQuery) {
95
+ this._currentChat.acceptInput();
96
+ }
97
+ }
98
+ }
99
+ focus() {
100
+ this._currentChat?.focus();
101
+ }
102
+ close() {
103
+ this._input?.dispose();
104
+ this._input = undefined;
105
+ }
106
+ async openInChatView() {
107
+ await this._currentChat?.openChatView();
108
+ this.close();
109
+ }
110
+ };
111
+ QuickChatService = ( __decorate([
112
+ ( __param(0, IQuickInputService)),
113
+ ( __param(1, IChatService)),
114
+ ( __param(2, IInstantiationService))
115
+ ], QuickChatService));
116
+ let QuickChat = class QuickChat extends Disposable {
117
+ static { QuickChat_1 = this; }
118
+ static { this.DEFAULT_MIN_HEIGHT = 200; }
119
+ static { this.DEFAULT_HEIGHT_OFFSET = 100; }
120
+ constructor(_options, instantiationService, contextKeyService, chatService, _chatWidgetService, layoutService) {
121
+ super();
122
+ this._options = _options;
123
+ this.instantiationService = instantiationService;
124
+ this.contextKeyService = contextKeyService;
125
+ this.chatService = chatService;
126
+ this._chatWidgetService = _chatWidgetService;
127
+ this.layoutService = layoutService;
128
+ this.maintainScrollTimer = this._register(( new MutableDisposable()));
129
+ this._deferUpdatingDynamicLayout = false;
130
+ }
131
+ clear() {
132
+ this.model?.dispose();
133
+ this.model = undefined;
134
+ this.updateModel();
135
+ this.widget.inputEditor.setValue('');
136
+ }
137
+ focus(selection) {
138
+ if (this.widget) {
139
+ this.widget.focusInput();
140
+ const value = this.widget.inputEditor.getValue();
141
+ if (value) {
142
+ this.widget.inputEditor.setSelection(selection ?? {
143
+ startLineNumber: 1,
144
+ startColumn: 1,
145
+ endLineNumber: 1,
146
+ endColumn: value.length + 1
147
+ });
148
+ }
149
+ }
150
+ }
151
+ hide() {
152
+ this.widget.setVisible(false);
153
+ this.maintainScrollTimer.value = disposableTimeout(() => {
154
+ this.maintainScrollTimer.clear();
155
+ }, 30 * 1000);
156
+ }
157
+ show() {
158
+ this.widget.setVisible(true);
159
+ if (this._deferUpdatingDynamicLayout) {
160
+ this._deferUpdatingDynamicLayout = false;
161
+ this.widget.updateDynamicChatTreeItemLayout(2, this.maxHeight);
162
+ }
163
+ if (!this.maintainScrollTimer.value) {
164
+ this.widget.layoutDynamicChatTreeItemMode();
165
+ }
166
+ }
167
+ render(parent) {
168
+ if (this.widget) {
169
+ throw new Error('Cannot render quick chat twice');
170
+ }
171
+ const scopedInstantiationService = this.instantiationService.createChild(( new ServiceCollection([
172
+ IContextKeyService,
173
+ this._register(this.contextKeyService.createScoped(parent))
174
+ ])));
175
+ this.widget = this._register(scopedInstantiationService.createInstance(ChatWidget, { resource: true }, { renderInputOnTop: true, renderStyle: 'compact' }, {
176
+ listForeground: quickInputForeground,
177
+ listBackground: quickInputBackground,
178
+ inputEditorBackground: inputBackground,
179
+ resultEditorBackground: editorBackground
180
+ }));
181
+ this.widget.render(parent);
182
+ this.widget.setVisible(true);
183
+ this.widget.setDynamicChatTreeItemLayout(2, this.maxHeight);
184
+ this.updateModel();
185
+ this.sash = this._register(( new Sash(
186
+ parent,
187
+ { getHorizontalSashTop: () => parent.offsetHeight },
188
+ { orientation: 1 }
189
+ )));
190
+ this.registerListeners(parent);
191
+ }
192
+ get maxHeight() {
193
+ return this.layoutService.mainContainerDimension.height - QuickChat_1.DEFAULT_HEIGHT_OFFSET;
194
+ }
195
+ registerListeners(parent) {
196
+ this._register(this.layoutService.onDidLayoutMainContainer(() => {
197
+ if (this.widget.visible) {
198
+ this.widget.updateDynamicChatTreeItemLayout(2, this.maxHeight);
199
+ }
200
+ else {
201
+ this._deferUpdatingDynamicLayout = true;
202
+ }
203
+ }));
204
+ this._register(this.widget.inputEditor.onDidChangeModelContent((e) => {
205
+ this._currentQuery = this.widget.inputEditor.getValue();
206
+ }));
207
+ this._register(this.widget.onDidClear(() => this.clear()));
208
+ this._register(this.widget.onDidChangeHeight((e) => this.sash.layout()));
209
+ const width = parent.offsetWidth;
210
+ this._register(this.sash.onDidStart(() => {
211
+ this.widget.isDynamicChatTreeItemLayoutEnabled = false;
212
+ }));
213
+ this._register(this.sash.onDidChange((e) => {
214
+ if (e.currentY < QuickChat_1.DEFAULT_MIN_HEIGHT || e.currentY > this.maxHeight) {
215
+ return;
216
+ }
217
+ this.widget.layout(e.currentY, width);
218
+ this.sash.layout();
219
+ }));
220
+ this._register(this.sash.onDidReset(() => {
221
+ this.widget.isDynamicChatTreeItemLayoutEnabled = true;
222
+ this.widget.layoutDynamicChatTreeItemMode();
223
+ }));
224
+ }
225
+ async acceptInput() {
226
+ return this.widget.acceptInput();
227
+ }
228
+ async openChatView() {
229
+ const widget = await this._chatWidgetService.revealViewForProvider(this._options.providerId);
230
+ if (!widget?.viewModel || !this.model) {
231
+ return;
232
+ }
233
+ for (const request of this.model.getRequests()) {
234
+ if (request.response?.response.value || request.response?.errorDetails) {
235
+ this.chatService.addCompleteRequest(widget.viewModel.sessionId, request.message, {
236
+ message: request.response.response.value,
237
+ errorDetails: request.response.errorDetails,
238
+ followups: request.response.followups
239
+ });
240
+ }
241
+ }
242
+ const value = this.widget.inputEditor.getValue();
243
+ if (value) {
244
+ widget.inputEditor.setValue(value);
245
+ }
246
+ widget.focusInput();
247
+ }
248
+ setValue(value, selection) {
249
+ this.widget.inputEditor.setValue(value);
250
+ this.focus(selection);
251
+ }
252
+ clearValue() {
253
+ this.widget.inputEditor.setValue('');
254
+ }
255
+ updateModel() {
256
+ this.model ??= this.chatService.startSession(this._options.providerId, CancellationToken.None);
257
+ if (!this.model) {
258
+ throw new Error('Could not start chat session');
259
+ }
260
+ this.widget.setModel(this.model, { inputValue: this._currentQuery });
261
+ }
262
+ };
263
+ QuickChat = QuickChat_1 = ( __decorate([
264
+ ( __param(1, IInstantiationService)),
265
+ ( __param(2, IContextKeyService)),
266
+ ( __param(3, IChatService)),
267
+ ( __param(4, IChatWidgetService)),
268
+ ( __param(5, ILayoutService))
269
+ ], QuickChat));
270
+
271
+ export { QuickChatService };
@@ -0,0 +1,91 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { onUnexpectedExternalError } from 'monaco-editor/esm/vs/base/common/errors.js';
3
+ import { Iterable } from 'monaco-editor/esm/vs/base/common/iterator.js';
4
+ import { toDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
5
+ import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
6
+ import { ChatDynamicVariableModel } from 'vscode/vscode/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables';
7
+ import { ChatRequestVariablePart, ChatRequestDynamicVariablePart } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
8
+
9
+ let ChatVariablesService = class ChatVariablesService {
10
+ constructor(chatWidgetService) {
11
+ this.chatWidgetService = chatWidgetService;
12
+ this._resolver = ( new Map());
13
+ }
14
+ async resolveVariables(prompt, model, token) {
15
+ const resolvedVariables = {};
16
+ const jobs = [];
17
+ const parsedPrompt = [];
18
+ prompt.parts
19
+ .forEach((part, i) => {
20
+ if (part instanceof ChatRequestVariablePart) {
21
+ const data = this._resolver.get(part.variableName.toLowerCase());
22
+ if (data) {
23
+ jobs.push(data.resolver(prompt.text, part.variableArg, model, token).then(value => {
24
+ if (value) {
25
+ resolvedVariables[part.variableName] = value;
26
+ parsedPrompt[i] = `[${part.text}](values:${part.variableName})`;
27
+ }
28
+ else {
29
+ parsedPrompt[i] = part.promptText;
30
+ }
31
+ }).catch(onUnexpectedExternalError));
32
+ }
33
+ }
34
+ else if (part instanceof ChatRequestDynamicVariablePart) {
35
+ const referenceName = this.getUniqueReferenceName(part.referenceText, resolvedVariables);
36
+ resolvedVariables[referenceName] = part.data;
37
+ const safeText = part.text.replace(/[\[\]]/g, '_');
38
+ const safeTarget = referenceName.replace(/[\(\)]/g, '_');
39
+ parsedPrompt[i] = `[${safeText}](values:${safeTarget})`;
40
+ }
41
+ else {
42
+ parsedPrompt[i] = part.promptText;
43
+ }
44
+ });
45
+ await Promise.allSettled(jobs);
46
+ return {
47
+ variables: resolvedVariables,
48
+ prompt: parsedPrompt.join('').trim()
49
+ };
50
+ }
51
+ getUniqueReferenceName(name, vars) {
52
+ let i = 1;
53
+ while (vars[name]) {
54
+ name = `${name}_${i++}`;
55
+ }
56
+ return name;
57
+ }
58
+ hasVariable(name) {
59
+ return ( this._resolver.has(name.toLowerCase()));
60
+ }
61
+ getVariables() {
62
+ const all = ( Iterable.map(( this._resolver.values()), data => data.data));
63
+ return Iterable.filter(all, data => !data.hidden);
64
+ }
65
+ getDynamicVariables(sessionId) {
66
+ const widget = this.chatWidgetService.getWidgetBySessionId(sessionId);
67
+ if (!widget || !widget.viewModel || !widget.supportsFileReferences) {
68
+ return [];
69
+ }
70
+ const model = widget.getContrib(ChatDynamicVariableModel.ID);
71
+ if (!model) {
72
+ return [];
73
+ }
74
+ return model.variables;
75
+ }
76
+ registerVariable(data, resolver) {
77
+ const key = data.name.toLowerCase();
78
+ if (( this._resolver.has(key))) {
79
+ throw new Error(`A chat variable with the name '${data.name}' already exists.`);
80
+ }
81
+ this._resolver.set(key, { data, resolver });
82
+ return toDisposable(() => {
83
+ this._resolver.delete(key);
84
+ });
85
+ }
86
+ };
87
+ ChatVariablesService = ( __decorate([
88
+ ( __param(0, IChatWidgetService))
89
+ ], ChatVariablesService));
90
+
91
+ export { ChatVariablesService };
@@ -0,0 +1,165 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { CancellationToken } from 'monaco-editor/esm/vs/base/common/cancellation.js';
3
+ import { DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
4
+ import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
5
+ import { IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
6
+ import { IContextMenuService } from 'monaco-editor/esm/vs/platform/contextview/browser/contextView.js';
7
+ import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
8
+ import { ServiceCollection } from 'monaco-editor/esm/vs/platform/instantiation/common/serviceCollection.js';
9
+ import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
10
+ import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
11
+ import { IOpenerService } from 'monaco-editor/esm/vs/platform/opener/common/opener.js';
12
+ import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
13
+ import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
14
+ import { editorBackground } from 'monaco-editor/esm/vs/platform/theme/common/colorRegistry.js';
15
+ import { IThemeService } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
16
+ import { ViewPane } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPane';
17
+ import { Memento } from 'vscode/vscode/vs/workbench/common/memento';
18
+ import { SIDE_BAR_FOREGROUND } from 'vscode/vscode/vs/workbench/common/theme';
19
+ import { IViewDescriptorService } from 'vscode/vscode/vs/workbench/common/views';
20
+ import { ChatWidget } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatWidget';
21
+ import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
22
+
23
+ const CHAT_SIDEBAR_PANEL_ID = 'workbench.panel.chatSidebar';
24
+ let ChatViewPane = class ChatViewPane extends ViewPane {
25
+ static { this.ID = 'workbench.panel.chat.view'; }
26
+ get widget() { return this._widget; }
27
+ constructor(chatViewOptions, options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, storageService, chatService, logService) {
28
+ super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
29
+ this.chatViewOptions = chatViewOptions;
30
+ this.storageService = storageService;
31
+ this.chatService = chatService;
32
+ this.logService = logService;
33
+ this.modelDisposables = this._register(( new DisposableStore()));
34
+ this.didProviderRegistrationFail = false;
35
+ this.memento = ( new Memento(
36
+ 'interactive-session-view-' + this.chatViewOptions.providerId,
37
+ this.storageService
38
+ ));
39
+ this.viewState = this.memento.getMemento(1 , 1 );
40
+ this._register(this.chatService.onDidRegisterProvider(({ providerId }) => {
41
+ if (providerId === this.chatViewOptions.providerId && !this._widget?.viewModel) {
42
+ const sessionId = this.getSessionId();
43
+ const model = sessionId ? this.chatService.getOrRestoreSession(sessionId) : undefined;
44
+ try {
45
+ this._widget.setVisible(false);
46
+ this.updateModel(model);
47
+ this._onDidChangeViewWelcomeState.fire();
48
+ }
49
+ finally {
50
+ this.widget.setVisible(true);
51
+ }
52
+ }
53
+ }));
54
+ }
55
+ updateModel(model, viewState) {
56
+ this.modelDisposables.clear();
57
+ model = model ?? (this.chatService.transferredSessionData?.sessionId
58
+ ? this.chatService.getOrRestoreSession(this.chatService.transferredSessionData.sessionId)
59
+ : this.chatService.startSession(this.chatViewOptions.providerId, CancellationToken.None));
60
+ if (!model) {
61
+ throw new Error('Could not start chat session');
62
+ }
63
+ this._widget.setModel(model, { ...(viewState ?? this.viewState) });
64
+ this.viewState.sessionId = model.sessionId;
65
+ }
66
+ shouldShowWelcome() {
67
+ const noPersistedSessions = !this.chatService.hasSessions(this.chatViewOptions.providerId);
68
+ return !this._widget?.viewModel && (noPersistedSessions || this.didProviderRegistrationFail);
69
+ }
70
+ getSessionId() {
71
+ let sessionId;
72
+ if (this.chatService.transferredSessionData) {
73
+ sessionId = this.chatService.transferredSessionData.sessionId;
74
+ this.viewState.inputValue = this.chatService.transferredSessionData.inputValue;
75
+ }
76
+ else {
77
+ sessionId = this.viewState.sessionId;
78
+ }
79
+ return sessionId;
80
+ }
81
+ renderBody(parent) {
82
+ try {
83
+ super.renderBody(parent);
84
+ const scopedInstantiationService = this.instantiationService.createChild(( new ServiceCollection([IContextKeyService, this.scopedContextKeyService])));
85
+ this._widget = this._register(scopedInstantiationService.createInstance(ChatWidget, { viewId: this.id }, { supportsFileReferences: true }, {
86
+ listForeground: SIDE_BAR_FOREGROUND,
87
+ listBackground: this.getBackgroundColor(),
88
+ inputEditorBackground: this.getBackgroundColor(),
89
+ resultEditorBackground: editorBackground
90
+ }));
91
+ this._register(this.onDidChangeBodyVisibility(visible => {
92
+ this._widget.setVisible(visible);
93
+ }));
94
+ this._register(this._widget.onDidClear(() => this.clear()));
95
+ this._widget.render(parent);
96
+ const sessionId = this.getSessionId();
97
+ const disposeListener = sessionId ? this._register(this.chatService.onDidDisposeSession((e) => {
98
+ if (e.reason === 'initializationFailed' && e.providerId === this.chatViewOptions.providerId) {
99
+ this.didProviderRegistrationFail = true;
100
+ disposeListener?.dispose();
101
+ this._onDidChangeViewWelcomeState.fire();
102
+ }
103
+ })) : undefined;
104
+ const model = sessionId ? this.chatService.getOrRestoreSession(sessionId) : undefined;
105
+ this.updateModel(model);
106
+ }
107
+ catch (e) {
108
+ this.logService.error(e);
109
+ throw e;
110
+ }
111
+ }
112
+ acceptInput(query) {
113
+ this._widget.acceptInput(query);
114
+ }
115
+ async clear() {
116
+ if (this.widget.viewModel) {
117
+ this.chatService.clearSession(this.widget.viewModel.sessionId);
118
+ }
119
+ this.updateModel(undefined, { ...this.viewState, inputValue: undefined });
120
+ }
121
+ loadSession(sessionId) {
122
+ if (this.widget.viewModel) {
123
+ this.chatService.clearSession(this.widget.viewModel.sessionId);
124
+ }
125
+ const newModel = this.chatService.getOrRestoreSession(sessionId);
126
+ this.updateModel(newModel);
127
+ }
128
+ focusInput() {
129
+ this._widget.focusInput();
130
+ }
131
+ focus() {
132
+ super.focus();
133
+ this._widget.focusInput();
134
+ }
135
+ layoutBody(height, width) {
136
+ super.layoutBody(height, width);
137
+ this._widget.layout(height, width);
138
+ }
139
+ saveState() {
140
+ if (this._widget) {
141
+ this._widget.saveState();
142
+ const widgetViewState = this._widget.getViewState();
143
+ this.viewState.inputValue = widgetViewState.inputValue;
144
+ this.viewState.inputState = widgetViewState.inputState;
145
+ this.memento.saveMemento();
146
+ }
147
+ super.saveState();
148
+ }
149
+ };
150
+ ChatViewPane = ( __decorate([
151
+ ( __param(2, IKeybindingService)),
152
+ ( __param(3, IContextMenuService)),
153
+ ( __param(4, IConfigurationService)),
154
+ ( __param(5, IContextKeyService)),
155
+ ( __param(6, IViewDescriptorService)),
156
+ ( __param(7, IInstantiationService)),
157
+ ( __param(8, IOpenerService)),
158
+ ( __param(9, IThemeService)),
159
+ ( __param(10, ITelemetryService)),
160
+ ( __param(11, IStorageService)),
161
+ ( __param(12, IChatService)),
162
+ ( __param(13, ILogService))
163
+ ], ChatViewPane));
164
+
165
+ export { CHAT_SIDEBAR_PANEL_ID, ChatViewPane };
@@ -0,0 +1,26 @@
1
+ import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
2
+ import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
3
+ import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
4
+ import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
5
+ import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatVariables';
6
+
7
+ let ChatHistoryVariables = class ChatHistoryVariables extends Disposable {
8
+ constructor(chatVariablesService) {
9
+ super();
10
+ this._register(chatVariablesService.registerVariable({ name: 'response', description: '', canTakeArgument: true, hidden: true }, async (message, arg, model, token) => {
11
+ if (!arg) {
12
+ return undefined;
13
+ }
14
+ const responseNum = parseInt(arg, 10);
15
+ const response = model.getRequests()[responseNum - 1].response;
16
+ if (!response) {
17
+ return undefined;
18
+ }
19
+ return [{ level: 'full', value: response.response.asString() }];
20
+ }));
21
+ }
22
+ };
23
+ ChatHistoryVariables = ( __decorate([
24
+ ( __param(0, IChatVariablesService))
25
+ ], ChatHistoryVariables));
26
+ ( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(ChatHistoryVariables, 4 );