@codingame/monaco-vscode-chat-service-override 2.2.2 → 3.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 (24) hide show
  1. package/package.json +2 -2
  2. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +2 -2
  3. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +45 -53
  4. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +11 -17
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +11 -17
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +20 -27
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.js +29 -41
  8. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +25 -9
  9. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +10 -10
  10. package/vscode/src/vs/workbench/contrib/chat/browser/chatContributionServiceImpl.js +10 -10
  11. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +4 -4
  12. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +2 -2
  13. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +9 -26
  14. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +10 -1
  15. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatHistoryVariables.js +1 -1
  16. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +71 -112
  17. package/vscode/src/vs/workbench/contrib/chat/common/chatColors.js +6 -1
  18. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +101 -73
  19. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +4 -4
  20. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.js +94 -24
  21. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +4 -4
  22. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.js +37 -24
  23. package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl.js +4 -6
  24. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions2.js +0 -94
@@ -2,20 +2,20 @@ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.e
2
2
  import { status } from 'vscode/vscode/vs/base/browser/ui/aria/aria';
3
3
  import { RunOnceScheduler } from 'vscode/vscode/vs/base/common/async';
4
4
  import { Disposable, DisposableMap } from 'vscode/vscode/vs/base/common/lifecycle';
5
- import { AudioCue, IAudioCueService } from 'vscode/vscode/vs/platform/audioCues/browser/audioCueService';
5
+ import { AccessibilitySignal, IAccessibilitySignalService } from 'vscode/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService';
6
6
  import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
7
7
 
8
8
  let ChatAccessibilityService = class ChatAccessibilityService extends Disposable {
9
- constructor(_audioCueService, _instantiationService) {
9
+ constructor(_accessibilitySignalService, _instantiationService) {
10
10
  super();
11
- this._audioCueService = _audioCueService;
11
+ this._accessibilitySignalService = _accessibilitySignalService;
12
12
  this._instantiationService = _instantiationService;
13
13
  this._pendingCueMap = this._register(( new DisposableMap()));
14
14
  this._requestId = 0;
15
15
  }
16
16
  acceptRequest() {
17
17
  this._requestId++;
18
- this._audioCueService.playAudioCue(AudioCue.chatRequestSent, { allowManyInParallel: true });
18
+ this._accessibilitySignalService.playSignal(AccessibilitySignal.chatRequestSent, { allowManyInParallel: true });
19
19
  this._pendingCueMap.set(this._requestId, this._instantiationService.createInstance(AudioCueScheduler));
20
20
  return this._requestId;
21
21
  }
@@ -23,7 +23,7 @@ let ChatAccessibilityService = class ChatAccessibilityService extends Disposable
23
23
  this._pendingCueMap.deleteAndDispose(requestId);
24
24
  const isPanelChat = typeof response !== 'string';
25
25
  const responseContent = typeof response === 'string' ? response : response?.response.asString();
26
- this._audioCueService.playAudioCue(AudioCue.chatResponseReceived, { allowManyInParallel: true });
26
+ this._accessibilitySignalService.playSignal(AccessibilitySignal.chatResponseReceived, { allowManyInParallel: true });
27
27
  if (!response) {
28
28
  return;
29
29
  }
@@ -32,17 +32,17 @@ let ChatAccessibilityService = class ChatAccessibilityService extends Disposable
32
32
  }
33
33
  };
34
34
  ChatAccessibilityService = ( __decorate([
35
- ( __param(0, IAudioCueService)),
35
+ ( __param(0, IAccessibilitySignalService)),
36
36
  ( __param(1, IInstantiationService))
37
37
  ], ChatAccessibilityService));
38
38
  const CHAT_RESPONSE_PENDING_AUDIO_CUE_LOOP_MS = 5000;
39
39
  const CHAT_RESPONSE_PENDING_ALLOWANCE_MS = 4000;
40
40
  let AudioCueScheduler = class AudioCueScheduler extends Disposable {
41
- constructor(_audioCueService) {
41
+ constructor(_accessibilitySignalService) {
42
42
  super();
43
- this._audioCueService = _audioCueService;
43
+ this._accessibilitySignalService = _accessibilitySignalService;
44
44
  this._scheduler = ( new RunOnceScheduler(() => {
45
- this._audioCueLoop = this._audioCueService.playAudioCueLoop(AudioCue.chatResponsePending, CHAT_RESPONSE_PENDING_AUDIO_CUE_LOOP_MS);
45
+ this._audioCueLoop = this._accessibilitySignalService.playSignalLoop(AccessibilitySignal.chatResponsePending, CHAT_RESPONSE_PENDING_AUDIO_CUE_LOOP_MS);
46
46
  }, CHAT_RESPONSE_PENDING_ALLOWANCE_MS));
47
47
  this._scheduler.schedule();
48
48
  }
@@ -54,7 +54,7 @@ let AudioCueScheduler = class AudioCueScheduler extends Disposable {
54
54
  }
55
55
  };
56
56
  AudioCueScheduler = ( __decorate([
57
- ( __param(0, IAudioCueService))
57
+ ( __param(0, IAccessibilitySignalService))
58
58
  ], AudioCueScheduler));
59
59
 
60
60
  export { ChatAccessibilityService };
@@ -7,8 +7,8 @@ import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/cont
7
7
  import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
8
8
  import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
9
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';
10
+ import { registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
11
+ import { Extensions } from 'vscode/vscode/vs/workbench/common/views';
12
12
  import { getHistoryAction, getOpenChatEditorAction } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
13
13
  import { getNewChatAction } from './actions/chatClearActions.js';
14
14
  import { getMoveToEditorAction, getMoveToNewWindowAction } from './actions/chatMoveActions.js';
@@ -17,7 +17,7 @@ import { ChatViewPane, CHAT_SIDEBAR_PANEL_ID } from './chatViewPane.js';
17
17
  import { IChatContributionService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContributionService';
18
18
  import { ExtensionsRegistry } from 'vscode/vscode/vs/workbench/services/extensions/common/extensionsRegistry';
19
19
 
20
- const chatExtensionPoint = ( ExtensionsRegistry.registerExtensionPoint({
20
+ const chatExtensionPoint = ExtensionsRegistry.registerExtensionPoint({
21
21
  extensionPoint: 'interactiveSession',
22
22
  jsonSchema: {
23
23
  description: ( localizeWithPath(
@@ -72,8 +72,9 @@ const chatExtensionPoint = ( ExtensionsRegistry.registerExtensionPoint({
72
72
  result.push(`onInteractiveSession:${contrib.id}`);
73
73
  }
74
74
  },
75
- }));
75
+ });
76
76
  let ChatExtensionPointHandler = class ChatExtensionPointHandler {
77
+ static { this.ID = 'workbench.contrib.chatExtensionPointHandler'; }
77
78
  constructor(_chatContributionService) {
78
79
  this._chatContributionService = _chatContributionService;
79
80
  this._registrationDisposables = ( new Map());
@@ -110,7 +111,7 @@ let ChatExtensionPointHandler = class ChatExtensionPointHandler {
110
111
  ));
111
112
  const icon = Codicon.commentDiscussion;
112
113
  const viewContainerId = CHAT_SIDEBAR_PANEL_ID;
113
- const viewContainer = ( Registry.as(Extensions$1.ViewContainersRegistry)).registerViewContainer({
114
+ const viewContainer = ( Registry.as(Extensions.ViewContainersRegistry)).registerViewContainer({
114
115
  id: viewContainerId,
115
116
  title,
116
117
  icon,
@@ -136,7 +137,7 @@ let ChatExtensionPointHandler = class ChatExtensionPointHandler {
136
137
  ctorDescriptor: ( new SyncDescriptor(ChatViewPane, [{ providerId: providerDescriptor.id }])),
137
138
  when: ContextKeyExpr.deserialize(providerDescriptor.when)
138
139
  }];
139
- ( Registry.as(Extensions$1.ViewsRegistry)).registerViews(viewDescriptor, this._viewContainer);
140
+ ( Registry.as(Extensions.ViewsRegistry)).registerViews(viewDescriptor, this._viewContainer);
140
141
  const disposables = ( new DisposableStore());
141
142
  disposables.add(registerAction2(getHistoryAction(viewId, providerDescriptor.id)));
142
143
  disposables.add(registerAction2(getNewChatAction(viewId, providerDescriptor.id)));
@@ -146,8 +147,8 @@ let ChatExtensionPointHandler = class ChatExtensionPointHandler {
146
147
  disposables.add(registerAction2(getQuickChatActionForProvider(providerDescriptor.id, providerDescriptor.label)));
147
148
  return {
148
149
  dispose: () => {
149
- ( Registry.as(Extensions$1.ViewsRegistry)).deregisterViews(viewDescriptor, this._viewContainer);
150
- ( Registry.as(Extensions$1.ViewContainersRegistry)).deregisterViewContainer(this._viewContainer);
150
+ ( Registry.as(Extensions.ViewsRegistry)).deregisterViews(viewDescriptor, this._viewContainer);
151
+ ( Registry.as(Extensions.ViewContainersRegistry)).deregisterViewContainer(this._viewContainer);
151
152
  disposables.dispose();
152
153
  }
153
154
  };
@@ -156,8 +157,7 @@ let ChatExtensionPointHandler = class ChatExtensionPointHandler {
156
157
  ChatExtensionPointHandler = ( __decorate([
157
158
  ( __param(0, IChatContributionService))
158
159
  ], ChatExtensionPointHandler));
159
- const workbenchRegistry = ( Registry.as(Extensions.Workbench));
160
- workbenchRegistry.registerWorkbenchContribution(ChatExtensionPointHandler, 1 );
160
+ registerWorkbenchContribution2(ChatExtensionPointHandler.ID, ChatExtensionPointHandler, 1 );
161
161
  class ChatContributionService {
162
162
  constructor() {
163
163
  this._registeredProviders = ( new Map());
@@ -55,11 +55,11 @@ let ChatEditor = class ChatEditor extends EditorPane {
55
55
  if (!this.widget) {
56
56
  throw new Error('ChatEditor lifecycle issue: no editor widget');
57
57
  }
58
- this.updateModel(editorModel.model);
58
+ this.updateModel(editorModel.model, options?.viewState ?? input.options.viewState);
59
59
  }
60
- updateModel(model) {
61
- this._memento = ( new Memento('interactive-session-editor-' + model.sessionId, this.storageService));
62
- this._viewState = this._memento.getMemento(1 , 1 );
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
63
  this.widget.setModel(model, { ...this._viewState });
64
64
  }
65
65
  saveState() {
@@ -231,10 +231,10 @@ let QuickChat = class QuickChat extends Disposable {
231
231
  return;
232
232
  }
233
233
  for (const request of this.model.getRequests()) {
234
- if (request.response?.response.value || request.response?.errorDetails) {
234
+ if (request.response?.response.value || request.response?.result) {
235
235
  this.chatService.addCompleteRequest(widget.viewModel.sessionId, request.message, request.variableData, {
236
236
  message: request.response.response.value,
237
- errorDetails: request.response.errorDetails,
237
+ result: request.response.result,
238
238
  followups: request.response.followups
239
239
  });
240
240
  }
@@ -1,4 +1,5 @@
1
1
  import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { coalesce } from 'vscode/vscode/vs/base/common/arrays';
2
3
  import { onUnexpectedExternalError } from 'vscode/vscode/vs/base/common/errors';
3
4
  import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
4
5
  import { toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
@@ -11,50 +12,32 @@ let ChatVariablesService = class ChatVariablesService {
11
12
  this.chatWidgetService = chatWidgetService;
12
13
  this._resolver = ( new Map());
13
14
  }
14
- async resolveVariables(prompt, model, token) {
15
- const resolvedVariables = {};
15
+ async resolveVariables(prompt, model, progress, token) {
16
+ let resolvedVariables = [];
16
17
  const jobs = [];
17
- const parsedPrompt = [];
18
18
  prompt.parts
19
19
  .forEach((part, i) => {
20
20
  if (part instanceof ChatRequestVariablePart) {
21
21
  const data = this._resolver.get(part.variableName.toLowerCase());
22
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;
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 };
30
26
  }
31
27
  }).catch(onUnexpectedExternalError));
32
28
  }
33
29
  }
34
30
  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;
31
+ resolvedVariables[i] = { name: part.referenceText, range: part.range, values: part.data };
43
32
  }
44
33
  });
45
34
  await Promise.allSettled(jobs);
35
+ resolvedVariables = coalesce(resolvedVariables);
36
+ resolvedVariables.sort((a, b) => b.range.start - a.range.start);
46
37
  return {
47
38
  variables: resolvedVariables,
48
- message: parsedPrompt.join('').trim()
49
39
  };
50
40
  }
51
- getUniqueReferenceName(name, vars) {
52
- let i = 1;
53
- while (vars[name]) {
54
- name = `${name}_${i++}`;
55
- }
56
- return name;
57
- }
58
41
  hasVariable(name) {
59
42
  return ( this._resolver.has(name.toLowerCase()));
60
43
  }
@@ -32,6 +32,7 @@ let ChatViewPane = class ChatViewPane extends ViewPane {
32
32
  this.logService = logService;
33
33
  this.modelDisposables = this._register(( new DisposableStore()));
34
34
  this.didProviderRegistrationFail = false;
35
+ this.didUnregisterProvider = false;
35
36
  this.memento = ( new Memento(
36
37
  'interactive-session-view-' + this.chatViewOptions.providerId,
37
38
  this.storageService
@@ -44,6 +45,8 @@ let ChatViewPane = class ChatViewPane extends ViewPane {
44
45
  try {
45
46
  this._widget.setVisible(false);
46
47
  this.updateModel(model);
48
+ this.didProviderRegistrationFail = false;
49
+ this.didUnregisterProvider = false;
47
50
  this._onDidChangeViewWelcomeState.fire();
48
51
  }
49
52
  finally {
@@ -51,6 +54,12 @@ let ChatViewPane = class ChatViewPane extends ViewPane {
51
54
  }
52
55
  }
53
56
  }));
57
+ this._register(this.chatService.onDidUnregisterProvider(({ providerId }) => {
58
+ if (providerId === this.chatViewOptions.providerId) {
59
+ this.didUnregisterProvider = true;
60
+ this._onDidChangeViewWelcomeState.fire();
61
+ }
62
+ }));
54
63
  }
55
64
  updateModel(model, viewState) {
56
65
  this.modelDisposables.clear();
@@ -65,7 +74,7 @@ let ChatViewPane = class ChatViewPane extends ViewPane {
65
74
  }
66
75
  shouldShowWelcome() {
67
76
  const noPersistedSessions = !this.chatService.hasSessions(this.chatViewOptions.providerId);
68
- return !this._widget?.viewModel && (noPersistedSessions || this.didProviderRegistrationFail);
77
+ return this.didUnregisterProvider || !this._widget?.viewModel && (noPersistedSessions || this.didProviderRegistrationFail);
69
78
  }
70
79
  getSessionId() {
71
80
  let sessionId;
@@ -7,7 +7,7 @@ import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/c
7
7
  let ChatHistoryVariables = class ChatHistoryVariables extends Disposable {
8
8
  constructor(chatVariablesService) {
9
9
  super();
10
- this._register(chatVariablesService.registerVariable({ name: 'response', description: '', canTakeArgument: true, hidden: true }, async (message, arg, model, token) => {
10
+ this._register(chatVariablesService.registerVariable({ name: 'response', description: '', canTakeArgument: true, hidden: true }, async (message, arg, model, progress, token) => {
11
11
  if (!arg) {
12
12
  return undefined;
13
13
  }