@codingame/monaco-vscode-chat-service-override 15.0.2 → 16.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/index.js +11 -8
- package/package.json +29 -20
- package/vscode/src/vs/editor/common/diff/documentDiffProvider.d.ts +22 -0
- package/vscode/src/vs/editor/common/diff/documentDiffProvider.js +10 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.d.ts +9 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +80 -55
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.js +17 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/{askToSelectPrompt.d.ts → askToSelectPrompt/askToSelectPrompt.d.ts} +9 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/askToSelectPrompt.js +79 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/constants.d.ts +7 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/constants.js +27 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/attachPrompts.d.ts +5 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/attachPrompts.js +53 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPlaceholderText.d.ts +2 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPlaceholderText.js +19 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPromptPickItem.d.ts +5 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPromptPickItem.js +27 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/handleButtonClick.d.ts +13 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/handleButtonClick.js +49 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.d.ts +6 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +163 -72
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +22 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +4 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +17 -17
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +9 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTransfer.d.ts +7 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTransfer.js +17 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +15 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +242 -74
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditing.d.ts +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditing.js +15 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.d.ts +47 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.js +688 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.d.ts +28 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.js +355 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorOverlay.js +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.d.ts +71 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.js +395 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.d.ts +98 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.js +216 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.d.ts +97 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.js +831 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.d.ts +7 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.js +32 -47
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +110 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +985 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.d.ts +20 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.js +69 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookDiff.d.ts +15 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookDiff.js +67 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookSnapshot.d.ts +26 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookSnapshot.js +147 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.d.ts +56 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.js +284 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.d.ts +38 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.js +578 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookFileSystemProvider.d.ts +45 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookFileSystemProvider.js +122 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/helpers.d.ts +15 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/helpers.js +320 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/notebookCellChanges.d.ts +31 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/notebookCellChanges.js +50 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.d.ts +5 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +22 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.d.ts +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.js +166 -62
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.d.ts +6 -104
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.js +704 -732
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.d.ts +10 -25
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.js +329 -236
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatusItemService.d.ts +19 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatusItemService.js +27 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.d.ts +4 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +14 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/media/editorHoverWrapper.css +3 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.d.ts +17 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js +217 -18
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditingEditorOverlay.css +114 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditorController.css +30 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatSetup.css +56 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatStatus.css +90 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/createPromptCommand.js +65 -19
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptName.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptSourceFolder.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/errors.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/utils/createPromptFile.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/utils/createPromptFile.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/usePromptCommand.js +14 -12
- package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.d.ts +5 -3
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +5 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.d.ts +16 -8
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +175 -57
- package/vscode/src/vs/workbench/contrib/chat/common/chatSessionStore.d.ts +66 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatSessionStore.js +313 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.d.ts +3 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +4 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatTransferService.d.ts +14 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatTransferService.js +30 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/constants.d.ts +2 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/constants.js +6 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.d.ts +10 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.js +18 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkDiagnosticsProvider.d.ts +9 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkDiagnosticsProvider.js +117 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptPathAutocompletion.js +3 -4
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.d.ts +6 -4
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.js +157 -65
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.d.ts +2 -1
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +39 -21
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.d.ts +0 -1
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +2 -3
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +4 -4
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +11 -10
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookModifiedCellDecorator.d.ts +10 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookModifiedCellDecorator.js +47 -0
- package/vscode/src/vs/workbench/services/workspaces/common/workspaceUtils.d.ts +5 -0
- package/vscode/src/vs/workbench/services/workspaces/common/workspaceUtils.js +26 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt.js +0 -142
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.d.ts +0 -52
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +0 -331
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.d.ts +0 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.js +0 -110
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/media/editorHoverWrapper.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditingEditorOverlay.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatStatus.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatViewSetup.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/chat/common/chatEntitlementsService.d.ts +0 -19
- package/vscode/src/vs/workbench/contrib/chat/common/chatEntitlementsService.js +0 -13
- package/vscode/src/vs/workbench/contrib/chat/common/chatQuotasService.d.ts +0 -31
- package/vscode/src/vs/workbench/contrib/chat/common/chatQuotasService.js +0 -85
- package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.d.ts +0 -11
- package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.js +0 -22
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
4
|
+
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
5
|
+
import { ResourceMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
|
|
6
|
+
import { FileSystemProviderCapabilities, FileType } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files';
|
|
7
|
+
import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
|
|
8
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
9
|
+
import { INotebookService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService.service';
|
|
10
|
+
import { IChatEditingService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService.service';
|
|
11
|
+
import { ChatEditingNotebookSnapshotScheme, deserializeSnapshot } from './chatEditingModifiedNotebookSnapshot.js';
|
|
12
|
+
import { ChatEditingSession } from '../chatEditingSession.js';
|
|
13
|
+
|
|
14
|
+
var ChatEditingNotebookFileSystemProvider_1;
|
|
15
|
+
let ChatEditingNotebookFileSystemProviderContrib = class ChatEditingNotebookFileSystemProviderContrib extends Disposable {
|
|
16
|
+
static { this.ID = 'chatEditingNotebookFileSystemProviderContribution'; }
|
|
17
|
+
constructor(fileService, instantiationService) {
|
|
18
|
+
super();
|
|
19
|
+
this.fileService = fileService;
|
|
20
|
+
const fileSystemProvider = instantiationService.createInstance(ChatEditingNotebookFileSystemProvider);
|
|
21
|
+
this._register(this.fileService.registerProvider(ChatEditingNotebookSnapshotScheme, fileSystemProvider));
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
ChatEditingNotebookFileSystemProviderContrib = ( __decorate([
|
|
25
|
+
( __param(0, IFileService)),
|
|
26
|
+
( __param(1, IInstantiationService))
|
|
27
|
+
], ChatEditingNotebookFileSystemProviderContrib));
|
|
28
|
+
let ChatEditingNotebookFileSystemProvider = class ChatEditingNotebookFileSystemProvider {
|
|
29
|
+
static { ChatEditingNotebookFileSystemProvider_1 = this; }
|
|
30
|
+
static { this.registeredFiles = ( new ResourceMap()); }
|
|
31
|
+
static registerFile(resource, buffer) {
|
|
32
|
+
ChatEditingNotebookFileSystemProvider_1.registeredFiles.set(resource, buffer);
|
|
33
|
+
return {
|
|
34
|
+
dispose() {
|
|
35
|
+
if (ChatEditingNotebookFileSystemProvider_1.registeredFiles.get(resource) === buffer) {
|
|
36
|
+
ChatEditingNotebookFileSystemProvider_1.registeredFiles.delete(resource);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
constructor(_chatEditingService, notebookService) {
|
|
42
|
+
this._chatEditingService = _chatEditingService;
|
|
43
|
+
this.notebookService = notebookService;
|
|
44
|
+
this.capabilities = FileSystemProviderCapabilities.Readonly | FileSystemProviderCapabilities.FileAtomicRead | FileSystemProviderCapabilities.FileReadWrite;
|
|
45
|
+
this.onDidChangeCapabilities = Event.None;
|
|
46
|
+
this.onDidChangeFile = Event.None;
|
|
47
|
+
}
|
|
48
|
+
watch(_resource, _opts) {
|
|
49
|
+
return Disposable.None;
|
|
50
|
+
}
|
|
51
|
+
async stat(_resource) {
|
|
52
|
+
return {
|
|
53
|
+
type: FileType.File,
|
|
54
|
+
ctime: 0,
|
|
55
|
+
mtime: 0,
|
|
56
|
+
size: 0
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
mkdir(_resource) {
|
|
60
|
+
throw ( new Error('Method not implemented1.'));
|
|
61
|
+
}
|
|
62
|
+
readdir(_resource) {
|
|
63
|
+
throw ( new Error('Method not implemented2.'));
|
|
64
|
+
}
|
|
65
|
+
delete(_resource, _opts) {
|
|
66
|
+
throw ( new Error('Method not implemented3.'));
|
|
67
|
+
}
|
|
68
|
+
rename(_from, _to, _opts) {
|
|
69
|
+
throw ( new Error('Method not implemented4.'));
|
|
70
|
+
}
|
|
71
|
+
copy(_from, _to, _opts) {
|
|
72
|
+
throw ( new Error('Method not implemented5.'));
|
|
73
|
+
}
|
|
74
|
+
async readFile(resource) {
|
|
75
|
+
const buffer = ChatEditingNotebookFileSystemProvider_1.registeredFiles.get(resource);
|
|
76
|
+
if (buffer) {
|
|
77
|
+
return buffer.buffer;
|
|
78
|
+
}
|
|
79
|
+
const queryData = JSON.parse(resource.query);
|
|
80
|
+
if (!queryData.viewType) {
|
|
81
|
+
throw ( new Error('File not found, viewType not found'));
|
|
82
|
+
}
|
|
83
|
+
const session = this._chatEditingService.getEditingSession(queryData.sessionId);
|
|
84
|
+
if (!(session instanceof ChatEditingSession) || !queryData.requestId) {
|
|
85
|
+
throw ( new Error('File not found, session not found'));
|
|
86
|
+
}
|
|
87
|
+
const snapshotEntry = session.getSnapshot(queryData.requestId, queryData.undoStop || undefined, resource);
|
|
88
|
+
if (!snapshotEntry) {
|
|
89
|
+
throw ( new Error('File not found, snapshot not found'));
|
|
90
|
+
}
|
|
91
|
+
const { data } = deserializeSnapshot(snapshotEntry.current);
|
|
92
|
+
const { serializer } = await this.notebookService.withNotebookDataProvider(queryData.viewType);
|
|
93
|
+
return serializer.notebookToData(data).then(s => s.buffer);
|
|
94
|
+
}
|
|
95
|
+
writeFile(__resource, _content, _opts) {
|
|
96
|
+
throw ( new Error('Method not implemented7.'));
|
|
97
|
+
}
|
|
98
|
+
readFileStream(__resource, _opts, _token) {
|
|
99
|
+
throw ( new Error('Method not implemented8.'));
|
|
100
|
+
}
|
|
101
|
+
open(__resource, _opts) {
|
|
102
|
+
throw ( new Error('Method not implemented9.'));
|
|
103
|
+
}
|
|
104
|
+
close(_fd) {
|
|
105
|
+
throw ( new Error('Method not implemented10.'));
|
|
106
|
+
}
|
|
107
|
+
read(_fd, _pos, _data, _offset, _length) {
|
|
108
|
+
throw ( new Error('Method not implemented11.'));
|
|
109
|
+
}
|
|
110
|
+
write(_fd, _pos, _data, _offset, _length) {
|
|
111
|
+
throw ( new Error('Method not implemented12.'));
|
|
112
|
+
}
|
|
113
|
+
cloneFile(_from, __to) {
|
|
114
|
+
throw ( new Error('Method not implemented13.'));
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
ChatEditingNotebookFileSystemProvider = ChatEditingNotebookFileSystemProvider_1 = ( __decorate([
|
|
118
|
+
( __param(0, IChatEditingService)),
|
|
119
|
+
( __param(1, INotebookService))
|
|
120
|
+
], ChatEditingNotebookFileSystemProvider));
|
|
121
|
+
|
|
122
|
+
export { ChatEditingNotebookFileSystemProvider, ChatEditingNotebookFileSystemProviderContrib };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NotebookTextModel } from "@codingame/monaco-vscode-notebook-service-override/vscode/vs/workbench/contrib/notebook/common/model/notebookTextModel";
|
|
2
|
+
import { ICell, ICellDto2, ICellEditOperation, NotebookCellsModelMoveEvent, NotebookCellTextModelSplice, NotebookTextModelChangedEvent } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon";
|
|
3
|
+
import { ICellDiffInfo } from "./notebookCellChanges.js";
|
|
4
|
+
export declare function adjustCellDiffForKeepingADeletedCell(originalCellIndex: number, cellDiffInfo: ICellDiffInfo[], applyEdits: typeof NotebookTextModel.prototype.applyEdits): ICellDiffInfo[];
|
|
5
|
+
export declare function adjustCellDiffForRevertingADeletedCell(originalCellIndex: number, cellDiffInfo: ICellDiffInfo[], cellToInsert: ICellDto2, applyEdits: typeof NotebookTextModel.prototype.applyEdits, createModifiedCellDiffInfo: (modifiedCellIndex: number, originalCellIndex: number) => ICellDiffInfo): ICellDiffInfo[];
|
|
6
|
+
export declare function adjustCellDiffForRevertingAnInsertedCell(modifiedCellIndex: number, cellDiffInfo: ICellDiffInfo[], applyEdits: typeof NotebookTextModel.prototype.applyEdits): ICellDiffInfo[];
|
|
7
|
+
export declare function adjustCellDiffForKeepingAnInsertedCell(modifiedCellIndex: number, cellDiffInfo: ICellDiffInfo[], cellToInsert: ICellDto2, applyEdits: typeof NotebookTextModel.prototype.applyEdits, createModifiedCellDiffInfo: (modifiedCellIndex: number, originalCellIndex: number) => ICellDiffInfo): ICellDiffInfo[];
|
|
8
|
+
export declare function adjustCellDiffAndOriginalModelBasedOnCellAddDelete(change: NotebookCellTextModelSplice<ICell>, cellDiffInfo: ICellDiffInfo[], modifiedModelCellCount: number, originalModelCellCount: number, applyEdits: typeof NotebookTextModel.prototype.applyEdits, createModifiedCellDiffInfo: (modifiedCellIndex: number, originalCellIndex: number) => ICellDiffInfo): ICellDiffInfo[];
|
|
9
|
+
export declare function adjustCellDiffAndOriginalModelBasedOnCellMovements(event: NotebookCellsModelMoveEvent<ICell>, cellDiffInfo: ICellDiffInfo[]): [
|
|
10
|
+
ICellDiffInfo[],
|
|
11
|
+
ICellEditOperation[]
|
|
12
|
+
] | undefined;
|
|
13
|
+
export declare function getCorrespondingOriginalCellIndex(modifiedCellIndex: number, cellDiffInfo: ICellDiffInfo[]): number | undefined;
|
|
14
|
+
export declare function isTransientIPyNbExtensionEvent(notebookKind: string, e: NotebookTextModelChangedEvent): boolean;
|
|
15
|
+
export declare function calculateNotebookRewriteRatio(cellsDiff: ICellDiffInfo[], originalModel: NotebookTextModel, modifiedModel: NotebookTextModel): number;
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
|
|
2
|
+
import { CellEditType, NotebookCellsChangeType } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
3
|
+
import { sortCellChanges } from './notebookCellChanges.js';
|
|
4
|
+
|
|
5
|
+
function adjustCellDiffForRevertingADeletedCell(originalCellIndex, cellDiffInfo, cellToInsert, applyEdits, createModifiedCellDiffInfo) {
|
|
6
|
+
cellDiffInfo = sortCellChanges(cellDiffInfo);
|
|
7
|
+
const indexOfEntry = cellDiffInfo.findIndex(d => d.originalCellIndex === originalCellIndex);
|
|
8
|
+
if (indexOfEntry === -1) {
|
|
9
|
+
return cellDiffInfo;
|
|
10
|
+
}
|
|
11
|
+
let modifiedCellIndex = -1;
|
|
12
|
+
for (let i = 0; i < cellDiffInfo.length; i++) {
|
|
13
|
+
const diff = cellDiffInfo[i];
|
|
14
|
+
if (i < indexOfEntry) {
|
|
15
|
+
modifiedCellIndex = Math.max(modifiedCellIndex, diff.modifiedCellIndex ?? modifiedCellIndex);
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (i === indexOfEntry) {
|
|
19
|
+
const edit = { cells: [cellToInsert], count: 0, editType: CellEditType.Replace, index: modifiedCellIndex + 1, };
|
|
20
|
+
applyEdits([edit], true, undefined, () => undefined, undefined, true);
|
|
21
|
+
cellDiffInfo[i] = createModifiedCellDiffInfo(modifiedCellIndex + 1, originalCellIndex);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
if (typeof diff.modifiedCellIndex === 'number') {
|
|
26
|
+
diff.modifiedCellIndex++;
|
|
27
|
+
cellDiffInfo[i] = { ...diff };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return cellDiffInfo;
|
|
32
|
+
}
|
|
33
|
+
function adjustCellDiffForRevertingAnInsertedCell(modifiedCellIndex, cellDiffInfo, applyEdits) {
|
|
34
|
+
if (modifiedCellIndex === -1) {
|
|
35
|
+
return cellDiffInfo;
|
|
36
|
+
}
|
|
37
|
+
cellDiffInfo = ( sortCellChanges(cellDiffInfo)
|
|
38
|
+
.filter(d => !(d.type === 'insert' && d.modifiedCellIndex === modifiedCellIndex))
|
|
39
|
+
.map(d => {
|
|
40
|
+
if (d.type === 'insert' && d.modifiedCellIndex === modifiedCellIndex) {
|
|
41
|
+
return d;
|
|
42
|
+
}
|
|
43
|
+
if (d.type !== 'delete' && d.modifiedCellIndex > modifiedCellIndex) {
|
|
44
|
+
return {
|
|
45
|
+
...d,
|
|
46
|
+
modifiedCellIndex: d.modifiedCellIndex - 1,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return d;
|
|
50
|
+
}));
|
|
51
|
+
const edit = { cells: [], count: 1, editType: CellEditType.Replace, index: modifiedCellIndex, };
|
|
52
|
+
applyEdits([edit], true, undefined, () => undefined, undefined, true);
|
|
53
|
+
return cellDiffInfo;
|
|
54
|
+
}
|
|
55
|
+
function adjustCellDiffForKeepingAnInsertedCell(modifiedCellIndex, cellDiffInfo, cellToInsert, applyEdits, createModifiedCellDiffInfo) {
|
|
56
|
+
cellDiffInfo = sortCellChanges(cellDiffInfo);
|
|
57
|
+
if (modifiedCellIndex === -1) {
|
|
58
|
+
return cellDiffInfo;
|
|
59
|
+
}
|
|
60
|
+
const indexOfEntry = cellDiffInfo.findIndex(d => d.modifiedCellIndex === modifiedCellIndex);
|
|
61
|
+
if (indexOfEntry === -1) {
|
|
62
|
+
return cellDiffInfo;
|
|
63
|
+
}
|
|
64
|
+
let originalCellIndex = -1;
|
|
65
|
+
for (let i = 0; i < cellDiffInfo.length; i++) {
|
|
66
|
+
const diff = cellDiffInfo[i];
|
|
67
|
+
if (i < indexOfEntry) {
|
|
68
|
+
originalCellIndex = Math.max(originalCellIndex, diff.originalCellIndex ?? originalCellIndex);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (i === indexOfEntry) {
|
|
72
|
+
const edit = { cells: [cellToInsert], count: 0, editType: CellEditType.Replace, index: originalCellIndex + 1 };
|
|
73
|
+
applyEdits([edit], true, undefined, () => undefined, undefined, true);
|
|
74
|
+
cellDiffInfo[i] = createModifiedCellDiffInfo(modifiedCellIndex, originalCellIndex + 1);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
if (typeof diff.originalCellIndex === 'number') {
|
|
79
|
+
diff.originalCellIndex++;
|
|
80
|
+
cellDiffInfo[i] = { ...diff };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return cellDiffInfo;
|
|
85
|
+
}
|
|
86
|
+
function adjustCellDiffAndOriginalModelBasedOnCellAddDelete(change, cellDiffInfo, modifiedModelCellCount, originalModelCellCount, applyEdits, createModifiedCellDiffInfo) {
|
|
87
|
+
cellDiffInfo = sortCellChanges(cellDiffInfo);
|
|
88
|
+
const numberOfCellsInserted = change[2].length;
|
|
89
|
+
const numberOfCellsDeleted = change[1];
|
|
90
|
+
const cells = ( change[2].map(cell => {
|
|
91
|
+
return {
|
|
92
|
+
cellKind: cell.cellKind,
|
|
93
|
+
language: cell.language,
|
|
94
|
+
metadata: cell.metadata,
|
|
95
|
+
outputs: cell.outputs,
|
|
96
|
+
source: cell.getValue(),
|
|
97
|
+
mime: undefined,
|
|
98
|
+
internalMetadata: cell.internalMetadata
|
|
99
|
+
};
|
|
100
|
+
}));
|
|
101
|
+
let diffEntryIndex = -1;
|
|
102
|
+
let indexToInsertInOriginalModel = undefined;
|
|
103
|
+
if (cells.length) {
|
|
104
|
+
for (let i = 0; i < cellDiffInfo.length; i++) {
|
|
105
|
+
const diff = cellDiffInfo[i];
|
|
106
|
+
if (typeof diff.modifiedCellIndex === 'number' && diff.modifiedCellIndex === change[0]) {
|
|
107
|
+
diffEntryIndex = i;
|
|
108
|
+
if (typeof diff.originalCellIndex === 'number') {
|
|
109
|
+
indexToInsertInOriginalModel = diff.originalCellIndex;
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
if (typeof diff.originalCellIndex === 'number') {
|
|
114
|
+
indexToInsertInOriginalModel = diff.originalCellIndex + 1;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const edit = {
|
|
118
|
+
editType: CellEditType.Replace,
|
|
119
|
+
cells,
|
|
120
|
+
index: indexToInsertInOriginalModel ?? 0,
|
|
121
|
+
count: change[1]
|
|
122
|
+
};
|
|
123
|
+
applyEdits([edit], true, undefined, () => undefined, undefined, true);
|
|
124
|
+
}
|
|
125
|
+
if (numberOfCellsDeleted) {
|
|
126
|
+
let numberOfOriginalCellsRemovedSoFar = 0;
|
|
127
|
+
let numberOfModifiedCellsRemovedSoFar = 0;
|
|
128
|
+
const modifiedIndexesToRemove = ( new Set());
|
|
129
|
+
for (let i = 0; i < numberOfCellsDeleted; i++) {
|
|
130
|
+
modifiedIndexesToRemove.add(change[0] + i);
|
|
131
|
+
}
|
|
132
|
+
const itemsToRemove = ( new Set());
|
|
133
|
+
for (let i = 0; i < cellDiffInfo.length; i++) {
|
|
134
|
+
const diff = cellDiffInfo[i];
|
|
135
|
+
if (i < diffEntryIndex) {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
let changed = false;
|
|
139
|
+
if (typeof diff.modifiedCellIndex === 'number' && ( modifiedIndexesToRemove.has(diff.modifiedCellIndex))) {
|
|
140
|
+
numberOfModifiedCellsRemovedSoFar++;
|
|
141
|
+
if (typeof diff.originalCellIndex === 'number') {
|
|
142
|
+
numberOfOriginalCellsRemovedSoFar++;
|
|
143
|
+
}
|
|
144
|
+
itemsToRemove.add(diff);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (typeof diff.modifiedCellIndex === 'number' && numberOfModifiedCellsRemovedSoFar) {
|
|
148
|
+
diff.modifiedCellIndex -= numberOfModifiedCellsRemovedSoFar;
|
|
149
|
+
changed = true;
|
|
150
|
+
}
|
|
151
|
+
if (typeof diff.originalCellIndex === 'number' && numberOfOriginalCellsRemovedSoFar) {
|
|
152
|
+
diff.originalCellIndex -= numberOfOriginalCellsRemovedSoFar;
|
|
153
|
+
changed = true;
|
|
154
|
+
}
|
|
155
|
+
if (changed) {
|
|
156
|
+
cellDiffInfo[i] = { ...diff };
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (itemsToRemove.size) {
|
|
160
|
+
Array.from(itemsToRemove)
|
|
161
|
+
.filter(diff => typeof diff.originalCellIndex === 'number')
|
|
162
|
+
.forEach(diff => {
|
|
163
|
+
const edit = {
|
|
164
|
+
editType: CellEditType.Replace,
|
|
165
|
+
cells: [],
|
|
166
|
+
index: diff.originalCellIndex,
|
|
167
|
+
count: 1
|
|
168
|
+
};
|
|
169
|
+
applyEdits([edit], true, undefined, () => undefined, undefined, true);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
cellDiffInfo = cellDiffInfo.filter(d => !( itemsToRemove.has(d)));
|
|
173
|
+
}
|
|
174
|
+
if (numberOfCellsInserted && diffEntryIndex >= 0) {
|
|
175
|
+
for (let i = 0; i < cellDiffInfo.length; i++) {
|
|
176
|
+
const diff = cellDiffInfo[i];
|
|
177
|
+
if (i < diffEntryIndex) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
let changed = false;
|
|
181
|
+
if (typeof diff.modifiedCellIndex === 'number') {
|
|
182
|
+
diff.modifiedCellIndex += numberOfCellsInserted;
|
|
183
|
+
changed = true;
|
|
184
|
+
}
|
|
185
|
+
if (typeof diff.originalCellIndex === 'number') {
|
|
186
|
+
diff.originalCellIndex += numberOfCellsInserted;
|
|
187
|
+
changed = true;
|
|
188
|
+
}
|
|
189
|
+
if (changed) {
|
|
190
|
+
cellDiffInfo[i] = { ...diff };
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
cells.forEach((_, i) => {
|
|
195
|
+
const originalCellIndex = i + (indexToInsertInOriginalModel ?? 0);
|
|
196
|
+
const modifiedCellIndex = change[0] + i;
|
|
197
|
+
const unchangedCell = createModifiedCellDiffInfo(modifiedCellIndex, originalCellIndex);
|
|
198
|
+
cellDiffInfo.splice((diffEntryIndex === -1 ? cellDiffInfo.length : diffEntryIndex) + i, 0, unchangedCell);
|
|
199
|
+
});
|
|
200
|
+
return cellDiffInfo;
|
|
201
|
+
}
|
|
202
|
+
function adjustCellDiffAndOriginalModelBasedOnCellMovements(event, cellDiffInfo) {
|
|
203
|
+
const minimumIndex = Math.min(event.index, event.newIdx);
|
|
204
|
+
const maximumIndex = Math.max(event.index, event.newIdx);
|
|
205
|
+
const cellDiffs = cellDiffInfo.slice();
|
|
206
|
+
const indexOfEntry = cellDiffs.findIndex(d => d.modifiedCellIndex === event.index);
|
|
207
|
+
const indexOfEntryToPlaceBelow = cellDiffs.findIndex(d => d.modifiedCellIndex === event.newIdx);
|
|
208
|
+
if (indexOfEntry === -1 || indexOfEntryToPlaceBelow === -1) {
|
|
209
|
+
return undefined;
|
|
210
|
+
}
|
|
211
|
+
const entryToBeMoved = { ...cellDiffs[indexOfEntry] };
|
|
212
|
+
const moveDirection = event.newIdx > event.index ? 'down' : 'up';
|
|
213
|
+
const startIndex = cellDiffs.findIndex(d => d.modifiedCellIndex === minimumIndex);
|
|
214
|
+
const endIndex = cellDiffs.findIndex(d => d.modifiedCellIndex === maximumIndex);
|
|
215
|
+
const movingExistingCell = typeof entryToBeMoved.originalCellIndex === 'number';
|
|
216
|
+
let originalCellsWereEffected = false;
|
|
217
|
+
for (let i = 0; i < cellDiffs.length; i++) {
|
|
218
|
+
const diff = cellDiffs[i];
|
|
219
|
+
let changed = false;
|
|
220
|
+
if (moveDirection === 'down') {
|
|
221
|
+
if (i > startIndex && i <= endIndex) {
|
|
222
|
+
if (typeof diff.modifiedCellIndex === 'number') {
|
|
223
|
+
changed = true;
|
|
224
|
+
diff.modifiedCellIndex = diff.modifiedCellIndex - 1;
|
|
225
|
+
}
|
|
226
|
+
if (typeof diff.originalCellIndex === 'number' && movingExistingCell) {
|
|
227
|
+
diff.originalCellIndex = diff.originalCellIndex - 1;
|
|
228
|
+
originalCellsWereEffected = true;
|
|
229
|
+
changed = true;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
if (i >= startIndex && i < endIndex) {
|
|
235
|
+
if (typeof diff.modifiedCellIndex === 'number') {
|
|
236
|
+
changed = true;
|
|
237
|
+
diff.modifiedCellIndex = diff.modifiedCellIndex + 1;
|
|
238
|
+
}
|
|
239
|
+
if (typeof diff.originalCellIndex === 'number' && movingExistingCell) {
|
|
240
|
+
diff.originalCellIndex = diff.originalCellIndex + 1;
|
|
241
|
+
originalCellsWereEffected = true;
|
|
242
|
+
changed = true;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (changed) {
|
|
247
|
+
cellDiffs[i] = { ...diff };
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
entryToBeMoved.modifiedCellIndex = event.newIdx;
|
|
251
|
+
const originalCellIndex = entryToBeMoved.originalCellIndex;
|
|
252
|
+
if (moveDirection === 'down') {
|
|
253
|
+
cellDiffs.splice(endIndex + 1, 0, entryToBeMoved);
|
|
254
|
+
cellDiffs.splice(startIndex, 1);
|
|
255
|
+
if (typeof entryToBeMoved.originalCellIndex === 'number') {
|
|
256
|
+
entryToBeMoved.originalCellIndex = cellDiffs.slice(0, endIndex).reduce((lastOriginalIndex, diff) => typeof diff.originalCellIndex === 'number' ? Math.max(lastOriginalIndex, diff.originalCellIndex) : lastOriginalIndex, -1) + 1;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
cellDiffs.splice(endIndex, 1);
|
|
261
|
+
cellDiffs.splice(startIndex, 0, entryToBeMoved);
|
|
262
|
+
if (typeof entryToBeMoved.originalCellIndex === 'number') {
|
|
263
|
+
entryToBeMoved.originalCellIndex = cellDiffs.slice(0, startIndex).reduce((lastOriginalIndex, diff) => typeof diff.originalCellIndex === 'number' ? Math.max(lastOriginalIndex, diff.originalCellIndex) : lastOriginalIndex, -1) + 1;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
if (typeof entryToBeMoved.originalCellIndex === 'number' && originalCellsWereEffected && typeof originalCellIndex === 'number' && entryToBeMoved.originalCellIndex !== originalCellIndex) {
|
|
267
|
+
const edit = {
|
|
268
|
+
editType: CellEditType.Move,
|
|
269
|
+
index: originalCellIndex,
|
|
270
|
+
length: event.length,
|
|
271
|
+
newIdx: entryToBeMoved.originalCellIndex
|
|
272
|
+
};
|
|
273
|
+
return [cellDiffs, [edit]];
|
|
274
|
+
}
|
|
275
|
+
return [cellDiffs, []];
|
|
276
|
+
}
|
|
277
|
+
function getCorrespondingOriginalCellIndex(modifiedCellIndex, cellDiffInfo) {
|
|
278
|
+
const entry = cellDiffInfo.find(d => d.modifiedCellIndex === modifiedCellIndex);
|
|
279
|
+
return entry?.originalCellIndex;
|
|
280
|
+
}
|
|
281
|
+
function isTransientIPyNbExtensionEvent(notebookKind, e) {
|
|
282
|
+
if (notebookKind !== 'jupyter-notebook') {
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
if (e.rawEvents.every(event => {
|
|
286
|
+
if (event.kind !== NotebookCellsChangeType.ChangeCellMetadata) {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
if (JSON.stringify(event.metadata || {}) === JSON.stringify({ execution_count: null, metadata: {} })) {
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
return true;
|
|
293
|
+
})) {
|
|
294
|
+
return true;
|
|
295
|
+
}
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
function calculateNotebookRewriteRatio(cellsDiff, originalModel, modifiedModel) {
|
|
299
|
+
const totalNumberOfUpdatedLines = cellsDiff.reduce((totalUpdatedLines, value) => {
|
|
300
|
+
const getUpadtedLineCount = () => {
|
|
301
|
+
if (value.type === 'unchanged') {
|
|
302
|
+
return 0;
|
|
303
|
+
}
|
|
304
|
+
if (value.type === 'delete') {
|
|
305
|
+
return originalModel.cells[value.originalCellIndex].textModel?.getLineCount() ?? 0;
|
|
306
|
+
}
|
|
307
|
+
if (value.type === 'insert') {
|
|
308
|
+
return modifiedModel.cells[value.modifiedCellIndex].textModel?.getLineCount() ?? 0;
|
|
309
|
+
}
|
|
310
|
+
return value.diff.get().changes.reduce((maxLineNumber, change) => {
|
|
311
|
+
return Math.max(maxLineNumber, change.modified.endLineNumberExclusive);
|
|
312
|
+
}, 0);
|
|
313
|
+
};
|
|
314
|
+
return totalUpdatedLines + getUpadtedLineCount();
|
|
315
|
+
}, 0);
|
|
316
|
+
const totalNumberOfLines = modifiedModel.cells.reduce((totalLines, cell) => totalLines + (cell.textModel?.getLineCount() ?? 0), 0);
|
|
317
|
+
return totalNumberOfLines === 0 ? 0 : Math.min(1, totalNumberOfUpdatedLines / totalNumberOfLines);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export { adjustCellDiffAndOriginalModelBasedOnCellAddDelete, adjustCellDiffAndOriginalModelBasedOnCellMovements, adjustCellDiffForKeepingAnInsertedCell, adjustCellDiffForRevertingADeletedCell, adjustCellDiffForRevertingAnInsertedCell, calculateNotebookRewriteRatio, getCorrespondingOriginalCellIndex, isTransientIPyNbExtensionEvent };
|
package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/notebookCellChanges.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ISettableObservable, ObservablePromise } from "@codingame/monaco-vscode-api/vscode/vs/base/common/observable";
|
|
2
|
+
import { IDocumentDiff } from "../../../../../../editor/common/diff/documentDiffProvider.js";
|
|
3
|
+
import { DetailedLineRangeMapping } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/diff/rangeMapping";
|
|
4
|
+
import { ITextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
|
|
5
|
+
export type ICellDiffInfo = {
|
|
6
|
+
originalCellIndex: number;
|
|
7
|
+
modifiedCellIndex: number;
|
|
8
|
+
type: "unchanged";
|
|
9
|
+
} & IDocumentDiffWithModelsAndActions | {
|
|
10
|
+
originalCellIndex: number;
|
|
11
|
+
modifiedCellIndex: number;
|
|
12
|
+
type: "modified";
|
|
13
|
+
} & IDocumentDiffWithModelsAndActions | {
|
|
14
|
+
modifiedCellIndex: undefined;
|
|
15
|
+
originalCellIndex: number;
|
|
16
|
+
type: "delete";
|
|
17
|
+
} & IDocumentDiffWithModelsAndActions | {
|
|
18
|
+
modifiedCellIndex: number;
|
|
19
|
+
originalCellIndex: undefined;
|
|
20
|
+
type: "insert";
|
|
21
|
+
} & IDocumentDiffWithModelsAndActions;
|
|
22
|
+
interface IDocumentDiffWithModelsAndActions {
|
|
23
|
+
diff: ISettableObservable<IDocumentDiff>;
|
|
24
|
+
originalModel: ObservablePromise<ITextModel>;
|
|
25
|
+
modifiedModel: ObservablePromise<ITextModel>;
|
|
26
|
+
keep(changes: DetailedLineRangeMapping): Promise<boolean>;
|
|
27
|
+
undo(changes: DetailedLineRangeMapping): Promise<boolean>;
|
|
28
|
+
}
|
|
29
|
+
export declare function countChanges(changes: ICellDiffInfo[]): number;
|
|
30
|
+
export declare function sortCellChanges(changes: ICellDiffInfo[]): ICellDiffInfo[];
|
|
31
|
+
export {};
|
package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/notebookCellChanges.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
function countChanges(changes) {
|
|
4
|
+
return changes.reduce((count, change) => {
|
|
5
|
+
const diff = change.diff.get();
|
|
6
|
+
if (diff.identical) {
|
|
7
|
+
return count;
|
|
8
|
+
}
|
|
9
|
+
switch (change.type) {
|
|
10
|
+
case 'delete':
|
|
11
|
+
return count + 1;
|
|
12
|
+
case 'insert':
|
|
13
|
+
return count + 1;
|
|
14
|
+
case 'modified':
|
|
15
|
+
return count + diff.changes.length;
|
|
16
|
+
default:
|
|
17
|
+
return count;
|
|
18
|
+
}
|
|
19
|
+
}, 0);
|
|
20
|
+
}
|
|
21
|
+
function sortCellChanges(changes) {
|
|
22
|
+
return [...changes].sort((a, b) => {
|
|
23
|
+
if ((a.type === 'unchanged' || a.type === 'modified') &&
|
|
24
|
+
(b.type === 'unchanged' || b.type === 'modified')) {
|
|
25
|
+
return a.modifiedCellIndex - b.modifiedCellIndex;
|
|
26
|
+
}
|
|
27
|
+
if (a.type === 'delete' && b.type === 'delete') {
|
|
28
|
+
return a.originalCellIndex - b.originalCellIndex;
|
|
29
|
+
}
|
|
30
|
+
if (a.type === 'insert' && b.type === 'insert') {
|
|
31
|
+
return a.modifiedCellIndex - b.modifiedCellIndex;
|
|
32
|
+
}
|
|
33
|
+
if (a.type === 'delete' && b.type === 'insert') {
|
|
34
|
+
return -1;
|
|
35
|
+
}
|
|
36
|
+
if (a.type === 'insert' && b.type === 'delete') {
|
|
37
|
+
return 1;
|
|
38
|
+
}
|
|
39
|
+
if ((a.type === 'delete' && b.type !== 'insert') || (a.type !== 'insert' && b.type === 'delete')) {
|
|
40
|
+
return a.originalCellIndex - b.originalCellIndex;
|
|
41
|
+
}
|
|
42
|
+
const aIndex = a.type === 'delete' ? a.originalCellIndex :
|
|
43
|
+
(a.type === 'insert' ? a.modifiedCellIndex : a.modifiedCellIndex);
|
|
44
|
+
const bIndex = b.type === 'delete' ? b.originalCellIndex :
|
|
45
|
+
(b.type === 'insert' ? b.modifiedCellIndex : b.modifiedCellIndex);
|
|
46
|
+
return aIndex - bIndex;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { countChanges, sortCellChanges };
|
|
@@ -9,9 +9,10 @@ import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platfo
|
|
|
9
9
|
import { IThemeService } from "@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service";
|
|
10
10
|
import { EditorPane } from "@codingame/monaco-vscode-12c5f9eb-72d3-57ca-babd-5bef7aa9de3b-common/vscode/vs/workbench/browser/parts/editor/editorPane";
|
|
11
11
|
import { IEditorOpenContext } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor";
|
|
12
|
-
import { ChatEditorInput } from "@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/browser/chatEditorInput";
|
|
13
|
-
import { IExportableChatData, ISerializableChatData } from "@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatModel";
|
|
14
12
|
import { IEditorGroup } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService";
|
|
13
|
+
import { IExportableChatData, ISerializableChatData } from "@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatModel";
|
|
14
|
+
import { IChatService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService.service";
|
|
15
|
+
import { ChatEditorInput } from "@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/browser/chatEditorInput";
|
|
15
16
|
export interface IChatEditorOptions extends IEditorOptions {
|
|
16
17
|
target?: {
|
|
17
18
|
sessionId: string;
|
|
@@ -23,12 +24,13 @@ export declare class ChatEditor extends EditorPane {
|
|
|
23
24
|
private readonly instantiationService;
|
|
24
25
|
private readonly storageService;
|
|
25
26
|
private readonly contextKeyService;
|
|
27
|
+
private readonly chatService;
|
|
26
28
|
private widget;
|
|
27
29
|
private _scopedContextKeyService;
|
|
28
30
|
get scopedContextKeyService(): IScopedContextKeyService;
|
|
29
31
|
private _memento;
|
|
30
32
|
private _viewState;
|
|
31
|
-
constructor(group: IEditorGroup, telemetryService: ITelemetryService, themeService: IThemeService, instantiationService: IInstantiationService, storageService: IStorageService, contextKeyService: IContextKeyService);
|
|
33
|
+
constructor(group: IEditorGroup, telemetryService: ITelemetryService, themeService: IThemeService, instantiationService: IInstantiationService, storageService: IStorageService, contextKeyService: IContextKeyService, chatService: IChatService);
|
|
32
34
|
private clear;
|
|
33
35
|
protected createEditor(parent: HTMLElement): void;
|
|
34
36
|
protected setEditorVisible(visible: boolean): void;
|
|
@@ -20,22 +20,24 @@ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/sear
|
|
|
20
20
|
import { IThemeService } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service';
|
|
21
21
|
import { EditorPane } from '@codingame/monaco-vscode-12c5f9eb-72d3-57ca-babd-5bef7aa9de3b-common/vscode/vs/workbench/browser/parts/editor/editorPane';
|
|
22
22
|
import { Memento } from '@codingame/monaco-vscode-12c5f9eb-72d3-57ca-babd-5bef7aa9de3b-common/vscode/vs/workbench/common/memento';
|
|
23
|
+
import { EDITOR_DRAG_AND_DROP_BACKGROUND } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/theme';
|
|
24
|
+
import { CHAT_PROVIDER_ID } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatParticipantContribTypes';
|
|
25
|
+
import { IChatService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService.service';
|
|
26
|
+
import { ChatAgentLocation, ChatMode } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
|
|
23
27
|
import { clearChatEditor } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/browser/actions/chatClear';
|
|
24
28
|
import { ChatEditorInput } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/browser/chatEditorInput';
|
|
25
29
|
import { ChatWidget } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/browser/chatWidget';
|
|
26
|
-
import { ChatAgentLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents';
|
|
27
|
-
import { CHAT_PROVIDER_ID } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatParticipantContribTypes';
|
|
28
|
-
import { EDITOR_DRAG_AND_DROP_BACKGROUND } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/theme';
|
|
29
30
|
|
|
30
31
|
let ChatEditor = class ChatEditor extends EditorPane {
|
|
31
32
|
get scopedContextKeyService() {
|
|
32
33
|
return this._scopedContextKeyService;
|
|
33
34
|
}
|
|
34
|
-
constructor(group, telemetryService, themeService, instantiationService, storageService, contextKeyService) {
|
|
35
|
+
constructor(group, telemetryService, themeService, instantiationService, storageService, contextKeyService, chatService) {
|
|
35
36
|
super(ChatEditorInput.EditorID, group, telemetryService, themeService, storageService);
|
|
36
37
|
this.instantiationService = instantiationService;
|
|
37
38
|
this.storageService = storageService;
|
|
38
39
|
this.contextKeyService = contextKeyService;
|
|
40
|
+
this.chatService = chatService;
|
|
39
41
|
}
|
|
40
42
|
async clear() {
|
|
41
43
|
if (this.input) {
|
|
@@ -46,7 +48,20 @@ let ChatEditor = class ChatEditor extends EditorPane {
|
|
|
46
48
|
this._scopedContextKeyService = this._register(this.contextKeyService.createScoped(parent));
|
|
47
49
|
const scopedInstantiationService = this._register(this.instantiationService.createChild(( new ServiceCollection([IContextKeyService, this.scopedContextKeyService]))));
|
|
48
50
|
this.widget = this._register(scopedInstantiationService.createInstance(ChatWidget, ChatAgentLocation.Panel, undefined, {
|
|
51
|
+
autoScroll: mode => mode !== ChatMode.Ask,
|
|
52
|
+
renderFollowups: true,
|
|
49
53
|
supportsFileReferences: true,
|
|
54
|
+
supportsAdditionalParticipants: true,
|
|
55
|
+
rendererOptions: {
|
|
56
|
+
renderTextEditsAsSummary: (uri) => {
|
|
57
|
+
return this.chatService.isEditingLocation(ChatAgentLocation.Panel);
|
|
58
|
+
},
|
|
59
|
+
referencesExpandedWhenEmptyResponse: !this.chatService.isEditingLocation(ChatAgentLocation.Panel),
|
|
60
|
+
progressMessageAtBottomOfResponse: mode => mode !== ChatMode.Ask,
|
|
61
|
+
},
|
|
62
|
+
enableImplicitContext: true,
|
|
63
|
+
enableWorkingSet: this.chatService.isEditingLocation(ChatAgentLocation.Panel) ? 'explicit' : undefined,
|
|
64
|
+
supportsChangingModes: this.chatService.isEditingLocation(ChatAgentLocation.Panel),
|
|
50
65
|
}, {
|
|
51
66
|
listForeground: editorForeground,
|
|
52
67
|
listBackground: editorBackground,
|
|
@@ -91,6 +106,7 @@ let ChatEditor = class ChatEditor extends EditorPane {
|
|
|
91
106
|
if (this._memento && this._viewState) {
|
|
92
107
|
const widgetViewState = this.widget.getViewState();
|
|
93
108
|
this._viewState.inputValue = widgetViewState.inputValue;
|
|
109
|
+
this._viewState.inputState = widgetViewState.inputState;
|
|
94
110
|
this._memento.saveMemento();
|
|
95
111
|
}
|
|
96
112
|
}
|
|
@@ -108,7 +124,8 @@ ChatEditor = ( __decorate([
|
|
|
108
124
|
( __param(2, IThemeService)),
|
|
109
125
|
( __param(3, IInstantiationService)),
|
|
110
126
|
( __param(4, IStorageService)),
|
|
111
|
-
( __param(5, IContextKeyService))
|
|
127
|
+
( __param(5, IContextKeyService)),
|
|
128
|
+
( __param(6, IChatService))
|
|
112
129
|
], ChatEditor));
|
|
113
130
|
|
|
114
131
|
export { ChatEditor };
|
|
@@ -2,6 +2,7 @@ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/l
|
|
|
2
2
|
import { IContextKeyService } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service";
|
|
3
3
|
import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
|
|
4
4
|
import { IProductService } from "@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service";
|
|
5
|
+
import { ViewPane } from "@codingame/monaco-vscode-65619f8f-0eab-5d8b-855a-43b6353fe527-common/vscode/vs/workbench/browser/parts/views/viewPane";
|
|
5
6
|
import { IWorkbenchContribution } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions";
|
|
6
7
|
import { IExtensionsWorkbenchService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/extensions/common/extensions.service";
|
|
7
8
|
import { IChatAgentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents.service";
|
|
@@ -20,3 +21,6 @@ export declare class ChatCompatibilityNotifier extends Disposable implements IWo
|
|
|
20
21
|
constructor(extensionsWorkbenchService: IExtensionsWorkbenchService, contextKeyService: IContextKeyService, productService: IProductService);
|
|
21
22
|
private registerWelcomeView;
|
|
22
23
|
}
|
|
24
|
+
export declare class MovedChatEditsViewPane extends ViewPane {
|
|
25
|
+
shouldShowWelcome(): boolean;
|
|
26
|
+
}
|