@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,578 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { Disposable, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
4
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
|
5
|
+
import { debouncedObservable, observableFromEvent } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/utils';
|
|
6
|
+
import { basename } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
7
|
+
import { assertType } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
8
|
+
import { LineRange } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/lineRange';
|
|
9
|
+
import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
|
|
10
|
+
import { nullDocumentDiff } from '../../../../../../editor/common/diff/documentDiffProvider.js';
|
|
11
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
12
|
+
import { AccessibilitySignal } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService';
|
|
13
|
+
import { IAccessibilitySignalService } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService.service';
|
|
14
|
+
import { MenuId } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
15
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
16
|
+
import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
17
|
+
import { NotebookDeletedCellDecorator } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookDeletedCellDecorator';
|
|
18
|
+
import { NotebookInsertedCellDecorator } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInsertedCellDecorator';
|
|
19
|
+
import { NotebookModifiedCellDecorator } from '../../../../notebook/browser/diff/inlineDiff/notebookModifiedCellDecorator.js';
|
|
20
|
+
import { getNotebookEditorFromEditorPane } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
|
|
21
|
+
import { INotebookEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/services/notebookEditorService.service';
|
|
22
|
+
import { CellKind } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
23
|
+
import { IChatAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
|
|
24
|
+
import { ChatAgentLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
|
|
25
|
+
import { ChatEditingCodeEditorIntegration } from '../chatEditingCodeEditorIntegration.js';
|
|
26
|
+
import { sortCellChanges, countChanges } from './notebookCellChanges.js';
|
|
27
|
+
import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/base';
|
|
28
|
+
import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/autorun';
|
|
29
|
+
|
|
30
|
+
let ChatEditingNotebookEditorIntegration = class ChatEditingNotebookEditorIntegration extends Disposable {
|
|
31
|
+
constructor(_entry, editor, notebookModel, originalModel, cellChanges, instantiationService) {
|
|
32
|
+
super();
|
|
33
|
+
this.instantiationService = instantiationService;
|
|
34
|
+
const notebookEditor = getNotebookEditorFromEditorPane(editor);
|
|
35
|
+
assertType(notebookEditor);
|
|
36
|
+
this.notebookEditor = notebookEditor;
|
|
37
|
+
this.integration = this.instantiationService.createInstance(ChatEditingNotebookEditorWidgetIntegration, _entry, notebookEditor, notebookModel, originalModel, cellChanges);
|
|
38
|
+
this._register(editor.onDidChangeControl(() => {
|
|
39
|
+
const notebookEditor = getNotebookEditorFromEditorPane(editor);
|
|
40
|
+
if (notebookEditor && notebookEditor !== this.notebookEditor) {
|
|
41
|
+
this.notebookEditor = notebookEditor;
|
|
42
|
+
this.integration.dispose();
|
|
43
|
+
this.integration = this.instantiationService.createInstance(ChatEditingNotebookEditorWidgetIntegration, _entry, notebookEditor, notebookModel, originalModel, cellChanges);
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
get currentIndex() {
|
|
48
|
+
return this.integration.currentIndex;
|
|
49
|
+
}
|
|
50
|
+
reveal(firstOrLast) {
|
|
51
|
+
return this.integration.reveal(firstOrLast);
|
|
52
|
+
}
|
|
53
|
+
next(wrap) {
|
|
54
|
+
return this.integration.next(wrap);
|
|
55
|
+
}
|
|
56
|
+
previous(wrap) {
|
|
57
|
+
return this.integration.previous(wrap);
|
|
58
|
+
}
|
|
59
|
+
enableAccessibleDiffView() {
|
|
60
|
+
this.integration.enableAccessibleDiffView();
|
|
61
|
+
}
|
|
62
|
+
acceptNearestChange(change) {
|
|
63
|
+
this.integration.acceptNearestChange(change);
|
|
64
|
+
}
|
|
65
|
+
rejectNearestChange(change) {
|
|
66
|
+
this.integration.rejectNearestChange(change);
|
|
67
|
+
}
|
|
68
|
+
toggleDiff(change) {
|
|
69
|
+
return this.integration.toggleDiff(change);
|
|
70
|
+
}
|
|
71
|
+
dispose() {
|
|
72
|
+
this.integration.dispose();
|
|
73
|
+
super.dispose();
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
ChatEditingNotebookEditorIntegration = ( __decorate([
|
|
77
|
+
( __param(5, IInstantiationService))
|
|
78
|
+
], ChatEditingNotebookEditorIntegration));
|
|
79
|
+
let ChatEditingNotebookEditorWidgetIntegration = class ChatEditingNotebookEditorWidgetIntegration extends Disposable {
|
|
80
|
+
constructor(_entry, notebookEditor, notebookModel, originalModel, cellChanges, instantiationService, _editorService, _chatAgentService, notebookEditorService, accessibilitySignalService) {
|
|
81
|
+
super();
|
|
82
|
+
this._entry = _entry;
|
|
83
|
+
this.notebookEditor = notebookEditor;
|
|
84
|
+
this.notebookModel = notebookModel;
|
|
85
|
+
this.cellChanges = cellChanges;
|
|
86
|
+
this.instantiationService = instantiationService;
|
|
87
|
+
this._editorService = _editorService;
|
|
88
|
+
this._chatAgentService = _chatAgentService;
|
|
89
|
+
this.accessibilitySignalService = accessibilitySignalService;
|
|
90
|
+
this._currentIndex = observableValue(this, -1);
|
|
91
|
+
this.currentIndex = this._currentIndex;
|
|
92
|
+
this._currentChange = observableValue(this, undefined);
|
|
93
|
+
this.currentChange = this._currentChange;
|
|
94
|
+
this.cellEditorIntegrations = ( new Map());
|
|
95
|
+
this.mdCellEditorAttached = observableValue(this, -1);
|
|
96
|
+
this.markupCellListeners = ( new Map());
|
|
97
|
+
const onDidChangeVisibleRanges = debouncedObservable(observableFromEvent(notebookEditor.onDidChangeVisibleRanges, () => notebookEditor.visibleRanges), 50);
|
|
98
|
+
this._register(toDisposable(() => {
|
|
99
|
+
this.markupCellListeners.forEach((v) => v.dispose());
|
|
100
|
+
}));
|
|
101
|
+
let originalReadonly = undefined;
|
|
102
|
+
const shouldBeReadonly = ( _entry.isCurrentlyBeingModifiedBy.map(value => !!value));
|
|
103
|
+
this._register(autorun(r => {
|
|
104
|
+
const isReadOnly = shouldBeReadonly.read(r);
|
|
105
|
+
const notebookEditor = notebookEditorService.retrieveExistingWidgetFromURI(_entry.modifiedURI)?.value;
|
|
106
|
+
if (!notebookEditor) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
originalReadonly ??= notebookEditor.isReadOnly;
|
|
110
|
+
if (isReadOnly) {
|
|
111
|
+
notebookEditor.setOptions({ isReadOnly: true });
|
|
112
|
+
}
|
|
113
|
+
else if (originalReadonly === false) {
|
|
114
|
+
notebookEditor.setOptions({ isReadOnly: false });
|
|
115
|
+
const timeout = setTimeout(() => {
|
|
116
|
+
notebookEditor.setOptions({ isReadOnly: true });
|
|
117
|
+
notebookEditor.setOptions({ isReadOnly: false });
|
|
118
|
+
disposable.dispose();
|
|
119
|
+
}, 100);
|
|
120
|
+
const disposable = toDisposable(() => clearTimeout(timeout));
|
|
121
|
+
this._register(disposable);
|
|
122
|
+
}
|
|
123
|
+
}));
|
|
124
|
+
let lastModifyingRequestId;
|
|
125
|
+
this._store.add(autorun(r => {
|
|
126
|
+
if (!_entry.isCurrentlyBeingModifiedBy.read(r)
|
|
127
|
+
&& !_entry.isProcessingResponse.read(r)
|
|
128
|
+
&& lastModifyingRequestId !== _entry.lastModifyingRequestId
|
|
129
|
+
&& ( cellChanges.read(r).some(c => c.type !== 'unchanged' && !c.diff.read(r).identical))) {
|
|
130
|
+
lastModifyingRequestId = _entry.lastModifyingRequestId;
|
|
131
|
+
this.reveal(true);
|
|
132
|
+
}
|
|
133
|
+
}));
|
|
134
|
+
this._register(autorun(r => {
|
|
135
|
+
if (this.notebookEditor.textModel !== this.notebookModel) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const sortedCellChanges = sortCellChanges(cellChanges.read(r));
|
|
139
|
+
const changes = sortedCellChanges.filter(c => c.type !== 'delete');
|
|
140
|
+
onDidChangeVisibleRanges.read(r);
|
|
141
|
+
if (!changes.length) {
|
|
142
|
+
this.cellEditorIntegrations.forEach(({ diff }) => {
|
|
143
|
+
diff.set({ ...diff.get(), ...nullDocumentDiff }, undefined);
|
|
144
|
+
});
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
this.mdCellEditorAttached.read(r);
|
|
148
|
+
const validCells = ( new Set());
|
|
149
|
+
changes.forEach((change) => {
|
|
150
|
+
if (change.modifiedCellIndex === undefined || change.modifiedCellIndex >= notebookModel.cells.length) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const cell = notebookModel.cells[change.modifiedCellIndex];
|
|
154
|
+
const editor = notebookEditor.codeEditors.find(([vm,]) => vm.handle === notebookModel.cells[change.modifiedCellIndex].handle)?.[1];
|
|
155
|
+
const modifiedModel = change.modifiedModel.promiseResult.read(r)?.data;
|
|
156
|
+
const originalModel = change.originalModel.promiseResult.read(r)?.data;
|
|
157
|
+
if (!cell || !originalModel || !modifiedModel) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (!editor) {
|
|
161
|
+
if (!( this.markupCellListeners.has(cell.handle)) && cell.cellKind === CellKind.Markup) {
|
|
162
|
+
const cellModel = this.notebookEditor.getViewModel()?.viewCells.find(c => c.handle === cell.handle);
|
|
163
|
+
if (cellModel) {
|
|
164
|
+
const listener = cellModel.onDidChangeEditorAttachState(() => {
|
|
165
|
+
if (cellModel.editorAttached) {
|
|
166
|
+
this.mdCellEditorAttached.set(cell.handle, undefined);
|
|
167
|
+
listener.dispose();
|
|
168
|
+
this.markupCellListeners.delete(cell.handle);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
this.markupCellListeners.set(cell.handle, listener);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const diff = {
|
|
177
|
+
...change.diff.read(r),
|
|
178
|
+
modifiedModel,
|
|
179
|
+
originalModel,
|
|
180
|
+
keep: change.keep,
|
|
181
|
+
undo: change.undo
|
|
182
|
+
};
|
|
183
|
+
validCells.add(cell);
|
|
184
|
+
const currentDiff = this.cellEditorIntegrations.get(cell);
|
|
185
|
+
if (currentDiff) {
|
|
186
|
+
if (!areDocumentDiff2Equal(currentDiff.diff.get(), diff)) {
|
|
187
|
+
currentDiff.diff.set(diff, undefined);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
const diff2 = observableValue(`diff${cell.handle}`, diff);
|
|
192
|
+
const integration = this.instantiationService.createInstance(ChatEditingCodeEditorIntegration, _entry, editor, diff2);
|
|
193
|
+
this.cellEditorIntegrations.set(cell, { integration, diff: diff2 });
|
|
194
|
+
this._register(integration);
|
|
195
|
+
this._register(editor.onDidDispose(() => {
|
|
196
|
+
this.cellEditorIntegrations.get(cell)?.integration.dispose();
|
|
197
|
+
this.cellEditorIntegrations.delete(cell);
|
|
198
|
+
}));
|
|
199
|
+
this._register(editor.onDidChangeModel(() => {
|
|
200
|
+
if (editor.getModel() !== cell.textModel) {
|
|
201
|
+
this.cellEditorIntegrations.get(cell)?.integration.dispose();
|
|
202
|
+
this.cellEditorIntegrations.delete(cell);
|
|
203
|
+
}
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
this.cellEditorIntegrations.forEach((v, cell) => {
|
|
208
|
+
if (!( validCells.has(cell))) {
|
|
209
|
+
v.integration.dispose();
|
|
210
|
+
this.cellEditorIntegrations.delete(cell);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}));
|
|
214
|
+
this._register(autorun(r => {
|
|
215
|
+
const currentChange = this.currentChange.read(r);
|
|
216
|
+
if (!currentChange) {
|
|
217
|
+
this._currentIndex.set(-1, undefined);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
let index = 0;
|
|
221
|
+
const sortedCellChanges = sortCellChanges(cellChanges.read(r));
|
|
222
|
+
for (const change of sortedCellChanges) {
|
|
223
|
+
if (currentChange && currentChange.change === change) {
|
|
224
|
+
if (change.type === 'modified') {
|
|
225
|
+
index += currentChange.index;
|
|
226
|
+
}
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
if (change.type === 'insert' || change.type === 'delete') {
|
|
230
|
+
index++;
|
|
231
|
+
}
|
|
232
|
+
else if (change.type === 'modified') {
|
|
233
|
+
index += change.diff.read(r).changes.length;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
this._currentIndex.set(index, undefined);
|
|
237
|
+
}));
|
|
238
|
+
const cellsAreVisible = ( onDidChangeVisibleRanges.map(v => v.length > 0));
|
|
239
|
+
const debouncedChanges = debouncedObservable(cellChanges, 10);
|
|
240
|
+
this._register(autorun(r => {
|
|
241
|
+
if (this.notebookEditor.textModel !== this.notebookModel || !cellsAreVisible.read(r) || !this.notebookEditor.getViewModel()) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const changes = debouncedChanges.read(r).filter(c => c.type === 'insert' ? !c.diff.read(r).identical : true);
|
|
245
|
+
const modifiedChanges = changes.filter(c => c.type === 'modified');
|
|
246
|
+
this.createDecorators();
|
|
247
|
+
this.insertedCellDecorator?.apply(changes);
|
|
248
|
+
this.modifiedCellDecorator?.apply(modifiedChanges);
|
|
249
|
+
this.deletedCellDecorator?.apply(changes, originalModel);
|
|
250
|
+
}));
|
|
251
|
+
}
|
|
252
|
+
createDecorators() {
|
|
253
|
+
const cellChanges = this.cellChanges.get();
|
|
254
|
+
const accessibilitySignalService = this.accessibilitySignalService;
|
|
255
|
+
this.insertedCellDecorator ??= this._register(this.instantiationService.createInstance(NotebookInsertedCellDecorator, this.notebookEditor));
|
|
256
|
+
this.modifiedCellDecorator ??= this._register(this.instantiationService.createInstance(NotebookModifiedCellDecorator, this.notebookEditor));
|
|
257
|
+
if (this.deletedCellDecorator) {
|
|
258
|
+
this._store.delete(this.deletedCellDecorator);
|
|
259
|
+
this.deletedCellDecorator.dispose();
|
|
260
|
+
}
|
|
261
|
+
this.deletedCellDecorator = this._register(this.instantiationService.createInstance(NotebookDeletedCellDecorator, this.notebookEditor, {
|
|
262
|
+
className: 'chat-diff-change-content-widget',
|
|
263
|
+
telemetrySource: 'chatEditingNotebookHunk',
|
|
264
|
+
menuId: MenuId.ChatEditingEditorHunk,
|
|
265
|
+
argFactory: (deletedCellIndex) => {
|
|
266
|
+
return {
|
|
267
|
+
accept() {
|
|
268
|
+
const entry = cellChanges.find(c => c.type === 'delete' && c.originalCellIndex === deletedCellIndex);
|
|
269
|
+
if (entry) {
|
|
270
|
+
return entry.keep(entry.diff.get().changes[0]);
|
|
271
|
+
}
|
|
272
|
+
accessibilitySignalService.playSignal(AccessibilitySignal.editsKept, { allowManyInParallel: true });
|
|
273
|
+
return Promise.resolve(true);
|
|
274
|
+
},
|
|
275
|
+
reject() {
|
|
276
|
+
const entry = cellChanges.find(c => c.type === 'delete' && c.originalCellIndex === deletedCellIndex);
|
|
277
|
+
if (entry) {
|
|
278
|
+
return entry.undo(entry.diff.get().changes[0]);
|
|
279
|
+
}
|
|
280
|
+
accessibilitySignalService.playSignal(AccessibilitySignal.editsUndone, { allowManyInParallel: true });
|
|
281
|
+
return Promise.resolve(true);
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
}));
|
|
286
|
+
}
|
|
287
|
+
getCell(modifiedCellIndex) {
|
|
288
|
+
const cell = this.notebookModel.cells[modifiedCellIndex];
|
|
289
|
+
const integration = this.cellEditorIntegrations.get(cell)?.integration;
|
|
290
|
+
return integration;
|
|
291
|
+
}
|
|
292
|
+
reveal(firstOrLast) {
|
|
293
|
+
const changes = sortCellChanges(this.cellChanges.get().filter(c => c.type !== 'unchanged'));
|
|
294
|
+
if (!changes.length) {
|
|
295
|
+
return undefined;
|
|
296
|
+
}
|
|
297
|
+
const change = firstOrLast ? changes[0] : changes[changes.length - 1];
|
|
298
|
+
this._revealFirstOrLast(change, firstOrLast);
|
|
299
|
+
}
|
|
300
|
+
_revealFirstOrLast(change, firstOrLast = true) {
|
|
301
|
+
switch (change.type) {
|
|
302
|
+
case 'insert':
|
|
303
|
+
case 'modified':
|
|
304
|
+
{
|
|
305
|
+
const index = firstOrLast || change.type === 'insert' ? 0 : change.diff.get().changes.length - 1;
|
|
306
|
+
const cellIntegration = this.getCell(change.modifiedCellIndex);
|
|
307
|
+
if (cellIntegration) {
|
|
308
|
+
cellIntegration.reveal(firstOrLast);
|
|
309
|
+
this._currentChange.set({ change: change, index }, undefined);
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
return this._revealChange(change, index);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
case 'delete':
|
|
317
|
+
this.deletedCellDecorator?.reveal(change.originalCellIndex);
|
|
318
|
+
this._currentChange.set({ change: change, index: 0 }, undefined);
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
_revealChange(change, indexInCell) {
|
|
324
|
+
switch (change.type) {
|
|
325
|
+
case 'insert':
|
|
326
|
+
case 'modified':
|
|
327
|
+
{
|
|
328
|
+
const textChange = change.diff.get().changes[indexInCell];
|
|
329
|
+
const cellViewModel = this.getCellViewModel(change);
|
|
330
|
+
if (cellViewModel) {
|
|
331
|
+
this.revealChangeInView(cellViewModel, textChange?.modified);
|
|
332
|
+
this._currentChange.set({ change: change, index: indexInCell }, undefined);
|
|
333
|
+
}
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
336
|
+
case 'delete':
|
|
337
|
+
this.deletedCellDecorator?.reveal(change.originalCellIndex);
|
|
338
|
+
this._currentChange.set({ change: change, index: 0 }, undefined);
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
getCellViewModel(change) {
|
|
344
|
+
if (change.type === 'delete' || change.modifiedCellIndex === undefined) {
|
|
345
|
+
return undefined;
|
|
346
|
+
}
|
|
347
|
+
const cell = this.notebookModel.cells[change.modifiedCellIndex];
|
|
348
|
+
const cellViewModel = this.notebookEditor.getViewModel()?.viewCells.find(c => c.handle === cell.handle);
|
|
349
|
+
return cellViewModel;
|
|
350
|
+
}
|
|
351
|
+
async revealChangeInView(cell, lines) {
|
|
352
|
+
const targetLines = lines ?? ( new LineRange(0, 0));
|
|
353
|
+
await this.notebookEditor.focusNotebookCell(cell, 'container', { focusEditorLine: targetLines.startLineNumber });
|
|
354
|
+
await this.notebookEditor.revealRangeInCenterAsync(cell, ( new Range(targetLines.startLineNumber, 0, targetLines.endLineNumberExclusive, 0)));
|
|
355
|
+
}
|
|
356
|
+
next(wrap) {
|
|
357
|
+
const changes = sortCellChanges(this.cellChanges.get().filter(c => c.type !== 'unchanged'));
|
|
358
|
+
const currentChange = this.currentChange.get();
|
|
359
|
+
if (!currentChange) {
|
|
360
|
+
const firstChange = changes[0];
|
|
361
|
+
if (firstChange) {
|
|
362
|
+
return this._revealFirstOrLast(firstChange);
|
|
363
|
+
}
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
switch (currentChange.change.type) {
|
|
367
|
+
case 'modified':
|
|
368
|
+
{
|
|
369
|
+
const cellIntegration = this.getCell(currentChange.change.modifiedCellIndex);
|
|
370
|
+
if (cellIntegration) {
|
|
371
|
+
if (cellIntegration.next(false)) {
|
|
372
|
+
this._currentChange.set({ change: currentChange.change, index: cellIntegration.currentIndex.get() }, undefined);
|
|
373
|
+
return true;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
const isLastChangeInCell = currentChange.index === lastChangeIndex(currentChange.change);
|
|
377
|
+
const index = isLastChangeInCell ? 0 : currentChange.index + 1;
|
|
378
|
+
const change = isLastChangeInCell ? changes[changes.indexOf(currentChange.change) + 1] : currentChange.change;
|
|
379
|
+
if (change) {
|
|
380
|
+
return this._revealChange(change, index);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
break;
|
|
384
|
+
case 'insert':
|
|
385
|
+
case 'delete':
|
|
386
|
+
{
|
|
387
|
+
const nextChange = changes[changes.indexOf(currentChange.change) + 1];
|
|
388
|
+
if (nextChange) {
|
|
389
|
+
return this._revealFirstOrLast(nextChange, true);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
if (wrap) {
|
|
395
|
+
return this.next(false);
|
|
396
|
+
}
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
previous(wrap) {
|
|
400
|
+
const changes = sortCellChanges(this.cellChanges.get().filter(c => c.type !== 'unchanged'));
|
|
401
|
+
const currentChange = this.currentChange.get();
|
|
402
|
+
if (!currentChange) {
|
|
403
|
+
const lastChange = changes[changes.length - 1];
|
|
404
|
+
if (lastChange) {
|
|
405
|
+
return this._revealFirstOrLast(lastChange, false);
|
|
406
|
+
}
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
switch (currentChange.change.type) {
|
|
410
|
+
case 'modified':
|
|
411
|
+
{
|
|
412
|
+
const cellIntegration = this.getCell(currentChange.change.modifiedCellIndex);
|
|
413
|
+
if (cellIntegration) {
|
|
414
|
+
if (cellIntegration.previous(false)) {
|
|
415
|
+
this._currentChange.set({ change: currentChange.change, index: cellIntegration.currentIndex.get() }, undefined);
|
|
416
|
+
return true;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
const isFirstChangeInCell = currentChange.index === 0;
|
|
420
|
+
const change = isFirstChangeInCell ? changes[changes.indexOf(currentChange.change) - 1] : currentChange.change;
|
|
421
|
+
if (change) {
|
|
422
|
+
const index = isFirstChangeInCell ? lastChangeIndex(change) : currentChange.index - 1;
|
|
423
|
+
return this._revealChange(change, index);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
break;
|
|
427
|
+
case 'insert':
|
|
428
|
+
case 'delete':
|
|
429
|
+
{
|
|
430
|
+
const prevChange = changes[changes.indexOf(currentChange.change) - 1];
|
|
431
|
+
if (prevChange) {
|
|
432
|
+
return this._revealFirstOrLast(prevChange, false);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
if (wrap) {
|
|
438
|
+
const lastChange = changes[changes.length - 1];
|
|
439
|
+
if (lastChange) {
|
|
440
|
+
return this._revealFirstOrLast(lastChange, false);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
return false;
|
|
444
|
+
}
|
|
445
|
+
enableAccessibleDiffView() {
|
|
446
|
+
const cell = this.notebookEditor.getActiveCell()?.model;
|
|
447
|
+
if (cell) {
|
|
448
|
+
const integration = this.cellEditorIntegrations.get(cell)?.integration;
|
|
449
|
+
integration?.enableAccessibleDiffView();
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
acceptNearestChange(change) {
|
|
453
|
+
change.accept();
|
|
454
|
+
this.next(true);
|
|
455
|
+
}
|
|
456
|
+
rejectNearestChange(change) {
|
|
457
|
+
change.reject();
|
|
458
|
+
this.next(true);
|
|
459
|
+
}
|
|
460
|
+
async toggleDiff(_change) {
|
|
461
|
+
const defaultAgentName = this._chatAgentService.getDefaultAgent(ChatAgentLocation.EditingSession)?.fullName;
|
|
462
|
+
const diffInput = {
|
|
463
|
+
original: { resource: this._entry.originalURI, options: { selection: undefined } },
|
|
464
|
+
modified: { resource: this._entry.modifiedURI, options: { selection: undefined } },
|
|
465
|
+
label: defaultAgentName
|
|
466
|
+
? ( localize(
|
|
467
|
+
4695,
|
|
468
|
+
'{0} (changes from {1})',
|
|
469
|
+
basename(this._entry.modifiedURI),
|
|
470
|
+
defaultAgentName
|
|
471
|
+
))
|
|
472
|
+
: ( localize(4696, '{0} (changes from chat)', basename(this._entry.modifiedURI)))
|
|
473
|
+
};
|
|
474
|
+
await this._editorService.openEditor(diffInput);
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
ChatEditingNotebookEditorWidgetIntegration = ( __decorate([
|
|
478
|
+
( __param(5, IInstantiationService)),
|
|
479
|
+
( __param(6, IEditorService)),
|
|
480
|
+
( __param(7, IChatAgentService)),
|
|
481
|
+
( __param(8, INotebookEditorService)),
|
|
482
|
+
( __param(9, IAccessibilitySignalService))
|
|
483
|
+
], ChatEditingNotebookEditorWidgetIntegration));
|
|
484
|
+
class ChatEditingNotebookDiffEditorIntegration extends Disposable {
|
|
485
|
+
constructor(notebookDiffEditor, cellChanges) {
|
|
486
|
+
super();
|
|
487
|
+
this.notebookDiffEditor = notebookDiffEditor;
|
|
488
|
+
this.cellChanges = cellChanges;
|
|
489
|
+
this._currentIndex = observableValue(this, -1);
|
|
490
|
+
this.currentIndex = this._currentIndex;
|
|
491
|
+
this._store.add(autorun(r => {
|
|
492
|
+
const index = notebookDiffEditor.currentChangedIndex.read(r);
|
|
493
|
+
const numberOfCellChanges = cellChanges.read(r).filter(c => !c.diff.read(r).identical);
|
|
494
|
+
if (numberOfCellChanges.length && index >= 0 && index < numberOfCellChanges.length) {
|
|
495
|
+
const changesSoFar = countChanges(numberOfCellChanges.slice(0, index + 1));
|
|
496
|
+
this._currentIndex.set(changesSoFar - 1, undefined);
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
this._currentIndex.set(-1, undefined);
|
|
500
|
+
}
|
|
501
|
+
}));
|
|
502
|
+
}
|
|
503
|
+
reveal(firstOrLast) {
|
|
504
|
+
const changes = sortCellChanges(this.cellChanges.get().filter(c => c.type !== 'unchanged'));
|
|
505
|
+
if (!changes.length) {
|
|
506
|
+
return undefined;
|
|
507
|
+
}
|
|
508
|
+
if (firstOrLast) {
|
|
509
|
+
this.notebookDiffEditor.firstChange();
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
this.notebookDiffEditor.lastChange();
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
next(_wrap) {
|
|
516
|
+
const changes = this.cellChanges.get().filter(c => !c.diff.get().identical).length;
|
|
517
|
+
if (this.notebookDiffEditor.currentChangedIndex.get() === changes - 1) {
|
|
518
|
+
return false;
|
|
519
|
+
}
|
|
520
|
+
this.notebookDiffEditor.nextChange();
|
|
521
|
+
return true;
|
|
522
|
+
}
|
|
523
|
+
previous(_wrap) {
|
|
524
|
+
const changes = this.cellChanges.get().filter(c => !c.diff.get().identical).length;
|
|
525
|
+
if (this.notebookDiffEditor.currentChangedIndex.get() === changes - 1) {
|
|
526
|
+
return false;
|
|
527
|
+
}
|
|
528
|
+
this.notebookDiffEditor.nextChange();
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
enableAccessibleDiffView() {
|
|
532
|
+
}
|
|
533
|
+
acceptNearestChange(change) {
|
|
534
|
+
change.accept();
|
|
535
|
+
this.next(true);
|
|
536
|
+
}
|
|
537
|
+
rejectNearestChange(change) {
|
|
538
|
+
change.reject();
|
|
539
|
+
this.next(true);
|
|
540
|
+
}
|
|
541
|
+
async toggleDiff(_change) {
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
function areDocumentDiff2Equal(diff1, diff2) {
|
|
545
|
+
if (diff1.changes !== diff2.changes) {
|
|
546
|
+
return false;
|
|
547
|
+
}
|
|
548
|
+
if (diff1.identical !== diff2.identical) {
|
|
549
|
+
return false;
|
|
550
|
+
}
|
|
551
|
+
if (diff1.moves !== diff2.moves) {
|
|
552
|
+
return false;
|
|
553
|
+
}
|
|
554
|
+
if (diff1.originalModel !== diff2.originalModel) {
|
|
555
|
+
return false;
|
|
556
|
+
}
|
|
557
|
+
if (diff1.modifiedModel !== diff2.modifiedModel) {
|
|
558
|
+
return false;
|
|
559
|
+
}
|
|
560
|
+
if (diff1.keep !== diff2.keep) {
|
|
561
|
+
return false;
|
|
562
|
+
}
|
|
563
|
+
if (diff1.undo !== diff2.undo) {
|
|
564
|
+
return false;
|
|
565
|
+
}
|
|
566
|
+
if (diff1.quitEarly !== diff2.quitEarly) {
|
|
567
|
+
return false;
|
|
568
|
+
}
|
|
569
|
+
return true;
|
|
570
|
+
}
|
|
571
|
+
function lastChangeIndex(change) {
|
|
572
|
+
if (change.type === 'modified') {
|
|
573
|
+
return change.diff.get().changes.length - 1;
|
|
574
|
+
}
|
|
575
|
+
return 0;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
export { ChatEditingNotebookDiffEditorIntegration, ChatEditingNotebookEditorIntegration };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { VSBuffer } from "@codingame/monaco-vscode-api/vscode/vs/base/common/buffer";
|
|
2
|
+
import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
|
|
3
|
+
import { Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event";
|
|
4
|
+
import { Disposable, IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
5
|
+
import { ReadableStreamEvents } from "@codingame/monaco-vscode-api/vscode/vs/base/common/stream";
|
|
6
|
+
import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
|
7
|
+
import { FileSystemProviderCapabilities, FileType, IFileChange, IFileDeleteOptions, IFileOpenOptions, IFileOverwriteOptions, IFileReadStreamOptions, IFileSystemProvider, IFileWriteOptions, IStat, IWatchOptions } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files";
|
|
8
|
+
import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
|
|
9
|
+
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
10
|
+
import { IWorkbenchContribution } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions";
|
|
11
|
+
import { INotebookService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService.service";
|
|
12
|
+
import { IChatEditingService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService.service";
|
|
13
|
+
export declare class ChatEditingNotebookFileSystemProviderContrib extends Disposable implements IWorkbenchContribution {
|
|
14
|
+
private readonly fileService;
|
|
15
|
+
static ID: string;
|
|
16
|
+
constructor(fileService: IFileService, instantiationService: IInstantiationService);
|
|
17
|
+
}
|
|
18
|
+
export declare class ChatEditingNotebookFileSystemProvider implements IFileSystemProvider {
|
|
19
|
+
private readonly _chatEditingService;
|
|
20
|
+
private readonly notebookService;
|
|
21
|
+
private static registeredFiles;
|
|
22
|
+
readonly capabilities: FileSystemProviderCapabilities;
|
|
23
|
+
static registerFile(resource: URI, buffer: VSBuffer): IDisposable;
|
|
24
|
+
constructor(_chatEditingService: IChatEditingService, notebookService: INotebookService);
|
|
25
|
+
readonly onDidChangeCapabilities: Event<any>;
|
|
26
|
+
readonly onDidChangeFile: Event<readonly IFileChange[]>;
|
|
27
|
+
watch(_resource: URI, _opts: IWatchOptions): IDisposable;
|
|
28
|
+
stat(_resource: URI): Promise<IStat>;
|
|
29
|
+
mkdir(_resource: URI): Promise<void>;
|
|
30
|
+
readdir(_resource: URI): Promise<[
|
|
31
|
+
string,
|
|
32
|
+
FileType
|
|
33
|
+
][]>;
|
|
34
|
+
delete(_resource: URI, _opts: IFileDeleteOptions): Promise<void>;
|
|
35
|
+
rename(_from: URI, _to: URI, _opts: IFileOverwriteOptions): Promise<void>;
|
|
36
|
+
copy?(_from: URI, _to: URI, _opts: IFileOverwriteOptions): Promise<void>;
|
|
37
|
+
readFile(resource: URI): Promise<Uint8Array>;
|
|
38
|
+
writeFile?(__resource: URI, _content: Uint8Array, _opts: IFileWriteOptions): Promise<void>;
|
|
39
|
+
readFileStream?(__resource: URI, _opts: IFileReadStreamOptions, _token: CancellationToken): ReadableStreamEvents<Uint8Array>;
|
|
40
|
+
open?(__resource: URI, _opts: IFileOpenOptions): Promise<number>;
|
|
41
|
+
close?(_fd: number): Promise<void>;
|
|
42
|
+
read?(_fd: number, _pos: number, _data: Uint8Array, _offset: number, _length: number): Promise<number>;
|
|
43
|
+
write?(_fd: number, _pos: number, _data: Uint8Array, _offset: number, _length: number): Promise<number>;
|
|
44
|
+
cloneFile?(_from: URI, __to: URI): Promise<void>;
|
|
45
|
+
}
|