@codingame/monaco-vscode-chat-service-override 10.1.3 → 11.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.
- package/chat.js +6 -3
- package/package.json +6 -2
- package/vscode/src/vs/editor/common/diff/documentDiffProvider.js +8 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +84 -38
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +265 -20
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +20 -39
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +373 -216
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +4 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +4 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +54 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +6 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +12 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +14 -42
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +82 -50
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.js +326 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.js +448 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +507 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.js +76 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorActions.js +109 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorController.js +284 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.js +116 -77
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +100 -9
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +7 -9
- package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +61 -42
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/{common → browser}/languageModelToolsService.js +28 -31
- package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeContributions.js +75 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.js +120 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +10 -8
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +33 -18
- package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/ignoredFiles.js +21 -0
- package/vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/languageModels.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +68 -47
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsParametersSchema.js +250 -0
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +2 -2
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +7 -8
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.js +1 -1
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +1 -1
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +3 -3
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +2 -2
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +65 -128
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +0 -170
- package/vscode/src/vs/workbench/contrib/chat/browser/chatGettingStarted.js +0 -131
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import { Sequencer } from 'vscode/vscode/vs/base/common/async';
|
|
3
|
+
import { BugIndicatingError } from 'vscode/vscode/vs/base/common/errors';
|
|
4
|
+
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
5
|
+
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
6
|
+
import { ResourceMap, ResourceSet } from 'vscode/vscode/vs/base/common/map';
|
|
7
|
+
import { observableValue, transaction } from 'vscode/vscode/vs/base/common/observableInternal/base';
|
|
8
|
+
import 'vscode/vscode/vs/base/common/arrays';
|
|
9
|
+
import 'vscode/vscode/vs/base/common/observableInternal/autorun';
|
|
10
|
+
import { derived } from 'vscode/vscode/vs/base/common/observableInternal/derived';
|
|
11
|
+
import 'vscode/vscode/vs/base/common/cancellation';
|
|
12
|
+
import 'vscode/vscode/vs/base/common/observableInternal/utils';
|
|
13
|
+
import { isDiffEditor, isCodeEditor } from 'vscode/vscode/vs/editor/browser/editorBrowser';
|
|
14
|
+
import { IBulkEditService } from 'vscode/vscode/vs/editor/browser/services/bulkEditService';
|
|
15
|
+
import { ILanguageService } from 'vscode/vscode/vs/editor/common/languages/language';
|
|
16
|
+
import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
|
|
17
|
+
import { ITextModelService } from 'vscode/vscode/vs/editor/common/services/resolverService';
|
|
18
|
+
import { localize } from 'vscode/vscode/vs/nls';
|
|
19
|
+
import { IFileDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs.service';
|
|
20
|
+
import { EditorActivation } from 'vscode/vscode/vs/platform/editor/common/editor';
|
|
21
|
+
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
22
|
+
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
23
|
+
import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
|
|
24
|
+
import { DiffEditorInput } from 'vscode/vscode/vs/workbench/common/editor/diffEditorInput';
|
|
25
|
+
import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService.service';
|
|
26
|
+
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
27
|
+
import { MultiDiffEditorInput } from 'vscode/vscode/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditorInput';
|
|
28
|
+
import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
|
|
29
|
+
import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
|
|
30
|
+
import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
|
|
31
|
+
import { ChatEditingMultiDiffSourceResolver } from './chatEditingService.js';
|
|
32
|
+
import { ChatEditingModifiedFileEntry } from './chatEditingModifiedFileEntry.js';
|
|
33
|
+
import { ChatEditingTextModelContentProvider } from './chatEditingTextModelContentProviders.js';
|
|
34
|
+
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
35
|
+
|
|
36
|
+
let ChatEditingSession = class ChatEditingSession extends Disposable {
|
|
37
|
+
get entries() {
|
|
38
|
+
this._assertNotDisposed();
|
|
39
|
+
return this._entriesObs;
|
|
40
|
+
}
|
|
41
|
+
get workingSet() {
|
|
42
|
+
this._assertNotDisposed();
|
|
43
|
+
const result = ( (new ResourceMap(this._workingSet)));
|
|
44
|
+
for (const entry of this._entriesObs.get()) {
|
|
45
|
+
result.set(entry.modifiedURI, entry.state.get());
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
get state() {
|
|
50
|
+
return this._state;
|
|
51
|
+
}
|
|
52
|
+
get onDidChange() {
|
|
53
|
+
this._assertNotDisposed();
|
|
54
|
+
return this._onDidChange.event;
|
|
55
|
+
}
|
|
56
|
+
get onDidDispose() {
|
|
57
|
+
this._assertNotDisposed();
|
|
58
|
+
return this._onDidDispose.event;
|
|
59
|
+
}
|
|
60
|
+
get isVisible() {
|
|
61
|
+
this._assertNotDisposed();
|
|
62
|
+
return Boolean(this.editorPane && this.editorPane.isVisible());
|
|
63
|
+
}
|
|
64
|
+
constructor(chatSessionId, editorPane, editingSessionFileLimitPromise, _instantiationService, _modelService, _languageService, _textModelService, _bulkEditService, _editorGroupsService, _editorService, _chatWidgetService, _workspaceContextService, _fileService, _dialogService, _chatAgentService) {
|
|
65
|
+
super();
|
|
66
|
+
this.chatSessionId = chatSessionId;
|
|
67
|
+
this.editorPane = editorPane;
|
|
68
|
+
this.editingSessionFileLimitPromise = editingSessionFileLimitPromise;
|
|
69
|
+
this._instantiationService = _instantiationService;
|
|
70
|
+
this._modelService = _modelService;
|
|
71
|
+
this._languageService = _languageService;
|
|
72
|
+
this._textModelService = _textModelService;
|
|
73
|
+
this._bulkEditService = _bulkEditService;
|
|
74
|
+
this._editorGroupsService = _editorGroupsService;
|
|
75
|
+
this._editorService = _editorService;
|
|
76
|
+
this._chatWidgetService = _chatWidgetService;
|
|
77
|
+
this._workspaceContextService = _workspaceContextService;
|
|
78
|
+
this._fileService = _fileService;
|
|
79
|
+
this._dialogService = _dialogService;
|
|
80
|
+
this._chatAgentService = _chatAgentService;
|
|
81
|
+
this._state = observableValue(this, 0 );
|
|
82
|
+
this._linearHistory = observableValue(this, []);
|
|
83
|
+
this._linearHistoryIndex = observableValue(this, 0);
|
|
84
|
+
this._initialFileContents = ( (new ResourceMap()));
|
|
85
|
+
this._snapshots = ( (new Map()));
|
|
86
|
+
this._filesToSkipCreating = ( (new ResourceSet()));
|
|
87
|
+
this._entriesObs = observableValue(this, []);
|
|
88
|
+
this._sequencer = ( (new Sequencer()));
|
|
89
|
+
this._workingSet = ( (new ResourceMap()));
|
|
90
|
+
this.canUndo = derived((r) => {
|
|
91
|
+
if (this.state.read(r) !== 2 ) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const linearHistoryIndex = this._linearHistoryIndex.read(r);
|
|
95
|
+
return linearHistoryIndex > 0;
|
|
96
|
+
});
|
|
97
|
+
this.canRedo = derived((r) => {
|
|
98
|
+
if (this.state.read(r) !== 2 ) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
const linearHistory = this._linearHistory.read(r);
|
|
102
|
+
const linearHistoryIndex = this._linearHistoryIndex.read(r);
|
|
103
|
+
return linearHistoryIndex < linearHistory.length;
|
|
104
|
+
});
|
|
105
|
+
this.hiddenRequestIds = derived((r) => {
|
|
106
|
+
const linearHistory = this._linearHistory.read(r);
|
|
107
|
+
const linearHistoryIndex = this._linearHistoryIndex.read(r);
|
|
108
|
+
return ( (linearHistory.slice(linearHistoryIndex).map(s => s.requestId))).filter((r) => !!r);
|
|
109
|
+
});
|
|
110
|
+
this._onDidChange = ( (new Emitter()));
|
|
111
|
+
this._onDidDispose = ( (new Emitter()));
|
|
112
|
+
const widget = _chatWidgetService.getWidgetBySessionId(chatSessionId);
|
|
113
|
+
if (!widget) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
this._trackCurrentEditorsInWorkingSet();
|
|
117
|
+
this._register(this._editorService.onDidActiveEditorChange(() => {
|
|
118
|
+
this._trackCurrentEditorsInWorkingSet();
|
|
119
|
+
}));
|
|
120
|
+
this._register(this._editorService.onDidCloseEditor((e) => {
|
|
121
|
+
this._trackCurrentEditorsInWorkingSet(e);
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
_trackCurrentEditorsInWorkingSet(e) {
|
|
125
|
+
const widget = this._chatWidgetService.getWidgetBySessionId(this.chatSessionId);
|
|
126
|
+
const requests = widget?.viewModel?.getItems();
|
|
127
|
+
if (requests && requests.length > 0) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const closedEditor = e?.editor.resource?.toString();
|
|
131
|
+
const existingTransientEntries = ( (new ResourceSet()));
|
|
132
|
+
for (const file of ( (this._workingSet.keys()))) {
|
|
133
|
+
if (this._workingSet.get(file) === 3 ) {
|
|
134
|
+
existingTransientEntries.add(file);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (existingTransientEntries.size === 0 && this._workingSet.size > 0) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const activeEditors = ( (new ResourceSet()));
|
|
141
|
+
this._editorGroupsService.groups.forEach((group) => {
|
|
142
|
+
if (!group.activeEditorPane) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
let activeEditorControl = group.activeEditorPane.getControl();
|
|
146
|
+
if (isDiffEditor(activeEditorControl)) {
|
|
147
|
+
activeEditorControl = activeEditorControl.getOriginalEditor().hasTextFocus() ? activeEditorControl.getOriginalEditor() : activeEditorControl.getModifiedEditor();
|
|
148
|
+
}
|
|
149
|
+
if (isCodeEditor(activeEditorControl) && activeEditorControl.hasModel()) {
|
|
150
|
+
const uri = activeEditorControl.getModel().uri;
|
|
151
|
+
if (closedEditor === ( (uri.toString()))) ;
|
|
152
|
+
else if (( (existingTransientEntries.has(uri)))) {
|
|
153
|
+
existingTransientEntries.delete(uri);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
activeEditors.add(uri);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
let didChange = false;
|
|
161
|
+
for (const entry of existingTransientEntries) {
|
|
162
|
+
didChange = this._workingSet.delete(entry) || didChange;
|
|
163
|
+
}
|
|
164
|
+
for (const entry of activeEditors) {
|
|
165
|
+
this._workingSet.set(entry, 3 );
|
|
166
|
+
didChange = true;
|
|
167
|
+
}
|
|
168
|
+
if (didChange) {
|
|
169
|
+
this._onDidChange.fire();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
createSnapshot(requestId) {
|
|
173
|
+
const snapshot = this._createSnapshot(requestId);
|
|
174
|
+
if (requestId) {
|
|
175
|
+
this._snapshots.set(requestId, snapshot);
|
|
176
|
+
for (const workingSetItem of ( (this._workingSet.keys()))) {
|
|
177
|
+
this._workingSet.set(workingSetItem, 5 );
|
|
178
|
+
}
|
|
179
|
+
const linearHistory = this._linearHistory.get();
|
|
180
|
+
const linearHistoryIndex = this._linearHistoryIndex.get();
|
|
181
|
+
const newLinearHistory = linearHistory.slice(0, linearHistoryIndex);
|
|
182
|
+
newLinearHistory.push(snapshot);
|
|
183
|
+
transaction((tx) => {
|
|
184
|
+
this._linearHistory.set(newLinearHistory, tx);
|
|
185
|
+
this._linearHistoryIndex.set(newLinearHistory.length, tx);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
this._pendingSnapshot = snapshot;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
_createSnapshot(requestId) {
|
|
193
|
+
const workingSet = ( (new ResourceMap()));
|
|
194
|
+
for (const [file, state] of this._workingSet) {
|
|
195
|
+
workingSet.set(file, state);
|
|
196
|
+
}
|
|
197
|
+
const entries = ( (new ResourceMap()));
|
|
198
|
+
for (const entry of this._entriesObs.get()) {
|
|
199
|
+
entries.set(entry.modifiedURI, entry.createSnapshot(requestId));
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
requestId,
|
|
203
|
+
workingSet,
|
|
204
|
+
entries
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
async getSnapshotModel(requestId, snapshotUri) {
|
|
208
|
+
const entries = this._snapshots.get(requestId)?.entries;
|
|
209
|
+
if (!entries) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
const snapshotEntry = [...( (entries.values()))].find((e) => ( (e.snapshotUri.toString())) === ( (snapshotUri.toString())));
|
|
213
|
+
if (!snapshotEntry) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
return this._modelService.createModel(snapshotEntry.current, this._languageService.createById(snapshotEntry.languageId), snapshotUri, false);
|
|
217
|
+
}
|
|
218
|
+
getSnapshot(requestId, uri) {
|
|
219
|
+
const snapshot = this._snapshots.get(requestId);
|
|
220
|
+
const snapshotEntries = snapshot?.entries;
|
|
221
|
+
return snapshotEntries?.get(uri);
|
|
222
|
+
}
|
|
223
|
+
async restoreSnapshot(requestId) {
|
|
224
|
+
if (requestId !== undefined) {
|
|
225
|
+
const snapshot = this._snapshots.get(requestId);
|
|
226
|
+
if (snapshot) {
|
|
227
|
+
await this._restoreSnapshot(snapshot);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
await this._restoreSnapshot(undefined);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
async _restoreSnapshot(snapshot) {
|
|
235
|
+
if (!snapshot) {
|
|
236
|
+
if (!this._pendingSnapshot) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
snapshot = this._pendingSnapshot;
|
|
240
|
+
this._pendingSnapshot = undefined;
|
|
241
|
+
}
|
|
242
|
+
else if (!this._pendingSnapshot) {
|
|
243
|
+
this.createSnapshot(undefined);
|
|
244
|
+
}
|
|
245
|
+
this._workingSet = ( (new ResourceMap()));
|
|
246
|
+
snapshot.workingSet.forEach((state, uri) => this._workingSet.set(uri, state));
|
|
247
|
+
for (const entry of this._entriesObs.get()) {
|
|
248
|
+
const snapshotEntry = snapshot.entries.get(entry.modifiedURI);
|
|
249
|
+
if (!snapshotEntry) {
|
|
250
|
+
const initialContents = this._initialFileContents.get(entry.modifiedURI);
|
|
251
|
+
if (typeof initialContents === 'string') {
|
|
252
|
+
entry.resetToInitialValue(initialContents);
|
|
253
|
+
}
|
|
254
|
+
entry.dispose();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
const entriesArr = [];
|
|
258
|
+
for (const snapshotEntry of ( (snapshot.entries.values()))) {
|
|
259
|
+
const entry = await this._getOrCreateModifiedFileEntry(snapshotEntry.resource, snapshotEntry.telemetryInfo);
|
|
260
|
+
entry.restoreFromSnapshot(snapshotEntry);
|
|
261
|
+
entriesArr.push(entry);
|
|
262
|
+
}
|
|
263
|
+
this._entriesObs.set(entriesArr, undefined);
|
|
264
|
+
}
|
|
265
|
+
remove(...uris) {
|
|
266
|
+
this._assertNotDisposed();
|
|
267
|
+
let didRemoveUris = false;
|
|
268
|
+
for (const uri of uris) {
|
|
269
|
+
didRemoveUris = this._workingSet.delete(uri) || didRemoveUris;
|
|
270
|
+
}
|
|
271
|
+
if (!didRemoveUris) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
this._onDidChange.fire();
|
|
275
|
+
}
|
|
276
|
+
_assertNotDisposed() {
|
|
277
|
+
if (this._state.get() === 3 ) {
|
|
278
|
+
throw ( (new BugIndicatingError(`Cannot access a disposed editing session`)));
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
async accept(...uris) {
|
|
282
|
+
this._assertNotDisposed();
|
|
283
|
+
if (uris.length === 0) {
|
|
284
|
+
await Promise.all(( (this._entriesObs.get().map(entry => entry.accept(undefined)))));
|
|
285
|
+
}
|
|
286
|
+
for (const uri of uris) {
|
|
287
|
+
const entry = this._entriesObs.get().find(e => ( (e.modifiedURI.toString())) === ( (uri.toString())));
|
|
288
|
+
if (entry) {
|
|
289
|
+
await entry.accept(undefined);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
this._onDidChange.fire();
|
|
293
|
+
}
|
|
294
|
+
async reject(...uris) {
|
|
295
|
+
this._assertNotDisposed();
|
|
296
|
+
if (uris.length === 0) {
|
|
297
|
+
await Promise.all(( (this._entriesObs.get().map(entry => entry.reject(undefined)))));
|
|
298
|
+
}
|
|
299
|
+
for (const uri of uris) {
|
|
300
|
+
const entry = this._entriesObs.get().find(e => ( (e.modifiedURI.toString())) === ( (uri.toString())));
|
|
301
|
+
if (entry) {
|
|
302
|
+
await entry.reject(undefined);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
this._onDidChange.fire();
|
|
306
|
+
}
|
|
307
|
+
async show() {
|
|
308
|
+
this._assertNotDisposed();
|
|
309
|
+
if (this.editorPane?.isVisible()) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
else if (this.editorPane?.input) {
|
|
313
|
+
await this._editorGroupsService.activeGroup.openEditor(this.editorPane.input, { pinned: true, activation: EditorActivation.ACTIVATE });
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
const input = MultiDiffEditorInput.fromResourceMultiDiffEditorInput({
|
|
317
|
+
multiDiffSource: ChatEditingMultiDiffSourceResolver.getMultiDiffSourceUri(),
|
|
318
|
+
label: ( localize(7665, "Suggested Edits"))
|
|
319
|
+
}, this._instantiationService);
|
|
320
|
+
const editorPane = await this._editorGroupsService.activeGroup.openEditor(input, { pinned: true, activation: EditorActivation.ACTIVATE });
|
|
321
|
+
this.editorPane = editorPane;
|
|
322
|
+
}
|
|
323
|
+
async stop() {
|
|
324
|
+
this._assertNotDisposed();
|
|
325
|
+
await Promise.allSettled(( (this._editorGroupsService.groups.map(async (g) => {
|
|
326
|
+
return Promise.allSettled(( (g.editors.map(async (e) => {
|
|
327
|
+
if (e instanceof MultiDiffEditorInput || e instanceof DiffEditorInput && (e.original.resource?.scheme === ChatEditingModifiedFileEntry.scheme || e.original.resource?.scheme === ChatEditingTextModelContentProvider.scheme)) {
|
|
328
|
+
await g.closeEditor(e);
|
|
329
|
+
}
|
|
330
|
+
}))));
|
|
331
|
+
}))));
|
|
332
|
+
if (this._state.get() !== 3 ) {
|
|
333
|
+
this.dispose();
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
dispose() {
|
|
337
|
+
this._assertNotDisposed();
|
|
338
|
+
for (const entry of this._entriesObs.get()) {
|
|
339
|
+
entry.dispose();
|
|
340
|
+
}
|
|
341
|
+
super.dispose();
|
|
342
|
+
this._state.set(3 , undefined);
|
|
343
|
+
this._onDidDispose.fire();
|
|
344
|
+
}
|
|
345
|
+
getVirtualModel(documentId) {
|
|
346
|
+
this._assertNotDisposed();
|
|
347
|
+
const entry = this._entriesObs.get().find(e => e.entryId === documentId);
|
|
348
|
+
return entry?.docSnapshot ?? null;
|
|
349
|
+
}
|
|
350
|
+
acceptStreamingEditsStart() {
|
|
351
|
+
if (this._state.get() === 3 ) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
this._sequencer.queue(() => this._acceptStreamingEditsStart());
|
|
355
|
+
}
|
|
356
|
+
acceptTextEdits(resource, textEdits, responseModel) {
|
|
357
|
+
if (this._state.get() === 3 ) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
this._sequencer.queue(() => this._acceptTextEdits(resource, textEdits, responseModel));
|
|
361
|
+
}
|
|
362
|
+
resolve() {
|
|
363
|
+
if (this._state.get() === 3 ) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
this._sequencer.queue(() => this._resolve());
|
|
367
|
+
}
|
|
368
|
+
addFileToWorkingSet(resource) {
|
|
369
|
+
if (!( (this._workingSet.has(resource)))) {
|
|
370
|
+
this._workingSet.set(resource, 4 );
|
|
371
|
+
for (const file of ( (this._workingSet.keys()))) {
|
|
372
|
+
if (this._workingSet.get(file) === 3 ) {
|
|
373
|
+
this._workingSet.set(file, 4 );
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
this._onDidChange.fire();
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
async undoInteraction() {
|
|
380
|
+
const linearHistory = this._linearHistory.get();
|
|
381
|
+
const linearHistoryIndex = this._linearHistoryIndex.get();
|
|
382
|
+
if (linearHistoryIndex <= 0) {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
const previousSnapshot = linearHistory[linearHistoryIndex - 1];
|
|
386
|
+
await this.restoreSnapshot(previousSnapshot.requestId);
|
|
387
|
+
this._linearHistoryIndex.set(linearHistoryIndex - 1, undefined);
|
|
388
|
+
}
|
|
389
|
+
async redoInteraction() {
|
|
390
|
+
const linearHistory = this._linearHistory.get();
|
|
391
|
+
const linearHistoryIndex = this._linearHistoryIndex.get();
|
|
392
|
+
if (linearHistoryIndex >= linearHistory.length) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
const nextSnapshot = (linearHistoryIndex + 1 < linearHistory.length ? linearHistory[linearHistoryIndex + 1] : this._pendingSnapshot);
|
|
396
|
+
if (!nextSnapshot) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
await this.restoreSnapshot(nextSnapshot.requestId);
|
|
400
|
+
this._linearHistoryIndex.set(linearHistoryIndex + 1, undefined);
|
|
401
|
+
}
|
|
402
|
+
async _acceptStreamingEditsStart() {
|
|
403
|
+
transaction((tx) => {
|
|
404
|
+
this._state.set(1 , tx);
|
|
405
|
+
for (const entry of this._entriesObs.get()) {
|
|
406
|
+
entry.acceptStreamingEditsStart(tx);
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
async _acceptTextEdits(resource, textEdits, responseModel) {
|
|
411
|
+
if (( (this._filesToSkipCreating.has(resource)))) {
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
if (!this._entriesObs.get().find(e => ( (e.resource.toString())) === ( (resource.toString()))) && this._entriesObs.get().length >= (await this.editingSessionFileLimitPromise)) {
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
if (resource.scheme !== Schemas.untitled && !this._workspaceContextService.getWorkspaceFolder(resource) && !(await this._fileService.exists(resource))) {
|
|
418
|
+
const saveLocation = await this._dialogService.showSaveDialog({ title: ( localize(
|
|
419
|
+
7666,
|
|
420
|
+
'{0} wants to create a file. Choose where it should be saved.',
|
|
421
|
+
this._chatAgentService.getDefaultAgent(ChatAgentLocation.EditingSession)?.fullName ?? 'Chat'
|
|
422
|
+
)) });
|
|
423
|
+
if (!saveLocation) {
|
|
424
|
+
this._filesToSkipCreating.add(resource);
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
resource = saveLocation;
|
|
428
|
+
}
|
|
429
|
+
const telemetryInfo = new class {
|
|
430
|
+
get agentId() { return responseModel.agent?.id; }
|
|
431
|
+
get command() { return responseModel.slashCommand?.name; }
|
|
432
|
+
get sessionId() { return responseModel.session.sessionId; }
|
|
433
|
+
get requestId() { return responseModel.requestId; }
|
|
434
|
+
get result() { return responseModel.result; }
|
|
435
|
+
};
|
|
436
|
+
const entry = await this._getOrCreateModifiedFileEntry(resource, telemetryInfo);
|
|
437
|
+
entry.acceptAgentEdits(textEdits);
|
|
438
|
+
}
|
|
439
|
+
async _resolve() {
|
|
440
|
+
transaction((tx) => {
|
|
441
|
+
for (const entry of this._entriesObs.get()) {
|
|
442
|
+
entry.acceptStreamingEditsEnd(tx);
|
|
443
|
+
}
|
|
444
|
+
this._state.set(2 , tx);
|
|
445
|
+
});
|
|
446
|
+
this._onDidChange.fire();
|
|
447
|
+
}
|
|
448
|
+
async _getOrCreateModifiedFileEntry(resource, responseModel) {
|
|
449
|
+
const existingEntry = this._entriesObs.get().find(e => ( (e.resource.toString())) === ( (resource.toString())));
|
|
450
|
+
if (existingEntry) {
|
|
451
|
+
if (responseModel.requestId !== existingEntry.telemetryInfo.requestId) {
|
|
452
|
+
existingEntry.updateTelemetryInfo(responseModel);
|
|
453
|
+
}
|
|
454
|
+
return existingEntry;
|
|
455
|
+
}
|
|
456
|
+
const entry = await this._createModifiedFileEntry(resource, responseModel);
|
|
457
|
+
if (!( (this._initialFileContents.has(resource)))) {
|
|
458
|
+
this._initialFileContents.set(resource, entry.modifiedModel.getValue());
|
|
459
|
+
}
|
|
460
|
+
this._register(entry.onDidDelete(() => {
|
|
461
|
+
const newEntries = this._entriesObs.get().filter(e => ( (e.modifiedURI.toString())) !== ( (entry.modifiedURI.toString())));
|
|
462
|
+
this._entriesObs.set(newEntries, undefined);
|
|
463
|
+
this._workingSet.delete(entry.modifiedURI);
|
|
464
|
+
this._onDidChange.fire();
|
|
465
|
+
}));
|
|
466
|
+
const entriesArr = [...this._entriesObs.get(), entry];
|
|
467
|
+
this._entriesObs.set(entriesArr, undefined);
|
|
468
|
+
this._onDidChange.fire();
|
|
469
|
+
return entry;
|
|
470
|
+
}
|
|
471
|
+
async _createModifiedFileEntry(resource, responseModel, mustExist = false) {
|
|
472
|
+
try {
|
|
473
|
+
const ref = await this._textModelService.createModelReference(resource);
|
|
474
|
+
return this._instantiationService.createInstance(ChatEditingModifiedFileEntry, resource, ref, { collapse: (transaction) => this._collapse(resource, transaction) }, responseModel, mustExist ? 0 : 1 );
|
|
475
|
+
}
|
|
476
|
+
catch (err) {
|
|
477
|
+
if (mustExist) {
|
|
478
|
+
throw err;
|
|
479
|
+
}
|
|
480
|
+
await this._bulkEditService.apply({ edits: [{ newResource: resource }] });
|
|
481
|
+
this._editorService.openEditor({ resource, options: { inactive: true, preserveFocus: true, pinned: true } });
|
|
482
|
+
return this._createModifiedFileEntry(resource, responseModel, true);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
_collapse(resource, transaction) {
|
|
486
|
+
const multiDiffItem = this.editorPane?.findDocumentDiffItem(resource);
|
|
487
|
+
if (multiDiffItem) {
|
|
488
|
+
this.editorPane?.viewModel?.items.get().find((documentDiffItem) => String(documentDiffItem.originalUri) === String(multiDiffItem.originalUri) && String(documentDiffItem.modifiedUri) === String(multiDiffItem.modifiedUri))?.collapsed.set(true, transaction);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
ChatEditingSession = ( (__decorate([
|
|
493
|
+
( (__param(3, IInstantiationService))),
|
|
494
|
+
( (__param(4, IModelService))),
|
|
495
|
+
( (__param(5, ILanguageService))),
|
|
496
|
+
( (__param(6, ITextModelService))),
|
|
497
|
+
( (__param(7, IBulkEditService))),
|
|
498
|
+
( (__param(8, IEditorGroupsService))),
|
|
499
|
+
( (__param(9, IEditorService))),
|
|
500
|
+
( (__param(10, IChatWidgetService))),
|
|
501
|
+
( (__param(11, IWorkspaceContextService))),
|
|
502
|
+
( (__param(12, IFileService))),
|
|
503
|
+
( (__param(13, IFileDialogService))),
|
|
504
|
+
( (__param(14, IChatAgentService)))
|
|
505
|
+
], ChatEditingSession)));
|
|
506
|
+
|
|
507
|
+
export { ChatEditingSession };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
3
|
+
import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
|
|
4
|
+
|
|
5
|
+
var ChatEditingTextModelContentProvider_1, ChatEditingSnapshotTextModelContentProvider_1;
|
|
6
|
+
let ChatEditingTextModelContentProvider = class ChatEditingTextModelContentProvider {
|
|
7
|
+
static { ChatEditingTextModelContentProvider_1 = this; }
|
|
8
|
+
static { this.scheme = 'chat-editing-text-model'; }
|
|
9
|
+
static getEmptyFileURI() {
|
|
10
|
+
return ( URI.from({
|
|
11
|
+
scheme: ChatEditingTextModelContentProvider_1.scheme,
|
|
12
|
+
query: JSON.stringify({ kind: 'empty' }),
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
static getFileURI(documentId, path) {
|
|
16
|
+
return ( URI.from({
|
|
17
|
+
scheme: ChatEditingTextModelContentProvider_1.scheme,
|
|
18
|
+
path,
|
|
19
|
+
query: JSON.stringify({ kind: 'doc', documentId }),
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
constructor(_currentSessionObs, _modelService) {
|
|
23
|
+
this._currentSessionObs = _currentSessionObs;
|
|
24
|
+
this._modelService = _modelService;
|
|
25
|
+
}
|
|
26
|
+
async provideTextContent(resource) {
|
|
27
|
+
const existing = this._modelService.getModel(resource);
|
|
28
|
+
if (existing && !existing.isDisposed()) {
|
|
29
|
+
return existing;
|
|
30
|
+
}
|
|
31
|
+
const data = JSON.parse(resource.query);
|
|
32
|
+
if (data.kind === 'empty') {
|
|
33
|
+
return this._modelService.createModel('', null, resource, false);
|
|
34
|
+
}
|
|
35
|
+
const session = this._currentSessionObs.get();
|
|
36
|
+
if (!session) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return session.getVirtualModel(data.documentId);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
ChatEditingTextModelContentProvider = ChatEditingTextModelContentProvider_1 = ( __decorate([
|
|
43
|
+
( __param(1, IModelService))
|
|
44
|
+
], ChatEditingTextModelContentProvider));
|
|
45
|
+
let ChatEditingSnapshotTextModelContentProvider = class ChatEditingSnapshotTextModelContentProvider {
|
|
46
|
+
static { ChatEditingSnapshotTextModelContentProvider_1 = this; }
|
|
47
|
+
static { this.scheme = 'chat-editing-snapshot-text-model'; }
|
|
48
|
+
static getSnapshotFileURI(requestId, path) {
|
|
49
|
+
return ( URI.from({
|
|
50
|
+
scheme: ChatEditingSnapshotTextModelContentProvider_1.scheme,
|
|
51
|
+
path,
|
|
52
|
+
query: JSON.stringify({ requestId: requestId ?? '' }),
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
constructor(_currentSessionObs, _modelService) {
|
|
56
|
+
this._currentSessionObs = _currentSessionObs;
|
|
57
|
+
this._modelService = _modelService;
|
|
58
|
+
}
|
|
59
|
+
async provideTextContent(resource) {
|
|
60
|
+
const existing = this._modelService.getModel(resource);
|
|
61
|
+
if (existing && !existing.isDisposed()) {
|
|
62
|
+
return existing;
|
|
63
|
+
}
|
|
64
|
+
const data = JSON.parse(resource.query);
|
|
65
|
+
const session = this._currentSessionObs.get();
|
|
66
|
+
if (!session || !data.requestId) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
return session.getSnapshotModel(data.requestId, resource);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
ChatEditingSnapshotTextModelContentProvider = ChatEditingSnapshotTextModelContentProvider_1 = ( __decorate([
|
|
73
|
+
( __param(1, IModelService))
|
|
74
|
+
], ChatEditingSnapshotTextModelContentProvider));
|
|
75
|
+
|
|
76
|
+
export { ChatEditingSnapshotTextModelContentProvider, ChatEditingTextModelContentProvider };
|
|
@@ -18,11 +18,11 @@ import 'vscode/vscode/vs/platform/theme/common/colors/searchColors';
|
|
|
18
18
|
import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService.service';
|
|
19
19
|
import { EditorPane } from 'vscode/vscode/vs/workbench/browser/parts/editor/editorPane';
|
|
20
20
|
import { Memento } from 'vscode/vscode/vs/workbench/common/memento';
|
|
21
|
-
import { clearChatEditor } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatClear';
|
|
22
|
-
import { ChatEditorInput } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatEditorInput';
|
|
23
|
-
import { ChatWidget } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatWidget';
|
|
21
|
+
import { clearChatEditor } from '@codingame/monaco-vscode-chat-extensions-interactive-notebook-quickaccess-search-terminal-common/vscode/vs/workbench/contrib/chat/browser/actions/chatClear';
|
|
22
|
+
import { ChatEditorInput } from '@codingame/monaco-vscode-chat-extensions-interactive-notebook-quickaccess-search-terminal-common/vscode/vs/workbench/contrib/chat/browser/chatEditorInput';
|
|
23
|
+
import { ChatWidget } from '@codingame/monaco-vscode-chat-extensions-notebook-common/vscode/vs/workbench/contrib/chat/browser/chatWidget';
|
|
24
24
|
import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
|
|
25
|
-
import { CHAT_PROVIDER_ID } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParticipantContribTypes';
|
|
25
|
+
import { CHAT_PROVIDER_ID } from '@codingame/monaco-vscode-chat-extensions-interactive-notebook-quickaccess-search-terminal-common/vscode/vs/workbench/contrib/chat/common/chatParticipantContribTypes';
|
|
26
26
|
import { EDITOR_DRAG_AND_DROP_BACKGROUND } from 'vscode/vscode/vs/workbench/common/theme';
|
|
27
27
|
|
|
28
28
|
let ChatEditor = class ChatEditor extends EditorPane {
|