@codingame/monaco-vscode-chat-service-override 2.2.1 → 3.0.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
@@ -15,10 +15,12 @@ import { IEditorWorkerService } from 'vscode/vscode/vs/editor/common/services/ed
15
15
  import { Schemas } from 'vscode/vscode/vs/base/common/network';
16
16
  import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
17
17
  import { generateUuid } from 'vscode/vscode/vs/base/common/uuid';
18
- import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles';
18
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
19
+ import { UntitledTextEditorInput } from 'vscode/vscode/vs/workbench/services/untitled/common/untitledTextEditorInput';
20
+ import { DEFAULT_EDITOR_ASSOCIATION } from 'vscode/vscode/vs/workbench/common/editor';
19
21
 
20
22
  let InlineChatSessionServiceImpl = class InlineChatSessionServiceImpl {
21
- constructor(_inlineChatService, _telemetryService, _modelService, _textModelService, _editorWorkerService, _logService, _instaService, _textFileService) {
23
+ constructor(_inlineChatService, _telemetryService, _modelService, _textModelService, _editorWorkerService, _logService, _instaService, _editorService) {
22
24
  this._inlineChatService = _inlineChatService;
23
25
  this._telemetryService = _telemetryService;
24
26
  this._modelService = _modelService;
@@ -26,7 +28,7 @@ let InlineChatSessionServiceImpl = class InlineChatSessionServiceImpl {
26
28
  this._editorWorkerService = _editorWorkerService;
27
29
  this._logService = _logService;
28
30
  this._instaService = _instaService;
29
- this._textFileService = _textFileService;
31
+ this._editorService = _editorService;
30
32
  this._onWillStartSession = ( new Emitter());
31
33
  this.onWillStartSession = this._onWillStartSession.event;
32
34
  this._onDidMoveSession = ( new Emitter());
@@ -68,33 +70,40 @@ let InlineChatSessionServiceImpl = class InlineChatSessionServiceImpl {
68
70
  return undefined;
69
71
  }
70
72
  this._logService.trace('[IE] NEW session', provider.debugName);
71
- this._logService.trace(`[IE] creating NEW session for ${editor.getId()}, ${provider.debugName}`);
73
+ this._logService.trace(`[IE] creating NEW session for ${editor.getId()}, ${provider.debugName}`);
72
74
  const store = ( new DisposableStore());
75
+ store.add(this._inlineChatService.onDidChangeProviders(e => {
76
+ if (e.removed === provider) {
77
+ this._logService.trace(`[IE] provider GONE for ${editor.getId()}, ${provider.debugName}`);
78
+ this._releaseSession(session, true);
79
+ }
80
+ }));
73
81
  const id = generateUuid();
74
82
  const targetUri = textModel.uri;
75
83
  let textModelN;
76
84
  if (options.editMode === "preview" ) {
77
- textModelN = store.add(this._modelService.createModel(createTextBufferFactoryFromSnapshot(textModel.createSnapshot()), { languageId: textModel.getLanguageId(), onDidChange: Event.None }, targetUri.with({ scheme: Schemas.inMemory, query: ( ( new URLSearchParams({ id, 'inline-chat-textModelN': '' })).toString()) }), true));
85
+ textModelN = store.add(this._modelService.createModel(createTextBufferFactoryFromSnapshot(textModel.createSnapshot()), { languageId: textModel.getLanguageId(), onDidChange: Event.None }, targetUri.with({ scheme: Schemas.vscode, authority: 'inline-chat', path: '', query: ( ( new URLSearchParams({ id, 'textModelN': '' })).toString()) })));
78
86
  }
79
87
  else {
80
88
  store.add((await this._textModelService.createModelReference(textModel.uri)));
81
89
  textModelN = textModel;
82
90
  }
83
- const textModel0 = store.add(this._modelService.createModel(createTextBufferFactoryFromSnapshot(textModel.createSnapshot()), { languageId: textModel.getLanguageId(), onDidChange: Event.None }, targetUri.with({ scheme: Schemas.inMemory, query: ( ( new URLSearchParams({ id, 'inline-chat-textModel0': '' })).toString()) }), true));
91
+ const textModel0 = store.add(this._modelService.createModel(createTextBufferFactoryFromSnapshot(textModel.createSnapshot()), { languageId: textModel.getLanguageId(), onDidChange: Event.None }, targetUri.with({ scheme: Schemas.vscode, authority: 'inline-chat', path: '', query: ( ( new URLSearchParams({ id, 'textModel0': '' })).toString()) }), true));
84
92
  if (targetUri.scheme === Schemas.untitled) {
85
- const untitledTextModel = this._textFileService.untitled.get(targetUri);
86
- if (untitledTextModel) {
87
- store.add(untitledTextModel.onDidChangeDirty(() => {
88
- if (!untitledTextModel.isDirty()) {
89
- this.releaseSession(session);
90
- }
91
- }));
92
- }
93
+ store.add(this._editorService.onDidCloseEditor(() => {
94
+ if (!this._editorService.isOpened({ resource: targetUri, typeId: UntitledTextEditorInput.ID, editorId: DEFAULT_EDITOR_ASSOCIATION.id })) {
95
+ this._releaseSession(session, true);
96
+ }
97
+ }));
93
98
  }
94
99
  let wholeRange = options.wholeRange;
95
100
  if (!wholeRange) {
96
101
  wholeRange = rawSession.wholeRange ? Range.lift(rawSession.wholeRange) : editor.getSelection();
97
102
  }
103
+ if (token.isCancellationRequested) {
104
+ store.dispose();
105
+ return undefined;
106
+ }
98
107
  const session = ( new Session(
99
108
  options.editMode,
100
109
  targetUri,
@@ -140,22 +149,26 @@ let InlineChatSessionServiceImpl = class InlineChatSessionServiceImpl {
140
149
  }
141
150
  }
142
151
  releaseSession(session) {
143
- let data;
144
- for (const [key, value] of this._sessions) {
145
- if (value.session === session) {
146
- data = value;
147
- value.store.dispose();
148
- this._sessions.delete(key);
149
- this._logService.trace(`[IE] did RELEASED session for ${value.editor.getId()}, ${session.provider.debugName}`);
152
+ this._releaseSession(session, false);
153
+ }
154
+ _releaseSession(session, byServer) {
155
+ let tuple;
156
+ for (const candidate of this._sessions) {
157
+ if (candidate[1].session === session) {
158
+ tuple = candidate;
150
159
  break;
151
160
  }
152
161
  }
153
- if (!data) {
162
+ if (!tuple) {
154
163
  return;
155
164
  }
156
165
  this._keepRecording(session);
157
166
  this._telemetryService.publicLog2('interactiveEditor/session', session.asTelemetryData());
158
- this._onDidEndSession.fire({ editor: data.editor, session });
167
+ const [key, value] = tuple;
168
+ this._sessions.delete(key);
169
+ this._logService.trace(`[IE] did RELEASED session for ${value.editor.getId()}, ${session.provider.debugName}`);
170
+ this._onDidEndSession.fire({ editor: value.editor, session, endedByExternalCause: byServer });
171
+ value.store.dispose();
159
172
  }
160
173
  stashSession(session, editor, undoCancelEdits) {
161
174
  this._keepRecording(session);
@@ -204,7 +217,7 @@ InlineChatSessionServiceImpl = ( __decorate([
204
217
  ( __param(4, IEditorWorkerService)),
205
218
  ( __param(5, ILogService)),
206
219
  ( __param(6, IInstantiationService)),
207
- ( __param(7, ITextFileService))
220
+ ( __param(7, IEditorService))
208
221
  ], InlineChatSessionServiceImpl));
209
222
 
210
223
  export { InlineChatSessionServiceImpl };
@@ -6,22 +6,20 @@ import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/
6
6
  import { CTX_INLINE_CHAT_HAS_PROVIDER } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
7
7
 
8
8
  let InlineChatServiceImpl = class InlineChatServiceImpl {
9
- get onDidChangeProviders() {
10
- return this._onDidChangeProviders.event;
11
- }
12
9
  constructor(contextKeyService) {
13
- this._entries = ( new LinkedList());
14
10
  this._onDidChangeProviders = ( new Emitter());
11
+ this._entries = ( new LinkedList());
12
+ this.onDidChangeProviders = this._onDidChangeProviders.event;
15
13
  this._ctxHasProvider = CTX_INLINE_CHAT_HAS_PROVIDER.bindTo(contextKeyService);
16
14
  }
17
15
  addProvider(provider) {
18
16
  const rm = this._entries.push(provider);
19
17
  this._ctxHasProvider.set(true);
20
- this._onDidChangeProviders.fire();
18
+ this._onDidChangeProviders.fire({ added: provider });
21
19
  return toDisposable(() => {
22
20
  rm();
23
21
  this._ctxHasProvider.set(this._entries.size > 0);
24
- this._onDidChangeProviders.fire();
22
+ this._onDidChangeProviders.fire({ removed: provider });
25
23
  });
26
24
  }
27
25
  getAllProvider() {
@@ -1,94 +0,0 @@
1
- import { KeyChord } from 'vscode/vscode/vs/base/common/keyCodes';
2
- import { EditorAction2 } from 'vscode/vscode/vs/editor/browser/editorExtensions';
3
- import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
4
- import { InlineChatController, InlineChatRunOptions } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
5
- import { LOCALIZED_START_INLINE_CHAT_STRING, AbstractInlineChatAction, START_INLINE_CHAT } from './inlineChatActions.js';
6
- import { disposableTimeout } from 'vscode/vscode/vs/base/common/async';
7
- import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
8
- import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
9
- import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
10
- import { CTX_INLINE_CHAT_HAS_PROVIDER, CTX_INLINE_CHAT_VISIBLE } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
11
- import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
12
- import { ISpeechService, HasSpeechProvider } from 'vscode/vscode/vs/workbench/contrib/speech/common/speechService';
13
- import { localize2WithPath } from 'vscode/vscode/vs/nls';
14
-
15
- class StartSessionAction extends EditorAction2 {
16
- constructor() {
17
- super({
18
- id: 'inlineChat.start',
19
- title: { value: LOCALIZED_START_INLINE_CHAT_STRING, original: 'Start Inline Chat' },
20
- category: AbstractInlineChatAction.category,
21
- f1: true,
22
- precondition: ( ContextKeyExpr.and(CTX_INLINE_CHAT_HAS_PROVIDER, EditorContextKeys.writable)),
23
- keybinding: {
24
- when: EditorContextKeys.focus,
25
- weight: 200 ,
26
- primary: 2048 | 39 ,
27
- secondary: [KeyChord(2048 | 41 , 39 )],
28
- },
29
- icon: START_INLINE_CHAT
30
- });
31
- }
32
- runEditorCommand(accessor, editor, ..._args) {
33
- const configService = accessor.get(IConfigurationService);
34
- const speechService = accessor.get(ISpeechService);
35
- if (configService.getValue("inlineChat.holdToSpeech" )
36
- && speechService.hasSpeechProvider
37
- ) {
38
- holdForSpeech(accessor, InlineChatController.get(editor), this.desc.id);
39
- }
40
- let options;
41
- const arg = _args[0];
42
- if (arg && InlineChatRunOptions.isInteractiveEditorOptions(arg)) {
43
- options = arg;
44
- }
45
- InlineChatController.get(editor)?.run({ ...options });
46
- }
47
- }
48
- class HoldToSpeak extends AbstractInlineChatAction {
49
- constructor() {
50
- super({
51
- id: 'inlineChat.holdForSpeech',
52
- precondition: ( ContextKeyExpr.and(HasSpeechProvider, CTX_INLINE_CHAT_VISIBLE)),
53
- title: ( localize2WithPath(
54
- 'vs/workbench/contrib/inlineChat/browser/inlineChatActions2',
55
- 'holdForSpeech',
56
- "Hold for Speech"
57
- )),
58
- keybinding: {
59
- when: EditorContextKeys.textInputFocus,
60
- weight: 200 ,
61
- primary: 2048 | 39 ,
62
- },
63
- });
64
- }
65
- runInlineChatCommand(accessor, ctrl, editor, ...args) {
66
- holdForSpeech(accessor, ctrl, this.desc.id);
67
- }
68
- }
69
- function holdForSpeech(accessor, ctrl, commandId) {
70
- const keybindingService = accessor.get(IKeybindingService);
71
- const commandService = accessor.get(ICommandService);
72
- if (!ctrl) {
73
- return;
74
- }
75
- const holdMode = keybindingService.enableKeybindingHoldMode(commandId);
76
- if (!holdMode) {
77
- return;
78
- }
79
- let listening = false;
80
- const handle = disposableTimeout(() => {
81
- commandService.executeCommand('workbench.action.chat.startVoiceChat', { voice: { disableTimeout: true } });
82
- listening = true;
83
- }, 250);
84
- holdMode.finally(() => {
85
- if (listening) {
86
- commandService.executeCommand('workbench.action.chat.stopListening').finally(() => {
87
- ctrl.acceptInput();
88
- });
89
- }
90
- handle.dispose();
91
- });
92
- }
93
-
94
- export { HoldToSpeak, StartSessionAction };