Skip to content

Commit a10c8be

Browse files
authored
nes: fix hasNextEdit field to be more trustworthy (#264)
Previous way of computation of this field came from stateless provider, ie it missed if the edit would come from cache, and in general if stream errored, then it could still be set, etc. Now it should be more fail-proof
1 parent 80889e5 commit a10c8be

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/extension/inlineEdits/node/nextEditProvider.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ export class NextEditProvider extends Disposable implements INextEditProvider<Ne
266266
}
267267

268268
tracer.trace('returning next edit result');
269+
telemetryBuilder.setHasNextEdit(true);
270+
269271
return nextEditResult;
270272
}
271273

src/extension/inlineEdits/node/nextEditProviderTelemetry.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export interface ILlmNESTelemetry extends Partial<IStatelessNextEditTelemetry> {
7070
readonly activeDocumentEditsCount: number | undefined;
7171
readonly activeDocumentLanguageId: string | undefined;
7272
readonly activeDocumentRepository: string | undefined;
73+
readonly hasNextEdit: boolean;
7374
readonly wasPreviouslyRejected: boolean;
7475
readonly status: NextEditTelemetryStatus;
7576
readonly nesConfigs: INesConfigs | undefined;
@@ -236,6 +237,7 @@ export class LlmNESTelemetryBuilder extends Disposable {
236237
activeDocumentLanguageId,
237238
activeDocumentOriginalLineCount,
238239
fetchStartedAfterMs,
240+
hasNextEdit: this._hasNextEdit,
239241
wasPreviouslyRejected: this._wasPreviouslyRejected,
240242
isNotebook: isNotebook,
241243
status: this._status,
@@ -317,6 +319,12 @@ export class LlmNESTelemetryBuilder extends Disposable {
317319
return this;
318320
}
319321

322+
private _hasNextEdit: boolean = false;
323+
public setHasNextEdit(hasNextEdit: boolean): this {
324+
this._hasNextEdit = hasNextEdit;
325+
return this;
326+
}
327+
320328
private _wasPreviouslyRejected: boolean = false;
321329
public setWasPreviouslyRejected(): this {
322330
this._wasPreviouslyRejected = true;
@@ -701,7 +709,7 @@ export class TelemetrySender implements IDisposable {
701709
"promptCharCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Number of characters in the prompt", "isMeasurement": true },
702710
"hadLowLogProbSuggestion": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether the suggestion had low log probability", "isMeasurement": true },
703711
"nEditsSuggested": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Number of edits suggested", "isMeasurement": true },
704-
"hasNextEdit": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether there is a next edit", "isMeasurement": true },
712+
"hasNextEdit": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether next edit provider returned an edit (if an edit was previously rejected, this field is false)", "isMeasurement": true },
705713
"nextEditLogprob": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Log probability of the next edit", "isMeasurement": true },
706714
"lineDistanceToMostRecentEdit": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Line distance to most recent edit", "isMeasurement": true },
707715
"isCursorAtEndOfLine": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether the cursor is at the end of the line", "isMeasurement": true },

src/platform/inlineEdits/common/statelessNextEditProvider.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ export interface IStatelessNextEditTelemetry {
287287
readonly lineDistanceToMostRecentEdit: number | undefined;
288288

289289
/* result info */
290-
readonly hasNextEdit: boolean;
291290
readonly nextEditLogprob: number | undefined;
292291
readonly noNextEditReasonKind: string | undefined;
293292
readonly noNextEditReasonMessage: string | undefined;
@@ -323,7 +322,6 @@ export class StatelessNextEditTelemetryBuilder {
323322
const promptLineCount = promptText?.split('\n').length;
324323
const promptCharCount = promptText?.length;
325324

326-
const hasNextEdit = result.isOk();
327325
const noNextEditReasonKind = result.isOk() ? undefined : result.err.kind;
328326

329327
let noNextEditReasonMessage: string | undefined;
@@ -342,7 +340,6 @@ export class StatelessNextEditTelemetryBuilder {
342340
return {
343341
hadStatelessNextEditProviderCall: true,
344342

345-
hasNextEdit,
346343
noNextEditReasonKind,
347344
noNextEditReasonMessage,
348345

0 commit comments

Comments
 (0)