feat: add user-friendly way to toggle between FIM and next edit (#7355)
* feat: don't format when model is not mercury * chore: bump * fix: remove mercury-coder-nextedit * refactor: remove refs to mercury-coder-nextedit * feat: add util function for converting model name to enum * refactor: add new types * refactor: create an abstract base class for providers * refactor: add child provider for instinct * refactor: add provider for mercury coder * refactor: provider factory * refactor: use factory to create model providers based on helper.modelName * refactor: clean up redundant logic to be more provider-friendly * add buildPromptMetadata as an abstract method * refactor: use handlebars and provider-specific template renderers * refactor: use this.modelProvider instead of prompt engine * refactor: remove redundant helper * fix: update vitest after refactor * feat: add test for convertNextEditModelNameToEnum * fix: add isSecurityConcern imports * feat: add functions to return next edit menu items and update config * fix: get rid of callbacks * feat: render next edit menu items * fix: get rid of redundant completion request * feat: update next edit status on vscode workspace config update, refactor out common logic * feat: add continue.enableNextEdit * feat: add aborted field to check for false positives * fix: remove zetaDataset suffix * feat: make sure that we are tracking completions * feat: log aborts and move id generation to the top * feat: all requests are tracked. when request is aborted, log as aborted with zero-value data. else, graduate it from pending completion and set aborted to false * feat: add aborted to schema * feat: add a toggleNextEditEnabled command * feat: show (NE) in the status bar when next edit is enabled, add keymap * feat: add command definitions for toggleNextEditEnabled * refactor: handle validation in VsCodeExtension * feat: check if model does not support next edit * feat: use better menu item labels * fix: casing * chore: bump * feat: add a function to disable next edit * feat: disable next edit before e2e tests * chore: bump * fix: add a small delay to wait for UI loading * fix: NE is shown for all statuses * fix: wait for the NE to pop up * fix: wait longer for disableNextEdit, clear potential next edit notifications * fix: roll back clearAllNotifications * fix: try disabling next edit before each * fix: revert * feat: add sane defaults when no workspace settings are set * fix: fall back to false * fix: debugging * chore: change name * fix: try waiting for text * debug: more debug logs * fix: clear notifs * fix: suppress warning * fix: string matching * fix: jump label overlapping with the inline tip label (#7399) * feat: add methods to temporarily hide and show tooltip * feat: hide the inline tooltip when the jumpmanager's tooltip is shown * feat: focus on chat input after apply * revert * fix: HOTFIX local assistant loading (#7354) * fix: local assistant loading * fix: no need for excluding .continue/.continue * test: cases for config.yml and config.yaml names * feat: remove hide/show logic for creating a new svgbuilder instance * feat: use a new svgBuilder istance * chore: update package-lock.json --------- Co-authored-by: uinstinct <61635505+uinstinct@users.noreply.github.com> Co-authored-by: Dallin Romney <dallinromney@gmail.com> Co-authored-by: Ting-Wai <40179554+tingwai@users.noreply.github.com> --------- Co-authored-by: uinstinct <61635505+uinstinct@users.noreply.github.com> Co-authored-by: Dallin Romney <dallinromney@gmail.com> Co-authored-by: Ting-Wai <40179554+tingwai@users.noreply.github.com>
This commit is contained in:
parent
37cbac5dd5
commit
f27e7c71de
23 changed files with 453 additions and 65 deletions
|
|
@ -215,12 +215,6 @@ export class CompletionProvider {
|
|||
const multiline =
|
||||
!helper.options.transform || shouldCompleteMultiline(helper);
|
||||
|
||||
const rawGeneration = await llm.complete(
|
||||
prompt,
|
||||
token,
|
||||
completionOptions,
|
||||
);
|
||||
|
||||
const completionStream =
|
||||
this.completionStreamer.streamCompletionWithFilters(
|
||||
token,
|
||||
|
|
|
|||
|
|
@ -11,6 +11,16 @@ export class NextEditLoggingService {
|
|||
private _abortControllers = new Map<string, AbortController>();
|
||||
private _logRejectionTimeouts = new Map<string, NodeJS.Timeout>();
|
||||
private _outcomes = new Map<string, NextEditOutcome>();
|
||||
// Track minimal data for completions that get aborted before we have full outcome.
|
||||
private _pendingCompletions = new Map<
|
||||
string,
|
||||
{
|
||||
startTime: number;
|
||||
modelName?: string;
|
||||
modelProvider?: string;
|
||||
filepath?: string;
|
||||
}
|
||||
>();
|
||||
_lastDisplayedCompletion: { id: string; displayedAt: number } | undefined =
|
||||
undefined;
|
||||
|
||||
|
|
@ -26,21 +36,54 @@ export class NextEditLoggingService {
|
|||
public createAbortController(completionId: string): AbortController {
|
||||
const abortController = new AbortController();
|
||||
this._abortControllers.set(completionId, abortController);
|
||||
this.trackPendingCompletion(completionId);
|
||||
return abortController;
|
||||
}
|
||||
|
||||
public deleteAbortController(completionId: string) {
|
||||
this._abortControllers.delete(completionId);
|
||||
this._pendingCompletions.delete(completionId);
|
||||
}
|
||||
|
||||
// Keep track of a new completion request.
|
||||
public trackPendingCompletion(completionId: string) {
|
||||
this._pendingCompletions.set(completionId, {
|
||||
startTime: Date.now(),
|
||||
});
|
||||
}
|
||||
|
||||
// Update pending completion info as it becomes available.
|
||||
public updatePendingCompletion(
|
||||
completionId: string,
|
||||
data: {
|
||||
modelName?: string;
|
||||
modelProvider?: string;
|
||||
filepath?: string;
|
||||
},
|
||||
) {
|
||||
const pending = this._pendingCompletions.get(completionId);
|
||||
if (pending) {
|
||||
this._pendingCompletions.set(completionId, { ...pending, ...data });
|
||||
} else {
|
||||
// If we haven't tracked it yet, create new entry with provided data.
|
||||
this._pendingCompletions.set(completionId, {
|
||||
startTime: Date.now(),
|
||||
...data,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public cancel() {
|
||||
this._abortControllers.forEach((abortController, id) => {
|
||||
this._abortControllers.forEach((abortController, completionId) => {
|
||||
this.handleAbort(completionId);
|
||||
abortController.abort();
|
||||
});
|
||||
this._abortControllers.clear();
|
||||
}
|
||||
|
||||
public accept(completionId: string): NextEditOutcome | undefined {
|
||||
this._pendingCompletions.delete(completionId);
|
||||
|
||||
if (this._logRejectionTimeouts.has(completionId)) {
|
||||
clearTimeout(this._logRejectionTimeouts.get(completionId));
|
||||
this._logRejectionTimeouts.delete(completionId);
|
||||
|
|
@ -48,6 +91,7 @@ export class NextEditLoggingService {
|
|||
if (this._outcomes.has(completionId)) {
|
||||
const outcome = this._outcomes.get(completionId)!;
|
||||
outcome.accepted = true;
|
||||
outcome.aborted = false;
|
||||
this.logNextEditOutcome(outcome);
|
||||
this._outcomes.delete(completionId);
|
||||
return outcome;
|
||||
|
|
@ -55,6 +99,8 @@ export class NextEditLoggingService {
|
|||
}
|
||||
|
||||
public reject(completionId: string): NextEditOutcome | undefined {
|
||||
this._pendingCompletions.delete(completionId);
|
||||
|
||||
if (this._logRejectionTimeouts.has(completionId)) {
|
||||
clearTimeout(this._logRejectionTimeouts.get(completionId));
|
||||
this._logRejectionTimeouts.delete(completionId);
|
||||
|
|
@ -63,6 +109,7 @@ export class NextEditLoggingService {
|
|||
if (this._outcomes.has(completionId)) {
|
||||
const outcome = this._outcomes.get(completionId)!;
|
||||
outcome.accepted = false;
|
||||
outcome.aborted = false;
|
||||
this.logNextEditOutcome(outcome);
|
||||
this._outcomes.delete(completionId);
|
||||
return outcome;
|
||||
|
|
@ -86,12 +133,19 @@ export class NextEditLoggingService {
|
|||
}
|
||||
|
||||
public markDisplayed(completionId: string, outcome: NextEditOutcome) {
|
||||
// Remove from pending since we now have full data.
|
||||
this._pendingCompletions.delete(completionId);
|
||||
outcome.aborted = false;
|
||||
|
||||
const logRejectionTimeout = setTimeout(() => {
|
||||
// Wait 10 seconds, then assume it wasn't accepted
|
||||
outcome.accepted = false;
|
||||
outcome.aborted = false;
|
||||
this.logNextEditOutcome(outcome);
|
||||
this._logRejectionTimeouts.delete(completionId);
|
||||
this._outcomes.delete(completionId);
|
||||
}, COUNT_COMPLETION_REJECTED_AFTER);
|
||||
|
||||
this._outcomes.set(completionId, outcome);
|
||||
this._logRejectionTimeouts.set(completionId, logRejectionTimeout);
|
||||
|
||||
|
|
@ -124,7 +178,62 @@ export class NextEditLoggingService {
|
|||
};
|
||||
}
|
||||
|
||||
public handleAbort(completionId: string) {
|
||||
// Clear any pending rejection timeout.
|
||||
if (this._logRejectionTimeouts.has(completionId)) {
|
||||
clearTimeout(this._logRejectionTimeouts.get(completionId));
|
||||
this._logRejectionTimeouts.delete(completionId);
|
||||
}
|
||||
|
||||
// If we have the full outcome, log it as aborted.
|
||||
if (this._outcomes.has(completionId)) {
|
||||
const outcome = this._outcomes.get(completionId)!;
|
||||
outcome.accepted = false;
|
||||
outcome.aborted = true;
|
||||
this.logNextEditOutcome(outcome);
|
||||
this._outcomes.delete(completionId);
|
||||
} else {
|
||||
// Log minimal abort event for requests that never got displayed.
|
||||
const pendingData = this._pendingCompletions.get(completionId);
|
||||
|
||||
const minimalAbortOutcome: Partial<NextEditOutcome> = {
|
||||
completionId,
|
||||
accepted: false,
|
||||
aborted: true,
|
||||
timestamp: Date.now(),
|
||||
uniqueId: completionId,
|
||||
elapsed: pendingData ? Date.now() - pendingData.startTime : 0,
|
||||
modelName: pendingData?.modelName || "unknown",
|
||||
modelProvider: pendingData?.modelProvider || "unknown",
|
||||
fileUri: pendingData?.filepath || "unknown",
|
||||
|
||||
// Empty/default values for fields we don't have.
|
||||
completion: "",
|
||||
prompt: "",
|
||||
userEdits: "",
|
||||
userExcerpts: "",
|
||||
originalEditableRange: "",
|
||||
workspaceDirUri: "",
|
||||
cursorPosition: { line: -1, character: -1 },
|
||||
finalCursorPosition: { line: -1, character: -1 },
|
||||
editableRegionStartLine: -1,
|
||||
editableRegionEndLine: -1,
|
||||
diffLines: [],
|
||||
completionOptions: {},
|
||||
};
|
||||
|
||||
this.logNextEditOutcome(minimalAbortOutcome as NextEditOutcome);
|
||||
}
|
||||
|
||||
// Clean up.
|
||||
this._pendingCompletions.delete(completionId);
|
||||
}
|
||||
|
||||
private logNextEditOutcome(outcome: NextEditOutcome) {
|
||||
if (outcome.aborted === undefined) {
|
||||
outcome.aborted = false;
|
||||
}
|
||||
|
||||
void DataLogger.getInstance().logDevData({
|
||||
name: "nextEditOutcome",
|
||||
data: outcome,
|
||||
|
|
|
|||
|
|
@ -311,7 +311,11 @@ export class NextEditProvider {
|
|||
input.completionId,
|
||||
);
|
||||
token = controller.signal;
|
||||
} else {
|
||||
// Token was provided externally, just track the completion.
|
||||
this.loggingService.trackPendingCompletion(input.completionId);
|
||||
}
|
||||
|
||||
const startTime = Date.now();
|
||||
const options = await this._getAutocompleteOptions();
|
||||
|
||||
|
|
@ -325,6 +329,13 @@ export class NextEditProvider {
|
|||
return { token, startTime, helper: undefined };
|
||||
}
|
||||
|
||||
// Update pending completion with model info.
|
||||
this.loggingService.updatePendingCompletion(input.completionId, {
|
||||
modelName: llm.model,
|
||||
modelProvider: llm.providerName,
|
||||
filepath: input.filepath,
|
||||
});
|
||||
|
||||
// Check model capabilities
|
||||
if (!modelSupportsNextEdit(llm.capabilities, llm.model, llm.title)) {
|
||||
console.error(`${llm.model} is not capable of next edit.`);
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ export abstract class BaseNextEditProvider {
|
|||
return {
|
||||
elapsed: Date.now() - outcomeCtx.startTime,
|
||||
modelProvider: outcomeCtx.llm.underlyingProviderName,
|
||||
modelName: outcomeCtx.llm.model + ":zetaDataset",
|
||||
modelName: outcomeCtx.llm.model,
|
||||
completionOptions: null,
|
||||
completionId:
|
||||
outcomeCtx.completionId || outcomeCtx.helper.input.completionId,
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ export interface NextEditOutcome extends TabAutocompleteOptions {
|
|||
cursorPosition: { line: number; character: number };
|
||||
finalCursorPosition: { line: number; character: number };
|
||||
accepted?: boolean;
|
||||
aborted?: boolean;
|
||||
editableRegionStartLine: number;
|
||||
editableRegionEndLine: number;
|
||||
diffLines: DiffLine[];
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import {
|
||||
By,
|
||||
EditorView,
|
||||
InputBox,
|
||||
TextEditor,
|
||||
VSBrowser,
|
||||
Workbench,
|
||||
Workbench
|
||||
} from "vscode-extension-tester";
|
||||
|
||||
import { DEFAULT_TIMEOUT } from "../constants";
|
||||
|
|
@ -82,4 +83,80 @@ export class GlobalActions {
|
|||
console.warn(`Failed to delete file ${filePath}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
static async setNextEditEnabled(enabled: boolean) {
|
||||
const workbench = new Workbench();
|
||||
|
||||
await workbench.openCommandPrompt();
|
||||
process.env.CONTINUE_E2E_NON_NEXT_EDIT_TEST = 'true';
|
||||
|
||||
|
||||
// Initial wait and clear
|
||||
await TestUtils.waitForTimeout(1000);
|
||||
await GlobalActions.clearAllNotifications();
|
||||
|
||||
const statusBar = await workbench.getStatusBar();
|
||||
|
||||
// Robust element finding with text validation
|
||||
const continueItem = await TestUtils.waitForSuccess(
|
||||
async () => {
|
||||
// Clear any new notifications
|
||||
try {
|
||||
await GlobalActions.clearAllNotifications();
|
||||
} catch (e) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
const element = await statusBar.findElement(
|
||||
By.xpath("//*[contains(text(), 'Continue')]")
|
||||
);
|
||||
|
||||
// Validate we can get text
|
||||
const text = await element.getText();
|
||||
if (!text || text.trim() === '') {
|
||||
// Try alternative methods
|
||||
const textContent = await element.getAttribute('textContent');
|
||||
if (!textContent || textContent.trim() === '') {
|
||||
throw new Error('Text not yet available');
|
||||
}
|
||||
}
|
||||
|
||||
return element;
|
||||
},
|
||||
DEFAULT_TIMEOUT.MD
|
||||
);
|
||||
|
||||
// Get text with retry
|
||||
const text = await TestUtils.waitForSuccess(
|
||||
async () => {
|
||||
const itemText = await continueItem.getText();
|
||||
if (!itemText || itemText.trim() === '') {
|
||||
// Fallback to textContent
|
||||
const textContent = await continueItem.getAttribute('textContent');
|
||||
if (textContent && textContent.trim() !== '') {
|
||||
return textContent;
|
||||
}
|
||||
throw new Error('Text content not yet available');
|
||||
}
|
||||
return itemText;
|
||||
},
|
||||
DEFAULT_TIMEOUT.MD
|
||||
);
|
||||
|
||||
console.log("Final text:", text);
|
||||
|
||||
const hasNE = text.includes('(NE)');
|
||||
console.log("hasNE:", hasNE);
|
||||
|
||||
if (hasNE !== enabled) {
|
||||
await workbench.executeCommand('Continue: Toggle Next Edit');
|
||||
// Clear any resulting notifications
|
||||
await TestUtils.waitForTimeout(500);
|
||||
await GlobalActions.clearAllNotifications();
|
||||
}
|
||||
}
|
||||
|
||||
static async disableNextEdit() {
|
||||
await this.setNextEditEnabled(false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ describe("Autocomplete", () => {
|
|||
let editor: TextEditor;
|
||||
|
||||
before(async function () {
|
||||
this.timeout(DEFAULT_TIMEOUT.MD);
|
||||
process.env.NEXT_EDIT_TEST_ENABLED = "false";
|
||||
await GlobalActions.disableNextEdit();
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ describe("Edit Test", () => {
|
|||
await GUIActions.moveContinueToSidebar(VSBrowser.instance.driver);
|
||||
await GlobalActions.openTestWorkspace();
|
||||
({ editor } = await GlobalActions.createAndOpenNewTextFile());
|
||||
await GlobalActions.disableNextEdit();
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import {
|
|||
WebDriver,
|
||||
WebElement,
|
||||
WebView,
|
||||
until,
|
||||
until
|
||||
} from "vscode-extension-tester";
|
||||
|
||||
import { GlobalActions } from "../actions/Global.actions";
|
||||
|
|
@ -21,11 +21,12 @@ describe("GUI Test", () => {
|
|||
let driver: WebDriver;
|
||||
|
||||
before(async function () {
|
||||
this.timeout(DEFAULT_TIMEOUT.XL);
|
||||
this.timeout(DEFAULT_TIMEOUT.XL + DEFAULT_TIMEOUT.MD + DEFAULT_TIMEOUT.MD);
|
||||
// Uncomment this line for faster testing
|
||||
await GUIActions.moveContinueToSidebar(VSBrowser.instance.driver);
|
||||
await GlobalActions.openTestWorkspace();
|
||||
await GlobalActions.clearAllNotifications();
|
||||
await GlobalActions.disableNextEdit();
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import {
|
|||
until,
|
||||
} from "vscode-extension-tester";
|
||||
|
||||
import { GlobalActions } from "../actions/Global.actions";
|
||||
import { GUIActions } from "../actions/GUI.actions";
|
||||
import { KeyboardShortcutsActions } from "../actions/KeyboardShortcuts.actions";
|
||||
import { DEFAULT_TIMEOUT } from "../constants";
|
||||
|
|
@ -26,6 +27,7 @@ describe("Keyboard Shortcuts", () => {
|
|||
before(async function () {
|
||||
this.timeout(DEFAULT_TIMEOUT.XL);
|
||||
await GUIActions.moveContinueToSidebar(VSBrowser.instance.driver);
|
||||
await GlobalActions.disableNextEdit();
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,11 @@ import { DEFAULT_TIMEOUT } from "../constants";
|
|||
describe("Prompt file", () => {
|
||||
let editor: TextEditor;
|
||||
|
||||
before(async function () {
|
||||
this.timeout(DEFAULT_TIMEOUT.MD);
|
||||
await GlobalActions.disableNextEdit();
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(DEFAULT_TIMEOUT.XL);
|
||||
|
||||
|
|
|
|||
9
extensions/vscode/package-lock.json
generated
9
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "1.1.79",
|
||||
"version": "1.3.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "1.1.79",
|
||||
"version": "1.3.1",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "file:../../packages/config-types",
|
||||
|
|
@ -116,7 +116,6 @@
|
|||
"@sentry/esbuild-plugin": "^4.0.2",
|
||||
"@sentry/node": "^9.43.0",
|
||||
"@sentry/vite-plugin": "^4.0.2",
|
||||
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
||||
"@xenova/transformers": "2.14.0",
|
||||
"adf-to-md": "^1.1.0",
|
||||
"async-mutex": "^0.5.0",
|
||||
|
|
@ -135,7 +134,7 @@
|
|||
"http-proxy-agent": "^7.0.1",
|
||||
"https-proxy-agent": "^7.0.3",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"ignore": "^5.3.1",
|
||||
"ignore": "^7.0.5",
|
||||
"is-localhost-ip": "^2.0.0",
|
||||
"jinja-js": "0.1.8",
|
||||
"js-tiktoken": "^1.0.8",
|
||||
|
|
@ -196,6 +195,8 @@
|
|||
"@types/tar": "^6.1.13",
|
||||
"@types/uuid": "^9.0.7",
|
||||
"@types/win-ca": "^3.5.4",
|
||||
"@typescript-eslint/eslint-plugin": "^8.40.0",
|
||||
"@typescript-eslint/parser": "^8.40.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"esbuild": "0.17.19",
|
||||
"eslint": "^8",
|
||||
|
|
|
|||
|
|
@ -111,6 +111,11 @@
|
|||
"default": true,
|
||||
"markdownDescription": "Enable Continue's tab autocomplete feature. Read our walkthrough to learn about configuration and how to share feedback: [continue.dev › Walkthrough: Tab Autocomplete (beta)](https://docs.continue.dev/features/tab-autocomplete)"
|
||||
},
|
||||
"continue.enableNextEdit": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"markdownDescription": "Enable Continue's next edit feature. Read our docs to learn about configuration and how to share feedback: [continue.dev › Features › Autocomplete › Next Edit (experimental)](https://docs.continue.dev/features/autocomplete/next-edit)"
|
||||
},
|
||||
"continue.pauseTabAutocompleteOnBattery": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
|
|
@ -335,6 +340,10 @@
|
|||
"title": "Enter Enterprise License Key",
|
||||
"group": "Continue"
|
||||
},
|
||||
{
|
||||
"command": "continue.toggleNextEditEnabled",
|
||||
"title": "Continue: Toggle Next Edit"
|
||||
},
|
||||
{
|
||||
"command": "continue.nextEditWindow.hideNextEditSuggestion",
|
||||
"category": "Continue",
|
||||
|
|
@ -458,6 +467,12 @@
|
|||
"mac": "alt+a",
|
||||
"key": "alt+a"
|
||||
},
|
||||
{
|
||||
"command": "continue.toggleNextEditEnabled",
|
||||
"key": "ctrl+k ctrl+n",
|
||||
"mac": "cmd+k cmd+n",
|
||||
"when": "editorTextFocus"
|
||||
},
|
||||
{
|
||||
"command": "continue.nextEditWindow.hideNextEditSuggestion",
|
||||
"key": "escape",
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ export class InlineTipManager {
|
|||
}
|
||||
|
||||
private createSvgTooltipDecoration() {
|
||||
var backgroundColour = 0;
|
||||
var backgroundColour = "#333333";
|
||||
if (this.theme) {
|
||||
backgroundColour = this.theme.colors["editor.background"];
|
||||
}
|
||||
|
|
@ -258,12 +258,15 @@ export class InlineTipManager {
|
|||
"font-size": SVG_CONFIG.fontSize,
|
||||
};
|
||||
|
||||
if (!this.theme) {
|
||||
return;
|
||||
}
|
||||
// if (!this.theme) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
try {
|
||||
const svgContent = svgBuilder
|
||||
const builder = svgBuilder.newInstance
|
||||
? svgBuilder.newInstance()
|
||||
: svgBuilder;
|
||||
const svgContent = builder
|
||||
.width(SVG_CONFIG.tipWidth)
|
||||
.height(SVG_CONFIG.tipHeight)
|
||||
// Chat
|
||||
|
|
@ -271,7 +274,7 @@ export class InlineTipManager {
|
|||
{
|
||||
...baseTextConfig,
|
||||
x: SVG_CONFIG.chatLabelX,
|
||||
fill: this.theme.colors["editor.foreground"],
|
||||
fill: this.theme?.colors["editor.foreground"] ?? SVG_CONFIG.stroke,
|
||||
},
|
||||
SVG_CONFIG.chatLabel,
|
||||
)
|
||||
|
|
@ -288,7 +291,7 @@ export class InlineTipManager {
|
|||
{
|
||||
...baseTextConfig,
|
||||
x: SVG_CONFIG.editLabelX,
|
||||
fill: this.theme.colors["editor.foreground"],
|
||||
fill: this.theme?.colors["editor.foreground"] ?? SVG_CONFIG.stroke,
|
||||
},
|
||||
SVG_CONFIG.editLabel,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -130,7 +130,10 @@ export class JumpManager {
|
|||
};
|
||||
|
||||
try {
|
||||
const svgContent = svgBuilder
|
||||
const builder = svgBuilder.newInstance
|
||||
? svgBuilder.newInstance()
|
||||
: svgBuilder;
|
||||
const svgContent = builder
|
||||
.width(SVG_CONFIG.getTipWidth())
|
||||
.height(SVG_CONFIG.getTipHeight())
|
||||
.text(
|
||||
|
|
|
|||
|
|
@ -199,7 +199,18 @@ export class ContinueCompletionProvider
|
|||
try {
|
||||
const abortController = new AbortController();
|
||||
const signal = abortController.signal;
|
||||
token.onCancellationRequested(() => abortController.abort());
|
||||
const completionId = uuidv4();
|
||||
|
||||
if (this.isNextEditActive) {
|
||||
this.nextEditLoggingService.trackPendingCompletion(completionId);
|
||||
}
|
||||
|
||||
token.onCancellationRequested(() => {
|
||||
abortController.abort();
|
||||
if (this.isNextEditActive) {
|
||||
this.nextEditLoggingService.handleAbort(completionId);
|
||||
}
|
||||
});
|
||||
|
||||
// Handle notebook cells
|
||||
let pos = {
|
||||
|
|
@ -252,7 +263,7 @@ export class ContinueCompletionProvider
|
|||
const wasManuallyTriggered =
|
||||
context.triggerKind === vscode.InlineCompletionTriggerKind.Invoke;
|
||||
|
||||
const completionId = uuidv4();
|
||||
// const completionId = uuidv4();
|
||||
const filepath = document.uri.toString();
|
||||
const recentlyVisitedRanges = this.recentlyVisitedRanges.getSnippets();
|
||||
let recentlyEditedRanges =
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { EXTENSION_NAME } from "core/control-plane/env";
|
|||
import * as vscode from "vscode";
|
||||
|
||||
import { Battery } from "../util/battery";
|
||||
import { getMetaKeyLabel } from "../util/util";
|
||||
import {
|
||||
CONTINUE_WORKSPACE_KEY,
|
||||
getContinueWorkspaceConfig,
|
||||
|
|
@ -50,18 +51,36 @@ const statusBarItemText = (
|
|||
return "$(alert) Continue (config error)";
|
||||
}
|
||||
|
||||
let text: string;
|
||||
switch (status) {
|
||||
case undefined:
|
||||
if (loading) {
|
||||
return "$(loading~spin) Continue";
|
||||
text = "$(loading~spin) Continue";
|
||||
} else {
|
||||
text = "Continue";
|
||||
}
|
||||
break;
|
||||
case StatusBarStatus.Disabled:
|
||||
return "$(circle-slash) Continue";
|
||||
text = "$(circle-slash) Continue";
|
||||
break;
|
||||
case StatusBarStatus.Enabled:
|
||||
return "$(check) Continue";
|
||||
text = "$(check) Continue";
|
||||
break;
|
||||
case StatusBarStatus.Paused:
|
||||
return "$(debug-pause) Continue";
|
||||
text = "$(debug-pause) Continue";
|
||||
break;
|
||||
default:
|
||||
text = "Continue";
|
||||
}
|
||||
|
||||
// Append Next Edit indicator if enabled.
|
||||
const config = vscode.workspace.getConfiguration(EXTENSION_NAME);
|
||||
const nextEditEnabled = config.get<boolean>("enableNextEdit") ?? false;
|
||||
if (nextEditEnabled) {
|
||||
text += " (NE)";
|
||||
}
|
||||
|
||||
return text;
|
||||
};
|
||||
|
||||
const statusBarItemTooltip = (status: StatusBarStatus | undefined) => {
|
||||
|
|
@ -70,7 +89,11 @@ const statusBarItemTooltip = (status: StatusBarStatus | undefined) => {
|
|||
case StatusBarStatus.Disabled:
|
||||
return "Click to enable tab autocomplete";
|
||||
case StatusBarStatus.Enabled:
|
||||
return "Tab autocomplete is enabled";
|
||||
const config = vscode.workspace.getConfiguration(EXTENSION_NAME);
|
||||
const nextEditEnabled = config.get<boolean>("enableNextEdit") ?? false;
|
||||
return nextEditEnabled
|
||||
? "Next Edit is enabled"
|
||||
: "Tab autocomplete is enabled";
|
||||
case StatusBarStatus.Paused:
|
||||
return "Tab autocomplete is paused";
|
||||
}
|
||||
|
|
@ -199,3 +222,45 @@ export function getAutocompleteStatusBarTitle(
|
|||
|
||||
return title;
|
||||
}
|
||||
|
||||
const USE_FIM_MENU_ITEM_LABEL = "$(export) Use FIM autocomplete over Next Edit";
|
||||
const USE_NEXT_EDIT_MENU_ITEM_LABEL =
|
||||
"$(sparkle) Use Next Edit over FIM autocomplete";
|
||||
|
||||
// Shows what items get rendered in the autocomplete menu.
|
||||
export function getNextEditMenuItems(
|
||||
currentStatus: StatusBarStatus | undefined,
|
||||
nextEditEnabled: boolean,
|
||||
): vscode.QuickPickItem[] {
|
||||
if (currentStatus !== StatusBarStatus.Enabled) return [];
|
||||
|
||||
return [
|
||||
{
|
||||
label: nextEditEnabled
|
||||
? USE_FIM_MENU_ITEM_LABEL
|
||||
: USE_NEXT_EDIT_MENU_ITEM_LABEL,
|
||||
description: getMetaKeyLabel() + " + K, " + getMetaKeyLabel() + " + N",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
// Checks if the current selected option is a Next Edit toggle label.
|
||||
export function isNextEditToggleLabel(label: string): boolean {
|
||||
return (
|
||||
label === USE_FIM_MENU_ITEM_LABEL || label === USE_NEXT_EDIT_MENU_ITEM_LABEL
|
||||
);
|
||||
}
|
||||
|
||||
// Updates the config once Next Edit is toggled.
|
||||
export function handleNextEditToggle(
|
||||
label: string,
|
||||
config: vscode.WorkspaceConfiguration,
|
||||
) {
|
||||
const isEnabling = label === USE_NEXT_EDIT_MENU_ITEM_LABEL;
|
||||
|
||||
config.update(
|
||||
"enableNextEdit",
|
||||
isEnabling,
|
||||
vscode.ConfigurationTarget.Global,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,11 @@ import { NextEditLoggingService } from "core/nextEdit/NextEditLoggingService";
|
|||
import {
|
||||
getAutocompleteStatusBarDescription,
|
||||
getAutocompleteStatusBarTitle,
|
||||
getNextEditMenuItems,
|
||||
getStatusBarStatus,
|
||||
getStatusBarStatusFromQuickPickItemLabel,
|
||||
handleNextEditToggle,
|
||||
isNextEditToggleLabel,
|
||||
quickPickStatusText,
|
||||
setupStatusBar,
|
||||
StatusBarStatus,
|
||||
|
|
@ -639,6 +642,8 @@ const getCommandsMap: (
|
|||
: StatusBarStatus.Disabled;
|
||||
}
|
||||
|
||||
const nextEditEnabled = config.get<boolean>("enableNextEdit") ?? false;
|
||||
|
||||
quickPick.items = [
|
||||
{
|
||||
label: "$(gear) Open settings",
|
||||
|
|
@ -657,6 +662,7 @@ const getCommandsMap: (
|
|||
description:
|
||||
getMetaKeyLabel() + " + K, " + getMetaKeyLabel() + " + A",
|
||||
},
|
||||
...getNextEditMenuItems(currentStatus, nextEditEnabled),
|
||||
{
|
||||
kind: vscode.QuickPickItemKind.Separator,
|
||||
label: "Switch model",
|
||||
|
|
@ -678,6 +684,8 @@ const getCommandsMap: (
|
|||
targetStatus === StatusBarStatus.Enabled,
|
||||
vscode.ConfigurationTarget.Global,
|
||||
);
|
||||
} else if (isNextEditToggleLabel(selectedOption)) {
|
||||
handleNextEditToggle(selectedOption, config);
|
||||
} else if (
|
||||
autocompleteModels.some((model) => model.title === selectedOption)
|
||||
) {
|
||||
|
|
@ -792,6 +800,30 @@ const getCommandsMap: (
|
|||
);
|
||||
}
|
||||
},
|
||||
"continue.toggleNextEditEnabled": async () => {
|
||||
captureCommandTelemetry("toggleNextEditEnabled");
|
||||
|
||||
const config = vscode.workspace.getConfiguration(EXTENSION_NAME);
|
||||
const tabAutocompleteEnabled = config.get<boolean>(
|
||||
"enableTabAutocomplete",
|
||||
);
|
||||
|
||||
if (!tabAutocompleteEnabled) {
|
||||
vscode.window.showInformationMessage(
|
||||
"Please enable tab autocomplete first to use Next Edit",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const nextEditEnabled = config.get<boolean>("enableNextEdit") ?? false;
|
||||
|
||||
// updateNextEditState in VsCodeExtension.ts will handle the validation.
|
||||
config.update(
|
||||
"enableNextEdit",
|
||||
!nextEditEnabled,
|
||||
vscode.ConfigurationTarget.Global,
|
||||
);
|
||||
},
|
||||
"continue.forceNextEdit": async () => {
|
||||
captureCommandTelemetry("forceNextEdit");
|
||||
|
||||
|
|
|
|||
|
|
@ -84,6 +84,88 @@ export class VsCodeExtension {
|
|||
|
||||
private ARBITRARY_TYPING_DELAY = 2000;
|
||||
|
||||
private async updateNextEditState(
|
||||
context: vscode.ExtensionContext,
|
||||
): Promise<void> {
|
||||
const { config: continueConfig } = await this.configHandler.loadConfig();
|
||||
const autocompleteModel = continueConfig?.selectedModelByRole.autocomplete;
|
||||
const vscodeConfig = vscode.workspace.getConfiguration(EXTENSION_NAME);
|
||||
|
||||
const modelSupportsNext =
|
||||
autocompleteModel &&
|
||||
modelSupportsNextEdit(
|
||||
autocompleteModel.capabilities,
|
||||
autocompleteModel.model,
|
||||
autocompleteModel.title,
|
||||
);
|
||||
|
||||
// Use smart defaults.
|
||||
let nextEditEnabled = vscodeConfig.get<boolean>("enableNextEdit");
|
||||
if (nextEditEnabled === undefined) {
|
||||
// First time - set smart default.
|
||||
nextEditEnabled = modelSupportsNext ?? false;
|
||||
await vscodeConfig.update(
|
||||
"enableNextEdit",
|
||||
nextEditEnabled,
|
||||
vscode.ConfigurationTarget.Global,
|
||||
);
|
||||
}
|
||||
|
||||
// Check if Next Edit is enabled but model doesn't support it.
|
||||
if (
|
||||
nextEditEnabled &&
|
||||
!modelSupportsNext &&
|
||||
!isNextEditTest() &&
|
||||
process.env.CONTINUE_E2E_NON_NEXT_EDIT_TEST === "true"
|
||||
) {
|
||||
vscode.window
|
||||
.showWarningMessage(
|
||||
`The current autocomplete model (${autocompleteModel?.title || "unknown"}) does not support Next Edit.`,
|
||||
"Disable Next Edit",
|
||||
"Select different model",
|
||||
)
|
||||
.then((selection) => {
|
||||
if (selection === "Disable Next Edit") {
|
||||
vscodeConfig.update(
|
||||
"enableNextEdit",
|
||||
false,
|
||||
vscode.ConfigurationTarget.Global,
|
||||
);
|
||||
} else if (selection === "Select different model") {
|
||||
vscode.commands.executeCommand(
|
||||
"continue.openTabAutocompleteConfigMenu",
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const shouldEnableNextEdit =
|
||||
(modelSupportsNext && nextEditEnabled) || isNextEditTest();
|
||||
|
||||
if (shouldEnableNextEdit) {
|
||||
await setupNextEditWindowManager(context);
|
||||
this.activateNextEdit();
|
||||
await NextEditWindowManager.freeTabAndEsc();
|
||||
|
||||
const jumpManager = JumpManager.getInstance();
|
||||
jumpManager.registerSelectionChangeHandler();
|
||||
|
||||
const ghostTextAcceptanceTracker =
|
||||
GhostTextAcceptanceTracker.getInstance();
|
||||
ghostTextAcceptanceTracker.registerSelectionChangeHandler();
|
||||
|
||||
const nextEditWindowManager = NextEditWindowManager.getInstance();
|
||||
nextEditWindowManager.registerSelectionChangeHandler();
|
||||
} else {
|
||||
NextEditWindowManager.clearInstance();
|
||||
this.deactivateNextEdit();
|
||||
await NextEditWindowManager.freeTabAndEsc();
|
||||
|
||||
JumpManager.clearInstance();
|
||||
GhostTextAcceptanceTracker.clearInstance();
|
||||
}
|
||||
}
|
||||
|
||||
constructor(context: vscode.ExtensionContext) {
|
||||
// Register auth provider
|
||||
this.workOsAuthProvider = new WorkOsAuthProvider(context, this.uriHandler);
|
||||
|
|
@ -238,39 +320,7 @@ export class VsCodeExtension {
|
|||
this.completionProvider.updateUsingFullFileDiff(shouldUseFullFileDiff);
|
||||
selectionManager.updateUsingFullFileDiff(shouldUseFullFileDiff);
|
||||
|
||||
const autocompleteModel = newConfig?.selectedModelByRole.autocomplete;
|
||||
|
||||
if (
|
||||
(autocompleteModel &&
|
||||
modelSupportsNextEdit(
|
||||
autocompleteModel.capabilities,
|
||||
autocompleteModel.model,
|
||||
autocompleteModel.title,
|
||||
)) ||
|
||||
isNextEditTest()
|
||||
) {
|
||||
// Set up next edit window manager only for Continue team members
|
||||
await setupNextEditWindowManager(context);
|
||||
this.activateNextEdit();
|
||||
await NextEditWindowManager.freeTabAndEsc();
|
||||
|
||||
const jumpManager = JumpManager.getInstance();
|
||||
jumpManager.registerSelectionChangeHandler();
|
||||
|
||||
const ghostTextAcceptanceTracker =
|
||||
GhostTextAcceptanceTracker.getInstance();
|
||||
ghostTextAcceptanceTracker.registerSelectionChangeHandler();
|
||||
|
||||
const nextEditWindowManager = NextEditWindowManager.getInstance();
|
||||
nextEditWindowManager.registerSelectionChangeHandler();
|
||||
} else {
|
||||
NextEditWindowManager.clearInstance();
|
||||
this.deactivateNextEdit();
|
||||
await NextEditWindowManager.freeTabAndEsc();
|
||||
|
||||
JumpManager.clearInstance();
|
||||
GhostTextAcceptanceTracker.clearInstance();
|
||||
}
|
||||
await this.updateNextEditState(context);
|
||||
|
||||
if (configLoadInterrupted) {
|
||||
// Show error in status bar
|
||||
|
|
@ -562,6 +612,10 @@ export class VsCodeExtension {
|
|||
if (event.affectsConfiguration(EXTENSION_NAME)) {
|
||||
const settings = await this.ide.getIdeSettings();
|
||||
void this.core.invoke("config/ideSettingsUpdate", settings);
|
||||
|
||||
if (event.affectsConfiguration(`${EXTENSION_NAME}.enableNextEdit`)) {
|
||||
await this.updateNextEditState(context);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
2
package-lock.json
generated
2
package-lock.json
generated
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "wt-mcp-flag",
|
||||
"name": "continue",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ export const nextEditOutcomeEventAllSchema = baseDevDataAllSchema.extend({
|
|||
completion: z.string(),
|
||||
cursorPosition: z.object({ line: z.number(), character: z.number() }),
|
||||
accepted: z.boolean().optional(),
|
||||
aborted: z.boolean().optional(),
|
||||
modelProvider: z.string(),
|
||||
modelName: z.string(),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ export const nextEditOutcomeEventSchema_0_2_0 =
|
|||
completion: true,
|
||||
cursorPosition: true,
|
||||
accepted: true,
|
||||
aborted: true,
|
||||
modelProvider: true,
|
||||
modelName: true,
|
||||
});
|
||||
|
|
|
|||
1
packages/openai-adapters/package-lock.json
generated
1
packages/openai-adapters/package-lock.json
generated
|
|
@ -12528,7 +12528,6 @@
|
|||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz",
|
||||
"integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue