@codingame/monaco-vscode-api 1.85.0 → 1.85.1
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/README.md +19 -10
- package/contributions.js +1 -0
- package/missing-services.js +91 -5
- package/monaco-editor-treemending.patch +957 -950
- package/package.json +6 -6
- package/vscode/src/vs/base/common/jsonFormatter.js +8 -1
- package/vscode/src/vs/platform/actions/browser/buttonbar.js +128 -0
- package/vscode/src/vs/platform/extensionManagement/common/extensionManagement.js +2 -1
- package/vscode/src/vs/platform/layout/browser/zIndexRegistry.js +58 -0
- package/vscode/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.js +56 -1
- package/vscode/src/vs/workbench/browser/actions/layoutActions.js +186 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +191 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatActions.js +238 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.js +75 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +205 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorInput.js +168 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatFollowups.js +35 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatInputPart.js +340 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatListRenderer.js +1195 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatMarkdownDecorationsRenderer.js +115 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatOptions.js +81 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSlashCommandContentWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSlashCommandContentWidget.js +62 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatWidget.js +583 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockPart.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockPart.js +290 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables.js +167 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chat.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatContextKeys.js +6 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatModel.js +562 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatParserTypes.js +31 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatProvider.js +24 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatRequestParser.js +193 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatService.js +22 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +52 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatViewModel.js +258 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +37 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatWordCounter.js +25 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.js +388 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentColors.js +61 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentFormActions.js +49 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentNode.js +647 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentReply.js +300 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadAdditionalActions.js +60 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadBody.js +249 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadHeader.js +107 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadWidget.js +333 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/media/review.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/reactionsAction.js +99 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/timestamp.js +55 -0
- package/vscode/src/vs/workbench/contrib/comments/common/commentsConfiguration.js +2 -0
- package/vscode/src/vs/workbench/contrib/contextmenu/browser/contextmenu.contribution.js +20 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointEditorContribution.js +855 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointWidget.js +410 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointsView.js +1591 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/callStackEditorContribution.js +178 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/media/breakpointWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/media/callStackEditorContribution.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/debug/common/debugModel.js +1485 -0
- package/vscode/src/vs/workbench/contrib/debug/common/debugSource.js +125 -0
- package/vscode/src/vs/workbench/contrib/debug/common/disassemblyViewInput.js +29 -0
- package/vscode/src/vs/workbench/contrib/extensions/common/extensionsInput.js +41 -0
- package/vscode/src/vs/workbench/contrib/extensions/common/extensionsUtils.js +102 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.js +988 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatLivePreviewWidget.js +431 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSession.js +417 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatStrategies.js +806 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.js +915 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/utils.js +19 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChat.js +129 -10
- package/vscode/src/vs/workbench/contrib/markdown/browser/markdownDocumentRenderer.js +205 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.js +150 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInputModel.js +480 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeMarkers/mergeMarkersController.js +5 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/diffComputer.js +90 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/editing.js +54 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/lineRange.js +108 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mapping.js +258 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel.js +614 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/modifiedBaseRange.js +307 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/rangeUtils.js +44 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/textModelDiffs.js +165 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/telemetry.js +78 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/utils.js +169 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/common/mergeEditor.js +64 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/cellOutputClipboard.js +49 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/findFilters.js +70 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/findMatchDecorationModel.js +120 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.js +416 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.js +663 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.js +593 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOutputActions.js +72 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/coreActions.js +326 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/editActions.js +539 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/foldingController.js +265 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +348 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebook.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellChat.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellEditorHint.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellInsertToolbar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellOutput.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellStatusBar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellTitleToolbar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookDnd.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookEditorStickyScroll.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookFocusIndicator.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookFolding.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookKernelActionViewItem.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookOutline.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookToolbar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookBrowser.js +95 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditor.js +437 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditorExtensions.js +29 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.js +2730 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookIcons.js +139 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookLogger.js +17 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookOptions.js +564 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookViewEvents.js +27 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellPart.js +119 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellActionView.js +27 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellComments.js +135 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellContextKeys.js +178 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDecorations.js +35 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDnd.js +377 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDragRenderer.js +97 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellEditorOptions.js +194 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellExecution.js +71 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellFocus.js +20 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellFocusIndicator.js +85 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellOutput.js +652 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellProgressBar.js +59 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellStatusPart.js +303 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbarStickyScroll.js +24 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbars.js +228 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatActions.js +302 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatController.js +438 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatPart.js +45 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCell.js +435 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCellExecutionIcon.js +95 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCellRunToolbar.js +107 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/collapsedCellInput.js +29 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/collapsedCellOutput.js +59 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/foldedCellHint.js +67 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/markupCell.js +430 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/notebookCellAnchor.js +54 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.js +1131 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/notebookCellListView.js +21 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.js +1591 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.js +341 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/webviewPreloads.js +2155 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/webviewThemeMapping.js +65 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/OutlineEntry.js +95 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.js +507 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/cellEditorOptions.js +85 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/cellOutputViewModel.js +47 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/cellSelectionCollection.js +40 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.js +435 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/eventDispatcher.js +31 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/foldingModel.js +257 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/markupCellViewModel.js +239 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.js +103 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineProvider.js +211 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl.js +808 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/viewContext.js +8 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorStickyScroll.js +381 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorToolbar.js +527 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorWidgetContextKeys.js +163 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookKernelQuickPickStrategy.js +651 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookKernelView.js +173 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookOverviewRuler.js +98 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookTopCellToolbar.js +62 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookCellOutputTextModel.js +101 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.js +346 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookCommon.js +152 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookContextKeys.js +39 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorInput.js +296 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModel.js +261 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookExecutionService.js +3 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookKernelService.js +2 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookKeymapService.js +3 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookLoggingService.js +3 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookPerformance.js +16 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookRange.js +66 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookWorkerService.js +4 -0
- package/vscode/src/vs/workbench/contrib/preferences/common/settingsEditorColorRegistry.js +130 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/media/tunnelView.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/remoteExplorer.js +847 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/remoteIcons.js +89 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/tunnelView.js +1942 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/urlFinder.js +107 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsBase.js +49 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsFind.js +387 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchModel.js +2 -2
- package/vscode/src/vs/workbench/contrib/search/common/constants.js +66 -0
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/constants.js +11 -0
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/abstractSnippetsActions.js +24 -0
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/fileTemplateSnippets.js +95 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminal.js +4 -1
- package/vscode/src/vs/workbench/contrib/terminal/common/terminal.js +2 -1
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/featuredExtensionService.js +159 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedExtensionPoint.js +375 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.js +563 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/common/gettingStartedContent.js +932 -0
- package/vscode/src/vs/workbench/services/layout/browser/layoutService.js +15 -1
- package/vscode/src/vs/workbench/services/remote/common/remoteExplorerService.d.ts +2 -2
- package/vscode/src/vs/workbench/services/remote/common/remoteExplorerService.js +190 -2
- package/vscode/src/vs/workbench/services/workingCopy/common/resourceWorkingCopy.js +77 -0
- package/assets/break.mp3 +0 -0
- package/assets/chatRequestSent.mp3 +0 -0
- package/assets/chatResponsePending.mp3 +0 -0
- package/assets/chatResponseReceived1.mp3 +0 -0
- package/assets/chatResponseReceived2.mp3 +0 -0
- package/assets/chatResponseReceived3.mp3 +0 -0
- package/assets/chatResponseReceived4.mp3 +0 -0
- package/assets/clear.mp3 +0 -0
- package/assets/defaultIcon.png +0 -0
- package/assets/diffLineDeleted.mp3 +0 -0
- package/assets/diffLineInserted.mp3 +0 -0
- package/assets/diffLineModified.mp3 +0 -0
- package/assets/error.mp3 +0 -0
- package/assets/fake.html +0 -10
- package/assets/foldedAreas.mp3 +0 -0
- package/assets/format.mp3 +0 -0
- package/assets/index-no-csp.html +0 -1226
- package/assets/index.html +0 -1227
- package/assets/quickFixes.mp3 +0 -0
- package/assets/save.mp3 +0 -0
- package/assets/service-worker.js +0 -457
- package/assets/taskCompleted.mp3 +0 -0
- package/assets/taskFailed.mp3 +0 -0
- package/assets/terminalBell.mp3 +0 -0
- package/assets/warning.mp3 +0 -0
- package/assets/webWorkerExtensionHostIframe.html +0 -123
- package/override/vs/workbench/contrib/notebook/browser/contrib/find/findMatchDecorationModel.js +0 -2
- package/override/vs/workbench/contrib/notebook/browser/notebookEditorWidget.js +0 -2
- package/override/vs/workbench/contrib/notebook/common/notebookEditorInput.js +0 -5
package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatController.js
ADDED
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { h, Dimension } from 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
3
|
+
import { createCancelablePromise, raceCancellationError, Queue } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
4
|
+
import { CancellationTokenSource } from 'monaco-editor/esm/vs/base/common/cancellation.js';
|
|
5
|
+
import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
6
|
+
import { MarkdownString } from 'monaco-editor/esm/vs/base/common/htmlContent.js';
|
|
7
|
+
import { Disposable, DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
8
|
+
import { MovingAverage } from 'monaco-editor/esm/vs/base/common/numbers.js';
|
|
9
|
+
import { StopWatch } from 'monaco-editor/esm/vs/base/common/stopwatch.js';
|
|
10
|
+
import { assertType } from 'monaco-editor/esm/vs/base/common/types.js';
|
|
11
|
+
import { generateUuid } from 'monaco-editor/esm/vs/base/common/uuid.js';
|
|
12
|
+
import { Selection } from 'monaco-editor/esm/vs/editor/common/core/selection.js';
|
|
13
|
+
import { TextEdit } from 'monaco-editor/esm/vs/editor/common/languages.js';
|
|
14
|
+
import { IEditorWorkerService } from 'monaco-editor/esm/vs/editor/common/services/editorWorker.js';
|
|
15
|
+
import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
|
|
16
|
+
import { MenuWorkbenchToolBar } from 'monaco-editor/esm/vs/platform/actions/browser/toolbar.js';
|
|
17
|
+
import { MenuId } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
|
|
18
|
+
import { RawContextKey, IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
|
|
19
|
+
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
20
|
+
import { AsyncProgress } from 'monaco-editor/esm/vs/platform/progress/common/progress.js';
|
|
21
|
+
import { countWords } from '../../../../../chat/common/chatWordCounter.js';
|
|
22
|
+
import { InlineChatController } from '../../../../../inlineChat/browser/inlineChatController.js';
|
|
23
|
+
import { SessionPrompt, ReplyResponse, SessionExchange, EmptyResponse, ErrorResponse, IInlineChatSessionService } from '../../../../../inlineChat/browser/inlineChatSession.js';
|
|
24
|
+
import { performAsyncTextEdit, asProgressiveEdit } from '../../../../../inlineChat/browser/inlineChatStrategies.js';
|
|
25
|
+
import { InlineChatWidget } from '../../../../../inlineChat/browser/inlineChatWidget.js';
|
|
26
|
+
import { CTX_INLINE_CHAT_VISIBLE, CTX_INLINE_CHAT_LAST_RESPONSE_TYPE } from '../../../../../inlineChat/common/inlineChat.js';
|
|
27
|
+
import { NotebookExecutionType, INotebookExecutionStateService } from '../../../../common/notebookExecutionStateService.js';
|
|
28
|
+
var NotebookCellChatController_1;
|
|
29
|
+
const CTX_NOTEBOOK_CELL_CHAT_FOCUSED = ( new RawContextKey('notebookCellChatFocused', false, ( localizeWithPath(
|
|
30
|
+
'vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatController',
|
|
31
|
+
'notebookCellChatFocused',
|
|
32
|
+
"Whether the cell chat editor is focused"
|
|
33
|
+
))));
|
|
34
|
+
const CTX_NOTEBOOK_CHAT_HAS_ACTIVE_REQUEST = ( new RawContextKey('notebookChatHasActiveRequest', false, ( localizeWithPath(
|
|
35
|
+
'vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatController',
|
|
36
|
+
'notebookChatHasActiveRequest',
|
|
37
|
+
"Whether the cell chat editor has an active request"
|
|
38
|
+
))));
|
|
39
|
+
const MENU_CELL_CHAT_WIDGET = MenuId.for('cellChatWidget');
|
|
40
|
+
const MENU_CELL_CHAT_WIDGET_STATUS = MenuId.for('cellChatWidget.status');
|
|
41
|
+
const MENU_CELL_CHAT_WIDGET_FEEDBACK = MenuId.for('cellChatWidget.feedback');
|
|
42
|
+
const MENU_CELL_CHAT_WIDGET_TOOLBAR = MenuId.for('cellChatWidget.toolbar');
|
|
43
|
+
let NotebookCellChatController = class NotebookCellChatController extends Disposable {
|
|
44
|
+
static { NotebookCellChatController_1 = this; }
|
|
45
|
+
static { this._cellChatControllers = ( new WeakMap()); }
|
|
46
|
+
static get(cell) {
|
|
47
|
+
return NotebookCellChatController_1._cellChatControllers.get(cell);
|
|
48
|
+
}
|
|
49
|
+
constructor(_notebookEditor, _chatPart, _cell, _partContainer, _contextKeyService, _inlineChatSessionService, _editorWorkerService, _instantiationService, _notebookExecutionStateService) {
|
|
50
|
+
super();
|
|
51
|
+
this._notebookEditor = _notebookEditor;
|
|
52
|
+
this._chatPart = _chatPart;
|
|
53
|
+
this._cell = _cell;
|
|
54
|
+
this._partContainer = _partContainer;
|
|
55
|
+
this._contextKeyService = _contextKeyService;
|
|
56
|
+
this._inlineChatSessionService = _inlineChatSessionService;
|
|
57
|
+
this._editorWorkerService = _editorWorkerService;
|
|
58
|
+
this._instantiationService = _instantiationService;
|
|
59
|
+
this._notebookExecutionStateService = _notebookExecutionStateService;
|
|
60
|
+
this._isVisible = false;
|
|
61
|
+
this._toolbarDOM = h('div.toolbar@editorToolbar');
|
|
62
|
+
this._widgetDisposableStore = this._register(( new DisposableStore()));
|
|
63
|
+
NotebookCellChatController_1._cellChatControllers.set(this._cell, this);
|
|
64
|
+
this._ctxHasActiveRequest = CTX_NOTEBOOK_CHAT_HAS_ACTIVE_REQUEST.bindTo(this._contextKeyService);
|
|
65
|
+
this._ctxVisible = CTX_INLINE_CHAT_VISIBLE.bindTo(_contextKeyService);
|
|
66
|
+
this._ctxCellWidgetFocused = CTX_NOTEBOOK_CELL_CHAT_FOCUSED.bindTo(this._contextKeyService);
|
|
67
|
+
this._ctxLastResponseType = CTX_INLINE_CHAT_LAST_RESPONSE_TYPE.bindTo(this._contextKeyService);
|
|
68
|
+
this._register(this._cell.onDidChangeEditorAttachState(() => {
|
|
69
|
+
const editor = this._getCellEditor();
|
|
70
|
+
this._inlineChatListener?.dispose();
|
|
71
|
+
if (!editor) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (!this._widget && this._isVisible) {
|
|
75
|
+
this._initialize(editor);
|
|
76
|
+
}
|
|
77
|
+
const inlineChatController = InlineChatController.get(editor);
|
|
78
|
+
if (inlineChatController) {
|
|
79
|
+
this._inlineChatListener = inlineChatController.onWillStartSession(() => {
|
|
80
|
+
this.dismiss(false);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
_initialize(editor) {
|
|
86
|
+
this._widget = this._instantiationService.createInstance(InlineChatWidget, editor, {
|
|
87
|
+
menuId: MENU_CELL_CHAT_WIDGET,
|
|
88
|
+
statusMenuId: MENU_CELL_CHAT_WIDGET_STATUS,
|
|
89
|
+
feedbackMenuId: MENU_CELL_CHAT_WIDGET_FEEDBACK
|
|
90
|
+
});
|
|
91
|
+
this._widgetDisposableStore.add(this._widget.onDidChangeHeight(() => {
|
|
92
|
+
this._updateHeight();
|
|
93
|
+
}));
|
|
94
|
+
this._widgetDisposableStore.add(this._notebookExecutionStateService.onDidChangeExecution(e => {
|
|
95
|
+
if (( e.notebook.toString()) !== this._notebookEditor.textModel?.uri.toString()) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (e.type === NotebookExecutionType.cell && e.affectsCell(this._cell.uri) && e.changed === undefined ) {
|
|
99
|
+
const { lastRunSuccess } = this._cell.internalMetadata;
|
|
100
|
+
if (lastRunSuccess) {
|
|
101
|
+
this._strategy?.createSnapshot();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}));
|
|
105
|
+
this._partContainer.appendChild(this._widget.domNode);
|
|
106
|
+
this._partContainer.appendChild(this._toolbarDOM.editorToolbar);
|
|
107
|
+
this._toolbar = this._register(this._instantiationService.createInstance(MenuWorkbenchToolBar, this._toolbarDOM.editorToolbar, MENU_CELL_CHAT_WIDGET_TOOLBAR, {
|
|
108
|
+
telemetrySource: 'interactiveEditorWidget-toolbar',
|
|
109
|
+
toolbarOptions: { primaryGroup: 'main' }
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
dispose() {
|
|
113
|
+
if (this._isVisible) {
|
|
114
|
+
this._widget?.reset();
|
|
115
|
+
this._sessionCtor?.cancel();
|
|
116
|
+
this._sessionCtor = undefined;
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
if (this._widget) {
|
|
120
|
+
this._partContainer.removeChild(this._widget.domNode);
|
|
121
|
+
this._partContainer.removeChild(this._toolbarDOM.editorToolbar);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch (_ex) {
|
|
125
|
+
}
|
|
126
|
+
this._widget?.dispose();
|
|
127
|
+
this._inlineChatListener?.dispose();
|
|
128
|
+
this._toolbar?.dispose();
|
|
129
|
+
this._inlineChatListener = undefined;
|
|
130
|
+
this._ctxHasActiveRequest.reset();
|
|
131
|
+
this._ctxVisible.reset();
|
|
132
|
+
NotebookCellChatController_1._cellChatControllers.delete(this._cell);
|
|
133
|
+
super.dispose();
|
|
134
|
+
}
|
|
135
|
+
layout() {
|
|
136
|
+
if (this._isVisible && this._widget) {
|
|
137
|
+
const innerEditorWidth = this._cell.layoutInfo.editorWidth;
|
|
138
|
+
const height = this._widget.getHeight();
|
|
139
|
+
this._widget.layout(( new Dimension(innerEditorWidth, height)));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
_updateHeight() {
|
|
143
|
+
const margin = 6;
|
|
144
|
+
const heightWithMargin = this._isVisible && this._widget
|
|
145
|
+
? ((this._widget.getHeight() - 8 - 18 + margin) )
|
|
146
|
+
: 0;
|
|
147
|
+
if (this._cell.chatHeight === heightWithMargin) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
this._cell.chatHeight = heightWithMargin;
|
|
151
|
+
this._partContainer.style.height = `${heightWithMargin - margin}px`;
|
|
152
|
+
}
|
|
153
|
+
async show() {
|
|
154
|
+
this._isVisible = true;
|
|
155
|
+
if (!this._widget) {
|
|
156
|
+
const editor = this._getCellEditor();
|
|
157
|
+
if (editor) {
|
|
158
|
+
this._initialize(editor);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
this._partContainer.style.display = 'flex';
|
|
162
|
+
this._widget?.focus();
|
|
163
|
+
this._widget?.updateInfo(( localizeWithPath(
|
|
164
|
+
'vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatController',
|
|
165
|
+
'welcome.1',
|
|
166
|
+
"AI-generated code may be incorrect"
|
|
167
|
+
)));
|
|
168
|
+
this._ctxVisible.set(true);
|
|
169
|
+
this._ctxCellWidgetFocused.set(true);
|
|
170
|
+
this._updateHeight();
|
|
171
|
+
this._sessionCtor = createCancelablePromise(async (token) => {
|
|
172
|
+
if (this._cell.editorAttached) {
|
|
173
|
+
const editor = this._getCellEditor();
|
|
174
|
+
if (editor) {
|
|
175
|
+
await this._startSession(editor, token);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
await Event.toPromise(Event.once(this._cell.onDidChangeEditorAttachState));
|
|
180
|
+
if (token.isCancellationRequested) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const editor = this._getCellEditor();
|
|
184
|
+
if (editor) {
|
|
185
|
+
await this._startSession(editor, token);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (this._widget) {
|
|
189
|
+
this._widget.placeholder = this._activeSession?.session.placeholder ?? ( localizeWithPath(
|
|
190
|
+
'vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatController',
|
|
191
|
+
'default.placeholder',
|
|
192
|
+
"Ask a question"
|
|
193
|
+
));
|
|
194
|
+
this._widget.updateInfo(this._activeSession?.session.message ?? ( localizeWithPath(
|
|
195
|
+
'vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatController',
|
|
196
|
+
'welcome.1',
|
|
197
|
+
"AI-generated code may be incorrect"
|
|
198
|
+
)));
|
|
199
|
+
this._widget.focus();
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
_getCellEditor() {
|
|
204
|
+
const editors = this._notebookEditor.codeEditors.find(editor => editor[0] === this._chatPart.activeCell);
|
|
205
|
+
if (!editors || !editors[1].hasModel()) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const editor = editors[1];
|
|
209
|
+
return editor;
|
|
210
|
+
}
|
|
211
|
+
async _startSession(editor, token) {
|
|
212
|
+
if (this._activeSession) {
|
|
213
|
+
this._inlineChatSessionService.releaseSession(this._activeSession);
|
|
214
|
+
}
|
|
215
|
+
const session = await this._inlineChatSessionService.createSession(editor, { editMode: "livePreview" }, token);
|
|
216
|
+
if (!session) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
this._activeSession = session;
|
|
220
|
+
this._strategy = ( new EditStrategy(session));
|
|
221
|
+
}
|
|
222
|
+
async acceptInput() {
|
|
223
|
+
assertType(this._activeSession);
|
|
224
|
+
assertType(this._widget);
|
|
225
|
+
this._activeSession.addInput(( new SessionPrompt(this._widget.value)));
|
|
226
|
+
assertType(this._activeSession.lastInput);
|
|
227
|
+
const value = this._activeSession.lastInput.value;
|
|
228
|
+
const editors = this._notebookEditor.codeEditors.find(editor => editor[0] === this._chatPart.activeCell);
|
|
229
|
+
if (!editors || !editors[1].hasModel()) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const editor = editors[1];
|
|
233
|
+
this._ctxHasActiveRequest.set(true);
|
|
234
|
+
this._widget?.updateProgress(true);
|
|
235
|
+
const request = {
|
|
236
|
+
requestId: generateUuid(),
|
|
237
|
+
prompt: value,
|
|
238
|
+
attempt: 0,
|
|
239
|
+
selection: { selectionStartLineNumber: 1, selectionStartColumn: 1, positionLineNumber: 1, positionColumn: 1 },
|
|
240
|
+
wholeRange: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 },
|
|
241
|
+
live: true
|
|
242
|
+
};
|
|
243
|
+
const requestCts = ( new CancellationTokenSource());
|
|
244
|
+
const progressEdits = [];
|
|
245
|
+
const progressiveEditsQueue = ( new Queue());
|
|
246
|
+
const progressiveEditsClock = StopWatch.create();
|
|
247
|
+
const progressiveEditsAvgDuration = ( new MovingAverage());
|
|
248
|
+
const progressiveEditsCts = ( new CancellationTokenSource(requestCts.token));
|
|
249
|
+
const progress = ( new AsyncProgress(async (data) => {
|
|
250
|
+
if (requestCts.token.isCancellationRequested) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (data.message) {
|
|
254
|
+
this._widget?.updateToolbar(false);
|
|
255
|
+
this._widget?.updateInfo(data.message);
|
|
256
|
+
}
|
|
257
|
+
if (data.edits?.length) {
|
|
258
|
+
if (!request.live) {
|
|
259
|
+
throw new Error('Progress in NOT supported in non-live mode');
|
|
260
|
+
}
|
|
261
|
+
progressEdits.push(data.edits);
|
|
262
|
+
progressiveEditsAvgDuration.update(progressiveEditsClock.elapsed());
|
|
263
|
+
progressiveEditsClock.reset();
|
|
264
|
+
progressiveEditsQueue.queue(async () => {
|
|
265
|
+
await this._makeChanges(editor, data.edits, data.editsShouldBeInstant
|
|
266
|
+
? undefined
|
|
267
|
+
: { duration: progressiveEditsAvgDuration.value, token: progressiveEditsCts.token });
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}));
|
|
271
|
+
const task = this._activeSession.provider.provideResponse(this._activeSession.session, request, progress, requestCts.token);
|
|
272
|
+
let response;
|
|
273
|
+
try {
|
|
274
|
+
this._widget?.updateChatMessage(undefined);
|
|
275
|
+
this._widget?.updateFollowUps(undefined);
|
|
276
|
+
this._widget?.updateProgress(true);
|
|
277
|
+
this._widget?.updateInfo(!this._activeSession.lastExchange ? ( localizeWithPath(
|
|
278
|
+
'vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatController',
|
|
279
|
+
'thinking',
|
|
280
|
+
"Thinking\u2026"
|
|
281
|
+
)) : '');
|
|
282
|
+
this._ctxHasActiveRequest.set(true);
|
|
283
|
+
const reply = await raceCancellationError(Promise.resolve(task), requestCts.token);
|
|
284
|
+
if (progressiveEditsQueue.size > 0) {
|
|
285
|
+
await Event.toPromise(progressiveEditsQueue.onDrained);
|
|
286
|
+
}
|
|
287
|
+
await progress.drain();
|
|
288
|
+
if (!reply) {
|
|
289
|
+
response = ( new EmptyResponse());
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
const markdownContents = ( new MarkdownString('', { supportThemeIcons: true, supportHtml: true, isTrusted: false }));
|
|
293
|
+
const replyResponse = response = this._instantiationService.createInstance(ReplyResponse, reply, markdownContents, this._activeSession.textModelN.uri, this._activeSession.textModelN.getAlternativeVersionId(), progressEdits, request.requestId);
|
|
294
|
+
for (let i = progressEdits.length; i < replyResponse.allLocalEdits.length; i++) {
|
|
295
|
+
await this._makeChanges(editor, replyResponse.allLocalEdits[i], undefined);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
catch (e) {
|
|
300
|
+
response = ( new ErrorResponse(e));
|
|
301
|
+
}
|
|
302
|
+
finally {
|
|
303
|
+
this._ctxHasActiveRequest.set(false);
|
|
304
|
+
this._widget?.updateProgress(false);
|
|
305
|
+
this._widget?.updateInfo('');
|
|
306
|
+
this._widget?.updateToolbar(true);
|
|
307
|
+
}
|
|
308
|
+
this._ctxHasActiveRequest.set(false);
|
|
309
|
+
this._widget?.updateProgress(false);
|
|
310
|
+
this._widget?.updateInfo('');
|
|
311
|
+
this._widget?.updateToolbar(true);
|
|
312
|
+
this._activeSession.addExchange(( new SessionExchange(this._activeSession.lastInput, response)));
|
|
313
|
+
this._ctxLastResponseType.set(response instanceof ReplyResponse ? response.raw.type : undefined);
|
|
314
|
+
}
|
|
315
|
+
async cancelCurrentRequest(discard) {
|
|
316
|
+
if (discard) {
|
|
317
|
+
this._strategy?.cancel();
|
|
318
|
+
}
|
|
319
|
+
if (this._activeSession) {
|
|
320
|
+
this._inlineChatSessionService.releaseSession(this._activeSession);
|
|
321
|
+
}
|
|
322
|
+
this._activeSession = undefined;
|
|
323
|
+
}
|
|
324
|
+
async acceptSession() {
|
|
325
|
+
assertType(this._activeSession);
|
|
326
|
+
assertType(this._strategy);
|
|
327
|
+
const editor = this._getCellEditor();
|
|
328
|
+
assertType(editor);
|
|
329
|
+
try {
|
|
330
|
+
await this._strategy.apply(editor);
|
|
331
|
+
}
|
|
332
|
+
catch (_err) { }
|
|
333
|
+
this._inlineChatSessionService.releaseSession(this._activeSession);
|
|
334
|
+
this.dismiss(false);
|
|
335
|
+
}
|
|
336
|
+
async dismiss(discard) {
|
|
337
|
+
this._isVisible = false;
|
|
338
|
+
this._partContainer.style.display = 'none';
|
|
339
|
+
this.cancelCurrentRequest(discard);
|
|
340
|
+
this._ctxCellWidgetFocused.set(false);
|
|
341
|
+
this._ctxVisible.set(false);
|
|
342
|
+
this._ctxLastResponseType.reset();
|
|
343
|
+
this._widget?.reset();
|
|
344
|
+
this._updateHeight();
|
|
345
|
+
}
|
|
346
|
+
async feedbackLast(kind) {
|
|
347
|
+
if (this._activeSession?.lastExchange && this._activeSession.lastExchange.response instanceof ReplyResponse) {
|
|
348
|
+
this._activeSession.provider.handleInlineChatResponseFeedback?.(this._activeSession.session, this._activeSession.lastExchange.response.raw, kind);
|
|
349
|
+
this._widget?.updateStatus('Thank you for your feedback!', { resetAfter: 1250 });
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
async _makeChanges(editor, edits, opts) {
|
|
353
|
+
assertType(this._activeSession);
|
|
354
|
+
assertType(this._strategy);
|
|
355
|
+
const moreMinimalEdits = await this._editorWorkerService.computeMoreMinimalEdits(this._activeSession.textModelN.uri, edits);
|
|
356
|
+
if (moreMinimalEdits?.length === 0) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
const actualEdits = !opts && moreMinimalEdits ? moreMinimalEdits : edits;
|
|
360
|
+
const editOperations = ( actualEdits.map(TextEdit.asEditOperation));
|
|
361
|
+
try {
|
|
362
|
+
this._activeSession.wholeRange.trackEdits(editOperations);
|
|
363
|
+
if (opts) {
|
|
364
|
+
await this._strategy.makeProgressiveChanges(editor, editOperations, opts);
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
await this._strategy.makeChanges(editor, editOperations);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
finally {
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
NotebookCellChatController = NotebookCellChatController_1 = ( __decorate([
|
|
375
|
+
( __param(4, IContextKeyService)),
|
|
376
|
+
( __param(5, IInlineChatSessionService)),
|
|
377
|
+
( __param(6, IEditorWorkerService)),
|
|
378
|
+
( __param(7, IInstantiationService)),
|
|
379
|
+
( __param(8, INotebookExecutionStateService))
|
|
380
|
+
], NotebookCellChatController));
|
|
381
|
+
class EditStrategy {
|
|
382
|
+
constructor(_session) {
|
|
383
|
+
this._session = _session;
|
|
384
|
+
this._editCount = 0;
|
|
385
|
+
}
|
|
386
|
+
async makeProgressiveChanges(editor, edits, opts) {
|
|
387
|
+
if (++this._editCount === 1) {
|
|
388
|
+
editor.pushUndoStop();
|
|
389
|
+
}
|
|
390
|
+
const durationInSec = opts.duration / 1000;
|
|
391
|
+
for (const edit of edits) {
|
|
392
|
+
const wordCount = countWords(edit.text ?? '');
|
|
393
|
+
const speed = wordCount / durationInSec;
|
|
394
|
+
await performAsyncTextEdit(editor.getModel(), asProgressiveEdit(edit, speed, opts.token));
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
async makeChanges(editor, edits) {
|
|
398
|
+
const cursorStateComputerAndInlineDiffCollection = (undoEdits) => {
|
|
399
|
+
let last = null;
|
|
400
|
+
for (const edit of undoEdits) {
|
|
401
|
+
last = !last || last.isBefore(edit.range.getEndPosition()) ? edit.range.getEndPosition() : last;
|
|
402
|
+
}
|
|
403
|
+
return last && [Selection.fromPositions(last)];
|
|
404
|
+
};
|
|
405
|
+
if (++this._editCount === 1) {
|
|
406
|
+
editor.pushUndoStop();
|
|
407
|
+
}
|
|
408
|
+
editor.executeEdits('inline-chat-live', edits, cursorStateComputerAndInlineDiffCollection);
|
|
409
|
+
}
|
|
410
|
+
async apply(editor) {
|
|
411
|
+
if (this._editCount > 0) {
|
|
412
|
+
editor.pushUndoStop();
|
|
413
|
+
}
|
|
414
|
+
if (!(this._session.lastExchange?.response instanceof ReplyResponse)) {
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
const { untitledTextModel } = this._session.lastExchange.response;
|
|
418
|
+
if (untitledTextModel && !untitledTextModel.isDisposed() && untitledTextModel.isDirty()) {
|
|
419
|
+
await untitledTextModel.save({ reason: 1 });
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
async cancel() {
|
|
423
|
+
const { textModelN: modelN, textModelNAltVersion, textModelNSnapshotAltVersion } = this._session;
|
|
424
|
+
if (modelN.isDisposed()) {
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
const targetAltVersion = textModelNSnapshotAltVersion ?? textModelNAltVersion;
|
|
428
|
+
while (targetAltVersion < modelN.getAlternativeVersionId() && modelN.canUndo()) {
|
|
429
|
+
modelN.undo();
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
createSnapshot() {
|
|
433
|
+
if (this._session && !this._session.textModel0.equalsTextBuffer(this._session.textModelN.getTextBuffer())) {
|
|
434
|
+
this._session.createSnapshot();
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
export { CTX_NOTEBOOK_CELL_CHAT_FOCUSED, CTX_NOTEBOOK_CHAT_HAS_ACTIVE_REQUEST, MENU_CELL_CHAT_WIDGET, MENU_CELL_CHAT_WIDGET_FEEDBACK, MENU_CELL_CHAT_WIDGET_STATUS, MENU_CELL_CHAT_WIDGET_TOOLBAR, NotebookCellChatController };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
3
|
+
import { CellContentPart } from '../../cellPart.js';
|
|
4
|
+
import { NotebookCellChatController } from './cellChatController.js';
|
|
5
|
+
import './cellChatActions.js';
|
|
6
|
+
import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
|
|
7
|
+
import { NotebookSetting } from '../../../../common/notebookCommon.js';
|
|
8
|
+
let CellChatPart = class CellChatPart extends CellContentPart {
|
|
9
|
+
get activeCell() {
|
|
10
|
+
return this.currentCell;
|
|
11
|
+
}
|
|
12
|
+
constructor(_notebookEditor, _partContainer, _instantiationService, _configurationService) {
|
|
13
|
+
super();
|
|
14
|
+
this._notebookEditor = _notebookEditor;
|
|
15
|
+
this._partContainer = _partContainer;
|
|
16
|
+
this._instantiationService = _instantiationService;
|
|
17
|
+
this._configurationService = _configurationService;
|
|
18
|
+
}
|
|
19
|
+
didRenderCell(element) {
|
|
20
|
+
this._controller?.dispose();
|
|
21
|
+
const enabled = this._configurationService.getValue(NotebookSetting.cellChat);
|
|
22
|
+
if (enabled) {
|
|
23
|
+
this._controller = this._instantiationService.createInstance(NotebookCellChatController, this._notebookEditor, this, element, this._partContainer);
|
|
24
|
+
}
|
|
25
|
+
super.didRenderCell(element);
|
|
26
|
+
}
|
|
27
|
+
unrenderCell(element) {
|
|
28
|
+
this._controller?.dispose();
|
|
29
|
+
this._controller = undefined;
|
|
30
|
+
super.unrenderCell(element);
|
|
31
|
+
}
|
|
32
|
+
updateInternalLayoutNow(element) {
|
|
33
|
+
this._controller?.layout();
|
|
34
|
+
}
|
|
35
|
+
dispose() {
|
|
36
|
+
this._controller?.dispose();
|
|
37
|
+
this._controller = undefined;
|
|
38
|
+
super.dispose();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
CellChatPart = ( __decorate([
|
|
42
|
+
( __param(2, IInstantiationService)),
|
|
43
|
+
( __param(3, IConfigurationService))
|
|
44
|
+
], CellChatPart));
|
|
45
|
+
export { CellChatPart };
|