@vscode/chat-lib 0.45.2026041733 → 0.46.2026042102
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/completions-core/vscode-node/lib/src/experiments/featuresService.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/similarFiles/openTabFiles.d.ts +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/similarFiles/openTabFiles.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/similarFiles/openTabFiles.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nesConfigs.d.ts +0 -1
- package/dist/src/_internal/extension/inlineEdits/node/nesConfigs.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.d.ts +21 -15
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.js +79 -60
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/speculativeRequestManager.d.ts +94 -0
- package/dist/src/_internal/extension/inlineEdits/node/speculativeRequestManager.d.ts.map +1 -0
- package/dist/src/_internal/extension/inlineEdits/node/speculativeRequestManager.js +133 -0
- package/dist/src/_internal/extension/inlineEdits/node/speculativeRequestManager.js.map +1 -0
- package/dist/src/_internal/platform/chat/common/commonTypes.d.ts.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts +2 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.js +2 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/endpointProvider.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/messagesApi.d.ts +6 -0
- package/dist/src/_internal/platform/endpoint/node/messagesApi.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/messagesApi.js +22 -19
- package/dist/src/_internal/platform/endpoint/node/messagesApi.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/responsesApi.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/responsesApi.js +2 -1
- package/dist/src/_internal/platform/endpoint/node/responsesApi.js.map +1 -1
- package/dist/src/_internal/platform/inlineCompletions/common/api.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/languageContext.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/inlineEditLogContext.d.ts +6 -0
- package/dist/src/_internal/platform/inlineEdits/common/inlineEditLogContext.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/inlineEditLogContext.js +28 -0
- package/dist/src/_internal/platform/inlineEdits/common/inlineEditLogContext.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/utils/utils.d.ts +1 -0
- package/dist/src/_internal/platform/inlineEdits/common/utils/utils.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/utils/utils.js +4 -0
- package/dist/src/_internal/platform/inlineEdits/common/utils/utils.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/workspaceEditTracker/nesXtabHistoryTracker.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetch.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/networking.d.ts.map +1 -1
- package/dist/src/_internal/platform/thinking/common/thinking.d.ts.map +1 -1
- package/dist/src/_internal/util/node/worker.d.ts.map +1 -1
- package/dist/src/main.d.ts.map +1 -1
- package/dist/src/package.json +32 -9
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"featuresService.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/_internal/extension/completions-core/vscode-node/lib/src/experiments/featuresService.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,MAAM,sBAAsB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzE,MAAM,MAAM,0BAA0B,GAAG;IACxC,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,uBAAuB,EAAE,OAAO,CAAC;IACjC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC,CAAC;CACnD,
|
|
1
|
+
{"version":3,"file":"featuresService.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/_internal/extension/completions-core/vscode-node/lib/src/experiments/featuresService.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,MAAM,sBAAsB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzE,MAAM,MAAM,0BAA0B,GAAG;IACxC,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,uBAAuB,EAAE,OAAO,CAAC;IACjC,mBAAmB,EAAE,OAAO,CAAC;IAC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,OAAO,CAAC;IAChE,uBAAuB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,MAAM,CAAC;IACpE,uBAAuB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC;IACrE,+BAA+B,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC;IAC7E,iBAAiB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,MAAM,CAAC;IAC9D,kBAAkB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,MAAM,CAAC;IAC/D,kBAAkB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,MAAM,CAAC;IAC/D,yBAAyB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,MAAM,CAAC;IACtE,gBAAgB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,MAAM,CAAC;IAC7D,wBAAwB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC;CACtE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ICompletionsTextDocumentManagerService } from '../../textDocumentManager';
|
|
2
2
|
import { INeighborSource, NeighboringFileType, NeighborsCollection } from './neighborFiles';
|
|
3
3
|
export declare class OpenTabFiles implements INeighborSource {
|
|
4
|
-
readonly docManager
|
|
4
|
+
private readonly docManager;
|
|
5
5
|
constructor(docManager: ICompletionsTextDocumentManagerService);
|
|
6
6
|
private truncateDocs;
|
|
7
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openTabFiles.d.ts","sourceRoot":"","sources":["../../../../../../../../../../src/_internal/extension/completions-core/vscode-node/lib/src/prompt/similarFiles/openTabFiles.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,sCAAsC,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EACN,eAAe,EAEf,mBAAmB,EACnB,mBAAmB,EAEnB,MAAM,iBAAiB,CAAC;AAEzB,qBAAa,YAAa,YAAW,eAAe;
|
|
1
|
+
{"version":3,"file":"openTabFiles.d.ts","sourceRoot":"","sources":["../../../../../../../../../../src/_internal/extension/completions-core/vscode-node/lib/src/prompt/similarFiles/openTabFiles.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,sCAAsC,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EACN,eAAe,EAEf,mBAAmB,EACnB,mBAAmB,EAEnB,MAAM,iBAAiB,CAAC;AAEzB,qBAAa,YAAa,YAAW,eAAe;IAEV,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,sCAAsC;IAG5G,OAAO,CAAC,YAAY;IAkCpB;;;;;;;;OAQG;IACG,gBAAgB,CACrB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,mBAAmB,EAAE,MAAM,GACzB,OAAO,CAAC;QAAE,IAAI,EAAE,mBAAmB,CAAC;QAAC,cAAc,EAAE,GAAG,CAAC,mBAAmB,EAAE,MAAM,EAAE,CAAC,CAAA;KAAE,CAAC;CAkB7F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openTabFiles.js","sourceRoot":"","sources":["../../../../../../../../../../src/_internal/extension/completions-core/vscode-node/lib/src/prompt/similarFiles/openTabFiles.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;;;;;;;AAEhG,2DAA0D;AAE1D,mEAAmF;AACnF,mDAMyB;AAElB,IAAM,YAAY,GAAlB,MAAM,YAAY;IACxB,
|
|
1
|
+
{"version":3,"file":"openTabFiles.js","sourceRoot":"","sources":["../../../../../../../../../../src/_internal/extension/completions-core/vscode-node/lib/src/prompt/similarFiles/openTabFiles.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;;;;;;;AAEhG,2DAA0D;AAE1D,mEAAmF;AACnF,mDAMyB;AAElB,IAAM,YAAY,GAAlB,MAAM,YAAY;IACxB,YAC0D,UAAkD;QAAlD,eAAU,GAAV,UAAU,CAAwC;IACxG,CAAC;IAEG,YAAY,CACnB,IAAqC,EACrC,GAAW,EACX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AC,aAAa,EAAE,CAAC,EACxD,GAAG,EACH,UAAU,EACV,mBAAmB,CACnB,CAAC;QACF,cAAc,CAAC,GAAG,CACjB,mCAAmB,CAAC,QAAQ,EAC5B,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAC3D,CAAC;QACF,OAAO;YACN,IAAI,EAAE,aAAa;YACnB,cAAc,EAAE,cAAc;SAC9B,CAAC;IACH,CAAC;CACD,CAAA;AAtEY,oCAAY;uBAAZ,YAAY;IAEtB,WAAA,4DAAsC,CAAA;GAF5B,YAAY,CAsExB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nesConfigs.d.ts","sourceRoot":"","sources":["../../../../../../src/_internal/extension/inlineEdits/node/nesConfigs.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,WAAW;IAC3B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,oBAAoB,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"nesConfigs.d.ts","sourceRoot":"","sources":["../../../../../../src/_internal/extension/inlineEdits/node/nesConfigs.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,WAAW;IAC3B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,oBAAoB,EAAE,OAAO,CAAC;CAC9B"}
|
|
@@ -51,20 +51,7 @@ export declare class NextEditProvider extends Disposable implements INextEditPro
|
|
|
51
51
|
private readonly _rejectionCollector;
|
|
52
52
|
private readonly _nextEditCache;
|
|
53
53
|
private _pendingStatelessNextEditRequest;
|
|
54
|
-
|
|
55
|
-
* Tracks a speculative request for the post-edit document state.
|
|
56
|
-
* When a suggestion is shown, we speculatively fetch the next edit as if the user had already accepted.
|
|
57
|
-
* This allows reusing the in-flight request when the user actually accepts the suggestion.
|
|
58
|
-
*/
|
|
59
|
-
private _speculativePendingRequest;
|
|
60
|
-
/**
|
|
61
|
-
* A speculative request that is deferred until the originating stream completes.
|
|
62
|
-
* When a suggestion is shown while its stream is still running, we schedule the
|
|
63
|
-
* speculative request here instead of firing immediately. If more edits arrive
|
|
64
|
-
* from the stream, the schedule is cleared (the shown edit wasn't the last one).
|
|
65
|
-
* When the stream ends, if the schedule is still present, the speculative fires.
|
|
66
|
-
*/
|
|
67
|
-
private _scheduledSpeculativeRequest;
|
|
54
|
+
private readonly _specManager;
|
|
68
55
|
private _lastShownTime;
|
|
69
56
|
/** The requestId of the last shown suggestion. We store only the requestId (not the object) to avoid preventing garbage collection. */
|
|
70
57
|
private _lastShownSuggestionId;
|
|
@@ -78,7 +65,26 @@ export declare class NextEditProvider extends Disposable implements INextEditPro
|
|
|
78
65
|
private _shouldExpandEditWindow;
|
|
79
66
|
private _logger;
|
|
80
67
|
constructor(_workspace: ObservableWorkspace, _statelessNextEditProvider: IStatelessNextEditProvider, _historyContextProvider: IHistoryContextProvider, _xtabHistoryTracker: NesXtabHistoryTracker, _debugRecorder: DebugRecorder | undefined, _configService: IConfigurationService, _snippyService: ISnippyService, _logService: ILogService, _expService: IExperimentationService, _requestLogger: IRequestLogger);
|
|
81
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Cancels the in-flight stateless next-edit request when the document it
|
|
70
|
+
* was issued for has diverged from the request's expected post-edit state.
|
|
71
|
+
*
|
|
72
|
+
* Invoked from the per-document `runOnChange` autorun in the constructor
|
|
73
|
+
* whenever an open document's value changes. The pending request was built
|
|
74
|
+
* against a specific snapshot (`documentAfterEdits`); if the user has since
|
|
75
|
+
* typed something that makes the current value differ from that snapshot,
|
|
76
|
+
* the result would no longer be applicable and is cancelled eagerly.
|
|
77
|
+
*
|
|
78
|
+
* Skipped when:
|
|
79
|
+
* - the `InlineEditsAsyncCompletions` experiment is enabled (that path
|
|
80
|
+
* tolerates divergence and rebases later), or
|
|
81
|
+
* - there is no pending request, or
|
|
82
|
+
* - the changed document is not the one the pending request targets.
|
|
83
|
+
*
|
|
84
|
+
* Note: this only handles the regular pending stateless request. Speculative
|
|
85
|
+
* requests have their own divergence handling via
|
|
86
|
+
* `SpeculativeRequestManager.onActiveDocumentChanged` (trajectory check).
|
|
87
|
+
*/
|
|
82
88
|
private _cancelPendingRequestDueToDocChange;
|
|
83
89
|
getNextEdit(docId: DocumentId, context: NESInlineCompletionContext, logContext: InlineEditRequestLogContext, cancellationToken: CancellationToken, telemetryBuilder: LlmNESTelemetryBuilder): Promise<NextEditResult>;
|
|
84
90
|
private _getNextEditCanThrow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextEditProvider.d.ts","sourceRoot":"","sources":["../../../../../../src/_internal/extension/inlineEdits/node/nextEditProvider.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAa,qBAAqB,EAAE,MAAM,6DAA6D,CAAC;AAC/G,OAAO,EAAE,UAAU,EAAE,MAAM,2DAA2D,CAAC;AAIvF,OAAO,EAAE,2BAA2B,EAAyB,MAAM,2DAA2D,CAAC;AAC/H,OAAO,EAAuB,mBAAmB,EAAE,MAAM,0DAA0D,CAAC;AACpH,OAAO,EAAE,0BAA0B,EAA+H,MAAM,gEAAgE,CAAC;AAEzO,OAAO,EAAmC,uBAAuB,EAAE,MAAM,kFAAkF,CAAC;AAC5J,OAAO,EAA4C,qBAAqB,EAAE,MAAM,iFAAiF,CAAC;AAClK,OAAO,EAAW,WAAW,EAAa,MAAM,yCAAyC,CAAC;AAE1F,OAAO,EAAE,cAAc,EAAqB,MAAM,sDAAsD,CAAC;AACzG,OAAO,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,+DAA+D,CAAC;AAMxG,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAmB,WAAW,EAAgB,MAAM,wCAAwC,CAAC;AAWhH,OAAO,EAA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K,EAAE,UAAU,EACjB,OAAO,EAAE,0BAA0B,EACnC,UAAU,EAAE,2BAA2B,EACvC,iBAAiB,EAAE,iBAAiB,EACpC,gBAAgB,EAAE,sBAAsB,GACtC,OAAO,CAAC,cAAc,CAAC;YAgCZ,oBAAoB;IA4KlC,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,WAAW;YA+BL,aAAa;YAkJb,oBAAoB;IAgBlC,OAAO,CAAC,iBAAiB;YAMX,0BAA0B;IA+PxC,OAAO,CAAC,mBAAmB;IA+C3B,OAAO,CAAC,2BAA2B;IA+B5B,WAAW,CAAC,UAAU,EAAE,cAAc;YAyB/B,0BAA0B;IAwIxC;;;;OAIG;YACW,yBAAyB;IA4HvC;;OAEG;YACW,2BAA2B;IAgHzC,OAAO,CAAC,MAAM,CAAC,6BAA6B;IAWrC,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc;IAc9D,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc;IAsB7D,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI;YAoBtG,SAAS;IAOvB,OAAO,CAAC,uBAAuB;IAYxB,UAAU;CAOjB;AASD,qBAAa,oBAAoB;aAEf,aAAa,EAAE,MAAM;aACrB,GAAG,EAAE,2BAA2B;aAChC,4BAA4B,EAAE,MAAM,GAAG,SAAS;aAChD,aAAa,EAAE,OAAO;aACtB,eAAe;gBAJf,aAAa,EAAE,MAAM,EACrB,GAAG,EAAE,2BAA2B,EAChC,4BAA4B,EAAE,MAAM,GAAG,SAAS,EAChD,aAAa,EAAE,OAAO,EACtB,eAAe,SAAiB;CAGjD"}
|
|
@@ -48,6 +48,7 @@ const editRebase_1 = require("../common/editRebase");
|
|
|
48
48
|
const rejectionCollector_1 = require("../common/rejectionCollector");
|
|
49
49
|
const nextEditCache_1 = require("./nextEditCache");
|
|
50
50
|
const nextEditResult_1 = require("./nextEditResult");
|
|
51
|
+
const speculativeRequestManager_1 = require("./speculativeRequestManager");
|
|
51
52
|
/**
|
|
52
53
|
* Computes a reduced window range that encompasses both the original window (shrunk by one line
|
|
53
54
|
* on each end) and the full line where the cursor is located.
|
|
@@ -141,20 +142,6 @@ let NextEditProvider = NextEditProvider_1 = class NextEditProvider extends lifec
|
|
|
141
142
|
this.ID = this._statelessNextEditProvider.ID;
|
|
142
143
|
this._rejectionCollector = this._register(new rejectionCollector_1.RejectionCollector(this._workspace, this._logService));
|
|
143
144
|
this._pendingStatelessNextEditRequest = null;
|
|
144
|
-
/**
|
|
145
|
-
* Tracks a speculative request for the post-edit document state.
|
|
146
|
-
* When a suggestion is shown, we speculatively fetch the next edit as if the user had already accepted.
|
|
147
|
-
* This allows reusing the in-flight request when the user actually accepts the suggestion.
|
|
148
|
-
*/
|
|
149
|
-
this._speculativePendingRequest = null;
|
|
150
|
-
/**
|
|
151
|
-
* A speculative request that is deferred until the originating stream completes.
|
|
152
|
-
* When a suggestion is shown while its stream is still running, we schedule the
|
|
153
|
-
* speculative request here instead of firing immediately. If more edits arrive
|
|
154
|
-
* from the stream, the schedule is cleared (the shown edit wasn't the last one).
|
|
155
|
-
* When the stream ends, if the schedule is still present, the speculative fires.
|
|
156
|
-
*/
|
|
157
|
-
this._scheduledSpeculativeRequest = null;
|
|
158
145
|
this._lastShownTime = 0;
|
|
159
146
|
/** The requestId of the last shown suggestion. We store only the requestId (not the object) to avoid preventing garbage collection. */
|
|
160
147
|
this._lastShownSuggestionId = undefined;
|
|
@@ -163,27 +150,40 @@ let NextEditProvider = NextEditProvider_1 = class NextEditProvider extends lifec
|
|
|
163
150
|
this._shouldExpandEditWindow = false;
|
|
164
151
|
this._logger = this._logService.createSubLogger(['NES', 'NextEditProvider']);
|
|
165
152
|
this._nextEditCache = new nextEditCache_1.NextEditCache(this._workspace, this._logService, this._configService, this._expService);
|
|
153
|
+
this._specManager = this._register(new speculativeRequestManager_1.SpeculativeRequestManager(this._logger.createSubLogger('SpeculativeRequestManager')));
|
|
166
154
|
(0, observable_2.mapObservableArrayCached)(this, this._workspace.openDocuments, (doc, store) => {
|
|
167
155
|
store.add((0, observable_2.runOnChange)(doc.value, (value) => {
|
|
168
156
|
this._cancelPendingRequestDueToDocChange(doc.id, value);
|
|
157
|
+
// FIXME: don't invoke before fixing false positive cancellations
|
|
158
|
+
// this._specManager.onActiveDocumentChanged(doc.id, value.value);
|
|
169
159
|
}));
|
|
160
|
+
// When the per-doc store is disposed, the document was removed from
|
|
161
|
+
// openDocuments. Cancel any speculative targeting it — its cached result
|
|
162
|
+
// would never be hit again.
|
|
163
|
+
store.add((0, lifecycle_1.toDisposable)(() => this._specManager.onDocumentClosed(doc.id)));
|
|
170
164
|
}).recomputeInitiallyAndOnChange(this._store);
|
|
171
165
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Cancels the in-flight stateless next-edit request when the document it
|
|
168
|
+
* was issued for has diverged from the request's expected post-edit state.
|
|
169
|
+
*
|
|
170
|
+
* Invoked from the per-document `runOnChange` autorun in the constructor
|
|
171
|
+
* whenever an open document's value changes. The pending request was built
|
|
172
|
+
* against a specific snapshot (`documentAfterEdits`); if the user has since
|
|
173
|
+
* typed something that makes the current value differ from that snapshot,
|
|
174
|
+
* the result would no longer be applicable and is cancelled eagerly.
|
|
175
|
+
*
|
|
176
|
+
* Skipped when:
|
|
177
|
+
* - the `InlineEditsAsyncCompletions` experiment is enabled (that path
|
|
178
|
+
* tolerates divergence and rebases later), or
|
|
179
|
+
* - there is no pending request, or
|
|
180
|
+
* - the changed document is not the one the pending request targets.
|
|
181
|
+
*
|
|
182
|
+
* Note: this only handles the regular pending stateless request. Speculative
|
|
183
|
+
* requests have their own divergence handling via
|
|
184
|
+
* `SpeculativeRequestManager.onActiveDocumentChanged` (trajectory check).
|
|
185
|
+
*/
|
|
179
186
|
_cancelPendingRequestDueToDocChange(docId, docValue) {
|
|
180
|
-
// Note: we intentionally do NOT cancel the speculative request here.
|
|
181
|
-
// The speculative request's postEditContent represents a *future* document state
|
|
182
|
-
// (after the user would accept the suggestion), so it will almost never match the
|
|
183
|
-
// current document value while the user is still typing. Cancelling here would
|
|
184
|
-
// wastefully kill and recreate the speculative request on every keystroke.
|
|
185
|
-
// Instead, speculative requests are cancelled by the appropriate lifecycle handlers:
|
|
186
|
-
// handleRejection, handleIgnored, _triggerSpeculativeRequest, and _executeNewNextEditRequest.
|
|
187
187
|
const isAsyncCompletions = this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsAsyncCompletions, this._expService);
|
|
188
188
|
if (isAsyncCompletions || this._pendingStatelessNextEditRequest === null) {
|
|
189
189
|
return;
|
|
@@ -367,7 +367,6 @@ let NextEditProvider = NextEditProvider_1 = class NextEditProvider extends lifec
|
|
|
367
367
|
const nesConfigs = {
|
|
368
368
|
isAsyncCompletions: this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsAsyncCompletions, this._expService),
|
|
369
369
|
isEagerBackupRequest: this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsEagerBackupRequest, this._expService),
|
|
370
|
-
isCheckEditWindowOnReuse: this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsCheckEditWindowOnReuse, this._expService),
|
|
371
370
|
};
|
|
372
371
|
telemetryBuilder.setNESConfigs({ ...nesConfigs });
|
|
373
372
|
logContext.addCodeblockToLog(JSON.stringify(nesConfigs, null, '\t'));
|
|
@@ -399,7 +398,7 @@ let NextEditProvider = NextEditProvider_1 = class NextEditProvider extends lifec
|
|
|
399
398
|
const logContext = req.log;
|
|
400
399
|
logContext.setRecentEdit(historyContext);
|
|
401
400
|
const cursorAtInvocationTime = selectionAtInvocationTime.at(0);
|
|
402
|
-
const cursorInRequestEditWindow = (request) => !
|
|
401
|
+
const cursorInRequestEditWindow = (request) => !request.requestEditWindow || !cursorAtInvocationTime || request.requestEditWindow.containsCursor(cursorAtInvocationTime);
|
|
403
402
|
// Check if we can reuse the regular pending request
|
|
404
403
|
const pendingRequestStillCurrent = documentAtInvocationTime.value === this._pendingStatelessNextEditRequest?.documentBeforeEdits.value;
|
|
405
404
|
const cursorWithinPendingEditWindow = !this._pendingStatelessNextEditRequest || cursorInRequestEditWindow(this._pendingStatelessNextEditRequest);
|
|
@@ -407,19 +406,20 @@ let NextEditProvider = NextEditProvider_1 = class NextEditProvider extends lifec
|
|
|
407
406
|
&& !this._pendingStatelessNextEditRequest?.cancellationTokenSource.token.isCancellationRequested
|
|
408
407
|
&& this._pendingStatelessNextEditRequest || undefined;
|
|
409
408
|
// Check if we can reuse the speculative pending request (from when a suggestion was shown)
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
&&
|
|
413
|
-
&&
|
|
414
|
-
|
|
409
|
+
const specPending = this._specManager.pending;
|
|
410
|
+
const speculativeRequestMatches = specPending?.docId === curDocId
|
|
411
|
+
&& specPending?.postEditContent === documentAtInvocationTime.value
|
|
412
|
+
&& !specPending.request.cancellationTokenSource.token.isCancellationRequested
|
|
413
|
+
&& cursorInRequestEditWindow(specPending.request);
|
|
414
|
+
const speculativeRequest = speculativeRequestMatches ? specPending?.request : undefined;
|
|
415
415
|
// Prefer speculative request if it matches (it was specifically created for this post-edit state)
|
|
416
416
|
const requestToReuse = speculativeRequest ?? existingNextEditRequest;
|
|
417
417
|
if (requestToReuse) {
|
|
418
418
|
// Nice! No need to make another request, we can reuse the result from a pending request.
|
|
419
419
|
if (speculativeRequest) {
|
|
420
420
|
logger.trace(`reusing speculative pending request (opportunityId=${speculativeRequest.opportunityId}, headerRequestId=${speculativeRequest.headerRequestId})`);
|
|
421
|
-
//
|
|
422
|
-
this.
|
|
421
|
+
// Detach the speculative — caller is consuming it now.
|
|
422
|
+
this._specManager.consumePending();
|
|
423
423
|
}
|
|
424
424
|
else {
|
|
425
425
|
logger.trace(`reusing in-flight pending request (opportunityId=${requestToReuse.opportunityId}, headerRequestId=${requestToReuse.headerRequestId})`);
|
|
@@ -517,7 +517,7 @@ let NextEditProvider = NextEditProvider_1 = class NextEditProvider extends lifec
|
|
|
517
517
|
telemetryBuilder.setReusedRequest(reusedRequestKind);
|
|
518
518
|
telemetryBuilder.setRequest(nextEditRequest);
|
|
519
519
|
logContext.setRequestInput(nextEditRequest);
|
|
520
|
-
logContext.
|
|
520
|
+
logContext.setIsReusedInFlightResult(nextEditRequest.logContext);
|
|
521
521
|
const disp = this._hookupCancellation(nextEditRequest, cancellationToken);
|
|
522
522
|
try {
|
|
523
523
|
return await nextEditRequest.result;
|
|
@@ -553,15 +553,11 @@ let NextEditProvider = NextEditProvider_1 = class NextEditProvider extends lifec
|
|
|
553
553
|
// Clear any scheduled (but not yet triggered) speculative request tied to the
|
|
554
554
|
// old stream — it would otherwise fire stale when the old stream's background
|
|
555
555
|
// loop calls handleStreamEnd after the stream has already been superseded.
|
|
556
|
-
this.
|
|
556
|
+
this._specManager.clearScheduled();
|
|
557
557
|
}
|
|
558
558
|
// Cancel speculative request if it doesn't match the document/state
|
|
559
559
|
// of this new request — it was built for a different document or post-edit state.
|
|
560
|
-
|
|
561
|
-
&& (this._speculativePendingRequest.docId !== curDocId
|
|
562
|
-
|| this._speculativePendingRequest.postEditContent !== nextEditRequest.documentBeforeEdits.value)) {
|
|
563
|
-
this._cancelSpeculativeRequest();
|
|
564
|
-
}
|
|
560
|
+
this._specManager.cancelIfMismatch(curDocId, nextEditRequest.documentBeforeEdits.value, "superseded" /* SpeculativeCancelReason.Superseded */);
|
|
565
561
|
this._pendingStatelessNextEditRequest = nextEditRequest;
|
|
566
562
|
const removeFromPending = () => {
|
|
567
563
|
if (this._pendingStatelessNextEditRequest === nextEditRequest) {
|
|
@@ -666,9 +662,8 @@ let NextEditProvider = NextEditProvider_1 = class NextEditProvider extends lifec
|
|
|
666
662
|
removeFromPending();
|
|
667
663
|
// Fire any scheduled speculative request — the last shown edit
|
|
668
664
|
// was indeed the last edit from this stream.
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
this._scheduledSpeculativeRequest = null;
|
|
665
|
+
const scheduled = this._specManager.consumeScheduled(nextEditRequest.headerRequestId);
|
|
666
|
+
if (scheduled) {
|
|
672
667
|
void this._triggerSpeculativeRequest(scheduled.suggestion);
|
|
673
668
|
}
|
|
674
669
|
return result;
|
|
@@ -694,9 +689,7 @@ let NextEditProvider = NextEditProvider_1 = class NextEditProvider extends lifec
|
|
|
694
689
|
processEdit(streamedEdit, res.value.telemetryBuilder);
|
|
695
690
|
// A new edit arrived from the stream — the previously-shown
|
|
696
691
|
// edit was not the last one. Clear the scheduled speculative.
|
|
697
|
-
|
|
698
|
-
this._scheduledSpeculativeRequest = null;
|
|
699
|
-
}
|
|
692
|
+
this._specManager.consumeScheduled(nextEditRequest.headerRequestId);
|
|
700
693
|
res = await editStream.next();
|
|
701
694
|
}
|
|
702
695
|
// Stream completed
|
|
@@ -787,7 +780,7 @@ let NextEditProvider = NextEditProvider_1 = class NextEditProvider extends lifec
|
|
|
787
780
|
this._lastShownTime = Date.now();
|
|
788
781
|
this._lastShownSuggestionId = suggestion.requestId;
|
|
789
782
|
this._lastOutcome = undefined; // clear so that outcome is "pending" until resolved
|
|
790
|
-
this.
|
|
783
|
+
this._specManager.clearScheduled(); // clear any previously scheduled speculative
|
|
791
784
|
// Trigger speculative request for the post-edit document state
|
|
792
785
|
const speculativeRequestsEnablement = this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsSpeculativeRequests, this._expService);
|
|
793
786
|
if (speculativeRequestsEnablement === xtabPromptOptions_1.SpeculativeRequestsEnablement.On) {
|
|
@@ -797,10 +790,10 @@ let NextEditProvider = NextEditProvider_1 = class NextEditProvider extends lifec
|
|
|
797
790
|
// request only fires when the stream ends with the shown edit as the last one.
|
|
798
791
|
const originatingRequest = this._pendingStatelessNextEditRequest;
|
|
799
792
|
if (originatingRequest && originatingRequest.headerRequestId === suggestion.source.headerRequestId) {
|
|
800
|
-
this.
|
|
793
|
+
this._specManager.schedule({
|
|
801
794
|
suggestion,
|
|
802
795
|
headerRequestId: originatingRequest.headerRequestId,
|
|
803
|
-
};
|
|
796
|
+
});
|
|
804
797
|
}
|
|
805
798
|
else {
|
|
806
799
|
void this._triggerSpeculativeRequest(suggestion);
|
|
@@ -868,7 +861,8 @@ let NextEditProvider = NextEditProvider_1 = class NextEditProvider extends lifec
|
|
|
868
861
|
return;
|
|
869
862
|
}
|
|
870
863
|
// Check if we already have a speculative request for this post-edit state
|
|
871
|
-
|
|
864
|
+
const existingSpec = this._specManager.pending;
|
|
865
|
+
if (existingSpec?.docId === docId && existingSpec?.postEditContent === postEditContent) {
|
|
872
866
|
logger.trace('already have speculative request for post-edit state');
|
|
873
867
|
return;
|
|
874
868
|
}
|
|
@@ -880,8 +874,11 @@ let NextEditProvider = NextEditProvider_1 = class NextEditProvider extends lifec
|
|
|
880
874
|
logger.trace('document not found for speculative request');
|
|
881
875
|
return;
|
|
882
876
|
}
|
|
883
|
-
//
|
|
884
|
-
|
|
877
|
+
// Note: any previous speculative request will be cancelled (as `Replaced`)
|
|
878
|
+
// by `_specManager.setPending` once the new request is actually installed —
|
|
879
|
+
// see the `setPending` call at the end of this method. We deliberately do
|
|
880
|
+
// not cancel earlier so the prior speculative stays available for reuse
|
|
881
|
+
// while the new one is being constructed.
|
|
885
882
|
const historyContext = this._historyContextProvider.getHistoryContext(docId);
|
|
886
883
|
if (!historyContext) {
|
|
887
884
|
logger.trace('no history context for speculative request');
|
|
@@ -895,11 +892,24 @@ let NextEditProvider = NextEditProvider_1 = class NextEditProvider extends lifec
|
|
|
895
892
|
isSubsequentEdit: suggestion.result?.isSubsequentEdit ?? false,
|
|
896
893
|
}, logger);
|
|
897
894
|
if (speculativeRequest) {
|
|
898
|
-
|
|
895
|
+
// Capture trajectory data: while the user is typing in `docId`, the
|
|
896
|
+
// document is on a "type-through" trajectory iff:
|
|
897
|
+
// doc = preEdit[0..editStart] + newText[0..k] + preEdit[editEnd..]
|
|
898
|
+
// for some 0 <= k <= newText.length. Storing the prefix/suffix/newText
|
|
899
|
+
// (already-CRLF-normalized via `result.edit.newText` whose newlines
|
|
900
|
+
// match the original document) lets us check this in O(|cur|) on doc changes.
|
|
901
|
+
const preEditValue = result.documentBeforeEdits.value;
|
|
902
|
+
const trajectoryPrefix = preEditValue.slice(0, preciseEdit.replaceRange.start);
|
|
903
|
+
const trajectorySuffix = preEditValue.slice(preciseEdit.replaceRange.endExclusive);
|
|
904
|
+
const trajectoryNewText = preciseEdit.newText;
|
|
905
|
+
this._specManager.setPending({
|
|
899
906
|
request: speculativeRequest,
|
|
900
907
|
docId,
|
|
901
908
|
postEditContent,
|
|
902
|
-
|
|
909
|
+
trajectoryPrefix,
|
|
910
|
+
trajectorySuffix,
|
|
911
|
+
trajectoryNewText,
|
|
912
|
+
});
|
|
903
913
|
}
|
|
904
914
|
}
|
|
905
915
|
catch (e) {
|
|
@@ -1086,7 +1096,7 @@ let NextEditProvider = NextEditProvider_1 = class NextEditProvider extends lifec
|
|
|
1086
1096
|
// The user rejected the suggestion, so the speculative request (which
|
|
1087
1097
|
// predicted the post-accept state) will never be reused. Cancel it to
|
|
1088
1098
|
// avoid wasting a server slot.
|
|
1089
|
-
this.
|
|
1099
|
+
this._specManager.cancelAll("rejected" /* SpeculativeCancelReason.Rejected */);
|
|
1090
1100
|
const shownDuration = Date.now() - this._lastShownTime;
|
|
1091
1101
|
if (shownDuration > 1000 && suggestion.result.edit) {
|
|
1092
1102
|
// we can argue that the user had the time to review this
|
|
@@ -1106,9 +1116,15 @@ let NextEditProvider = NextEditProvider_1 = class NextEditProvider extends lifec
|
|
|
1106
1116
|
if (wasShown && !wasSuperseded) {
|
|
1107
1117
|
// The shown suggestion was dismissed (not superseded by a new one),
|
|
1108
1118
|
// so the speculative request for its post-accept state is useless.
|
|
1109
|
-
this.
|
|
1119
|
+
this._specManager.cancelAll("ignoredDismissed" /* SpeculativeCancelReason.IgnoredDismissed */);
|
|
1110
1120
|
this._statelessNextEditProvider.handleIgnored?.();
|
|
1111
1121
|
}
|
|
1122
|
+
// Note: the superseded case is intentionally NOT handled here. The trajectory
|
|
1123
|
+
// check on `_specManager.onActiveDocumentChanged` already cancels the
|
|
1124
|
+
// speculative iff the user's edit moved off the type-through trajectory; if
|
|
1125
|
+
// the new (superseding) suggestion is just a continuation of the old one
|
|
1126
|
+
// (e.g. typed `i` while `ibonacci` was shown → now `bonacci` is shown), the
|
|
1127
|
+
// speculative's `postEditContent` is still the right bet and we keep it.
|
|
1112
1128
|
}
|
|
1113
1129
|
async runSnippy(docId, suggestion) {
|
|
1114
1130
|
if (suggestion.result === undefined || suggestion.result.edit === undefined) {
|
|
@@ -1130,6 +1146,9 @@ let NextEditProvider = NextEditProvider_1 = class NextEditProvider extends lifec
|
|
|
1130
1146
|
clearCache() {
|
|
1131
1147
|
this._nextEditCache.clear();
|
|
1132
1148
|
this._rejectionCollector.clear();
|
|
1149
|
+
// Any in-flight speculative would land its result into a cache that's
|
|
1150
|
+
// meant to be empty (and may be based on a now-stale model/auth/prompt).
|
|
1151
|
+
this._specManager.cancelAll("cacheCleared" /* SpeculativeCancelReason.CacheCleared */);
|
|
1133
1152
|
}
|
|
1134
1153
|
};
|
|
1135
1154
|
exports.NextEditProvider = NextEditProvider;
|