@vscode/chat-lib 0.4.1-2 → 0.4.1-20
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/byok/node/openAIEndpoint.d.ts +2 -1
- package/dist/src/_internal/extension/byok/node/openAIEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/extension/byok/node/openAIEndpoint.js +6 -7
- package/dist/src/_internal/extension/byok/node/openAIEndpoint.js.map +1 -1
- package/dist/src/_internal/extension/common/constants.d.ts +0 -1
- package/dist/src/_internal/extension/common/constants.d.ts.map +1 -1
- package/dist/src/_internal/extension/common/constants.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/completionsFromNetwork.js +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/completionsFromNetwork.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/model.d.ts +4 -0
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/model.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/model.js +4 -0
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/model.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/common/delay.d.ts +3 -1
- package/dist/src/_internal/extension/inlineEdits/common/delay.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/common/delay.js +6 -0
- package/dist/src/_internal/extension/inlineEdits/common/delay.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/common/editRebase.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/common/editRebase.js +2 -35
- package/dist/src/_internal/extension/inlineEdits/common/editRebase.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/common/userInteractionMonitor.d.ts +6 -0
- package/dist/src/_internal/extension/inlineEdits/common/userInteractionMonitor.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/common/userInteractionMonitor.js +19 -35
- package/dist/src/_internal/extension/inlineEdits/common/userInteractionMonitor.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditCache.d.ts +1 -0
- package/dist/src/_internal/extension/inlineEdits/node/nextEditCache.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.d.ts +21 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.js +218 -106
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.d.ts +7 -0
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.js +18 -3
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditResult.d.ts +2 -0
- package/dist/src/_internal/extension/inlineEdits/node/nextEditResult.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditResult.js.map +1 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.d.ts +19 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.d.ts.map +1 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.js +367 -98
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.js.map +1 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcherTelemetry.d.ts +6 -3
- package/dist/src/_internal/extension/prompt/node/chatMLFetcherTelemetry.d.ts.map +1 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcherTelemetry.js +9 -3
- package/dist/src/_internal/extension/prompt/node/chatMLFetcherTelemetry.js.map +1 -1
- package/dist/src/_internal/extension/xtab/common/diffHistoryForPrompt.d.ts +6 -1
- package/dist/src/_internal/extension/xtab/common/diffHistoryForPrompt.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/common/diffHistoryForPrompt.js +3 -1
- package/dist/src/_internal/extension/xtab/common/diffHistoryForPrompt.js.map +1 -1
- package/dist/src/_internal/extension/xtab/common/lintErrors.js +2 -1
- package/dist/src/_internal/extension/xtab/common/lintErrors.js.map +1 -1
- package/dist/src/_internal/extension/xtab/common/promptCrafting.d.ts +6 -1
- package/dist/src/_internal/extension/xtab/common/promptCrafting.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/common/promptCrafting.js +43 -6
- package/dist/src/_internal/extension/xtab/common/promptCrafting.js.map +1 -1
- package/dist/src/_internal/extension/xtab/common/recentFilesForPrompt.d.ts +22 -0
- package/dist/src/_internal/extension/xtab/common/recentFilesForPrompt.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/common/recentFilesForPrompt.js +116 -17
- package/dist/src/_internal/extension/xtab/common/recentFilesForPrompt.js.map +1 -1
- package/dist/src/_internal/extension/xtab/common/similarFilesContextService.d.ts +10 -0
- package/dist/src/_internal/extension/xtab/common/similarFilesContextService.d.ts.map +1 -0
- package/dist/src/_internal/extension/xtab/common/similarFilesContextService.js +10 -0
- package/dist/src/_internal/extension/xtab/common/similarFilesContextService.js.map +1 -0
- package/dist/src/_internal/extension/xtab/common/tags.d.ts +1 -0
- package/dist/src/_internal/extension/xtab/common/tags.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/common/tags.js +1 -0
- package/dist/src/_internal/extension/xtab/common/tags.js.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabCustomDiffPatchResponseHandler.js +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabCustomDiffPatchResponseHandler.js.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabEndpoint.d.ts +2 -1
- package/dist/src/_internal/extension/xtab/node/xtabEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabEndpoint.js +6 -3
- package/dist/src/_internal/extension/xtab/node/xtabEndpoint.js.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabNextCursorPredictor.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabNextCursorPredictor.js +3 -2
- package/dist/src/_internal/extension/xtab/node/xtabNextCursorPredictor.js.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabProvider.d.ts +6 -1
- package/dist/src/_internal/extension/xtab/node/xtabProvider.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabProvider.js +105 -20
- package/dist/src/_internal/extension/xtab/node/xtabProvider.js.map +1 -1
- package/dist/src/_internal/platform/authentication/common/copilotToken.d.ts +4 -0
- package/dist/src/_internal/platform/authentication/common/copilotToken.d.ts.map +1 -1
- package/dist/src/_internal/platform/authentication/common/copilotToken.js +6 -0
- package/dist/src/_internal/platform/authentication/common/copilotToken.js.map +1 -1
- package/dist/src/_internal/platform/chat/common/commonTypes.d.ts +2 -1
- package/dist/src/_internal/platform/chat/common/commonTypes.d.ts.map +1 -1
- package/dist/src/_internal/platform/chat/common/commonTypes.js +61 -17
- package/dist/src/_internal/platform/chat/common/commonTypes.js.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts +35 -48
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.js +57 -66
- package/dist/src/_internal/platform/configuration/common/configurationService.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/capiClient.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/capiClient.js +1 -0
- package/dist/src/_internal/platform/endpoint/common/capiClient.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.d.ts +2 -0
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.js +32 -5
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/endpointProvider.d.ts +3 -1
- package/dist/src/_internal/platform/endpoint/common/endpointProvider.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/endpointProvider.js +1 -0
- package/dist/src/_internal/platform/endpoint/common/endpointProvider.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/autoChatEndpoint.d.ts +2 -1
- package/dist/src/_internal/platform/endpoint/node/autoChatEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/autoChatEndpoint.js +6 -3
- package/dist/src/_internal/platform/endpoint/node/autoChatEndpoint.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.d.ts +6 -2
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.js +36 -14
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/copilotChatEndpoint.d.ts +2 -1
- package/dist/src/_internal/platform/endpoint/node/copilotChatEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/copilotChatEndpoint.js +5 -3
- package/dist/src/_internal/platform/endpoint/node/copilotChatEndpoint.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/messagesApi.d.ts +1 -1
- package/dist/src/_internal/platform/endpoint/node/messagesApi.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/messagesApi.js +62 -13
- package/dist/src/_internal/platform/endpoint/node/messagesApi.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/proxyXtabEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/proxyXtabEndpoint.js +1 -0
- package/dist/src/_internal/platform/endpoint/node/proxyXtabEndpoint.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/responsesApi.d.ts +1 -0
- package/dist/src/_internal/platform/endpoint/node/responsesApi.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/responsesApi.js +14 -10
- package/dist/src/_internal/platform/endpoint/node/responsesApi.js.map +1 -1
- package/dist/src/_internal/platform/git/common/gitService.d.ts +4 -0
- package/dist/src/_internal/platform/git/common/gitService.d.ts.map +1 -1
- package/dist/src/_internal/platform/git/common/gitService.js.map +1 -1
- package/dist/src/_internal/platform/github/common/githubAPI.d.ts +1 -0
- package/dist/src/_internal/platform/github/common/githubAPI.d.ts.map +1 -1
- package/dist/src/_internal/platform/github/common/githubAPI.js +2 -0
- package/dist/src/_internal/platform/github/common/githubAPI.js.map +1 -1
- package/dist/src/_internal/platform/github/common/githubService.d.ts +10 -0
- package/dist/src/_internal/platform/github/common/githubService.d.ts.map +1 -1
- package/dist/src/_internal/platform/github/common/githubService.js +38 -0
- package/dist/src/_internal/platform/github/common/githubService.js.map +1 -1
- package/dist/src/_internal/platform/github/common/nullOctokitServiceImpl.d.ts +2 -1
- package/dist/src/_internal/platform/github/common/nullOctokitServiceImpl.d.ts.map +1 -1
- package/dist/src/_internal/platform/github/common/nullOctokitServiceImpl.js +3 -0
- package/dist/src/_internal/platform/github/common/nullOctokitServiceImpl.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/triggerOptions.d.ts +8 -0
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/triggerOptions.d.ts.map +1 -0
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/triggerOptions.js +17 -0
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/triggerOptions.js.map +1 -0
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.d.ts +44 -0
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.js +71 -2
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/inlineEditLogContext.js +5 -5
- package/dist/src/_internal/platform/inlineEdits/common/inlineEditLogContext.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.d.ts +15 -1
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.js +22 -1
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/node/inlineEditsModelService.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/node/inlineEditsModelService.js +9 -44
- package/dist/src/_internal/platform/inlineEdits/node/inlineEditsModelService.js.map +1 -1
- package/dist/src/_internal/platform/nesFetch/common/responseStream.js +2 -35
- package/dist/src/_internal/platform/nesFetch/common/responseStream.js.map +1 -1
- package/dist/src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.js +3 -36
- package/dist/src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/anthropic.d.ts +14 -12
- package/dist/src/_internal/platform/networking/common/anthropic.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/anthropic.js +38 -23
- package/dist/src/_internal/platform/networking/common/anthropic.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetcherService.d.ts +60 -1
- package/dist/src/_internal/platform/networking/common/fetcherService.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetcherService.js +56 -5
- package/dist/src/_internal/platform/networking/common/fetcherService.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/networking.d.ts +42 -4
- package/dist/src/_internal/platform/networking/common/networking.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/networking.js +20 -6
- package/dist/src/_internal/platform/networking/common/networking.js.map +1 -1
- package/dist/src/_internal/platform/networking/node/chatWebSocketManager.d.ts +83 -0
- package/dist/src/_internal/platform/networking/node/chatWebSocketManager.d.ts.map +1 -0
- package/dist/src/_internal/platform/networking/node/chatWebSocketManager.js +496 -0
- package/dist/src/_internal/platform/networking/node/chatWebSocketManager.js.map +1 -0
- package/dist/src/_internal/platform/networking/node/chatWebSocketTelemetry.d.ts +89 -0
- package/dist/src/_internal/platform/networking/node/chatWebSocketTelemetry.d.ts.map +1 -0
- package/dist/src/_internal/platform/networking/node/chatWebSocketTelemetry.js +269 -0
- package/dist/src/_internal/platform/networking/node/chatWebSocketTelemetry.js.map +1 -0
- package/dist/src/_internal/platform/otel/common/genAiAttributes.d.ts +85 -0
- package/dist/src/_internal/platform/otel/common/genAiAttributes.d.ts.map +1 -0
- package/dist/src/_internal/platform/otel/common/genAiAttributes.js +105 -0
- package/dist/src/_internal/platform/otel/common/genAiAttributes.js.map +1 -0
- package/dist/src/_internal/platform/otel/common/genAiEvents.d.ts +28 -0
- package/dist/src/_internal/platform/otel/common/genAiEvents.d.ts.map +1 -0
- package/dist/src/_internal/platform/otel/common/genAiEvents.js +91 -0
- package/dist/src/_internal/platform/otel/common/genAiEvents.js.map +1 -0
- package/dist/src/_internal/platform/otel/common/genAiMetrics.d.ts +30 -0
- package/dist/src/_internal/platform/otel/common/genAiMetrics.d.ts.map +1 -0
- package/dist/src/_internal/platform/otel/common/genAiMetrics.js +68 -0
- package/dist/src/_internal/platform/otel/common/genAiMetrics.js.map +1 -0
- package/dist/src/_internal/platform/otel/common/index.d.ts +8 -0
- package/dist/src/_internal/platform/otel/common/index.d.ts.map +1 -0
- package/dist/src/_internal/platform/otel/common/index.js +35 -0
- package/dist/src/_internal/platform/otel/common/index.js.map +1 -0
- package/dist/src/_internal/platform/otel/common/messageFormatters.d.ts +85 -0
- package/dist/src/_internal/platform/otel/common/messageFormatters.d.ts.map +1 -0
- package/dist/src/_internal/platform/otel/common/messageFormatters.js +122 -0
- package/dist/src/_internal/platform/otel/common/messageFormatters.js.map +1 -0
- package/dist/src/_internal/platform/otel/common/noopOtelService.d.ts +23 -0
- package/dist/src/_internal/platform/otel/common/noopOtelService.d.ts.map +1 -0
- package/dist/src/_internal/platform/otel/common/noopOtelService.js +46 -0
- package/dist/src/_internal/platform/otel/common/noopOtelService.js.map +1 -0
- package/dist/src/_internal/platform/otel/common/otelConfig.d.ts +35 -0
- package/dist/src/_internal/platform/otel/common/otelConfig.d.ts.map +1 -0
- package/dist/src/_internal/platform/otel/common/otelConfig.js +140 -0
- package/dist/src/_internal/platform/otel/common/otelConfig.js.map +1 -0
- package/dist/src/_internal/platform/otel/common/otelService.d.ts +100 -0
- package/dist/src/_internal/platform/otel/common/otelService.d.ts.map +1 -0
- package/dist/src/_internal/platform/otel/common/otelService.js +10 -0
- package/dist/src/_internal/platform/otel/common/otelService.js.map +1 -0
- package/dist/src/_internal/platform/proxyModels/node/proxyModelsService.js +4 -37
- package/dist/src/_internal/platform/proxyModels/node/proxyModelsService.js.map +1 -1
- package/dist/src/_internal/platform/requestLogger/node/nullRequestLogger.d.ts +1 -0
- package/dist/src/_internal/platform/requestLogger/node/nullRequestLogger.d.ts.map +1 -1
- package/dist/src/_internal/platform/requestLogger/node/nullRequestLogger.js +3 -0
- package/dist/src/_internal/platform/requestLogger/node/nullRequestLogger.js.map +1 -1
- package/dist/src/_internal/platform/requestLogger/node/requestLogger.d.ts +2 -0
- package/dist/src/_internal/platform/requestLogger/node/requestLogger.d.ts.map +1 -1
- package/dist/src/_internal/platform/requestLogger/node/requestLogger.js.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/telemetry.d.ts +9 -1
- package/dist/src/_internal/platform/telemetry/common/telemetry.d.ts.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/telemetry.js +33 -15
- package/dist/src/_internal/platform/telemetry/common/telemetry.js.map +1 -1
- package/dist/src/_internal/platform/telemetry/node/azureInsightsReporter.d.ts +1 -1
- package/dist/src/_internal/platform/telemetry/node/azureInsightsReporter.d.ts.map +1 -1
- package/dist/src/_internal/platform/telemetry/node/azureInsightsReporter.js +3 -2
- package/dist/src/_internal/platform/telemetry/node/azureInsightsReporter.js.map +1 -1
- package/dist/src/_internal/util/common/errors.d.ts +4 -2
- package/dist/src/_internal/util/common/errors.d.ts.map +1 -1
- package/dist/src/_internal/util/common/errors.js +16 -12
- package/dist/src/_internal/util/common/errors.js.map +1 -1
- package/dist/src/_internal/util/common/result.js +4 -37
- package/dist/src/_internal/util/common/result.js.map +1 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts +14 -2
- package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts.map +1 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.js +17 -3
- package/dist/src/_internal/util/common/test/shims/chatTypes.js.map +1 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js +1 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js.map +1 -1
- package/dist/src/main.d.ts.map +1 -1
- package/dist/src/main.js +17 -0
- package/dist/src/main.js.map +1 -1
- package/dist/src/package.json +385 -234
- package/package.json +5 -4
|
@@ -3,50 +3,18 @@
|
|
|
3
3
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
4
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
6
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
23
7
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24
8
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
25
9
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
26
10
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
27
11
|
};
|
|
28
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
-
var ownKeys = function(o) {
|
|
30
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
-
var ar = [];
|
|
32
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
-
return ar;
|
|
34
|
-
};
|
|
35
|
-
return ownKeys(o);
|
|
36
|
-
};
|
|
37
|
-
return function (mod) {
|
|
38
|
-
if (mod && mod.__esModule) return mod;
|
|
39
|
-
var result = {};
|
|
40
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
-
__setModuleDefault(result, mod);
|
|
42
|
-
return result;
|
|
43
|
-
};
|
|
44
|
-
})();
|
|
45
12
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
46
13
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
47
14
|
};
|
|
15
|
+
var NextEditProvider_1;
|
|
48
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
-
exports.NextEditFetchRequest = exports.NextEditProvider = void 0;
|
|
17
|
+
exports.NextEditFetchRequest = exports.NextEditProvider = exports.NesOutcome = void 0;
|
|
50
18
|
const path_1 = require("path");
|
|
51
19
|
const configurationService_1 = require("../../../platform/configuration/common/configurationService");
|
|
52
20
|
const edit_1 = require("../../../platform/inlineEdits/common/dataTypes/edit");
|
|
@@ -60,12 +28,12 @@ const capturingToken_1 = require("../../../platform/requestLogger/common/capturi
|
|
|
60
28
|
const requestLogger_1 = require("../../../platform/requestLogger/node/requestLogger");
|
|
61
29
|
const snippyService_1 = require("../../../platform/snippy/common/snippyService");
|
|
62
30
|
const nullExperimentationService_1 = require("../../../platform/telemetry/common/nullExperimentationService");
|
|
63
|
-
const
|
|
31
|
+
const errors_1 = require("../../../util/common/errors");
|
|
64
32
|
const result_1 = require("../../../util/common/result");
|
|
65
33
|
const assert_1 = require("../../../util/vs/base/common/assert");
|
|
66
34
|
const async_1 = require("../../../util/vs/base/common/async");
|
|
67
35
|
const cache_1 = require("../../../util/vs/base/common/cache");
|
|
68
|
-
const
|
|
36
|
+
const errors_2 = require("../../../util/vs/base/common/errors");
|
|
69
37
|
const lifecycle_1 = require("../../../util/vs/base/common/lifecycle");
|
|
70
38
|
const observable_2 = require("../../../util/vs/base/common/observable");
|
|
71
39
|
const stopwatch_1 = require("../../../util/vs/base/common/stopwatch");
|
|
@@ -107,13 +75,22 @@ function convertLineEditToEdit(nextLineEdit, projectedDocuments, docId) {
|
|
|
107
75
|
const suggestedEdit = rootedLineEdit.toEdit();
|
|
108
76
|
return suggestedEdit;
|
|
109
77
|
}
|
|
110
|
-
|
|
78
|
+
var NesOutcome;
|
|
79
|
+
(function (NesOutcome) {
|
|
80
|
+
NesOutcome["Accepted"] = "accepted";
|
|
81
|
+
NesOutcome["Rejected"] = "rejected";
|
|
82
|
+
NesOutcome["Ignored"] = "ignored";
|
|
83
|
+
})(NesOutcome || (exports.NesOutcome = NesOutcome = {}));
|
|
84
|
+
let NextEditProvider = NextEditProvider_1 = class NextEditProvider extends lifecycle_1.Disposable {
|
|
111
85
|
get lastRejectionTime() {
|
|
112
86
|
return this._lastRejectionTime;
|
|
113
87
|
}
|
|
114
88
|
get lastTriggerTime() {
|
|
115
89
|
return this._lastTriggerTime;
|
|
116
90
|
}
|
|
91
|
+
get lastOutcome() {
|
|
92
|
+
return this._lastOutcome;
|
|
93
|
+
}
|
|
117
94
|
constructor(_workspace, _statelessNextEditProvider, _historyContextProvider, _xtabHistoryTracker, _debugRecorder, _configService, _snippyService, _logService, _expService, _requestLogger) {
|
|
118
95
|
super();
|
|
119
96
|
this._workspace = _workspace;
|
|
@@ -135,6 +112,14 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
135
112
|
* This allows reusing the in-flight request when the user actually accepts the suggestion.
|
|
136
113
|
*/
|
|
137
114
|
this._speculativePendingRequest = null;
|
|
115
|
+
/**
|
|
116
|
+
* A speculative request that is deferred until the originating stream completes.
|
|
117
|
+
* When a suggestion is shown while its stream is still running, we schedule the
|
|
118
|
+
* speculative request here instead of firing immediately. If more edits arrive
|
|
119
|
+
* from the stream, the schedule is cleared (the shown edit wasn't the last one).
|
|
120
|
+
* When the stream ends, if the schedule is still present, the speculative fires.
|
|
121
|
+
*/
|
|
122
|
+
this._scheduledSpeculativeRequest = null;
|
|
138
123
|
this._lastShownTime = 0;
|
|
139
124
|
/** The requestId of the last shown suggestion. We store only the requestId (not the object) to avoid preventing garbage collection. */
|
|
140
125
|
this._lastShownSuggestionId = undefined;
|
|
@@ -149,7 +134,21 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
149
134
|
}));
|
|
150
135
|
}).recomputeInitiallyAndOnChange(this._store);
|
|
151
136
|
}
|
|
137
|
+
_cancelSpeculativeRequest() {
|
|
138
|
+
this._scheduledSpeculativeRequest = null;
|
|
139
|
+
if (this._speculativePendingRequest) {
|
|
140
|
+
this._speculativePendingRequest.request.cancellationTokenSource.cancel();
|
|
141
|
+
this._speculativePendingRequest = null;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
152
144
|
_cancelPendingRequestDueToDocChange(docId, docValue) {
|
|
145
|
+
// Note: we intentionally do NOT cancel the speculative request here.
|
|
146
|
+
// The speculative request's postEditContent represents a *future* document state
|
|
147
|
+
// (after the user would accept the suggestion), so it will almost never match the
|
|
148
|
+
// current document value while the user is still typing. Cancelling here would
|
|
149
|
+
// wastefully kill and recreate the speculative request on every keystroke.
|
|
150
|
+
// Instead, speculative requests are cancelled by the appropriate lifecycle handlers:
|
|
151
|
+
// handleRejection, handleIgnored, _triggerSpeculativeRequest, and _executeNewNextEditRequest.
|
|
153
152
|
const isAsyncCompletions = this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsAsyncCompletions, this._expService);
|
|
154
153
|
if (isAsyncCompletions || this._pendingStatelessNextEditRequest === null) {
|
|
155
154
|
return;
|
|
@@ -175,7 +174,7 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
175
174
|
}
|
|
176
175
|
catch (error) {
|
|
177
176
|
logContext.setError(error);
|
|
178
|
-
telemetryBuilder.setNextEditProviderError(
|
|
177
|
+
telemetryBuilder.setNextEditProviderError(errors_1.ErrorUtils.toString(error));
|
|
179
178
|
throw error;
|
|
180
179
|
}
|
|
181
180
|
finally {
|
|
@@ -190,7 +189,7 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
190
189
|
const doc = this._workspace.getDocument(docId);
|
|
191
190
|
if (!doc) {
|
|
192
191
|
logger.trace(`Document "${docId.baseName}" not found`);
|
|
193
|
-
throw new
|
|
192
|
+
throw new errors_2.BugIndicatingError(`Document "${docId.baseName}" not found`);
|
|
194
193
|
}
|
|
195
194
|
const documentAtInvocationTime = doc.value.get();
|
|
196
195
|
const selections = doc.selection.get();
|
|
@@ -210,6 +209,7 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
210
209
|
let targetDocumentId = docId;
|
|
211
210
|
let isRebasedCachedEdit = false;
|
|
212
211
|
let isSubsequentCachedEdit = false;
|
|
212
|
+
let isFromSpeculativeRequest = false;
|
|
213
213
|
if (cachedEdit) {
|
|
214
214
|
logger.trace('using cached edit');
|
|
215
215
|
const actualEdit = cachedEdit.rebasedEdit || cachedEdit.edit;
|
|
@@ -232,7 +232,7 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
232
232
|
const providerRequestStartDateTime = (this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsDebounceUseCoreRequestTime, this._expService)
|
|
233
233
|
? (context.requestIssuedDateTime ?? undefined)
|
|
234
234
|
: undefined);
|
|
235
|
-
req = new NextEditFetchRequest(context.requestUuid, logContext, providerRequestStartDateTime);
|
|
235
|
+
req = new NextEditFetchRequest(context.requestUuid, logContext, providerRequestStartDateTime, false);
|
|
236
236
|
telemetryBuilder.setHeaderRequestId(req.headerRequestId);
|
|
237
237
|
const startVersion = doc.value.get();
|
|
238
238
|
logger.trace('awaiting firstEdit promise');
|
|
@@ -266,6 +266,7 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
266
266
|
logger.trace('fetch succeeded');
|
|
267
267
|
logContext.setResponseResults([suggestedNextEdit]); // TODO: other streamed edits?
|
|
268
268
|
edit = { actualEdit: suggestedNextEdit, isFromCursorJump: result.val.isFromCursorJump };
|
|
269
|
+
isFromSpeculativeRequest = result.val.isFromSpeculativeRequest ?? false;
|
|
269
270
|
}
|
|
270
271
|
}
|
|
271
272
|
}
|
|
@@ -280,7 +281,7 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
280
281
|
}
|
|
281
282
|
else {
|
|
282
283
|
telemetryBuilder.setStatus('emptyEditsButHasNextCursorPosition');
|
|
283
|
-
return new nextEditResult_1.NextEditResult(logContext.requestId, req, { jumpToPosition: error.nextCursorPosition, documentBeforeEdits: documentAtInvocationTime, isFromCursorJump: false });
|
|
284
|
+
return new nextEditResult_1.NextEditResult(logContext.requestId, req, { jumpToPosition: error.nextCursorPosition, documentBeforeEdits: documentAtInvocationTime, isFromCursorJump: false, isSubsequentEdit: false });
|
|
284
285
|
}
|
|
285
286
|
}
|
|
286
287
|
const emptyResult = new nextEditResult_1.NextEditResult(logContext.requestId, req, undefined);
|
|
@@ -303,9 +304,9 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
303
304
|
logContext.setResult(rootedLineEdit_1.RootedLineEdit.fromEdit(new edit_1.RootedEdit(documentAtInvocationTime, new stringEdit_1.StringEdit([edit.actualEdit]))));
|
|
304
305
|
(0, assert_1.assert)(currentDocument !== undefined, 'should be defined if edit is defined');
|
|
305
306
|
telemetryBuilder.setStatus('notAccepted'); // Acceptance pending.
|
|
306
|
-
const nextEditResult = new nextEditResult_1.NextEditResult(logContext.requestId, req, { edit: edit.actualEdit, isFromCursorJump: edit.isFromCursorJump, documentBeforeEdits: currentDocument, targetDocumentId });
|
|
307
|
+
const nextEditResult = new nextEditResult_1.NextEditResult(logContext.requestId, req, { edit: edit.actualEdit, isFromCursorJump: edit.isFromCursorJump, documentBeforeEdits: currentDocument, targetDocumentId, isSubsequentEdit: isSubsequentCachedEdit });
|
|
307
308
|
telemetryBuilder.setHasNextEdit(true);
|
|
308
|
-
const delay = this.computeMinimumResponseDelay({ triggerTime, isRebasedCachedEdit, isSubsequentCachedEdit, enforceCacheDelay: context.enforceCacheDelay }, logger);
|
|
309
|
+
const delay = this.computeMinimumResponseDelay({ triggerTime, isRebasedCachedEdit, isSubsequentCachedEdit, isFromSpeculativeRequest, enforceCacheDelay: context.enforceCacheDelay }, logger);
|
|
309
310
|
if (delay > 0) {
|
|
310
311
|
await (0, async_1.timeout)(delay);
|
|
311
312
|
if (cancellationToken.isCancellationRequested) {
|
|
@@ -356,7 +357,8 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
356
357
|
const existingNextEditRequest = (pendingRequestStillCurrent || nesConfigs.isAsyncCompletions) && !this._pendingStatelessNextEditRequest?.cancellationTokenSource.token.isCancellationRequested
|
|
357
358
|
&& this._pendingStatelessNextEditRequest || undefined;
|
|
358
359
|
// Check if we can reuse the speculative pending request (from when a suggestion was shown)
|
|
359
|
-
const speculativeRequestMatches = this._speculativePendingRequest?.
|
|
360
|
+
const speculativeRequestMatches = this._speculativePendingRequest?.docId === curDocId
|
|
361
|
+
&& this._speculativePendingRequest?.postEditContent === documentAtInvocationTime.value
|
|
360
362
|
&& !this._speculativePendingRequest.request.cancellationTokenSource.token.isCancellationRequested;
|
|
361
363
|
const speculativeRequest = speculativeRequestMatches ? this._speculativePendingRequest?.request : undefined;
|
|
362
364
|
// Prefer speculative request if it matches (it was specifically created for this post-edit state)
|
|
@@ -371,9 +373,14 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
371
373
|
const requestStillCurrent = speculativeRequest
|
|
372
374
|
? speculativeRequestMatches // For speculative, we already checked it matches
|
|
373
375
|
: pendingRequestStillCurrent;
|
|
376
|
+
const reusedRequestKind = speculativeRequest ? "speculative" /* ReusedRequestKind.Speculative */ : "async" /* ReusedRequestKind.Async */;
|
|
374
377
|
if (requestStillCurrent) {
|
|
375
|
-
const nextEditResult = await this._joinNextEditRequest(requestToReuse, telemetryBuilder, logContext, cancellationToken);
|
|
378
|
+
const nextEditResult = await this._joinNextEditRequest(requestToReuse, reusedRequestKind, telemetryBuilder, logContext, cancellationToken);
|
|
376
379
|
telemetryBuilder.setStatelessNextEditTelemetry(nextEditResult.telemetry);
|
|
380
|
+
if (speculativeRequest) {
|
|
381
|
+
const firstEdit = await requestToReuse.firstEdit.p;
|
|
382
|
+
return firstEdit.map(val => ({ ...val, isFromSpeculativeRequest: true }));
|
|
383
|
+
}
|
|
377
384
|
return nextEditResult.nextEdit.isError() ? nextEditResult.nextEdit : requestToReuse.firstEdit.p;
|
|
378
385
|
}
|
|
379
386
|
else if (nesConfigs.isEagerBackupRequest) {
|
|
@@ -391,7 +398,7 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
391
398
|
.catch(() => undefined);
|
|
392
399
|
};
|
|
393
400
|
// Simultaneously attempt to join + rebase the stale request
|
|
394
|
-
const nextEditResult = await this._joinNextEditRequest(requestToReuse, telemetryBuilder, logContext, cancellationToken);
|
|
401
|
+
const nextEditResult = await this._joinNextEditRequest(requestToReuse, reusedRequestKind, telemetryBuilder, logContext, cancellationToken);
|
|
395
402
|
const cacheResult = await requestToReuse.firstEdit.p;
|
|
396
403
|
if (cacheResult.isOk() && cacheResult.val.edit) {
|
|
397
404
|
const rebasedCachedEdit = this._nextEditCache.tryRebaseCacheEntry(cacheResult.val, documentAtInvocationTime, selectionAtInvocationTime);
|
|
@@ -415,7 +422,7 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
415
422
|
return backupRes.nextEditResult.nextEdit.isError() ? backupRes.nextEditResult.nextEdit : backupRes.nextEditRequest.firstEdit.p;
|
|
416
423
|
}
|
|
417
424
|
else {
|
|
418
|
-
const nextEditResult = await this._joinNextEditRequest(requestToReuse, telemetryBuilder, logContext, cancellationToken);
|
|
425
|
+
const nextEditResult = await this._joinNextEditRequest(requestToReuse, reusedRequestKind, telemetryBuilder, logContext, cancellationToken);
|
|
419
426
|
// Needs rebasing.
|
|
420
427
|
const cacheResult = await requestToReuse.firstEdit.p;
|
|
421
428
|
if (cacheResult.isOk() && cacheResult.val.edit) {
|
|
@@ -436,7 +443,7 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
436
443
|
&& this._pendingStatelessNextEditRequest || undefined;
|
|
437
444
|
if (existingNextEditRequest2) {
|
|
438
445
|
logger.trace('reusing 2nd existing next edit request after rebase failed');
|
|
439
|
-
const nextEditResult2 = await this._joinNextEditRequest(existingNextEditRequest2, telemetryBuilder, logContext, cancellationToken);
|
|
446
|
+
const nextEditResult2 = await this._joinNextEditRequest(existingNextEditRequest2, "async" /* ReusedRequestKind.Async */, telemetryBuilder, logContext, cancellationToken);
|
|
440
447
|
telemetryBuilder.setStatelessNextEditTelemetry(nextEditResult2.telemetry);
|
|
441
448
|
return nextEditResult2.nextEdit.isError() ? nextEditResult2.nextEdit : existingNextEditRequest2.firstEdit.p;
|
|
442
449
|
}
|
|
@@ -449,10 +456,9 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
449
456
|
telemetryBuilder.setStatelessNextEditTelemetry(nextEditResult.telemetry);
|
|
450
457
|
return nextEditResult.nextEdit.isError() ? nextEditResult.nextEdit : nextEditRequest.firstEdit.p;
|
|
451
458
|
}
|
|
452
|
-
async _joinNextEditRequest(nextEditRequest, telemetryBuilder, logContext, cancellationToken) {
|
|
453
|
-
// TODO: Will the telemetry look alright in this case?
|
|
459
|
+
async _joinNextEditRequest(nextEditRequest, reusedRequestKind, telemetryBuilder, logContext, cancellationToken) {
|
|
454
460
|
telemetryBuilder.setHeaderRequestId(nextEditRequest.headerRequestId);
|
|
455
|
-
telemetryBuilder.
|
|
461
|
+
telemetryBuilder.setReusedRequest(reusedRequestKind);
|
|
456
462
|
telemetryBuilder.setRequest(nextEditRequest);
|
|
457
463
|
logContext.setRequestInput(nextEditRequest);
|
|
458
464
|
logContext.setIsCachedResult(nextEditRequest.logContext);
|
|
@@ -477,11 +483,23 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
477
483
|
const nLinesEditWindow = (shouldExpandEditWindow
|
|
478
484
|
? this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsAutoExpandEditWindowLines, this._expService)
|
|
479
485
|
: undefined);
|
|
480
|
-
const nextEditRequest = new statelessNextEditProvider_1.StatelessNextEditRequest(req.headerRequestId, req.opportunityId, doc.value.get(), projectedDocuments.map(d => d.nextEditDoc), activeDocAndIdx.idx, xtabEditHistory, firstEdit, nLinesEditWindow,
|
|
486
|
+
const nextEditRequest = new statelessNextEditProvider_1.StatelessNextEditRequest(req.headerRequestId, req.opportunityId, doc.value.get(), projectedDocuments.map(d => d.nextEditDoc), activeDocAndIdx.idx, xtabEditHistory, firstEdit, nLinesEditWindow, false, // isSpeculative
|
|
487
|
+
logContext, req.log.recordingBookmark, recording, req.providerRequestStartDateTime);
|
|
481
488
|
let nextEditResult;
|
|
482
489
|
if (this._pendingStatelessNextEditRequest) {
|
|
483
490
|
this._pendingStatelessNextEditRequest.cancellationTokenSource.cancel();
|
|
484
491
|
this._pendingStatelessNextEditRequest = null;
|
|
492
|
+
// Clear any scheduled (but not yet triggered) speculative request tied to the
|
|
493
|
+
// old stream — it would otherwise fire stale when the old stream's background
|
|
494
|
+
// loop calls handleStreamEnd after the stream has already been superseded.
|
|
495
|
+
this._scheduledSpeculativeRequest = null;
|
|
496
|
+
}
|
|
497
|
+
// Cancel speculative request if it doesn't match the document/state
|
|
498
|
+
// of this new request — it was built for a different document or post-edit state.
|
|
499
|
+
if (this._speculativePendingRequest
|
|
500
|
+
&& (this._speculativePendingRequest.docId !== curDocId
|
|
501
|
+
|| this._speculativePendingRequest.postEditContent !== nextEditRequest.documentBeforeEdits.value)) {
|
|
502
|
+
this._cancelSpeculativeRequest();
|
|
485
503
|
}
|
|
486
504
|
this._pendingStatelessNextEditRequest = nextEditRequest;
|
|
487
505
|
const removeFromPending = () => {
|
|
@@ -514,7 +532,7 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
514
532
|
const statePerDoc = new cache_1.CachedFunction((id) => {
|
|
515
533
|
const doc = projectedDocuments.find(d => d.nextEditDoc.id === id);
|
|
516
534
|
if (!doc) {
|
|
517
|
-
throw new
|
|
535
|
+
throw new errors_2.BugIndicatingError();
|
|
518
536
|
}
|
|
519
537
|
return {
|
|
520
538
|
docContents: doc.documentAfterEdits,
|
|
@@ -596,6 +614,13 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
596
614
|
nextEditRequest.setResult(result);
|
|
597
615
|
disp.dispose();
|
|
598
616
|
removeFromPending();
|
|
617
|
+
// Fire any scheduled speculative request — the last shown edit
|
|
618
|
+
// was indeed the last edit from this stream.
|
|
619
|
+
if (this._scheduledSpeculativeRequest?.headerRequestId === nextEditRequest.headerRequestId) {
|
|
620
|
+
const scheduled = this._scheduledSpeculativeRequest;
|
|
621
|
+
this._scheduledSpeculativeRequest = null;
|
|
622
|
+
void this._triggerSpeculativeRequest(scheduled.suggestion);
|
|
623
|
+
}
|
|
599
624
|
return result;
|
|
600
625
|
};
|
|
601
626
|
try {
|
|
@@ -617,6 +642,11 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
617
642
|
while (!res.done) {
|
|
618
643
|
const streamedEdit = res.value.v;
|
|
619
644
|
processEdit(streamedEdit, res.value.telemetryBuilder);
|
|
645
|
+
// A new edit arrived from the stream — the previously-shown
|
|
646
|
+
// edit was not the last one. Clear the scheduled speculative.
|
|
647
|
+
if (this._scheduledSpeculativeRequest?.headerRequestId === nextEditRequest.headerRequestId) {
|
|
648
|
+
this._scheduledSpeculativeRequest = null;
|
|
649
|
+
}
|
|
620
650
|
res = await editStream.next();
|
|
621
651
|
}
|
|
622
652
|
// Stream completed
|
|
@@ -624,8 +654,8 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
624
654
|
handleStreamEnd(completionReason, res.value.telemetryBuilder);
|
|
625
655
|
}
|
|
626
656
|
catch (err) {
|
|
627
|
-
logger.trace(`Error while streaming further edits: ${
|
|
628
|
-
const errorReason = new statelessNextEditProvider_1.NoNextEditReason.Unexpected(
|
|
657
|
+
logger.trace(`Error while streaming further edits: ${errors_1.ErrorUtils.toString(err)}`);
|
|
658
|
+
const errorReason = new statelessNextEditProvider_1.NoNextEditReason.Unexpected(errors_1.ErrorUtils.fromUnknown(err));
|
|
629
659
|
handleStreamEnd(errorReason, firstTelemetry);
|
|
630
660
|
}
|
|
631
661
|
})();
|
|
@@ -679,7 +709,7 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
679
709
|
nextEditRequest.liveDependentants++;
|
|
680
710
|
return disposables;
|
|
681
711
|
}
|
|
682
|
-
computeMinimumResponseDelay({ triggerTime, isRebasedCachedEdit, isSubsequentCachedEdit, enforceCacheDelay }, logger) {
|
|
712
|
+
computeMinimumResponseDelay({ triggerTime, isRebasedCachedEdit, isSubsequentCachedEdit, isFromSpeculativeRequest, enforceCacheDelay }, logger) {
|
|
683
713
|
if (!enforceCacheDelay) {
|
|
684
714
|
logger.trace('[minimumDelay] no minimum delay enforced due to enforceCacheDelay being false');
|
|
685
715
|
return 0;
|
|
@@ -687,6 +717,7 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
687
717
|
const cacheDelay = this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsCacheDelay, this._expService);
|
|
688
718
|
const rebasedCacheDelay = this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsRebasedCacheDelay, this._expService);
|
|
689
719
|
const subsequentCacheDelay = this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsSubsequentCacheDelay, this._expService);
|
|
720
|
+
const speculativeRequestDelay = this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsSpeculativeRequestDelay, this._expService);
|
|
690
721
|
let minimumResponseDelay = cacheDelay;
|
|
691
722
|
if (isRebasedCachedEdit && rebasedCacheDelay !== undefined) {
|
|
692
723
|
minimumResponseDelay = rebasedCacheDelay;
|
|
@@ -694,41 +725,64 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
694
725
|
else if (isSubsequentCachedEdit && subsequentCacheDelay !== undefined) {
|
|
695
726
|
minimumResponseDelay = subsequentCacheDelay;
|
|
696
727
|
}
|
|
728
|
+
else if (isFromSpeculativeRequest && speculativeRequestDelay !== undefined) {
|
|
729
|
+
minimumResponseDelay = speculativeRequestDelay;
|
|
730
|
+
}
|
|
697
731
|
const nextEditProviderCallLatency = Date.now() - triggerTime;
|
|
698
732
|
// if the provider call took longer than the minimum delay, we don't need to delay further
|
|
699
733
|
const delay = Math.max(0, minimumResponseDelay - nextEditProviderCallLatency);
|
|
700
|
-
logger.trace(`[minimumDelay] expected delay: ${minimumResponseDelay}ms, effective delay: ${delay}. isRebasedCachedEdit: ${isRebasedCachedEdit} (rebasedCacheDelay: ${rebasedCacheDelay}), isSubsequentCachedEdit: ${isSubsequentCachedEdit} (subsequentCacheDelay: ${subsequentCacheDelay})`);
|
|
734
|
+
logger.trace(`[minimumDelay] expected delay: ${minimumResponseDelay}ms, effective delay: ${delay}. isRebasedCachedEdit: ${isRebasedCachedEdit} (rebasedCacheDelay: ${rebasedCacheDelay}), isSubsequentCachedEdit: ${isSubsequentCachedEdit} (subsequentCacheDelay: ${subsequentCacheDelay}), isFromSpeculativeRequest: ${isFromSpeculativeRequest} (speculativeRequestDelay: ${speculativeRequestDelay})`);
|
|
701
735
|
return delay;
|
|
702
736
|
}
|
|
703
737
|
handleShown(suggestion) {
|
|
704
738
|
this._lastShownTime = Date.now();
|
|
705
739
|
this._lastShownSuggestionId = suggestion.requestId;
|
|
740
|
+
this._lastOutcome = undefined; // clear so that outcome is "pending" until resolved
|
|
741
|
+
this._scheduledSpeculativeRequest = null; // clear any previously scheduled speculative
|
|
706
742
|
// Trigger speculative request for the post-edit document state
|
|
707
743
|
const speculativeRequestsEnablement = this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsSpeculativeRequests, this._expService);
|
|
708
744
|
if (speculativeRequestsEnablement === xtabPromptOptions_1.SpeculativeRequestsEnablement.On) {
|
|
709
|
-
|
|
745
|
+
// If the originating stream is still running, defer the speculative request
|
|
746
|
+
// until the stream completes. If more edits come from this stream, the
|
|
747
|
+
// schedule is cleared (the shown edit wasn't the last one). The speculative
|
|
748
|
+
// request only fires when the stream ends with the shown edit as the last one.
|
|
749
|
+
const originatingRequest = this._pendingStatelessNextEditRequest;
|
|
750
|
+
if (originatingRequest && originatingRequest.headerRequestId === suggestion.source.headerRequestId) {
|
|
751
|
+
this._scheduledSpeculativeRequest = {
|
|
752
|
+
suggestion,
|
|
753
|
+
headerRequestId: originatingRequest.headerRequestId,
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
else {
|
|
757
|
+
void this._triggerSpeculativeRequest(suggestion);
|
|
758
|
+
}
|
|
710
759
|
}
|
|
711
760
|
}
|
|
712
761
|
async _triggerSpeculativeRequest(suggestion) {
|
|
713
|
-
const logger = this._logger.createSubLogger('_triggerSpeculativeRequest');
|
|
714
762
|
const result = suggestion.result;
|
|
715
763
|
if (!result?.edit) {
|
|
716
|
-
logger.trace('no edit in suggestion result');
|
|
717
764
|
return;
|
|
718
765
|
}
|
|
719
766
|
const docId = result.targetDocumentId;
|
|
720
767
|
if (!docId) {
|
|
721
|
-
logger.trace('no target document ID in suggestion result');
|
|
722
768
|
return;
|
|
723
769
|
}
|
|
770
|
+
const logContext = new inlineEditLogContext_1.InlineEditRequestLogContext(docId.uri, 0, undefined);
|
|
771
|
+
const sw = new stopwatch_1.StopWatch();
|
|
772
|
+
const logger = this._logger.createSubLogger('_triggerSpeculativeRequest')
|
|
773
|
+
.withExtraTarget(logService_1.LogTarget.fromCallback((_level, msg) => {
|
|
774
|
+
logContext.trace(`[${Math.floor(sw.elapsed()).toString().padStart(4, ' ')}ms] ${msg}`);
|
|
775
|
+
}));
|
|
724
776
|
// Compute the post-edit document content
|
|
725
777
|
const postEditContent = result.edit.replace(result.documentBeforeEdits.value);
|
|
726
|
-
const
|
|
727
|
-
const
|
|
778
|
+
const preciseEdit = result.edit.removeCommonSuffixPrefix(result.documentBeforeEdits.value);
|
|
779
|
+
const postEditCursorOffset = preciseEdit.replaceRange.start + preciseEdit.newText.length;
|
|
780
|
+
const postEditCursorOffsetRange = new offsetRange_1.OffsetRange(postEditCursorOffset, postEditCursorOffset);
|
|
781
|
+
const selections = [postEditCursorOffsetRange];
|
|
728
782
|
const rootedEdit = new edit_1.RootedEdit(result.documentBeforeEdits, new stringEdit_1.StringEdit([result.edit]));
|
|
729
783
|
const postEditContentST = new abstractText_1.StringText(postEditContent);
|
|
730
784
|
let cachedEdit = this._nextEditCache.lookupNextEdit(docId, postEditContentST, selections);
|
|
731
|
-
let shiftedSelection;
|
|
785
|
+
let shiftedSelection = postEditCursorOffsetRange;
|
|
732
786
|
if (cachedEdit) {
|
|
733
787
|
// first cachedEdit should be without edits because of noSuggestions caching
|
|
734
788
|
if (cachedEdit.edit) {
|
|
@@ -736,17 +790,22 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
736
790
|
return;
|
|
737
791
|
}
|
|
738
792
|
else if (cachedEdit.editWindow) {
|
|
739
|
-
|
|
740
|
-
const
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
793
|
+
logger.trace('have cached no-suggestions entry for post-edit state, but it has an edit window. Checking if shifting selection based on cursor placement config can yield a cached edit');
|
|
794
|
+
const cursorPlacement = this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsSpeculativeRequestsCursorPlacement, this._expService);
|
|
795
|
+
if (cursorPlacement === xtabPromptOptions_1.SpeculativeRequestsCursorPlacement.AfterEditWindow) {
|
|
796
|
+
logger.trace('cursor placement config is AfterEditWindow, shifting selection to after edit window');
|
|
797
|
+
shiftedSelection = NextEditProvider_1.shiftSelectionAfterEditWindow(postEditContentST, cachedEdit.editWindow);
|
|
798
|
+
cachedEdit = this._nextEditCache.lookupNextEdit(docId, postEditContentST, [shiftedSelection]);
|
|
799
|
+
if (cachedEdit?.edit) {
|
|
800
|
+
logger.trace('already have cached edit for post-edit state (after shifting selection)');
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
else {
|
|
804
|
+
logger.trace('no cached edit even after shifting selection');
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
else {
|
|
808
|
+
logger.trace(`cursor placement config is ${cursorPlacement}, not shifting selection`);
|
|
750
809
|
}
|
|
751
810
|
}
|
|
752
811
|
else {
|
|
@@ -760,7 +819,7 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
760
819
|
return;
|
|
761
820
|
}
|
|
762
821
|
// Check if we already have a speculative request for this post-edit state
|
|
763
|
-
if (this._speculativePendingRequest?.postEditContent === postEditContent) {
|
|
822
|
+
if (this._speculativePendingRequest?.docId === docId && this._speculativePendingRequest?.postEditContent === postEditContent) {
|
|
764
823
|
logger.trace('already have speculative request for post-edit state');
|
|
765
824
|
return;
|
|
766
825
|
}
|
|
@@ -773,30 +832,29 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
773
832
|
return;
|
|
774
833
|
}
|
|
775
834
|
// Cancel any previous speculative request
|
|
776
|
-
this.
|
|
777
|
-
this._speculativePendingRequest = null;
|
|
835
|
+
this._cancelSpeculativeRequest();
|
|
778
836
|
const historyContext = this._historyContextProvider.getHistoryContext(docId);
|
|
779
837
|
if (!historyContext) {
|
|
780
838
|
logger.trace('no history context for speculative request');
|
|
781
839
|
return;
|
|
782
840
|
}
|
|
783
|
-
|
|
784
|
-
// Use a dummy version since this is speculative and we don't have the actual post-edit version
|
|
785
|
-
const logContext = new inlineEditLogContext_1.InlineEditRequestLogContext(docId.uri, 0, undefined);
|
|
786
|
-
const req = new NextEditFetchRequest(`sp-${suggestion.source.opportunityId}`, logContext, undefined, `sp-${(0, uuid_1.generateUuid)()}`);
|
|
787
|
-
logger.trace(`triggering speculative request for post-edit state (opportunityId=${req.opportunityId}, headerRequestId=${req.headerRequestId})`);
|
|
841
|
+
const req = new NextEditFetchRequest(`sp-${suggestion.source.opportunityId}`, logContext, undefined, true, `sp-${(0, uuid_1.generateUuid)()}`);
|
|
788
842
|
logger.trace(`triggering speculative request for post-edit state (opportunityId=${req.opportunityId}, headerRequestId=${req.headerRequestId})`);
|
|
789
843
|
try {
|
|
790
|
-
const speculativeRequest = await this._createSpeculativeRequest(req, doc, shiftedSelection, historyContext, postEditContent, rootedEdit, result.edit,
|
|
844
|
+
const speculativeRequest = await this._createSpeculativeRequest(req, doc, shiftedSelection, historyContext, postEditContent, rootedEdit, result.edit, {
|
|
845
|
+
triggeredBySpeculativeRequest: suggestion.source.isSpeculative,
|
|
846
|
+
isSubsequentEdit: suggestion.result?.isSubsequentEdit ?? false,
|
|
847
|
+
}, logger);
|
|
791
848
|
if (speculativeRequest) {
|
|
792
849
|
this._speculativePendingRequest = {
|
|
793
850
|
request: speculativeRequest,
|
|
851
|
+
docId,
|
|
794
852
|
postEditContent,
|
|
795
853
|
};
|
|
796
854
|
}
|
|
797
855
|
}
|
|
798
856
|
catch (e) {
|
|
799
|
-
logger.trace(`speculative request failed: ${
|
|
857
|
+
logger.trace(`speculative request failed: ${errors_1.ErrorUtils.toString(e)}`);
|
|
800
858
|
}
|
|
801
859
|
}
|
|
802
860
|
/**
|
|
@@ -804,11 +862,12 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
804
862
|
* The request will populate the cache so that when the user accepts the suggestion,
|
|
805
863
|
* the next NES request can reuse or find the result in cache.
|
|
806
864
|
*/
|
|
807
|
-
async _createSpeculativeRequest(req, doc, shiftedSelection, historyContext, postEditContent, rootedEdit, appliedEdit, parentLogger) {
|
|
808
|
-
const logger = parentLogger.createSubLogger('_createSpeculativeRequest');
|
|
865
|
+
async _createSpeculativeRequest(req, doc, shiftedSelection, historyContext, postEditContent, rootedEdit, appliedEdit, { triggeredBySpeculativeRequest, isSubsequentEdit }, parentLogger) {
|
|
809
866
|
const curDocId = doc.id;
|
|
810
867
|
const recording = this._debugRecorder?.getRecentLog();
|
|
811
868
|
const logContext = req.log;
|
|
869
|
+
logContext.setStatelessNextEditProviderId(this._statelessNextEditProvider.ID);
|
|
870
|
+
const logger = parentLogger.createSubLogger('_createSpeculativeRequest');
|
|
812
871
|
const activeDocAndIdx = historyContext.getDocumentAndIdx(curDocId);
|
|
813
872
|
if (!activeDocAndIdx) {
|
|
814
873
|
logger.trace('active doc not found in history context');
|
|
@@ -827,18 +886,11 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
827
886
|
const workspaceRoot = this._workspace.getWorkspaceRoot(curDocId);
|
|
828
887
|
const postEditEdit = new stringEdit_1.StringEdit([appliedEdit]);
|
|
829
888
|
const postEditLineEdit = rootedLineEdit_1.RootedLineEdit.fromEdit(new edit_1.RootedEdit(doc.value.get(), postEditEdit)).removeCommonSuffixPrefixLines().edit;
|
|
830
|
-
let selection = shiftedSelection;
|
|
831
|
-
if (selection === undefined) {
|
|
832
|
-
const appliedEditEndPos = postEditText.getTransformer().getPosition(appliedEdit.replaceRange.endExclusive + appliedEdit.getLengthDelta());
|
|
833
|
-
const pos = new position_1.Position(appliedEditEndPos.lineNumber, 1);
|
|
834
|
-
const offset = postEditText.getTransformer().getOffset(pos);
|
|
835
|
-
selection = new offsetRange_1.OffsetRange(offset, offset);
|
|
836
|
-
}
|
|
837
889
|
const nextEditDoc = new statelessNextEditProvider_1.StatelessNextEditDocument(curDocId, workspaceRoot, docHist.languageId, doc.value.get().getLines(), // lines before the NES edit
|
|
838
890
|
postEditLineEdit, // the NES edit as LineEdit
|
|
839
891
|
doc.value.get(), // document before NES edit
|
|
840
892
|
edit_1.Edits.single(postEditEdit), // the NES edit as Edits
|
|
841
|
-
|
|
893
|
+
shiftedSelection);
|
|
842
894
|
return {
|
|
843
895
|
recentEdit: new edit_1.RootedEdit(doc.value.get(), postEditEdit),
|
|
844
896
|
nextEditDoc,
|
|
@@ -850,15 +902,43 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
850
902
|
const suggestedEdit = { kind: 'edit', docId: curDocId, edit: rootedEdit };
|
|
851
903
|
xtabEditHistory.push(suggestedEdit);
|
|
852
904
|
const firstEdit = new async_1.DeferredPromise();
|
|
853
|
-
|
|
905
|
+
// FIXME@ulugbekna: implement advanced expansion
|
|
906
|
+
const autoExpandEditWindowLinesSetting = this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsSpeculativeRequestsAutoExpandEditWindowLines, this._expService);
|
|
907
|
+
let nLinesEditWindow;
|
|
908
|
+
switch (autoExpandEditWindowLinesSetting) {
|
|
909
|
+
case xtabPromptOptions_1.SpeculativeRequestsAutoExpandEditWindowLines.Off:
|
|
910
|
+
nLinesEditWindow = undefined;
|
|
911
|
+
break;
|
|
912
|
+
case xtabPromptOptions_1.SpeculativeRequestsAutoExpandEditWindowLines.Always:
|
|
913
|
+
nLinesEditWindow = this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsAutoExpandEditWindowLines, this._expService);
|
|
914
|
+
break;
|
|
915
|
+
case xtabPromptOptions_1.SpeculativeRequestsAutoExpandEditWindowLines.Smart: {
|
|
916
|
+
const isModelOnRightTrack = triggeredBySpeculativeRequest || isSubsequentEdit;
|
|
917
|
+
nLinesEditWindow = (isModelOnRightTrack
|
|
918
|
+
? this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsAutoExpandEditWindowLines, this._expService)
|
|
919
|
+
: undefined);
|
|
920
|
+
break;
|
|
921
|
+
}
|
|
922
|
+
default:
|
|
923
|
+
(0, assert_1.assertNever)(autoExpandEditWindowLinesSetting);
|
|
924
|
+
}
|
|
854
925
|
const nextEditRequest = new statelessNextEditProvider_1.StatelessNextEditRequest(req.headerRequestId, req.opportunityId, postEditText, // documentBeforeEdits is the post-edit state
|
|
855
|
-
projectedDocuments.map(d => d.nextEditDoc), activeDocAndIdx.idx, xtabEditHistory, firstEdit, nLinesEditWindow,
|
|
926
|
+
projectedDocuments.map(d => d.nextEditDoc), activeDocAndIdx.idx, xtabEditHistory, firstEdit, nLinesEditWindow, true, // isSpeculative
|
|
927
|
+
logContext, undefined, // recordingBookmark
|
|
856
928
|
recording, undefined);
|
|
929
|
+
logContext.setRequestInput(nextEditRequest);
|
|
857
930
|
logger.trace('starting speculative provider call');
|
|
858
931
|
// Start the provider call - this runs in the background and populates the cache
|
|
859
|
-
const label = `NES | spec | ${(0, path_1.basename)(doc.id.toUri().fsPath)} (v${doc.version})`;
|
|
860
|
-
const capturingToken = new capturingToken_1.CapturingToken(label, undefined,
|
|
861
|
-
void this._requestLogger.captureInvocation(capturingToken, () =>
|
|
932
|
+
const label = `NES | spec | ${(0, path_1.basename)(doc.id.toUri().fsPath)} (v${doc.version.get()})`;
|
|
933
|
+
const capturingToken = new capturingToken_1.CapturingToken(label, undefined, false, true);
|
|
934
|
+
void this._requestLogger.captureInvocation(capturingToken, async () => {
|
|
935
|
+
try {
|
|
936
|
+
await this._runSpeculativeProviderCall(nextEditRequest, projectedDocuments, curDocId, req, logger);
|
|
937
|
+
}
|
|
938
|
+
finally {
|
|
939
|
+
this._addLogContextEntry(logContext, label);
|
|
940
|
+
}
|
|
941
|
+
});
|
|
862
942
|
return nextEditRequest;
|
|
863
943
|
}
|
|
864
944
|
/**
|
|
@@ -869,7 +949,7 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
869
949
|
const statePerDoc = new cache_1.CachedFunction((id) => {
|
|
870
950
|
const doc = projectedDocuments.find(d => d.nextEditDoc.id === id);
|
|
871
951
|
if (!doc) {
|
|
872
|
-
throw new
|
|
952
|
+
throw new errors_2.BugIndicatingError();
|
|
873
953
|
}
|
|
874
954
|
return {
|
|
875
955
|
docContents: doc.documentAfterEdits,
|
|
@@ -929,12 +1009,23 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
929
1009
|
logger.trace(`speculative request completed with ${ithEdit + 1} edits`);
|
|
930
1010
|
}
|
|
931
1011
|
catch (e) {
|
|
932
|
-
logger.trace(`speculative provider call error: ${
|
|
1012
|
+
logger.trace(`speculative provider call error: ${errors_1.ErrorUtils.toString(e)}`);
|
|
933
1013
|
}
|
|
934
1014
|
}
|
|
1015
|
+
static shiftSelectionAfterEditWindow(postEditContentST, editWindowOffsetRange) {
|
|
1016
|
+
const trans = postEditContentST.getTransformer();
|
|
1017
|
+
const endOfEditWindow = trans.getPosition(editWindowOffsetRange.endExclusive - 1);
|
|
1018
|
+
const shiftedCursorLineNumber = (endOfEditWindow.lineNumber + 1 < postEditContentST.lineRange.endLineNumberExclusive
|
|
1019
|
+
? endOfEditWindow.lineNumber + 1
|
|
1020
|
+
: endOfEditWindow.lineNumber);
|
|
1021
|
+
const shiftedSelectionCursorOffset = trans.getOffset(new position_1.Position(shiftedCursorLineNumber, 1));
|
|
1022
|
+
const shiftedSelection = new offsetRange_1.OffsetRange(shiftedSelectionCursorOffset, shiftedSelectionCursorOffset);
|
|
1023
|
+
return shiftedSelection;
|
|
1024
|
+
}
|
|
935
1025
|
handleAcceptance(docId, suggestion) {
|
|
936
1026
|
this.runSnippy(docId, suggestion);
|
|
937
1027
|
this._statelessNextEditProvider.handleAcceptance?.();
|
|
1028
|
+
this._lastOutcome = NesOutcome.Accepted;
|
|
938
1029
|
const logger = this._logger.createSubLogger(suggestion.source.opportunityId.substring(4, 8)).createSubLogger('handleAcceptance');
|
|
939
1030
|
if (suggestion === this._lastNextEditResult) {
|
|
940
1031
|
logger.trace('setting shouldExpandEditWindow to true due to acceptance of last suggestion');
|
|
@@ -946,6 +1037,10 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
946
1037
|
}
|
|
947
1038
|
handleRejection(docId, suggestion) {
|
|
948
1039
|
(0, types_1.assertType)(suggestion.result, '@ulugbekna: undefined edit cannot be rejected?');
|
|
1040
|
+
// The user rejected the suggestion, so the speculative request (which
|
|
1041
|
+
// predicted the post-accept state) will never be reused. Cancel it to
|
|
1042
|
+
// avoid wasting a server slot.
|
|
1043
|
+
this._cancelSpeculativeRequest();
|
|
949
1044
|
const shownDuration = Date.now() - this._lastShownTime;
|
|
950
1045
|
if (shownDuration > 1000 && suggestion.result.edit) {
|
|
951
1046
|
// we can argue that the user had the time to review this
|
|
@@ -954,14 +1049,18 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
954
1049
|
this._nextEditCache.rejectedNextEdit(suggestion.source.headerRequestId);
|
|
955
1050
|
}
|
|
956
1051
|
this._lastRejectionTime = Date.now();
|
|
1052
|
+
this._lastOutcome = NesOutcome.Rejected;
|
|
957
1053
|
this._statelessNextEditProvider.handleRejection?.();
|
|
958
1054
|
}
|
|
959
1055
|
handleIgnored(docId, suggestion, supersededBy) {
|
|
1056
|
+
this._lastOutcome = NesOutcome.Ignored;
|
|
960
1057
|
// Check if this was the last shown suggestion
|
|
961
1058
|
const wasShown = this._lastShownSuggestionId === suggestion.requestId;
|
|
962
1059
|
const wasSuperseded = supersededBy !== undefined;
|
|
963
1060
|
if (wasShown && !wasSuperseded) {
|
|
964
|
-
//
|
|
1061
|
+
// The shown suggestion was dismissed (not superseded by a new one),
|
|
1062
|
+
// so the speculative request for its post-accept state is useless.
|
|
1063
|
+
this._cancelSpeculativeRequest();
|
|
965
1064
|
this._statelessNextEditProvider.handleIgnored?.();
|
|
966
1065
|
}
|
|
967
1066
|
}
|
|
@@ -971,13 +1070,25 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
971
1070
|
}
|
|
972
1071
|
this._snippyService.handlePostInsertion(docId.toUri(), suggestion.result.documentBeforeEdits, suggestion.result.edit);
|
|
973
1072
|
}
|
|
1073
|
+
_addLogContextEntry(logContext, debugNameOverride) {
|
|
1074
|
+
if (!logContext.includeInLogTree) {
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1077
|
+
this._requestLogger.addEntry({
|
|
1078
|
+
type: "MarkdownContentRequest" /* LoggedRequestKind.MarkdownContentRequest */,
|
|
1079
|
+
debugName: debugNameOverride ?? logContext.getDebugName(),
|
|
1080
|
+
icon: logContext.getIcon(),
|
|
1081
|
+
startTimeMs: logContext.time,
|
|
1082
|
+
markdownContent: logContext.toLogDocument(),
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
974
1085
|
clearCache() {
|
|
975
1086
|
this._nextEditCache.clear();
|
|
976
1087
|
this._rejectionCollector.clear();
|
|
977
1088
|
}
|
|
978
1089
|
};
|
|
979
1090
|
exports.NextEditProvider = NextEditProvider;
|
|
980
|
-
exports.NextEditProvider = NextEditProvider = __decorate([
|
|
1091
|
+
exports.NextEditProvider = NextEditProvider = NextEditProvider_1 = __decorate([
|
|
981
1092
|
__param(5, configurationService_1.IConfigurationService),
|
|
982
1093
|
__param(6, snippyService_1.ISnippyService),
|
|
983
1094
|
__param(7, logService_1.ILogService),
|
|
@@ -986,15 +1097,16 @@ exports.NextEditProvider = NextEditProvider = __decorate([
|
|
|
986
1097
|
], NextEditProvider);
|
|
987
1098
|
function assertDefined(value) {
|
|
988
1099
|
if (!value) {
|
|
989
|
-
throw new
|
|
1100
|
+
throw new errors_2.BugIndicatingError('expected value to be defined, but it was not');
|
|
990
1101
|
}
|
|
991
1102
|
return value;
|
|
992
1103
|
}
|
|
993
1104
|
class NextEditFetchRequest {
|
|
994
|
-
constructor(opportunityId, log, providerRequestStartDateTime, headerRequestId = (0, uuid_1.generateUuid)()) {
|
|
1105
|
+
constructor(opportunityId, log, providerRequestStartDateTime, isSpeculative, headerRequestId = (0, uuid_1.generateUuid)()) {
|
|
995
1106
|
this.opportunityId = opportunityId;
|
|
996
1107
|
this.log = log;
|
|
997
1108
|
this.providerRequestStartDateTime = providerRequestStartDateTime;
|
|
1109
|
+
this.isSpeculative = isSpeculative;
|
|
998
1110
|
this.headerRequestId = headerRequestId;
|
|
999
1111
|
}
|
|
1000
1112
|
}
|