@vscode/chat-lib 0.0.1 → 0.0.2
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/dist/src/_internal/extension/xtab/common/promptCrafting.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/common/promptCrafting.js +6 -5
- package/dist/src/_internal/extension/xtab/common/promptCrafting.js.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts +1 -0
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.js +1 -0
- package/dist/src/_internal/platform/configuration/common/configurationService.js.map +1 -1
- package/dist/src/_internal/platform/env/common/envService.d.ts +5 -0
- package/dist/src/_internal/platform/env/common/envService.d.ts.map +1 -1
- package/dist/src/_internal/platform/env/common/envService.js +2 -1
- package/dist/src/_internal/platform/env/common/envService.js.map +1 -1
- package/dist/src/_internal/platform/env/common/nullEnvService.d.ts +3 -0
- package/dist/src/_internal/platform/env/common/nullEnvService.d.ts.map +1 -1
- package/dist/src/_internal/platform/env/common/nullEnvService.js +8 -1
- package/dist/src/_internal/platform/env/common/nullEnvService.js.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.d.ts +7 -0
- package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.d.ts.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.js +1 -0
- package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.js.map +1 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts +8 -0
- package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts.map +1 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.js +19 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.js.map +1 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.d.ts.map +1 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js +8 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js.map +1 -1
- package/dist/src/_internal/vscodeTypes.d.ts +4 -0
- package/dist/src/_internal/vscodeTypes.d.ts.map +1 -1
- package/dist/src/_internal/vscodeTypes.js +5 -1
- package/dist/src/_internal/vscodeTypes.js.map +1 -1
- package/dist/src/main.d.ts +5 -0
- package/dist/src/main.d.ts.map +1 -1
- package/dist/src/main.js +12 -0
- package/dist/src/main.js.map +1 -1
- package/dist/src/package.json +46 -19
- package/package.json +3 -6
- package/src/_internal/extension/byok/node/openAIEndpoint.ts +0 -171
- package/src/_internal/extension/common/constants.ts +0 -90
- package/src/_internal/extension/inlineEdits/common/delayer.ts +0 -108
- package/src/_internal/extension/inlineEdits/common/editRebase.ts +0 -268
- package/src/_internal/extension/inlineEdits/common/ghNearbyNesProvider.tsx +0 -163
- package/src/_internal/extension/inlineEdits/common/nearbyCursorInlineEditProvider.ts +0 -225
- package/src/_internal/extension/inlineEdits/common/rejectionCollector.ts +0 -164
- package/src/_internal/extension/inlineEdits/node/debugRecorder.ts +0 -205
- package/src/_internal/extension/inlineEdits/node/importFiltering.ts +0 -25
- package/src/_internal/extension/inlineEdits/node/nesConfigs.ts +0 -12
- package/src/_internal/extension/inlineEdits/node/nextEditCache.ts +0 -278
- package/src/_internal/extension/inlineEdits/node/nextEditProvider.ts +0 -778
- package/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.ts +0 -983
- package/src/_internal/extension/inlineEdits/node/nextEditResult.ts +0 -40
- package/src/_internal/extension/prompt/common/importStatement.ts +0 -25
- package/src/_internal/extension/prompt/node/chatMLFetcher.ts +0 -706
- package/src/_internal/extension/prompts/node/inline/summarizedDocument/fragments.ts +0 -146
- package/src/_internal/extension/prompts/node/inline/summarizedDocument/implementation.ts +0 -527
- package/src/_internal/extension/prompts/node/inline/summarizedDocument/projectedText.ts +0 -76
- package/src/_internal/extension/prompts/node/inline/visualization.ts +0 -65
- package/src/_internal/extension/vscode.proposed.activeComment.d.ts +0 -23
- package/src/_internal/extension/vscode.proposed.aiRelatedInformation.d.ts +0 -49
- package/src/_internal/extension/vscode.proposed.aiSettingsSearch.d.ts +0 -31
- package/src/_internal/extension/vscode.proposed.aiTextSearchProvider.d.ts +0 -41
- package/src/_internal/extension/vscode.proposed.authLearnMore.d.ts +0 -16
- package/src/_internal/extension/vscode.proposed.chatBinaryReferenceData.d.ts +0 -41
- package/src/_internal/extension/vscode.proposed.chatEditing.d.ts +0 -29
- package/src/_internal/extension/vscode.proposed.chatParticipantAdditions.d.ts +0 -636
- package/src/_internal/extension/vscode.proposed.chatParticipantPrivate.d.ts +0 -276
- package/src/_internal/extension/vscode.proposed.chatProvider.d.ts +0 -62
- package/src/_internal/extension/vscode.proposed.chatReadonlyPromptReference.d.ts +0 -17
- package/src/_internal/extension/vscode.proposed.chatReferenceDiagnostic.d.ts +0 -23
- package/src/_internal/extension/vscode.proposed.chatSessionsProvider.d.ts +0 -218
- package/src/_internal/extension/vscode.proposed.chatStatusItem.d.ts +0 -61
- package/src/_internal/extension/vscode.proposed.codeActionAI.d.ts +0 -16
- package/src/_internal/extension/vscode.proposed.commentReveal.d.ts +0 -32
- package/src/_internal/extension/vscode.proposed.contribCommentThreadAdditionalMenu.d.ts +0 -8
- package/src/_internal/extension/vscode.proposed.contribCommentsViewThreadMenus.d.ts +0 -6
- package/src/_internal/extension/vscode.proposed.contribSourceControlInputBoxMenu.d.ts +0 -7
- package/src/_internal/extension/vscode.proposed.dataChannels.d.ts +0 -19
- package/src/_internal/extension/vscode.proposed.defaultChatParticipant.d.ts +0 -52
- package/src/_internal/extension/vscode.proposed.documentFiltersExclusive.d.ts +0 -13
- package/src/_internal/extension/vscode.proposed.embeddings.d.ts +0 -33
- package/src/_internal/extension/vscode.proposed.extensionsAny.d.ts +0 -40
- package/src/_internal/extension/vscode.proposed.findFiles2.d.ts +0 -125
- package/src/_internal/extension/vscode.proposed.findTextInFiles.d.ts +0 -104
- package/src/_internal/extension/vscode.proposed.findTextInFiles2.d.ts +0 -144
- package/src/_internal/extension/vscode.proposed.inlineCompletionsAdditions.d.ts +0 -202
- package/src/_internal/extension/vscode.proposed.interactive.d.ts +0 -11
- package/src/_internal/extension/vscode.proposed.languageModelCapabilities.d.ts +0 -25
- package/src/_internal/extension/vscode.proposed.languageModelDataPart.d.ts +0 -163
- package/src/_internal/extension/vscode.proposed.languageModelSystem.d.ts +0 -17
- package/src/_internal/extension/vscode.proposed.languageModelThinkingPart.d.ts +0 -49
- package/src/_internal/extension/vscode.proposed.languageModelToolResultAudience.d.ts +0 -36
- package/src/_internal/extension/vscode.proposed.mappedEditsProvider.d.ts +0 -110
- package/src/_internal/extension/vscode.proposed.newSymbolNamesProvider.d.ts +0 -47
- package/src/_internal/extension/vscode.proposed.readonlyMessage.d.ts +0 -14
- package/src/_internal/extension/vscode.proposed.resolvers.d.ts +0 -475
- package/src/_internal/extension/vscode.proposed.scmInputBoxValueProvider.d.ts +0 -25
- package/src/_internal/extension/vscode.proposed.taskProblemMatcherStatus.d.ts +0 -42
- package/src/_internal/extension/vscode.proposed.terminalDataWriteEvent.d.ts +0 -32
- package/src/_internal/extension/vscode.proposed.terminalExecuteCommandEvent.d.ts +0 -48
- package/src/_internal/extension/vscode.proposed.terminalQuickFixProvider.d.ts +0 -87
- package/src/_internal/extension/vscode.proposed.terminalSelection.d.ts +0 -16
- package/src/_internal/extension/vscode.proposed.testObserver.d.ts +0 -199
- package/src/_internal/extension/vscode.proposed.textDocumentChangeReason.d.ts +0 -30
- package/src/_internal/extension/vscode.proposed.textSearchProvider.d.ts +0 -281
- package/src/_internal/extension/vscode.proposed.textSearchProvider2.d.ts +0 -297
- package/src/_internal/extension/xtab/common/promptCrafting.ts +0 -670
- package/src/_internal/extension/xtab/node/xtabEndpoint.ts +0 -102
- package/src/_internal/extension/xtab/node/xtabProvider.ts +0 -976
- package/src/_internal/extension/xtab/node/xtabUtils.ts +0 -62
- package/src/_internal/platform/authentication/common/authentication.ts +0 -309
- package/src/_internal/platform/authentication/common/copilotToken.ts +0 -300
- package/src/_internal/platform/authentication/common/copilotTokenManager.ts +0 -59
- package/src/_internal/platform/authentication/common/copilotTokenStore.ts +0 -40
- package/src/_internal/platform/authentication/common/staticGitHubAuthenticationService.ts +0 -96
- package/src/_internal/platform/authentication/node/copilotTokenManager.ts +0 -303
- package/src/_internal/platform/chat/common/chatMLFetcher.ts +0 -124
- package/src/_internal/platform/chat/common/chatQuotaService.ts +0 -63
- package/src/_internal/platform/chat/common/chatQuotaServiceImpl.ts +0 -96
- package/src/_internal/platform/chat/common/commonTypes.ts +0 -353
- package/src/_internal/platform/chat/common/conversationOptions.ts +0 -16
- package/src/_internal/platform/chat/common/globalStringUtils.ts +0 -54
- package/src/_internal/platform/chat/common/interactionService.ts +0 -35
- package/src/_internal/platform/configuration/common/configurationService.ts +0 -803
- package/src/_internal/platform/configuration/common/defaultsOnlyConfigurationService.ts +0 -39
- package/src/_internal/platform/configuration/common/jsonSchema.ts +0 -139
- package/src/_internal/platform/configuration/common/validator.ts +0 -242
- package/src/_internal/platform/diff/common/diffService.ts +0 -41
- package/src/_internal/platform/diff/common/diffWorker.ts +0 -83
- package/src/_internal/platform/diff/node/diffServiceImpl.ts +0 -85
- package/src/_internal/platform/editing/common/abstractText.ts +0 -177
- package/src/_internal/platform/editing/common/notebookDocumentSnapshot.ts +0 -122
- package/src/_internal/platform/editing/common/positionOffsetTransformer.ts +0 -202
- package/src/_internal/platform/editing/common/textDocumentSnapshot.ts +0 -274
- package/src/_internal/platform/endpoint/common/capiClient.ts +0 -37
- package/src/_internal/platform/endpoint/common/chatModelCapabilities.ts +0 -115
- package/src/_internal/platform/endpoint/common/domainService.ts +0 -27
- package/src/_internal/platform/endpoint/common/endpointProvider.ts +0 -104
- package/src/_internal/platform/endpoint/common/endpointTypes.ts +0 -12
- package/src/_internal/platform/endpoint/common/licenseAgreement.ts +0 -11
- package/src/_internal/platform/endpoint/common/statefulMarkerContainer.tsx +0 -85
- package/src/_internal/platform/endpoint/common/thinkingDataContainer.tsx +0 -44
- package/src/_internal/platform/endpoint/node/capiClientImpl.ts +0 -18
- package/src/_internal/platform/endpoint/node/chatEndpoint.ts +0 -435
- package/src/_internal/platform/endpoint/node/domainServiceImpl.ts +0 -80
- package/src/_internal/platform/endpoint/node/proxyXtabEndpoint.ts +0 -43
- package/src/_internal/platform/endpoint/node/responsesApi.ts +0 -326
- package/src/_internal/platform/env/common/envService.ts +0 -134
- package/src/_internal/platform/env/common/nullEnvService.ts +0 -68
- package/src/_internal/platform/env/common/packagejson.ts +0 -49
- package/src/_internal/platform/git/common/gitExtensionService.ts +0 -21
- package/src/_internal/platform/git/common/nullGitExtensionService.ts +0 -20
- package/src/_internal/platform/git/vscode/git.d.ts +0 -414
- package/src/_internal/platform/github/common/githubAPI.ts +0 -44
- package/src/_internal/platform/github/common/githubService.ts +0 -87
- package/src/_internal/platform/github/common/nullOctokitServiceImpl.ts +0 -21
- package/src/_internal/platform/ignore/common/ignoreService.ts +0 -72
- package/src/_internal/platform/inlineCompletions/common/api.ts +0 -198
- package/src/_internal/platform/inlineEdits/common/dataTypes/diagnosticData.ts +0 -32
- package/src/_internal/platform/inlineEdits/common/dataTypes/documentId.ts +0 -52
- package/src/_internal/platform/inlineEdits/common/dataTypes/edit.ts +0 -165
- package/src/_internal/platform/inlineEdits/common/dataTypes/editUtils.ts +0 -74
- package/src/_internal/platform/inlineEdits/common/dataTypes/fetchCancellationError.ts +0 -14
- package/src/_internal/platform/inlineEdits/common/dataTypes/languageContext.ts +0 -107
- package/src/_internal/platform/inlineEdits/common/dataTypes/languageId.ts +0 -14
- package/src/_internal/platform/inlineEdits/common/dataTypes/permutation.ts +0 -69
- package/src/_internal/platform/inlineEdits/common/dataTypes/rootedLineEdit.ts +0 -49
- package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLength.ts +0 -74
- package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/combineTextEditInfos.ts +0 -132
- package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/length.ts +0 -184
- package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/textEditInfo.ts +0 -32
- package/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.ts +0 -89
- package/src/_internal/platform/inlineEdits/common/debugRecorderBookmark.ts +0 -10
- package/src/_internal/platform/inlineEdits/common/editReason.ts +0 -134
- package/src/_internal/platform/inlineEdits/common/inlineEditLogContext.ts +0 -490
- package/src/_internal/platform/inlineEdits/common/observableGit.ts +0 -49
- package/src/_internal/platform/inlineEdits/common/observableWorkspace.ts +0 -239
- package/src/_internal/platform/inlineEdits/common/responseProcessor.ts +0 -249
- package/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.ts +0 -468
- package/src/_internal/platform/inlineEdits/common/statelessNextEditProviders.ts +0 -59
- package/src/_internal/platform/inlineEdits/common/utils/observable.ts +0 -54
- package/src/_internal/platform/inlineEdits/common/utils/stringifyChatMessages.ts +0 -29
- package/src/_internal/platform/inlineEdits/common/utils/utils.ts +0 -56
- package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/historyContextProvider.ts +0 -60
- package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/nesHistoryContextProvider.ts +0 -353
- package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/nesXtabHistoryTracker.ts +0 -176
- package/src/_internal/platform/languageContextProvider/common/languageContextProviderService.ts +0 -25
- package/src/_internal/platform/languageContextProvider/common/nullLanguageContextProviderService.ts +0 -38
- package/src/_internal/platform/languageServer/common/languageContextService.ts +0 -186
- package/src/_internal/platform/languages/common/languageDiagnosticsService.ts +0 -67
- package/src/_internal/platform/languages/common/testLanguageDiagnosticsService.ts +0 -28
- package/src/_internal/platform/log/common/logService.ts +0 -232
- package/src/_internal/platform/nesFetch/common/completionsAPI.ts +0 -78
- package/src/_internal/platform/nesFetch/common/completionsFetchService.ts +0 -118
- package/src/_internal/platform/nesFetch/common/responseStream.ts +0 -151
- package/src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.ts +0 -236
- package/src/_internal/platform/nesFetch/node/streamTransformer.ts +0 -95
- package/src/_internal/platform/networking/common/fetch.ts +0 -349
- package/src/_internal/platform/networking/common/fetcherService.ts +0 -84
- package/src/_internal/platform/networking/common/networking.ts +0 -442
- package/src/_internal/platform/networking/common/openai.ts +0 -273
- package/src/_internal/platform/networking/node/chatStream.ts +0 -137
- package/src/_internal/platform/networking/node/stream.ts +0 -749
- package/src/_internal/platform/notebook/common/alternativeContent.ts +0 -89
- package/src/_internal/platform/notebook/common/alternativeContentFormat.ts +0 -10
- package/src/_internal/platform/notebook/common/alternativeContentProvider.json.ts +0 -262
- package/src/_internal/platform/notebook/common/alternativeContentProvider.text.ts +0 -243
- package/src/_internal/platform/notebook/common/alternativeContentProvider.ts +0 -41
- package/src/_internal/platform/notebook/common/alternativeContentProvider.xml.ts +0 -205
- package/src/_internal/platform/notebook/common/alternativeNotebookDocument.ts +0 -155
- package/src/_internal/platform/notebook/common/helpers.ts +0 -212
- package/src/_internal/platform/notebook/common/notebookService.ts +0 -43
- package/src/_internal/platform/openai/node/fetch.ts +0 -596
- package/src/_internal/platform/parser/node/nodes.ts +0 -190
- package/src/_internal/platform/requestLogger/node/nullRequestLogger.ts +0 -26
- package/src/_internal/platform/requestLogger/node/requestLogger.ts +0 -383
- package/src/_internal/platform/simulationTestContext/common/simulationTestContext.ts +0 -29
- package/src/_internal/platform/snippy/common/snippyService.ts +0 -25
- package/src/_internal/platform/telemetry/common/nullExperimentationService.ts +0 -64
- package/src/_internal/platform/telemetry/common/nullTelemetryService.ts +0 -53
- package/src/_internal/platform/telemetry/common/telemetry.ts +0 -215
- package/src/_internal/platform/telemetry/common/telemetryData.ts +0 -205
- package/src/_internal/platform/thinking/common/thinking.ts +0 -61
- package/src/_internal/platform/thinking/common/thinkingUtils.ts +0 -57
- package/src/_internal/platform/tokenizer/node/parseTikTokens.ts +0 -23
- package/src/_internal/platform/tokenizer/node/tikTokenizerImpl.ts +0 -74
- package/src/_internal/platform/tokenizer/node/tikTokenizerWorker.ts +0 -24
- package/src/_internal/platform/tokenizer/node/tokenizer.ts +0 -357
- package/src/_internal/platform/workspace/common/workspaceService.ts +0 -226
- package/src/_internal/platform/workspaceRecorder/common/workspaceLog.ts +0 -118
- package/src/_internal/util/common/anomalyDetection.ts +0 -112
- package/src/_internal/util/common/arrays.ts +0 -81
- package/src/_internal/util/common/async.ts +0 -155
- package/src/_internal/util/common/cache.ts +0 -183
- package/src/_internal/util/common/crypto.ts +0 -41
- package/src/_internal/util/common/errors.ts +0 -22
- package/src/_internal/util/common/globals.d.ts +0 -12
- package/src/_internal/util/common/imageUtils.ts +0 -154
- package/src/_internal/util/common/languages.ts +0 -940
- package/src/_internal/util/common/notebooks.ts +0 -286
- package/src/_internal/util/common/result.ts +0 -71
- package/src/_internal/util/common/services.ts +0 -43
- package/src/_internal/util/common/test/shims/chatTypes.ts +0 -448
- package/src/_internal/util/common/test/shims/editing.ts +0 -233
- package/src/_internal/util/common/test/shims/enums.ts +0 -61
- package/src/_internal/util/common/test/shims/l10n.ts +0 -37
- package/src/_internal/util/common/test/shims/newSymbolName.ts +0 -23
- package/src/_internal/util/common/test/shims/terminal.ts +0 -33
- package/src/_internal/util/common/test/shims/vscodeTypesShim.ts +0 -115
- package/src/_internal/util/common/time.ts +0 -31
- package/src/_internal/util/common/tokenizer.ts +0 -30
- package/src/_internal/util/common/tracing.ts +0 -52
- package/src/_internal/util/common/types.ts +0 -33
- package/src/_internal/util/common/variableLengthQuantity.ts +0 -40
- package/src/_internal/util/node/worker.ts +0 -130
- package/src/_internal/util/vs/base/common/arrays.ts +0 -926
- package/src/_internal/util/vs/base/common/arraysFind.ts +0 -206
- package/src/_internal/util/vs/base/common/assert.ts +0 -89
- package/src/_internal/util/vs/base/common/async.ts +0 -2582
- package/src/_internal/util/vs/base/common/buffer.ts +0 -501
- package/src/_internal/util/vs/base/common/cache.ts +0 -122
- package/src/_internal/util/vs/base/common/cancellation.ts +0 -150
- package/src/_internal/util/vs/base/common/charCode.ts +0 -452
- package/src/_internal/util/vs/base/common/codicons.ts +0 -66
- package/src/_internal/util/vs/base/common/codiconsLibrary.ts +0 -618
- package/src/_internal/util/vs/base/common/codiconsUtil.ts +0 -30
- package/src/_internal/util/vs/base/common/collections.ts +0 -156
- package/src/_internal/util/vs/base/common/diff/diff.ts +0 -1317
- package/src/_internal/util/vs/base/common/diff/diffChange.ts +0 -62
- package/src/_internal/util/vs/base/common/equals.ts +0 -148
- package/src/_internal/util/vs/base/common/errors.ts +0 -342
- package/src/_internal/util/vs/base/common/event.ts +0 -1782
- package/src/_internal/util/vs/base/common/extpath.ts +0 -425
- package/src/_internal/util/vs/base/common/filters.ts +0 -928
- package/src/_internal/util/vs/base/common/functional.ts +0 -34
- package/src/_internal/util/vs/base/common/glob.ts +0 -839
- package/src/_internal/util/vs/base/common/hash.ts +0 -326
- package/src/_internal/util/vs/base/common/htmlContent.ts +0 -212
- package/src/_internal/util/vs/base/common/iconLabels.ts +0 -118
- package/src/_internal/util/vs/base/common/iterator.ts +0 -196
- package/src/_internal/util/vs/base/common/lazy.ts +0 -59
- package/src/_internal/util/vs/base/common/lifecycle.ts +0 -845
- package/src/_internal/util/vs/base/common/linkedList.ts +0 -144
- package/src/_internal/util/vs/base/common/map.ts +0 -954
- package/src/_internal/util/vs/base/common/marshallingIds.ts +0 -35
- package/src/_internal/util/vs/base/common/mime.ts +0 -136
- package/src/_internal/util/vs/base/common/naturalLanguage/korean.ts +0 -425
- package/src/_internal/util/vs/base/common/network.ts +0 -429
- package/src/_internal/util/vs/base/common/numbers.ts +0 -166
- package/src/_internal/util/vs/base/common/objects.ts +0 -242
- package/src/_internal/util/vs/base/common/observable.ts +0 -10
- package/src/_internal/util/vs/base/common/observableInternal/base.ts +0 -208
- package/src/_internal/util/vs/base/common/observableInternal/changeTracker.ts +0 -96
- package/src/_internal/util/vs/base/common/observableInternal/commonFacade/cancellation.ts +0 -9
- package/src/_internal/util/vs/base/common/observableInternal/commonFacade/deps.ts +0 -12
- package/src/_internal/util/vs/base/common/observableInternal/debugLocation.ts +0 -88
- package/src/_internal/util/vs/base/common/observableInternal/debugName.ts +0 -150
- package/src/_internal/util/vs/base/common/observableInternal/experimental/utils.ts +0 -62
- package/src/_internal/util/vs/base/common/observableInternal/index.ts +0 -61
- package/src/_internal/util/vs/base/common/observableInternal/logging/consoleObservableLogger.ts +0 -388
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/debuggerApi.d.ts +0 -154
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/debuggerRpc.ts +0 -80
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/devToolsLogger.ts +0 -485
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/rpc.ts +0 -103
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/utils.ts +0 -69
- package/src/_internal/util/vs/base/common/observableInternal/logging/logging.ts +0 -133
- package/src/_internal/util/vs/base/common/observableInternal/map.ts +0 -81
- package/src/_internal/util/vs/base/common/observableInternal/observables/baseObservable.ts +0 -172
- package/src/_internal/util/vs/base/common/observableInternal/observables/constObservable.ts +0 -44
- package/src/_internal/util/vs/base/common/observableInternal/observables/derived.ts +0 -190
- package/src/_internal/util/vs/base/common/observableInternal/observables/derivedImpl.ts +0 -445
- package/src/_internal/util/vs/base/common/observableInternal/observables/lazyObservableValue.ts +0 -154
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableFromEvent.ts +0 -174
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableSignal.ts +0 -67
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableSignalFromEvent.ts +0 -62
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableValue.ts +0 -131
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableValueOpts.ts +0 -37
- package/src/_internal/util/vs/base/common/observableInternal/reactions/autorun.ts +0 -188
- package/src/_internal/util/vs/base/common/observableInternal/reactions/autorunImpl.ts +0 -256
- package/src/_internal/util/vs/base/common/observableInternal/set.ts +0 -78
- package/src/_internal/util/vs/base/common/observableInternal/transaction.ts +0 -115
- package/src/_internal/util/vs/base/common/observableInternal/utils/promise.ts +0 -129
- package/src/_internal/util/vs/base/common/observableInternal/utils/runOnChange.ts +0 -65
- package/src/_internal/util/vs/base/common/observableInternal/utils/utils.ts +0 -281
- package/src/_internal/util/vs/base/common/observableInternal/utils/utilsCancellation.ts +0 -101
- package/src/_internal/util/vs/base/common/observableInternal/utils/valueWithChangeEvent.ts +0 -31
- package/src/_internal/util/vs/base/common/path.ts +0 -1591
- package/src/_internal/util/vs/base/common/platform.ts +0 -282
- package/src/_internal/util/vs/base/common/process.ts +0 -78
- package/src/_internal/util/vs/base/common/resources.ts +0 -446
- package/src/_internal/util/vs/base/common/sequence.ts +0 -36
- package/src/_internal/util/vs/base/common/sseParser.ts +0 -247
- package/src/_internal/util/vs/base/common/stopwatch.ts +0 -43
- package/src/_internal/util/vs/base/common/stream.ts +0 -792
- package/src/_internal/util/vs/base/common/strings.ts +0 -1364
- package/src/_internal/util/vs/base/common/symbols.ts +0 -11
- package/src/_internal/util/vs/base/common/themables.ts +0 -106
- package/src/_internal/util/vs/base/common/types.ts +0 -345
- package/src/_internal/util/vs/base/common/uint.ts +0 -61
- package/src/_internal/util/vs/base/common/uri.ts +0 -752
- package/src/_internal/util/vs/base/common/uuid.ts +0 -72
- package/src/_internal/util/vs/base-common.d.ts +0 -42
- package/src/_internal/util/vs/editor/common/core/editOperation.ts +0 -62
- package/src/_internal/util/vs/editor/common/core/edits/edit.ts +0 -399
- package/src/_internal/util/vs/editor/common/core/edits/lineEdit.ts +0 -414
- package/src/_internal/util/vs/editor/common/core/edits/stringEdit.ts +0 -568
- package/src/_internal/util/vs/editor/common/core/edits/textEdit.ts +0 -411
- package/src/_internal/util/vs/editor/common/core/position.ts +0 -186
- package/src/_internal/util/vs/editor/common/core/range.ts +0 -519
- package/src/_internal/util/vs/editor/common/core/ranges/lineRange.ts +0 -416
- package/src/_internal/util/vs/editor/common/core/ranges/offsetRange.ts +0 -275
- package/src/_internal/util/vs/editor/common/core/text/abstractText.ts +0 -127
- package/src/_internal/util/vs/editor/common/core/text/positionToOffset.ts +0 -26
- package/src/_internal/util/vs/editor/common/core/text/positionToOffsetImpl.ts +0 -144
- package/src/_internal/util/vs/editor/common/core/text/textLength.ts +0 -150
- package/src/_internal/util/vs/editor/common/core/wordHelper.ts +0 -177
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/diffAlgorithm.ts +0 -210
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/dynamicProgrammingDiffing.ts +0 -109
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/myersDiffAlgorithm.ts +0 -178
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/computeMovedLines.ts +0 -331
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/defaultLinesDiffComputer.ts +0 -273
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/heuristicSequenceOptimizations.ts +0 -475
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/lineSequence.ts +0 -47
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/linesSliceCharSequence.ts +0 -248
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/utils.ts +0 -76
- package/src/_internal/util/vs/editor/common/diff/legacyLinesDiffComputer.ts +0 -693
- package/src/_internal/util/vs/editor/common/diff/linesDiffComputer.ts +0 -61
- package/src/_internal/util/vs/editor/common/diff/rangeMapping.ts +0 -418
- package/src/_internal/util/vs/editor/common/model/prefixSumComputer.ts +0 -304
- package/src/_internal/util/vs/nls.messages.ts +0 -21
- package/src/_internal/util/vs/nls.ts +0 -243
- package/src/_internal/util/vs/platform/instantiation/common/descriptors.ts +0 -23
- package/src/_internal/util/vs/platform/instantiation/common/graph.ts +0 -113
- package/src/_internal/util/vs/platform/instantiation/common/instantiation.ts +0 -127
- package/src/_internal/util/vs/platform/instantiation/common/instantiationService.ts +0 -483
- package/src/_internal/util/vs/platform/instantiation/common/serviceCollection.ts +0 -34
- package/src/_internal/util/vs/vscode-globals-nls.d.ts +0 -42
- package/src/_internal/util/vs/vscode-globals-product.d.ts +0 -35
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/diagnostic.ts +0 -109
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/es5ClassCompat.ts +0 -34
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/location.ts +0 -51
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/markdownString.ts +0 -83
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/notebooks.ts +0 -296
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/position.ts +0 -195
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/range.ts +0 -167
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/selection.ts +0 -94
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetString.ts +0 -103
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetTextEdit.ts +0 -44
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/symbolInformation.ts +0 -89
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/textEdit.ts +0 -99
- package/src/_internal/vscodeTypes.ts +0 -100
- package/src/main.ts +0 -207
- package/src/package.json +0 -4063
|
@@ -1,778 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
|
|
6
|
-
import type * as vscode from 'vscode';
|
|
7
|
-
import { ConfigKey, IConfigurationService } from '../../../platform/configuration/common/configurationService';
|
|
8
|
-
import { DocumentId } from '../../../platform/inlineEdits/common/dataTypes/documentId';
|
|
9
|
-
import { RootedEdit } from '../../../platform/inlineEdits/common/dataTypes/edit';
|
|
10
|
-
import { RootedLineEdit } from '../../../platform/inlineEdits/common/dataTypes/rootedLineEdit';
|
|
11
|
-
import { InlineEditRequestLogContext } from '../../../platform/inlineEdits/common/inlineEditLogContext';
|
|
12
|
-
import { IObservableDocument, ObservableWorkspace } from '../../../platform/inlineEdits/common/observableWorkspace';
|
|
13
|
-
import { IStatelessNextEditProvider, NoNextEditReason, PushEdit, ShowNextEditPreference, StatelessNextEditDocument, StatelessNextEditRequest, StatelessNextEditResult } from '../../../platform/inlineEdits/common/statelessNextEditProvider';
|
|
14
|
-
import { autorunWithChanges } from '../../../platform/inlineEdits/common/utils/observable';
|
|
15
|
-
import { DocumentHistory, HistoryContext, IHistoryContextProvider } from '../../../platform/inlineEdits/common/workspaceEditTracker/historyContextProvider';
|
|
16
|
-
import { NesXtabHistoryTracker } from '../../../platform/inlineEdits/common/workspaceEditTracker/nesXtabHistoryTracker';
|
|
17
|
-
import { ILogService } from '../../../platform/log/common/logService';
|
|
18
|
-
import { ISnippyService } from '../../../platform/snippy/common/snippyService';
|
|
19
|
-
import { IExperimentationService } from '../../../platform/telemetry/common/nullExperimentationService';
|
|
20
|
-
import { Result } from '../../../util/common/result';
|
|
21
|
-
import { createTracer, ITracer } from '../../../util/common/tracing';
|
|
22
|
-
import { assert } from '../../../util/vs/base/common/assert';
|
|
23
|
-
import { DeferredPromise, timeout, TimeoutTimer } from '../../../util/vs/base/common/async';
|
|
24
|
-
import { CachedFunction } from '../../../util/vs/base/common/cache';
|
|
25
|
-
import { CancellationToken } from '../../../util/vs/base/common/cancellation';
|
|
26
|
-
import { BugIndicatingError } from '../../../util/vs/base/common/errors';
|
|
27
|
-
import { Disposable, DisposableStore, IDisposable, toDisposable } from '../../../util/vs/base/common/lifecycle';
|
|
28
|
-
import { LRUCache } from '../../../util/vs/base/common/map';
|
|
29
|
-
import { mapObservableArrayCached, runOnChange } from '../../../util/vs/base/common/observable';
|
|
30
|
-
import { assertType } from '../../../util/vs/base/common/types';
|
|
31
|
-
import { generateUuid } from '../../../util/vs/base/common/uuid';
|
|
32
|
-
import { LineEdit } from '../../../util/vs/editor/common/core/edits/lineEdit';
|
|
33
|
-
import { StringEdit, StringReplacement } from '../../../util/vs/editor/common/core/edits/stringEdit';
|
|
34
|
-
import { OffsetRange } from '../../../util/vs/editor/common/core/ranges/offsetRange';
|
|
35
|
-
import { StringText } from '../../../util/vs/editor/common/core/text/abstractText';
|
|
36
|
-
import { checkEditConsistency } from '../common/editRebase';
|
|
37
|
-
import { RejectionCollector } from '../common/rejectionCollector';
|
|
38
|
-
import { DebugRecorder } from './debugRecorder';
|
|
39
|
-
import { INesConfigs } from './nesConfigs';
|
|
40
|
-
import { CachedOrRebasedEdit, NextEditCache } from './nextEditCache';
|
|
41
|
-
import { LlmNESTelemetryBuilder } from './nextEditProviderTelemetry';
|
|
42
|
-
import { INextEditResult, NextEditResult } from './nextEditResult';
|
|
43
|
-
|
|
44
|
-
export interface INextEditProvider<T extends INextEditResult, TTelemetry, TData = void> extends IDisposable {
|
|
45
|
-
readonly ID: string;
|
|
46
|
-
getNextEdit(docId: DocumentId, context: vscode.InlineCompletionContext, logContext: InlineEditRequestLogContext, cancellationToken: CancellationToken, telemetryBuilder: TTelemetry, data?: TData): Promise<T>;
|
|
47
|
-
handleShown(suggestion: T): void;
|
|
48
|
-
handleAcceptance(docId: DocumentId, suggestion: T): void;
|
|
49
|
-
handleRejection(docId: DocumentId, suggestion: T): void;
|
|
50
|
-
handleIgnored(docId: DocumentId, suggestion: T, supersededByRequestUuid: INextEditResult | undefined): void;
|
|
51
|
-
lastRejectionTime: number;
|
|
52
|
-
lastTriggerTime: number;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
interface ProcessedDoc {
|
|
56
|
-
recentEdit: RootedEdit<StringEdit>;
|
|
57
|
-
nextEditDoc: StatelessNextEditDocument;
|
|
58
|
-
documentAfterEdits: StringText;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export class NextEditProvider extends Disposable implements INextEditProvider<NextEditResult, LlmNESTelemetryBuilder> {
|
|
62
|
-
|
|
63
|
-
public readonly ID = this._statelessNextEditProvider.ID;
|
|
64
|
-
|
|
65
|
-
private readonly _rejectionCollector = this._register(new RejectionCollector(this._workspace, s => this._logService.trace(s)));
|
|
66
|
-
private readonly _nextEditCache: NextEditCache;
|
|
67
|
-
private readonly _recentlyShownCache = new RecentlyShownCache();
|
|
68
|
-
|
|
69
|
-
private _pendingStatelessNextEditRequest: StatelessNextEditRequest<CachedOrRebasedEdit> | null = null;
|
|
70
|
-
|
|
71
|
-
private _lastShownTime = 0;
|
|
72
|
-
|
|
73
|
-
private _lastRejectionTime = 0;
|
|
74
|
-
public get lastRejectionTime() {
|
|
75
|
-
return this._lastRejectionTime;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private _lastTriggerTime = 0;
|
|
79
|
-
public get lastTriggerTime() {
|
|
80
|
-
return this._lastTriggerTime;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private _lastNextEditResult: NextEditResult | undefined;
|
|
84
|
-
private _shouldExpandEditWindow = false;
|
|
85
|
-
|
|
86
|
-
private _tracer: ITracer;
|
|
87
|
-
|
|
88
|
-
constructor(
|
|
89
|
-
private readonly _workspace: ObservableWorkspace,
|
|
90
|
-
private readonly _statelessNextEditProvider: IStatelessNextEditProvider,
|
|
91
|
-
private readonly _historyContextProvider: IHistoryContextProvider,
|
|
92
|
-
private readonly _xtabHistoryTracker: NesXtabHistoryTracker,
|
|
93
|
-
private readonly _debugRecorder: DebugRecorder | undefined,
|
|
94
|
-
@IConfigurationService private readonly _configService: IConfigurationService,
|
|
95
|
-
@ISnippyService private readonly _snippyService: ISnippyService,
|
|
96
|
-
@ILogService private readonly _logService: ILogService,
|
|
97
|
-
@IExperimentationService private readonly _expService: IExperimentationService,
|
|
98
|
-
) {
|
|
99
|
-
super();
|
|
100
|
-
|
|
101
|
-
this._tracer = createTracer(['NES', 'NextEditProvider'], (s) => this._logService.trace(s));
|
|
102
|
-
this._nextEditCache = new NextEditCache(this._workspace, this._logService);
|
|
103
|
-
|
|
104
|
-
mapObservableArrayCached(this, this._workspace.openDocuments, (doc, store) => {
|
|
105
|
-
store.add(runOnChange(doc.value, (value) => {
|
|
106
|
-
this._cancelPendingRequestDueToDocChange(doc.id, value);
|
|
107
|
-
}));
|
|
108
|
-
}).recomputeInitiallyAndOnChange(this._store);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
private _cancelPendingRequestDueToDocChange(docId: DocumentId, docValue: StringText) {
|
|
112
|
-
const isAsyncCompletions = this._configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsAsyncCompletions, this._expService);
|
|
113
|
-
if (isAsyncCompletions || this._pendingStatelessNextEditRequest === null) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
const activeDoc = this._pendingStatelessNextEditRequest.getActiveDocument();
|
|
117
|
-
if (activeDoc.id === docId && activeDoc.documentAfterEdits.value !== docValue.value) {
|
|
118
|
-
this._pendingStatelessNextEditRequest.cancellationTokenSource.cancel();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
public async getNextEdit(docId: DocumentId, context: vscode.InlineCompletionContext, logContext: InlineEditRequestLogContext, cancellationToken: CancellationToken, telemetryBuilder: LlmNESTelemetryBuilder): Promise<NextEditResult> {
|
|
123
|
-
this._lastTriggerTime = Date.now();
|
|
124
|
-
|
|
125
|
-
const shouldExpandEditWindow = this._shouldExpandEditWindow;
|
|
126
|
-
this._shouldExpandEditWindow = false;
|
|
127
|
-
|
|
128
|
-
logContext.setStatelessNextEditProviderId(this._statelessNextEditProvider.ID);
|
|
129
|
-
|
|
130
|
-
let result: NextEditResult;
|
|
131
|
-
try {
|
|
132
|
-
result = await this._getNextEdit(docId, context, this._lastTriggerTime, shouldExpandEditWindow, logContext, cancellationToken, telemetryBuilder);
|
|
133
|
-
} catch (error) {
|
|
134
|
-
logContext.setError(error);
|
|
135
|
-
throw error;
|
|
136
|
-
} finally {
|
|
137
|
-
telemetryBuilder.markEndTime();
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
this._lastNextEditResult = result;
|
|
141
|
-
|
|
142
|
-
return result;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
public async _getNextEdit(docId: DocumentId, context: vscode.InlineCompletionContext, triggerTime: number, shouldExpandEditWindow: boolean, logContext: InlineEditRequestLogContext, cancellationToken: CancellationToken, telemetryBuilder: LlmNESTelemetryBuilder): Promise<NextEditResult> {
|
|
146
|
-
const tracer = this._tracer.sub('_getNextEdit');
|
|
147
|
-
|
|
148
|
-
const doc = this._workspace.getDocument(docId);
|
|
149
|
-
if (!doc) {
|
|
150
|
-
tracer.throws(`Document "${docId}" not found`);
|
|
151
|
-
throw new BugIndicatingError(`Document "${docId}" not found`); // FIXME@ulugbekna: currently this's not reported in telemetry
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const documentAtInvocationTime = doc.value.get();
|
|
155
|
-
|
|
156
|
-
const nesConfigs: INesConfigs = {
|
|
157
|
-
isAsyncCompletions: this._configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsAsyncCompletions, this._expService),
|
|
158
|
-
isRevisedCacheStrategy: this._configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsRevisedCacheStrategy, this._expService),
|
|
159
|
-
isCacheTracksRejections: this._configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsCacheTracksRejections, this._expService),
|
|
160
|
-
isRecentlyShownCacheEnabled: this._configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsRecentlyShownCacheEnabled, this._expService),
|
|
161
|
-
debounceUseCoreRequestTime: this._configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsDebounceUseCoreRequestTime, this._expService),
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
telemetryBuilder.setNESConfigs({ ...nesConfigs });
|
|
165
|
-
logContext.addCodeblockToLog(JSON.stringify(nesConfigs, null, '\t'));
|
|
166
|
-
|
|
167
|
-
const recentlyShownCachedEdit = this._recentlyShownCache.get(docId, documentAtInvocationTime);
|
|
168
|
-
const cachedEdit = this._nextEditCache.lookupNextEdit(docId, documentAtInvocationTime, doc.selection.get(), nesConfigs);
|
|
169
|
-
|
|
170
|
-
if (cachedEdit?.rejected) {
|
|
171
|
-
tracer.trace('cached edit was previously rejected');
|
|
172
|
-
telemetryBuilder.setStatus('previouslyRejectedCache');
|
|
173
|
-
telemetryBuilder.setWasPreviouslyRejected();
|
|
174
|
-
const nextEditResult = new NextEditResult(logContext.requestId, cachedEdit.source, undefined);
|
|
175
|
-
return nextEditResult;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
let edit: StringReplacement | undefined;
|
|
179
|
-
let currentDocument: StringText | undefined;
|
|
180
|
-
let throwingError: Error | undefined;
|
|
181
|
-
let req: NextEditFetchRequest;
|
|
182
|
-
let targetDocumentId = docId;
|
|
183
|
-
|
|
184
|
-
const cacheDelay = this._configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsCacheDelay, this._expService);
|
|
185
|
-
const minimumResponseDelay = cacheDelay;
|
|
186
|
-
|
|
187
|
-
let isRebasedCachedEdit = false;
|
|
188
|
-
let isSubsequentCachedEdit = false;
|
|
189
|
-
|
|
190
|
-
if (recentlyShownCachedEdit) {
|
|
191
|
-
tracer.trace('using recently shown cached edit');
|
|
192
|
-
edit = recentlyShownCachedEdit[0];
|
|
193
|
-
req = recentlyShownCachedEdit[1];
|
|
194
|
-
logContext.setIsCachedResult(req.log);
|
|
195
|
-
currentDocument = documentAtInvocationTime;
|
|
196
|
-
telemetryBuilder.setHeaderRequestId(req.headerRequestId);
|
|
197
|
-
telemetryBuilder.setIsFromCache();
|
|
198
|
-
// TODO
|
|
199
|
-
// telemetryBuilder.setSubsequentEditOrder(cachedEdit.subsequentN);
|
|
200
|
-
// back-date the recording bookmark of the cached edit to the bookmark of the original request.
|
|
201
|
-
logContext.recordingBookmark = req.log.recordingBookmark;
|
|
202
|
-
|
|
203
|
-
} else if (cachedEdit) {
|
|
204
|
-
tracer.trace('using cached edit');
|
|
205
|
-
edit = cachedEdit.rebasedEdit || cachedEdit.edit;
|
|
206
|
-
isRebasedCachedEdit = !!cachedEdit.rebasedEdit;
|
|
207
|
-
isSubsequentCachedEdit = cachedEdit.subsequentN !== undefined && cachedEdit.subsequentN > 0;
|
|
208
|
-
req = cachedEdit.source;
|
|
209
|
-
logContext.setIsCachedResult(cachedEdit.source.log);
|
|
210
|
-
currentDocument = documentAtInvocationTime;
|
|
211
|
-
telemetryBuilder.setHeaderRequestId(req.headerRequestId);
|
|
212
|
-
telemetryBuilder.setIsFromCache();
|
|
213
|
-
telemetryBuilder.setSubsequentEditOrder(cachedEdit.rebasedEditIndex ?? cachedEdit.subsequentN);
|
|
214
|
-
// back-date the recording bookmark of the cached edit to the bookmark of the original request.
|
|
215
|
-
logContext.recordingBookmark = req.log.recordingBookmark;
|
|
216
|
-
|
|
217
|
-
} else {
|
|
218
|
-
tracer.trace('fetching next edit');
|
|
219
|
-
req = new NextEditFetchRequest(context.requestUuid, logContext, nesConfigs.debounceUseCoreRequestTime ? (context.requestIssuedDateTime ?? undefined) : undefined);
|
|
220
|
-
telemetryBuilder.setHeaderRequestId(req.headerRequestId);
|
|
221
|
-
|
|
222
|
-
const startVersion = doc.value.get();
|
|
223
|
-
tracer.trace('awaiting firstEdit promise');
|
|
224
|
-
const result = await this.fetchNextEdit(req, doc, nesConfigs, shouldExpandEditWindow, telemetryBuilder, cancellationToken);
|
|
225
|
-
tracer.trace('resolved firstEdit promise');
|
|
226
|
-
const latency = `First edit latency: ${Date.now() - this._lastTriggerTime} ms`;
|
|
227
|
-
logContext.addLog(latency);
|
|
228
|
-
tracer.trace(latency);
|
|
229
|
-
|
|
230
|
-
if (result.isError()) {
|
|
231
|
-
tracer.trace(`failed to fetch next edit ${result.err.kind}${(result.err as any).message ? ` (${(result.err as any).message})` : ''}`);
|
|
232
|
-
telemetryBuilder.setStatus(`noEdit:${result.err.kind}`);
|
|
233
|
-
if (result.err instanceof NoNextEditReason.FetchFailure || result.err instanceof NoNextEditReason.Unexpected) {
|
|
234
|
-
throwingError = result.err.error;
|
|
235
|
-
}
|
|
236
|
-
} else {
|
|
237
|
-
targetDocumentId = result.val.docId ?? targetDocumentId;
|
|
238
|
-
const targetDoc = targetDocumentId ? this._workspace.getDocument(targetDocumentId)! : doc;
|
|
239
|
-
currentDocument = targetDoc.value.get();
|
|
240
|
-
const docDidChange = targetDocumentId === doc.id && startVersion.value !== currentDocument.value;
|
|
241
|
-
|
|
242
|
-
if (docDidChange) {
|
|
243
|
-
tracer.trace('document changed while fetching next edit');
|
|
244
|
-
telemetryBuilder.setStatus('docChanged');
|
|
245
|
-
logContext.setIsSkipped();
|
|
246
|
-
} else {
|
|
247
|
-
const suggestedNextEdit = result.val.rebasedEdit || result.val.edit;
|
|
248
|
-
if (!suggestedNextEdit) {
|
|
249
|
-
tracer.trace('empty edits');
|
|
250
|
-
telemetryBuilder.setStatus('emptyEdits');
|
|
251
|
-
} else {
|
|
252
|
-
tracer.trace('fetch succeeded');
|
|
253
|
-
logContext.setResponseResults([suggestedNextEdit]); // TODO: other streamed edits?
|
|
254
|
-
edit = suggestedNextEdit;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if (throwingError) {
|
|
261
|
-
tracer.throws('has throwing error', throwingError);
|
|
262
|
-
throw throwingError;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
const emptyResult = new NextEditResult(logContext.requestId, req, undefined);
|
|
266
|
-
|
|
267
|
-
if (!edit) {
|
|
268
|
-
tracer.returns('had no edit');
|
|
269
|
-
// telemetry builder status must've been set earlier
|
|
270
|
-
return emptyResult;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
if (cancellationToken.isCancellationRequested) {
|
|
274
|
-
tracer.returns('cancelled');
|
|
275
|
-
telemetryBuilder.setStatus(`noEdit:gotCancelled`);
|
|
276
|
-
return emptyResult;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
if (this._rejectionCollector.isRejected(targetDocumentId, edit) || currentDocument && this._nextEditCache.isRejectedNextEdit(targetDocumentId, currentDocument, edit, nesConfigs)) {
|
|
280
|
-
tracer.returns('edit was previously rejected');
|
|
281
|
-
telemetryBuilder.setStatus('previouslyRejected');
|
|
282
|
-
telemetryBuilder.setWasPreviouslyRejected();
|
|
283
|
-
return emptyResult;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
assert(currentDocument !== undefined, 'should be defined if edit is defined');
|
|
287
|
-
|
|
288
|
-
telemetryBuilder.setStatus('notAccepted'); // Acceptance pending.
|
|
289
|
-
const showRangePreference = this._statelessNextEditProvider.showNextEditPreference ?? ShowNextEditPreference.AroundEdit;
|
|
290
|
-
const nextEditResult = new NextEditResult(logContext.requestId, req, { edit, showRangePreference, documentBeforeEdits: currentDocument, targetDocumentId });
|
|
291
|
-
|
|
292
|
-
if (nesConfigs.isRecentlyShownCacheEnabled && !edit.isEmpty) {
|
|
293
|
-
tracer.trace('edit is not neutral');
|
|
294
|
-
this._recentlyShownCache.add(targetDocumentId, currentDocument, [edit, req]);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
telemetryBuilder.setHasNextEdit(true);
|
|
298
|
-
|
|
299
|
-
if (isRebasedCachedEdit || isSubsequentCachedEdit) {
|
|
300
|
-
tracer.trace(`minimum response delay: NOT enforced. isRebasedCachedEdit: ${isRebasedCachedEdit}, isSubsequentCachedEdit: ${isSubsequentCachedEdit}`);
|
|
301
|
-
} else {
|
|
302
|
-
tracer.trace(`minimum response delay: enforced. isRebasedCachedEdit: ${isRebasedCachedEdit}, isSubsequentCachedEdit: ${isSubsequentCachedEdit}`);
|
|
303
|
-
const fetchLatency = Date.now() - triggerTime;
|
|
304
|
-
const delay = Math.max(0, minimumResponseDelay - fetchLatency);
|
|
305
|
-
if (delay > 0) {
|
|
306
|
-
await timeout(delay);
|
|
307
|
-
if (cancellationToken.isCancellationRequested) {
|
|
308
|
-
tracer.returns('cancelled');
|
|
309
|
-
telemetryBuilder.setStatus(`noEdit:gotCancelled`);
|
|
310
|
-
return emptyResult;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
tracer.returns('returning next edit result');
|
|
316
|
-
return nextEditResult;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
private _processDoc(doc: DocumentHistory): ProcessedDoc {
|
|
320
|
-
const documentLinesBeforeEdit = doc.lastEdit.base.getLines();
|
|
321
|
-
|
|
322
|
-
const recentEdits = doc.lastEdits;
|
|
323
|
-
|
|
324
|
-
const recentEdit = RootedLineEdit.fromEdit(new RootedEdit(doc.lastEdit.base, doc.lastEdits.compose())).removeCommonSuffixPrefixLines().edit;
|
|
325
|
-
|
|
326
|
-
const documentBeforeEdits = doc.lastEdit.base;
|
|
327
|
-
|
|
328
|
-
const lastSelectionInAfterEdits = doc.lastSelection;
|
|
329
|
-
|
|
330
|
-
const workspaceRoot = this._workspace.getWorkspaceRoot(doc.docId);
|
|
331
|
-
|
|
332
|
-
const nextEditDoc = new StatelessNextEditDocument(
|
|
333
|
-
doc.docId,
|
|
334
|
-
workspaceRoot,
|
|
335
|
-
doc.languageId,
|
|
336
|
-
documentLinesBeforeEdit,
|
|
337
|
-
recentEdit,
|
|
338
|
-
documentBeforeEdits,
|
|
339
|
-
recentEdits,
|
|
340
|
-
lastSelectionInAfterEdits,
|
|
341
|
-
);
|
|
342
|
-
|
|
343
|
-
return {
|
|
344
|
-
recentEdit: doc.lastEdit,
|
|
345
|
-
nextEditDoc,
|
|
346
|
-
documentAfterEdits: nextEditDoc.documentAfterEdits,
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
private async fetchNextEdit(req: NextEditFetchRequest, doc: IObservableDocument, nesConfigs: INesConfigs, shouldExpandEditWindow: boolean, telemetryBuilder: LlmNESTelemetryBuilder, cancellationToken: CancellationToken): Promise<Result<CachedOrRebasedEdit, NoNextEditReason>> {
|
|
351
|
-
const curDocId = doc.id;
|
|
352
|
-
const tracer = this._tracer.sub('fetchNextEdit');
|
|
353
|
-
const historyContext = this._historyContextProvider.getHistoryContext(curDocId);
|
|
354
|
-
|
|
355
|
-
if (!historyContext) {
|
|
356
|
-
return Result.error(new NoNextEditReason.Unexpected(new Error('DocumentMissingInHistoryContext')));
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
const documentAtInvocationTime = doc.value.get();
|
|
360
|
-
const selectionAtInvocationTime = doc.selection.get();
|
|
361
|
-
|
|
362
|
-
const logContext = req.log;
|
|
363
|
-
|
|
364
|
-
logContext.setRecentEdit(historyContext);
|
|
365
|
-
|
|
366
|
-
const pendingRequestStillCurrent = documentAtInvocationTime.value === this._pendingStatelessNextEditRequest?.documentBeforeEdits.value;
|
|
367
|
-
const existingNextEditRequest = (pendingRequestStillCurrent || nesConfigs.isAsyncCompletions) && !this._pendingStatelessNextEditRequest?.cancellationTokenSource.token.isCancellationRequested
|
|
368
|
-
&& this._pendingStatelessNextEditRequest || undefined;
|
|
369
|
-
if (existingNextEditRequest) {
|
|
370
|
-
// Nice! No need to make another request, we can reuse the result from a pending request.
|
|
371
|
-
|
|
372
|
-
const nextEditResult = await this._joinNextEditRequest(existingNextEditRequest, telemetryBuilder, logContext, cancellationToken);
|
|
373
|
-
|
|
374
|
-
if (pendingRequestStillCurrent) {
|
|
375
|
-
telemetryBuilder.setStatelessNextEditTelemetry(nextEditResult.telemetry);
|
|
376
|
-
return nextEditResult.nextEdit.isError() ? nextEditResult.nextEdit : existingNextEditRequest.firstEdit.p;
|
|
377
|
-
} else {
|
|
378
|
-
// Needs rebasing.
|
|
379
|
-
const cacheResult = await existingNextEditRequest.firstEdit.p;
|
|
380
|
-
if (cacheResult.isOk() && cacheResult.val.edit) {
|
|
381
|
-
const rebasedCachedEdit = this._nextEditCache.tryRebaseCacheEntry(cacheResult.val, documentAtInvocationTime, selectionAtInvocationTime, nesConfigs);
|
|
382
|
-
if (rebasedCachedEdit) {
|
|
383
|
-
telemetryBuilder.setStatelessNextEditTelemetry(nextEditResult.telemetry);
|
|
384
|
-
return Result.ok(rebasedCachedEdit);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
if (cancellationToken.isCancellationRequested) {
|
|
389
|
-
tracer.trace('document changed after rebase failed');
|
|
390
|
-
telemetryBuilder.setStatelessNextEditTelemetry(nextEditResult.telemetry);
|
|
391
|
-
return Result.error(new NoNextEditReason.GotCancelled('afterFailedRebase'));
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// Rebase failed (or result had error). Check if there is a new pending request. Otherwise continue with a new request below.
|
|
395
|
-
const pendingRequestStillCurrent = documentAtInvocationTime.value === this._pendingStatelessNextEditRequest?.documentBeforeEdits.value;
|
|
396
|
-
const existingNextEditRequest2 = pendingRequestStillCurrent && !this._pendingStatelessNextEditRequest?.cancellationTokenSource.token.isCancellationRequested
|
|
397
|
-
&& this._pendingStatelessNextEditRequest || undefined;
|
|
398
|
-
if (existingNextEditRequest2) {
|
|
399
|
-
tracer.trace('reusing 2nd existing next edit request after rebase failed');
|
|
400
|
-
const nextEditResult = await this._joinNextEditRequest(existingNextEditRequest2, telemetryBuilder, logContext, cancellationToken);
|
|
401
|
-
telemetryBuilder.setStatelessNextEditTelemetry(nextEditResult.telemetry);
|
|
402
|
-
return nextEditResult.nextEdit.isError() ? nextEditResult.nextEdit : existingNextEditRequest2.firstEdit.p;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
tracer.trace('creating new next edit request after rebase failed');
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
const res = await this._executeNewNextEditRequest(req, doc, historyContext, nesConfigs, shouldExpandEditWindow, telemetryBuilder, cancellationToken);
|
|
410
|
-
const nextEditRequest = res.nextEditRequest;
|
|
411
|
-
const nextEditResult = res.nextEditResult;
|
|
412
|
-
telemetryBuilder.setStatelessNextEditTelemetry(nextEditResult.telemetry);
|
|
413
|
-
return nextEditResult.nextEdit.isError() ? nextEditResult.nextEdit : nextEditRequest.firstEdit.p;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
private async _joinNextEditRequest(nextEditRequest: StatelessNextEditRequest, telemetryBuilder: LlmNESTelemetryBuilder, logContext: InlineEditRequestLogContext, cancellationToken: CancellationToken) {
|
|
417
|
-
// TODO: Will the telemetry look alright in this case?
|
|
418
|
-
telemetryBuilder.setHeaderRequestId(nextEditRequest.id);
|
|
419
|
-
telemetryBuilder.setIsFromCache();
|
|
420
|
-
|
|
421
|
-
telemetryBuilder.setRequest(nextEditRequest);
|
|
422
|
-
logContext.setRequestInput(nextEditRequest);
|
|
423
|
-
logContext.setIsCachedResult(nextEditRequest.logContext);
|
|
424
|
-
|
|
425
|
-
const disp = this._hookupCancellation(nextEditRequest, cancellationToken);
|
|
426
|
-
try {
|
|
427
|
-
return await nextEditRequest.result;
|
|
428
|
-
} finally {
|
|
429
|
-
disp.dispose();
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
private async _executeNewNextEditRequest(
|
|
434
|
-
req: NextEditFetchRequest,
|
|
435
|
-
doc: IObservableDocument,
|
|
436
|
-
historyContext: HistoryContext,
|
|
437
|
-
nesConfigs: INesConfigs,
|
|
438
|
-
shouldExpandEditWindow: boolean,
|
|
439
|
-
telemetryBuilder: LlmNESTelemetryBuilder,
|
|
440
|
-
cancellationToken: CancellationToken
|
|
441
|
-
) {
|
|
442
|
-
const curDocId = doc.id;
|
|
443
|
-
const tracer = this._tracer.sub('_executeNewNextEditRequest');
|
|
444
|
-
|
|
445
|
-
const recording = this._debugRecorder?.getRecentLog();
|
|
446
|
-
|
|
447
|
-
const logContext = req.log;
|
|
448
|
-
|
|
449
|
-
const activeDocAndIdx = assertDefined(historyContext.getDocumentAndIdx(curDocId));
|
|
450
|
-
const activeDocSelection = doc.selection.get()[0] as OffsetRange | undefined;
|
|
451
|
-
|
|
452
|
-
const projectedDocuments = historyContext.documents.map(doc => this._processDoc(doc));
|
|
453
|
-
|
|
454
|
-
const xtabEditHistory = this._xtabHistoryTracker.getHistory();
|
|
455
|
-
|
|
456
|
-
function convertLineEditToEdit(nextLineEdit: LineEdit, docId: DocumentId): StringEdit {
|
|
457
|
-
const doc = projectedDocuments.find(d => d.nextEditDoc.id === docId)!;
|
|
458
|
-
const rootedLineEdit = new RootedLineEdit(doc.documentAfterEdits, nextLineEdit);
|
|
459
|
-
const suggestedEdit = rootedLineEdit.toEdit();
|
|
460
|
-
return suggestedEdit;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
const firstEdit = new DeferredPromise<Result<CachedOrRebasedEdit, NoNextEditReason>>();
|
|
464
|
-
|
|
465
|
-
const nLinesEditWindow = (shouldExpandEditWindow
|
|
466
|
-
? this._configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsAutoExpandEditWindowLines, this._expService)
|
|
467
|
-
: undefined);
|
|
468
|
-
|
|
469
|
-
const nextEditRequest = new StatelessNextEditRequest(
|
|
470
|
-
req.headerRequestId,
|
|
471
|
-
req.opportunityId,
|
|
472
|
-
doc.value.get(),
|
|
473
|
-
projectedDocuments.map(d => d.nextEditDoc),
|
|
474
|
-
activeDocAndIdx.idx,
|
|
475
|
-
xtabEditHistory,
|
|
476
|
-
firstEdit,
|
|
477
|
-
nLinesEditWindow,
|
|
478
|
-
logContext,
|
|
479
|
-
req.log.recordingBookmark,
|
|
480
|
-
recording,
|
|
481
|
-
req.providerRequestStartDateTime,
|
|
482
|
-
);
|
|
483
|
-
let nextEditResult: StatelessNextEditResult | undefined;
|
|
484
|
-
|
|
485
|
-
if (this._pendingStatelessNextEditRequest) {
|
|
486
|
-
this._pendingStatelessNextEditRequest.cancellationTokenSource.cancel();
|
|
487
|
-
this._pendingStatelessNextEditRequest = null;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
this._pendingStatelessNextEditRequest = nextEditRequest;
|
|
491
|
-
|
|
492
|
-
const removeFromPending = () => {
|
|
493
|
-
if (this._pendingStatelessNextEditRequest === nextEditRequest) {
|
|
494
|
-
this._pendingStatelessNextEditRequest = null;
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
|
|
498
|
-
telemetryBuilder.setRequest(nextEditRequest);
|
|
499
|
-
telemetryBuilder.setStatus('requested');
|
|
500
|
-
logContext.setRequestInput(nextEditRequest);
|
|
501
|
-
|
|
502
|
-
// A note on cancellation:
|
|
503
|
-
//
|
|
504
|
-
// We don't cancel when the cancellation token is signalled, because we have our own
|
|
505
|
-
// separate cancellation logic which ends up cancelling based on documents changing.
|
|
506
|
-
//
|
|
507
|
-
// But we do cancel requests which didn't start yet if no-one really needs their result
|
|
508
|
-
//
|
|
509
|
-
const disp = this._hookupCancellation(nextEditRequest, cancellationToken, nesConfigs.isAsyncCompletions ? autorunWithChanges(this, {
|
|
510
|
-
value: doc.value,
|
|
511
|
-
}, data => {
|
|
512
|
-
data.value.changes.forEach(edit => {
|
|
513
|
-
if (nextEditRequest.intermediateUserEdit && !edit.isEmpty()) {
|
|
514
|
-
nextEditRequest.intermediateUserEdit = nextEditRequest.intermediateUserEdit.compose(edit);
|
|
515
|
-
if (!checkEditConsistency(nextEditRequest.documentBeforeEdits.value, nextEditRequest.intermediateUserEdit, data.value.value.value, tracer)) {
|
|
516
|
-
nextEditRequest.intermediateUserEdit = undefined;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
});
|
|
520
|
-
}) : undefined);
|
|
521
|
-
|
|
522
|
-
const createPushEdit = (): PushEdit => {
|
|
523
|
-
this._tracer.sub('createPushEdit');
|
|
524
|
-
let ithEdit = -1;
|
|
525
|
-
const statePerDoc = new CachedFunction((id: DocumentId) => {
|
|
526
|
-
const doc = projectedDocuments.find(d => d.nextEditDoc.id === id);
|
|
527
|
-
if (!doc) {
|
|
528
|
-
throw new BugIndicatingError();
|
|
529
|
-
}
|
|
530
|
-
return {
|
|
531
|
-
docContents: doc.documentAfterEdits,
|
|
532
|
-
editsSoFar: StringEdit.empty,
|
|
533
|
-
nextEdits: [] as StringReplacement[],
|
|
534
|
-
docId: id,
|
|
535
|
-
};
|
|
536
|
-
});
|
|
537
|
-
const pushEdit: PushEdit = (result) => {
|
|
538
|
-
const tracer = this._tracer.sub('pushEdit');
|
|
539
|
-
|
|
540
|
-
++ithEdit;
|
|
541
|
-
tracer.trace(`processing edit #${ithEdit} (starts at 0)`);
|
|
542
|
-
|
|
543
|
-
if (result.isError()) { // either error or stream of edits ended
|
|
544
|
-
if (statePerDoc.get(curDocId).nextEdits.length) {
|
|
545
|
-
tracer.returns(`${statePerDoc.get(curDocId).nextEdits.length} edits returned`);
|
|
546
|
-
} else {
|
|
547
|
-
tracer.returns(`no edit, reason: ${result.err.kind}`);
|
|
548
|
-
if (result.err instanceof NoNextEditReason.NoSuggestions) {
|
|
549
|
-
const { documentBeforeEdits, window } = result.err;
|
|
550
|
-
let reducedWindow = window;
|
|
551
|
-
if (activeDocSelection && window) {
|
|
552
|
-
const cursorOffset = activeDocSelection.endExclusive;
|
|
553
|
-
const t = documentBeforeEdits.getTransformer();
|
|
554
|
-
const cursorPosition = t.getPosition(cursorOffset);
|
|
555
|
-
const lineOffset = t.getOffset(cursorPosition.with(undefined, 1));
|
|
556
|
-
const lineEndOffset = t.getOffset(cursorPosition.with(undefined, t.getLineLength(cursorPosition.lineNumber) + 1));
|
|
557
|
-
const reducedOffset = t.getOffset(t.getPosition(window.start).delta(1));
|
|
558
|
-
const reducedEndPosition = t.getPosition(window.endExclusive).delta(-2);
|
|
559
|
-
const reducedEndOffset = t.getOffset(reducedEndPosition.column > 1 ? reducedEndPosition.with(undefined, t.getLineLength(reducedEndPosition.lineNumber) + 1) : reducedEndPosition);
|
|
560
|
-
reducedWindow = new OffsetRange(
|
|
561
|
-
Math.min(reducedOffset, lineOffset),
|
|
562
|
-
Math.max(reducedEndOffset, lineEndOffset)
|
|
563
|
-
);
|
|
564
|
-
}
|
|
565
|
-
this._nextEditCache.setNoNextEdit(curDocId, documentBeforeEdits, reducedWindow, req, nesConfigs);
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
{
|
|
569
|
-
disp.dispose();
|
|
570
|
-
removeFromPending();
|
|
571
|
-
}
|
|
572
|
-
if (!firstEdit.isSettled) {
|
|
573
|
-
firstEdit.complete(result);
|
|
574
|
-
}
|
|
575
|
-
return;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
const targetDocState = statePerDoc.get(result.val.targetDocument ?? curDocId);
|
|
579
|
-
|
|
580
|
-
const singleLineEdit = result.val.edit;
|
|
581
|
-
const lineEdit = new LineEdit([singleLineEdit]);
|
|
582
|
-
const edit = convertLineEditToEdit(lineEdit, targetDocState.docId);
|
|
583
|
-
const rebasedEdit = edit.tryRebase(targetDocState.editsSoFar);
|
|
584
|
-
|
|
585
|
-
if (rebasedEdit === undefined) {
|
|
586
|
-
tracer.trace(`edit ${ithEdit} is undefined after rebasing`);
|
|
587
|
-
if (!firstEdit.isSettled) {
|
|
588
|
-
firstEdit.complete(Result.error(new NoNextEditReason.Uncategorized(new Error('Rebased edit is undefined'))));
|
|
589
|
-
}
|
|
590
|
-
return;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
targetDocState.editsSoFar = targetDocState.editsSoFar.compose(rebasedEdit);
|
|
594
|
-
|
|
595
|
-
let cachedEdit;
|
|
596
|
-
if (rebasedEdit.replacements.length === 0) {
|
|
597
|
-
tracer.trace(`WARNING: ${ithEdit} has no edits`);
|
|
598
|
-
} else if (rebasedEdit.replacements.length > 1) {
|
|
599
|
-
tracer.trace(`WARNING: ${ithEdit} has ${rebasedEdit.replacements.length} edits, but expected only 1`);
|
|
600
|
-
} else {
|
|
601
|
-
// populate the cache
|
|
602
|
-
const nextEdit = rebasedEdit.replacements[0];
|
|
603
|
-
targetDocState.nextEdits.push(nextEdit);
|
|
604
|
-
cachedEdit = this._nextEditCache.setKthNextEdit(targetDocState.docId, targetDocState.docContents, ithEdit === 0 ? result.val.window : undefined, nextEdit, ithEdit, ithEdit === 0 ? targetDocState.nextEdits : undefined, ithEdit === 0 ? nextEditRequest.intermediateUserEdit : undefined, req);
|
|
605
|
-
tracer.trace(`populated cache for ${ithEdit}`);
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
if (!firstEdit.isSettled) {
|
|
609
|
-
tracer.trace('resolving firstEdit promise');
|
|
610
|
-
logContext.setResult(new RootedLineEdit(targetDocState.docContents, lineEdit)); // this's correct without rebasing because this's the first edit
|
|
611
|
-
firstEdit.complete(cachedEdit ? Result.ok(cachedEdit) : Result.error(new NoNextEditReason.Unexpected(new Error('No cached edit'))));
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
targetDocState.docContents = rebasedEdit.applyOnText(targetDocState.docContents);
|
|
615
|
-
};
|
|
616
|
-
|
|
617
|
-
return pushEdit;
|
|
618
|
-
};
|
|
619
|
-
const pushEdit = createPushEdit();
|
|
620
|
-
try {
|
|
621
|
-
nextEditResult = await this._statelessNextEditProvider.provideNextEdit(nextEditRequest, pushEdit, logContext, nextEditRequest.cancellationTokenSource.token);
|
|
622
|
-
nextEditRequest.setResult(nextEditResult);
|
|
623
|
-
} catch (err) {
|
|
624
|
-
nextEditRequest.setResultError(err);
|
|
625
|
-
throw err;
|
|
626
|
-
} finally {
|
|
627
|
-
if (!nextEditResult || nextEditResult.nextEdit.isError()) {
|
|
628
|
-
// when streaming, we need to keep the response going unless UI cancels it
|
|
629
|
-
// if we remove it from pending here, when UI cancels, we cannot cancel it because we think that the request has finished
|
|
630
|
-
disp.dispose();
|
|
631
|
-
removeFromPending();
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
return { nextEditRequest, nextEditResult };
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
private _hookupCancellation(nextEditRequest: StatelessNextEditRequest, cancellationToken: CancellationToken, attachedDisposable?: IDisposable): IDisposable {
|
|
638
|
-
const disposables = new DisposableStore();
|
|
639
|
-
|
|
640
|
-
let dependantRemoved = false;
|
|
641
|
-
const removeDependant = () => {
|
|
642
|
-
if (!dependantRemoved) {
|
|
643
|
-
dependantRemoved = true;
|
|
644
|
-
nextEditRequest.liveDependentants--;
|
|
645
|
-
}
|
|
646
|
-
};
|
|
647
|
-
|
|
648
|
-
const cancellationTimer = disposables.add(new TimeoutTimer());
|
|
649
|
-
|
|
650
|
-
disposables.add(cancellationToken.onCancellationRequested(() => {
|
|
651
|
-
removeDependant();
|
|
652
|
-
if (nextEditRequest.liveDependentants > 0) {
|
|
653
|
-
// there are others depending on this request
|
|
654
|
-
return;
|
|
655
|
-
}
|
|
656
|
-
if (!nextEditRequest.fetchIssued) {
|
|
657
|
-
// fetch not issued => cancel!
|
|
658
|
-
nextEditRequest.cancellationTokenSource.cancel();
|
|
659
|
-
attachedDisposable?.dispose();
|
|
660
|
-
return;
|
|
661
|
-
}
|
|
662
|
-
cancellationTimer.setIfNotSet(() => {
|
|
663
|
-
if (nextEditRequest.liveDependentants > 0) {
|
|
664
|
-
// there are others depending on this request
|
|
665
|
-
return;
|
|
666
|
-
}
|
|
667
|
-
nextEditRequest.cancellationTokenSource.cancel();
|
|
668
|
-
attachedDisposable?.dispose();
|
|
669
|
-
}, 1000); // This needs to be longer than the pause between two requests from Core otherwise we cancel running requests too early.
|
|
670
|
-
}));
|
|
671
|
-
|
|
672
|
-
disposables.add(toDisposable(() => {
|
|
673
|
-
removeDependant();
|
|
674
|
-
if (nextEditRequest.liveDependentants === 0) {
|
|
675
|
-
attachedDisposable?.dispose();
|
|
676
|
-
}
|
|
677
|
-
}));
|
|
678
|
-
|
|
679
|
-
nextEditRequest.liveDependentants++;
|
|
680
|
-
|
|
681
|
-
return disposables;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
public handleShown(suggestion: NextEditResult) {
|
|
685
|
-
this._lastShownTime = Date.now();
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
public handleAcceptance(docId: DocumentId, suggestion: NextEditResult) {
|
|
689
|
-
this.runSnippy(docId, suggestion);
|
|
690
|
-
this._statelessNextEditProvider.handleAcceptance?.();
|
|
691
|
-
|
|
692
|
-
if (suggestion === this._lastNextEditResult) {
|
|
693
|
-
this._shouldExpandEditWindow = true;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
public handleRejection(docId: DocumentId, suggestion: NextEditResult) {
|
|
698
|
-
assertType(suggestion.result, '@ulugbekna: undefined edit cannot be rejected?');
|
|
699
|
-
|
|
700
|
-
const shownDuration = Date.now() - this._lastShownTime;
|
|
701
|
-
if (shownDuration > 1000 && suggestion.result) {
|
|
702
|
-
// we can argue that the user had the time to review this
|
|
703
|
-
// so it wasn't an accidental rejection
|
|
704
|
-
this._recentlyShownCache.remove(suggestion.result.edit);
|
|
705
|
-
this._rejectionCollector.reject(docId, suggestion.result.edit);
|
|
706
|
-
if (this._configService.getExperimentBasedConfig(ConfigKey.Internal.InlineEditsCacheTracksRejections, this._expService)) {
|
|
707
|
-
this._nextEditCache.rejectedNextEdit(suggestion.source.headerRequestId);
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
this._lastRejectionTime = Date.now();
|
|
712
|
-
|
|
713
|
-
this._statelessNextEditProvider.handleRejection?.();
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
public handleIgnored(docId: DocumentId, suggestion: NextEditResult, supersededBy: INextEditResult | undefined): void { }
|
|
717
|
-
|
|
718
|
-
private async runSnippy(docId: DocumentId, suggestion: NextEditResult) {
|
|
719
|
-
if (suggestion.result === undefined) {
|
|
720
|
-
return;
|
|
721
|
-
}
|
|
722
|
-
this._snippyService.handlePostInsertion(docId.toUri(), suggestion.result.documentBeforeEdits, suggestion.result.edit);
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
public clearCache() {
|
|
726
|
-
this._nextEditCache.clear();
|
|
727
|
-
this._recentlyShownCache.clear();
|
|
728
|
-
this._rejectionCollector.clear();
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
function assertDefined<T>(value: T | undefined): T {
|
|
733
|
-
if (!value) {
|
|
734
|
-
throw new BugIndicatingError('expected value to be defined, but it was not');
|
|
735
|
-
}
|
|
736
|
-
return value;
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
export class NextEditFetchRequest {
|
|
740
|
-
public readonly headerRequestId = generateUuid();
|
|
741
|
-
constructor(
|
|
742
|
-
public readonly opportunityId: string,
|
|
743
|
-
public readonly log: InlineEditRequestLogContext,
|
|
744
|
-
public readonly providerRequestStartDateTime: number | undefined,
|
|
745
|
-
) {
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
class RecentlyShownCache {
|
|
750
|
-
private readonly _cache = new LRUCache<string, [StringReplacement, NextEditFetchRequest]>(10);
|
|
751
|
-
|
|
752
|
-
add(docId: DocumentId, documentBeforeEdits: StringText, edit: [StringReplacement, NextEditFetchRequest]) {
|
|
753
|
-
const key = this._key(docId, documentBeforeEdits);
|
|
754
|
-
this._cache.set(key, edit);
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
get(docId: DocumentId, documentContent: StringText): [StringReplacement, NextEditFetchRequest] | undefined {
|
|
758
|
-
const key = this._key(docId, documentContent);
|
|
759
|
-
return this._cache.get(key);
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
remove(edit: StringReplacement): void {
|
|
763
|
-
for (const entry of this._cache) {
|
|
764
|
-
if (entry[1][0] === edit) {
|
|
765
|
-
this._cache.delete(entry[0]);
|
|
766
|
-
break;
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
clear() {
|
|
772
|
-
this._cache.clear();
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
private _key(docId: DocumentId, documentContent: StringText) {
|
|
776
|
-
return docId.uri + ';' + documentContent.value;
|
|
777
|
-
}
|
|
778
|
-
}
|