@codingame/monaco-vscode-chat-service-override 3.2.3 → 4.1.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 (32) hide show
  1. package/chat.js +16 -14
  2. package/package.json +2 -2
  3. package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.js +16 -0
  4. package/external/tslib/tslib.es6.js +0 -11
  5. package/external/vscode-marked/lib/marked.esm.js +0 -2200
  6. package/override/vs/platform/dialogs/common/dialogs.js +0 -8
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClear.js +0 -17
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +0 -115
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +0 -501
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +0 -82
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +0 -77
  12. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +0 -110
  13. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +0 -171
  14. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.js +0 -271
  15. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +0 -299
  16. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +0 -60
  17. package/vscode/src/vs/workbench/contrib/chat/browser/chatContributionServiceImpl.js +0 -179
  18. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +0 -87
  19. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +0 -271
  20. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +0 -74
  21. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +0 -174
  22. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatHistoryVariables.js +0 -26
  23. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +0 -580
  24. package/vscode/src/vs/workbench/contrib/chat/common/chatColors.js +0 -36
  25. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +0 -601
  26. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +0 -43
  27. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +0 -41
  28. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.js +0 -814
  29. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +0 -72
  30. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +0 -236
  31. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.js +0 -223
  32. package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl.js +0 -33
@@ -1,179 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
3
- import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
4
- import { localizeWithPath, localize2WithPath } from 'vscode/vscode/vs/nls';
5
- import { registerAction2 } from 'vscode/vscode/vs/platform/actions/common/actions';
6
- import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
7
- import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
8
- import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
9
- import { ViewPaneContainer } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPaneContainer';
10
- import { registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
11
- import { Extensions } from 'vscode/vscode/vs/workbench/common/views';
12
- import { getHistoryAction, getOpenChatEditorAction } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
13
- import { getNewChatAction } 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
- static { this.ID = 'workbench.contrib.chatExtensionPointHandler'; }
78
- constructor(_chatContributionService) {
79
- this._chatContributionService = _chatContributionService;
80
- this._registrationDisposables = ( new Map());
81
- this._viewContainer = this.registerViewContainer();
82
- this.handleAndRegisterChatExtensions();
83
- }
84
- handleAndRegisterChatExtensions() {
85
- chatExtensionPoint.setHandler((extensions, delta) => {
86
- for (const extension of delta.added) {
87
- const extensionDisposable = ( new DisposableStore());
88
- for (const providerDescriptor of extension.value) {
89
- this.registerChatProvider(providerDescriptor);
90
- this._chatContributionService.registerChatProvider(providerDescriptor);
91
- }
92
- this._registrationDisposables.set(extension.description.identifier.value, extensionDisposable);
93
- }
94
- for (const extension of delta.removed) {
95
- const registration = this._registrationDisposables.get(extension.description.identifier.value);
96
- if (registration) {
97
- registration.dispose();
98
- this._registrationDisposables.delete(extension.description.identifier.value);
99
- }
100
- for (const providerDescriptor of extension.value) {
101
- this._chatContributionService.deregisterChatProvider(providerDescriptor.id);
102
- }
103
- }
104
- });
105
- }
106
- registerViewContainer() {
107
- const title = ( localize2WithPath(
108
- 'vs/workbench/contrib/chat/browser/chatContributionServiceImpl',
109
- 'chat.viewContainer.label',
110
- "Chat"
111
- ));
112
- const icon = Codicon.commentDiscussion;
113
- const viewContainerId = CHAT_SIDEBAR_PANEL_ID;
114
- const viewContainer = ( Registry.as(Extensions.ViewContainersRegistry)).registerViewContainer({
115
- id: viewContainerId,
116
- title,
117
- icon,
118
- ctorDescriptor: ( new SyncDescriptor(
119
- ViewPaneContainer,
120
- [viewContainerId, { mergeViewWithContainerWhenSingleView: true }]
121
- )),
122
- storageId: viewContainerId,
123
- hideIfEmpty: true,
124
- order: 100,
125
- }, 0 );
126
- return viewContainer;
127
- }
128
- registerChatProvider(providerDescriptor) {
129
- const viewId = this._chatContributionService.getViewIdForProvider(providerDescriptor.id);
130
- const viewDescriptor = [{
131
- id: viewId,
132
- containerIcon: this._viewContainer.icon,
133
- containerTitle: this._viewContainer.title.value,
134
- name: { value: providerDescriptor.label, original: providerDescriptor.label },
135
- canToggleVisibility: false,
136
- canMoveView: true,
137
- ctorDescriptor: ( new SyncDescriptor(ChatViewPane, [{ providerId: providerDescriptor.id }])),
138
- when: ContextKeyExpr.deserialize(providerDescriptor.when)
139
- }];
140
- ( Registry.as(Extensions.ViewsRegistry)).registerViews(viewDescriptor, this._viewContainer);
141
- const disposables = ( new DisposableStore());
142
- disposables.add(registerAction2(getHistoryAction(viewId, providerDescriptor.id)));
143
- disposables.add(registerAction2(getNewChatAction(viewId, providerDescriptor.id)));
144
- disposables.add(registerAction2(getMoveToEditorAction(viewId, providerDescriptor.id)));
145
- disposables.add(registerAction2(getMoveToNewWindowAction(viewId, providerDescriptor.id)));
146
- disposables.add(registerAction2(getOpenChatEditorAction(providerDescriptor.id, providerDescriptor.label, providerDescriptor.when)));
147
- disposables.add(registerAction2(getQuickChatActionForProvider(providerDescriptor.id, providerDescriptor.label)));
148
- return {
149
- dispose: () => {
150
- ( Registry.as(Extensions.ViewsRegistry)).deregisterViews(viewDescriptor, this._viewContainer);
151
- ( Registry.as(Extensions.ViewContainersRegistry)).deregisterViewContainer(this._viewContainer);
152
- disposables.dispose();
153
- }
154
- };
155
- }
156
- };
157
- ChatExtensionPointHandler = ( __decorate([
158
- ( __param(0, IChatContributionService))
159
- ], ChatExtensionPointHandler));
160
- registerWorkbenchContribution2(ChatExtensionPointHandler.ID, 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 };
@@ -1,87 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
3
- import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
4
- import { ServiceCollection } from 'vscode/vscode/vs/platform/instantiation/common/serviceCollection';
5
- import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
6
- import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
7
- import { editorForeground, editorBackground, inputBackground } from 'vscode/vscode/vs/platform/theme/common/colorRegistry';
8
- import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService';
9
- import { EditorPane } from 'vscode/vscode/vs/workbench/browser/parts/editor/editorPane';
10
- import { Memento } from 'vscode/vscode/vs/workbench/common/memento';
11
- import { ChatEditorInput } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatEditorInput';
12
- import { ChatWidget } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatWidget';
13
- import { clearChatEditor } from './actions/chatClear.js';
14
-
15
- let ChatEditor = class ChatEditor extends EditorPane {
16
- get scopedContextKeyService() {
17
- return this._scopedContextKeyService;
18
- }
19
- constructor(telemetryService, themeService, instantiationService, storageService, contextKeyService) {
20
- super(ChatEditorInput.EditorID, telemetryService, themeService, storageService);
21
- this.instantiationService = instantiationService;
22
- this.storageService = storageService;
23
- this.contextKeyService = contextKeyService;
24
- }
25
- async clear() {
26
- return this.instantiationService.invokeFunction(clearChatEditor);
27
- }
28
- createEditor(parent) {
29
- this._scopedContextKeyService = this._register(this.contextKeyService.createScoped(parent));
30
- const scopedInstantiationService = this.instantiationService.createChild(( new ServiceCollection([IContextKeyService, this.scopedContextKeyService])));
31
- this.widget = this._register(scopedInstantiationService.createInstance(ChatWidget, { resource: true }, { supportsFileReferences: true }, {
32
- listForeground: editorForeground,
33
- listBackground: editorBackground,
34
- inputEditorBackground: inputBackground,
35
- resultEditorBackground: editorBackground
36
- }));
37
- this._register(this.widget.onDidClear(() => this.clear()));
38
- this.widget.render(parent);
39
- this.widget.setVisible(true);
40
- }
41
- focus() {
42
- super.focus();
43
- this.widget?.focusInput();
44
- }
45
- clearInput() {
46
- this.saveState();
47
- super.clearInput();
48
- }
49
- async setInput(input, options, context, token) {
50
- super.setInput(input, options, context, token);
51
- const editorModel = await input.resolve();
52
- if (!editorModel) {
53
- throw new Error(`Failed to get model for chat editor. id: ${input.sessionId}`);
54
- }
55
- if (!this.widget) {
56
- throw new Error('ChatEditor lifecycle issue: no editor widget');
57
- }
58
- this.updateModel(editorModel.model, options?.viewState ?? input.options.viewState);
59
- }
60
- updateModel(model, viewState) {
61
- this._memento = ( new Memento('interactive-session-editor-' + model.providerId, this.storageService));
62
- this._viewState = viewState ?? this._memento.getMemento(1 , 1 );
63
- this.widget.setModel(model, { ...this._viewState });
64
- }
65
- saveState() {
66
- this.widget?.saveState();
67
- if (this._memento && this._viewState) {
68
- const widgetViewState = this.widget.getViewState();
69
- this._viewState.inputValue = widgetViewState.inputValue;
70
- this._memento.saveMemento();
71
- }
72
- }
73
- layout(dimension, position) {
74
- if (this.widget) {
75
- this.widget.layout(dimension.height, dimension.width);
76
- }
77
- }
78
- };
79
- ChatEditor = ( __decorate([
80
- ( __param(0, ITelemetryService)),
81
- ( __param(1, IThemeService)),
82
- ( __param(2, IInstantiationService)),
83
- ( __param(3, IStorageService)),
84
- ( __param(4, IContextKeyService))
85
- ], ChatEditor));
86
-
87
- export { ChatEditor };
@@ -1,271 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { isAncestorOfActiveElement, $ } from 'vscode/vscode/vs/base/browser/dom';
3
- import { Sash } from 'vscode/vscode/vs/base/browser/ui/sash/sash';
4
- import { disposableTimeout } from 'vscode/vscode/vs/base/common/async';
5
- import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
6
- import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
7
- import { Disposable, MutableDisposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
8
- import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
9
- import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
10
- import { ServiceCollection } from 'vscode/vscode/vs/platform/instantiation/common/serviceCollection';
11
- import { ILayoutService } from 'vscode/vscode/vs/platform/layout/browser/layoutService';
12
- import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput';
13
- import { quickInputForeground, quickInputBackground, inputBackground, editorBackground } from 'vscode/vscode/vs/platform/theme/common/colorRegistry';
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 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 ??= $('.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?.result) {
235
- this.chatService.addCompleteRequest(widget.viewModel.sessionId, request.message, request.variableData, {
236
- message: request.response.response.value,
237
- result: request.response.result,
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 };
@@ -1,74 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { coalesce } from 'vscode/vscode/vs/base/common/arrays';
3
- import { onUnexpectedExternalError } from 'vscode/vscode/vs/base/common/errors';
4
- import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
5
- import { toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
6
- import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat';
7
- import { ChatDynamicVariableModel } from 'vscode/vscode/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables';
8
- import { ChatRequestVariablePart, ChatRequestDynamicVariablePart } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
9
-
10
- let ChatVariablesService = class ChatVariablesService {
11
- constructor(chatWidgetService) {
12
- this.chatWidgetService = chatWidgetService;
13
- this._resolver = ( new Map());
14
- }
15
- async resolveVariables(prompt, model, progress, token) {
16
- let resolvedVariables = [];
17
- const jobs = [];
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, progress, token).then(values => {
24
- if (values?.length) {
25
- resolvedVariables[i] = { name: part.variableName, range: part.range, values };
26
- }
27
- }).catch(onUnexpectedExternalError));
28
- }
29
- }
30
- else if (part instanceof ChatRequestDynamicVariablePart) {
31
- resolvedVariables[i] = { name: part.referenceText, range: part.range, values: part.data };
32
- }
33
- });
34
- await Promise.allSettled(jobs);
35
- resolvedVariables = coalesce(resolvedVariables);
36
- resolvedVariables.sort((a, b) => b.range.start - a.range.start);
37
- return {
38
- variables: resolvedVariables,
39
- };
40
- }
41
- hasVariable(name) {
42
- return ( this._resolver.has(name.toLowerCase()));
43
- }
44
- getVariables() {
45
- const all = ( Iterable.map(( this._resolver.values()), data => data.data));
46
- return Iterable.filter(all, data => !data.hidden);
47
- }
48
- getDynamicVariables(sessionId) {
49
- const widget = this.chatWidgetService.getWidgetBySessionId(sessionId);
50
- if (!widget || !widget.viewModel || !widget.supportsFileReferences) {
51
- return [];
52
- }
53
- const model = widget.getContrib(ChatDynamicVariableModel.ID);
54
- if (!model) {
55
- return [];
56
- }
57
- return model.variables;
58
- }
59
- registerVariable(data, resolver) {
60
- const key = data.name.toLowerCase();
61
- if (( this._resolver.has(key))) {
62
- throw new Error(`A chat variable with the name '${data.name}' already exists.`);
63
- }
64
- this._resolver.set(key, { data, resolver });
65
- return toDisposable(() => {
66
- this._resolver.delete(key);
67
- });
68
- }
69
- };
70
- ChatVariablesService = ( __decorate([
71
- ( __param(0, IChatWidgetService))
72
- ], ChatVariablesService));
73
-
74
- export { ChatVariablesService };