Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/extension/inlineEdits/node/nextEditCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface CachedEdit {
cacheTime: number;
}

export type CachedOrRebasedEdit = CachedEdit & { rebasedEdit?: StringReplacement; rebasedEditIndex?: number; showLabel?: boolean };
export type CachedOrRebasedEdit = CachedEdit & { rebasedEdit?: StringReplacement; rebasedEditIndex?: number };

export class NextEditCache extends Disposable {
private readonly _documentCaches = new Map<DocumentId, DocumentEditCache>();
Expand Down
48 changes: 2 additions & 46 deletions src/extension/inlineEdits/node/nextEditProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { assertType } from '../../../util/vs/base/common/types';
import { generateUuid } from '../../../util/vs/base/common/uuid';
import { LineEdit } from '../../../util/vs/editor/common/core/edits/lineEdit';
import { StringEdit, StringReplacement } from '../../../util/vs/editor/common/core/edits/stringEdit';
import { Range } from '../../../util/vs/editor/common/core/range';
import { OffsetRange } from '../../../util/vs/editor/common/core/ranges/offsetRange';
import { StringText } from '../../../util/vs/editor/common/core/text/abstractText';
import { checkEditConsistency } from '../common/editRebase';
Expand All @@ -41,7 +40,7 @@ import { DebugRecorder } from './debugRecorder';
import { INesConfigs } from './nesConfigs';
import { CachedOrRebasedEdit, NextEditCache } from './nextEditCache';
import { LlmNESTelemetryBuilder } from './nextEditProviderTelemetry';
import { INextEditDisplayLocation, INextEditResult, NextEditResult } from './nextEditResult';
import { INextEditResult, NextEditResult } from './nextEditResult';

export interface INextEditProvider<T extends INextEditResult, TTelemetry, TData = void> extends IDisposable {
readonly ID: string;
Expand Down Expand Up @@ -193,7 +192,6 @@ export class NextEditProvider extends Disposable implements INextEditProvider<Ne
}

let edit: StringReplacement | undefined;
let showLabel: boolean | undefined;
let currentDocument: StringText | undefined;
let error: NoNextEditReason | undefined;
let req: NextEditFetchRequest;
Expand Down Expand Up @@ -248,7 +246,6 @@ export class NextEditProvider extends Disposable implements INextEditProvider<Ne
logContext.setIsSkipped();
} else {
const suggestedNextEdit = result.val.rebasedEdit || result.val.edit;
showLabel = result.val.showLabel;
if (!suggestedNextEdit) {
tracer.trace('empty edits');
telemetryBuilder.setStatus('emptyEdits');
Expand Down Expand Up @@ -303,44 +300,7 @@ export class NextEditProvider extends Disposable implements INextEditProvider<Ne

const showRangePreference = this._statelessNextEditProvider.showNextEditPreference ?? ShowNextEditPreference.AroundEdit;

let nextEditResult: NextEditResult;
const currentSelection = selections.at(0);
const transformer = documentAtInvocationTime.getTransformer();
const currentCursorPosition: Range | undefined = currentSelection ? transformer.getRange(currentSelection) : undefined;
const editPosition = transformer.getRange(edit.replaceRange);

if (!showLabel || !currentCursorPosition || /* is close enough to not show label */ currentCursorPosition.startLineNumber - 2 <= editPosition.startLineNumber && editPosition.endLineNumber <= currentCursorPosition.endLineNumber + 5) { // TODO@ulugbekna
tracer.trace('providing edit without label');
nextEditResult = new NextEditResult(logContext.requestId, req, { edit, showRangePreference, documentBeforeEdits: currentDocument, targetDocumentId });
} else {
tracer.trace('providing edit with label');
const lineWithCode = documentAtInvocationTime.getLineAt(editPosition.startLineNumber);
const trimmedLineWithCode = lineWithCode.trimStart();
const shortenedLineWithCode = trimmedLineWithCode.slice(0, 40);
const label = ['.ts', '.tsx', '.js', '.jsx'].includes(docId.extension) && this._configService.getExperimentBasedConfig(ConfigKey.Advanced.InlineEditsNextCursorPredictionDisplayLine, this._expService)
? `Jump to line ${editPosition.startLineNumber} | ${shortenedLineWithCode.length === trimmedLineWithCode.length ? shortenedLineWithCode : trimmedLineWithCode + '...'}`
: `Jump to line ${editPosition.startLineNumber}`;
const displayLocation: INextEditDisplayLocation = {
label,
range: currentCursorPosition,
};

// const commandJumpToEditRange: vscode.Command = {
// command: jumpToPositionCommandId,
// title: "Jump to next edit",
// arguments: [editPosition.getStartPosition()],
// };

// const noopEdit = StringReplacement.replace(new OffsetRange(0, 0), ''); // should be no-op edit
nextEditResult = new NextEditResult(logContext.requestId, req, {
edit, //: noopEdit,
showRangePreference,
documentBeforeEdits: currentDocument,
targetDocumentId,
displayLocation,
// action: commandJumpToEditRange
});
}
const nextEditResult = new NextEditResult(logContext.requestId, req, { edit, showRangePreference, documentBeforeEdits: currentDocument, targetDocumentId });

telemetryBuilder.setHasNextEdit(true);

Expand Down Expand Up @@ -640,7 +600,6 @@ export class NextEditProvider extends Disposable implements INextEditProvider<Ne
const targetDocState = statePerDoc.get(result.val.targetDocument ?? curDocId);

const singleLineEdit = result.val.edit;
const showLabel = result.val.showLabel;
const lineEdit = new LineEdit([singleLineEdit]);
const edit = convertLineEditToEdit(lineEdit, targetDocState.docId);
const rebasedEdit = edit.tryRebase(targetDocState.editsSoFar);
Expand Down Expand Up @@ -669,9 +628,6 @@ export class NextEditProvider extends Disposable implements INextEditProvider<Ne
}

if (!firstEdit.isSettled) {
if (cachedEdit) {
cachedEdit.showLabel = showLabel;
}
myTracer.trace('resolving firstEdit promise');
logContext.setResult(new RootedLineEdit(targetDocState.docContents, lineEdit)); // this's correct without rebasing because this's the first edit
firstEdit.complete(cachedEdit ? Result.ok(cachedEdit) : Result.error(new NoNextEditReason.Unexpected(new Error('No cached edit'))));
Expand Down
14 changes: 4 additions & 10 deletions src/extension/xtab/node/xtabProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ export class XtabProvider implements IStatelessNextEditProvider {
getOrDeduceSelectionFromLastEdit(request.getActiveDocument()),
pushEdit,
delaySession,
{ showLabel: false },
tracer,
logContext,
cancellationToken,
Expand All @@ -208,7 +207,6 @@ export class XtabProvider implements IStatelessNextEditProvider {
selection: Range | null,
pushEdit: PushEdit,
delaySession: DelaySession,
opts: { showLabel: boolean },
parentTracer: ITracer,
logContext: InlineEditRequestLogContext,
cancellationToken: CancellationToken,
Expand Down Expand Up @@ -351,7 +349,6 @@ export class XtabProvider implements IStatelessNextEditProvider {
promptPieces,
prediction,
{
showLabel: opts.showLabel,
shouldRemoveCursorTagFromResponse,
responseFormat,
retryState,
Expand Down Expand Up @@ -493,7 +490,6 @@ export class XtabProvider implements IStatelessNextEditProvider {
promptPieces: PromptPieces,
prediction: Prediction | undefined,
opts: {
showLabel: boolean;
responseFormat: xtabPromptOptions.ResponseFormat;
shouldRemoveCursorTagFromResponse: boolean;
retryState: RetryState;
Expand Down Expand Up @@ -698,9 +694,7 @@ export class XtabProvider implements IStatelessNextEditProvider {
}

const diffOptions: ResponseProcessor.DiffParams = {
emitFastCursorLineChange: opts.showLabel
? false
: this.configService.getExperimentBasedConfig(ConfigKey.TeamInternal.InlineEditsXtabProviderEmitFastCursorLineChange, this.expService),
emitFastCursorLineChange: this.configService.getExperimentBasedConfig(ConfigKey.TeamInternal.InlineEditsXtabProviderEmitFastCursorLineChange, this.expService),
nLinesToConverge: this.configService.getExperimentBasedConfig(ConfigKey.TeamInternal.InlineEditsXtabNNonSignificantLinesToConverge, this.expService),
nSignificantLinesToConverge: this.configService.getExperimentBasedConfig(ConfigKey.TeamInternal.InlineEditsXtabNSignificantLinesToConverge, this.expService),
};
Expand Down Expand Up @@ -767,7 +761,7 @@ export class XtabProvider implements IStatelessNextEditProvider {
}
}

pushEdit(Result.ok({ edit: singleLineEdit, window: editWindow, showLabel: opts.showLabel }));
pushEdit(Result.ok({ edit: singleLineEdit, window: editWindow }));
i++;
}
}
Expand Down Expand Up @@ -854,11 +848,11 @@ export class XtabProvider implements IStatelessNextEditProvider {
new Range(nextCursorLineOneBased, nextCursorColumn, nextCursorLineOneBased, nextCursorColumn),
pushEdit,
delaySession,
{ showLabel: nextCursorLinePrediction === NextCursorLinePrediction.LabelOnlyWithEdit },
tracer,
logContext,
cancellationToken,
telemetryBuilder, RetryState.Retrying,
telemetryBuilder,
RetryState.Retrying,
);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const enum ShowNextEditPreference {
AroundEdit = 'aroundEdit',
}

export type PushEdit = (edit: Result<{ edit: LineReplacement; window?: OffsetRange; targetDocument?: DocumentId; showLabel?: boolean }, NoNextEditReason>) => void;
export type PushEdit = (edit: Result<{ edit: LineReplacement; window?: OffsetRange; targetDocument?: DocumentId }, NoNextEditReason>) => void;

export interface IStatelessNextEditProvider {
readonly ID: string;
Expand Down