From 05158532f32473079277a418143ab859b1b1fc81 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Thu, 3 Jul 2025 11:56:01 -0700 Subject: [PATCH 1/8] initial logging setup for next edit --- core/nextEdit/NextEditLoggingService.ts | 150 ++++++++++ core/nextEdit/NextEditProvider.ts | 278 +++++++----------- .../templating/NextEditPromptEngine.ts | 47 ++- core/nextEdit/types.ts | 62 +++- .../src/activation/NextEditWindowManager.ts | 30 ++ .../src/autocomplete/completionProvider.ts | 52 +++- extensions/vscode/src/commands.ts | 13 + .../config-yaml/src/schemas/data/index.ts | 8 + .../src/schemas/data/nextEditOutcome/index.ts | 23 ++ .../schemas/data/nextEditOutcome/v0.2.0.ts | 43 +++ 10 files changed, 483 insertions(+), 223 deletions(-) create mode 100644 core/nextEdit/NextEditLoggingService.ts create mode 100644 packages/config-yaml/src/schemas/data/nextEditOutcome/index.ts create mode 100644 packages/config-yaml/src/schemas/data/nextEditOutcome/v0.2.0.ts diff --git a/core/nextEdit/NextEditLoggingService.ts b/core/nextEdit/NextEditLoggingService.ts new file mode 100644 index 000000000..8000b4d94 --- /dev/null +++ b/core/nextEdit/NextEditLoggingService.ts @@ -0,0 +1,150 @@ +import { COUNT_COMPLETION_REJECTED_AFTER } from "../util/parameters"; + +import { DataLogger } from "../data/log"; +import { NextEditOutcome } from "./types"; + +export class NextEditLoggingService { + private static instance: NextEditLoggingService; + + // Key is completionId + private _abortControllers = new Map(); + private _logRejectionTimeouts = new Map(); + private _outcomes = new Map(); + _lastDisplayedCompletion: { id: string; displayedAt: number } | undefined = + undefined; + + private constructor() {} + + public static getInstance(): NextEditLoggingService { + if (!NextEditLoggingService.instance) { + NextEditLoggingService.instance = new NextEditLoggingService(); + } + return NextEditLoggingService.instance; + } + + public createAbortController(completionId: string): AbortController { + const abortController = new AbortController(); + this._abortControllers.set(completionId, abortController); + return abortController; + } + + public deleteAbortController(completionId: string) { + this._abortControllers.delete(completionId); + } + + public cancel() { + this._abortControllers.forEach((abortController, id) => { + abortController.abort(); + }); + this._abortControllers.clear(); + } + + public accept(completionId: string): NextEditOutcome | undefined { + if (this._logRejectionTimeouts.has(completionId)) { + clearTimeout(this._logRejectionTimeouts.get(completionId)); + this._logRejectionTimeouts.delete(completionId); + } + if (this._outcomes.has(completionId)) { + const outcome = this._outcomes.get(completionId)!; + outcome.accepted = true; + this.logNextEditOutcome(outcome); + this._outcomes.delete(completionId); + return outcome; + } + } + + public reject(completionId: string): NextEditOutcome | undefined { + if (this._logRejectionTimeouts.has(completionId)) { + clearTimeout(this._logRejectionTimeouts.get(completionId)); + this._logRejectionTimeouts.delete(completionId); + } + + if (this._outcomes.has(completionId)) { + const outcome = this._outcomes.get(completionId)!; + outcome.accepted = false; + this.logNextEditOutcome(outcome); + this._outcomes.delete(completionId); + return outcome; + } + } + + public cancelRejectionTimeout(completionId: string) { + if (this._logRejectionTimeouts.has(completionId)) { + clearTimeout(this._logRejectionTimeouts.get(completionId)!); + this._logRejectionTimeouts.delete(completionId); + } + if (this._outcomes.has(completionId)) { + this._outcomes.delete(completionId); + } + } + + public markDisplayed(completionId: string, outcome: NextEditOutcome) { + const logRejectionTimeout = setTimeout(() => { + // Wait 10 seconds, then assume it wasn't accepted + outcome.accepted = false; + this.logNextEditOutcome(outcome); + this._logRejectionTimeouts.delete(completionId); + }, COUNT_COMPLETION_REJECTED_AFTER); + this._outcomes.set(completionId, outcome); + this._logRejectionTimeouts.set(completionId, logRejectionTimeout); + + // If the previously displayed completion is still waiting for rejection, + // and this one is a continuation of that (the outcome.completion is the same modulo prefix) + // then we should cancel the rejection timeout + const previous = this._lastDisplayedCompletion; + const now = Date.now(); + if (previous && this._logRejectionTimeouts.has(previous.id)) { + const previousOutcome = this._outcomes.get(previous.id); + const c1 = previousOutcome?.completion.split("\n")[0] ?? ""; + const c2 = outcome.completion.split("\n")[0]; + if ( + previousOutcome && + (c1.endsWith(c2) || + c2.endsWith(c1) || + c1.startsWith(c2) || + c2.startsWith(c1)) + ) { + this.cancelRejectionTimeout(previous.id); + } else if (now - previous.displayedAt < 500) { + // If a completion isn't shown for more than + this.cancelRejectionTimeout(previous.id); + } + } + + this._lastDisplayedCompletion = { + id: completionId, + displayedAt: now, + }; + } + + private logNextEditOutcome(outcome: NextEditOutcome) { + void DataLogger.getInstance().logDevData({ + name: "nextEditOutcome", + data: outcome, + // data: { + // ...outcome, // TODO: this is somehow getting messed up with autocomplete schema. + // }, + }); + + // const { prompt, completion, prefix, suffix, ...restOfOutcome } = outcome; + // void Telemetry.capture( + // "autocomplete", + // { + // accepted: restOfOutcome.accepted, + // cacheHit: restOfOutcome.cacheHit, + // completionId: restOfOutcome.completionId, + // completionOptions: restOfOutcome.completionOptions, + // debounceDelay: restOfOutcome.debounceDelay, + // fileExtension: getUriFileExtension(restOfOutcome.filepath), + // maxPromptTokens: restOfOutcome.maxPromptTokens, + // modelName: restOfOutcome.modelName, + // modelProvider: restOfOutcome.modelProvider, + // multilineCompletions: restOfOutcome.multilineCompletions, + // time: restOfOutcome.time, + // useRecentlyEdited: restOfOutcome.useRecentlyEdited, + // numLines: restOfOutcome.numLines, + // }, + // true, + // ); + } +} diff --git a/core/nextEdit/NextEditProvider.ts b/core/nextEdit/NextEditProvider.ts index df4168b28..a46ee2b70 100644 --- a/core/nextEdit/NextEditProvider.ts +++ b/core/nextEdit/NextEditProvider.ts @@ -1,3 +1,4 @@ +import * as path from "path"; import { ConfigHandler } from "../config/ConfigHandler.js"; import { ChatMessage, IDE, ILLM } from "../index.js"; import OpenAI from "../llm/llms/OpenAI.js"; @@ -11,20 +12,21 @@ import { shouldPrefilter } from "../autocomplete/prefiltering/index.js"; import { getAllSnippetsWithoutRace } from "../autocomplete/snippets/index.js"; import { GetLspDefinitionsFunction } from "../autocomplete/types.js"; import { AutocompleteDebouncer } from "../autocomplete/util/AutocompleteDebouncer.js"; -import { AutocompleteLoggingService } from "../autocomplete/util/AutocompleteLoggingService.js"; import AutocompleteLruCache from "../autocomplete/util/AutocompleteLruCache.js"; import { HelperVars } from "../autocomplete/util/HelperVars.js"; -import { - AutocompleteInput, - AutocompleteOutcome, -} from "../autocomplete/util/types.js"; +import { AutocompleteInput } from "../autocomplete/util/types.js"; import { replaceEscapedCharacters } from "../util/text.js"; import { - Prompt, + NEXT_EDIT_EDITABLE_REGION_BOTTOM_MARGIN, + NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN, +} from "./constants.js"; +import { NextEditLoggingService } from "./NextEditLoggingService.js"; +import { renderDefaultSystemPrompt, renderDefaultUserPrompt, renderPrompt, } from "./templating/NextEditPromptEngine.js"; +import { NextEditOutcome, Prompt, PromptMetadata } from "./types.js"; // import { renderPrompt } from "./templating/NextEditPromptEngine.js"; const autocompleteCache = AutocompleteLruCache.get(); @@ -45,10 +47,11 @@ export class NextEditProvider { private bracketMatchingService = new BracketMatchingService(); private debouncer = new AutocompleteDebouncer(); private completionStreamer: CompletionStreamer; - private loggingService = new AutocompleteLoggingService(); + private loggingService: NextEditLoggingService; private contextRetrievalService: ContextRetrievalService; private endpointType: "default" | "fineTuned"; private diffContext: string = ""; + private promptMetadata: PromptMetadata | null = null; private constructor( private readonly configHandler: ConfigHandler, @@ -61,6 +64,7 @@ export class NextEditProvider { this.completionStreamer = new CompletionStreamer(this.onError.bind(this)); this.contextRetrievalService = new ContextRetrievalService(this.ide); this.endpointType = endpointType; + this.loggingService = NextEditLoggingService.getInstance(); } public static initialize( @@ -154,18 +158,21 @@ export class NextEditProvider { this.loggingService.cancel(); } - public accept(completionId: string) { - const outcome = this.loggingService.accept(completionId); - if (!outcome) { - return; - } - this.bracketMatchingService.handleAcceptedCompletion( - outcome.completion, - outcome.filepath, - ); - } + // public accept(completionId: string) { + // const outcome = this.loggingService.accept(completionId); + // if (!outcome) { + // return; + // } + // } - public markDisplayed(completionId: string, outcome: AutocompleteOutcome) { + // public reject(completionId: string) { + // const outcome = this.loggingService.reject(completionId); + // if (!outcome) { + // return; + // } + // } + + public markDisplayed(completionId: string, outcome: NextEditOutcome) { this.loggingService.markDisplayed(completionId, outcome); } @@ -181,7 +188,7 @@ export class NextEditProvider { public async provideInlineCompletionItems( input: AutocompleteInput, token: AbortSignal | undefined, - ): Promise { + ): Promise { try { // Create abort signal if not given if (!token) { @@ -235,6 +242,8 @@ export class NextEditProvider { prompts.push(renderDefaultSystemPrompt()); prompts.push(renderDefaultUserPrompt(snippetPayload, helper)); } else { + const promptMetadata = renderPrompt(helper, this.diffContext); + this.promptMetadata = promptMetadata; prompts.push( // await renderFineTunedUserPrompt(snippetPayload, this.ide, helper), // await renderFineTunedBasicUserPrompt( @@ -243,7 +252,7 @@ export class NextEditProvider { // helper, // this.diffContext, // ), - renderPrompt(helper, this.diffContext), + promptMetadata.prompt, ); } @@ -251,22 +260,45 @@ export class NextEditProvider { const msg: ChatMessage = await llm.chat(prompts, token); if (typeof msg.content === "string") { const nextCompletion = JSON.parse(msg.content).newCode; - const outcomeNext: AutocompleteOutcome = { - time: Date.now() - startTime, - completion: nextCompletion, - prefix: "", - suffix: "", - prompt: "", + // const outcomeNext: AutocompleteOutcome = { + // time: Date.now() - startTime, + // completion: nextCompletion, + // prefix: "", + // suffix: "", + // prompt: "", + // modelProvider: llm.underlyingProviderName, + // modelName: llm.model, + // completionOptions: null, + // cacheHit: false, + // filepath: helper.filepath, + // numLines: nextCompletion.split("\n").length, + // completionId: helper.input.completionId, + // gitRepo: await this.ide.getRepoName(helper.filepath), + // uniqueId: await this.ide.getUniqueId(), + // timestamp: Date.now(), + // ...helper.options, + // }; + // TODO: clean this up, or delete. + const outcomeNext: NextEditOutcome = { + elapsed: Date.now() - startTime, modelProvider: llm.underlyingProviderName, modelName: llm.model, completionOptions: null, - cacheHit: false, - filepath: helper.filepath, - numLines: nextCompletion.split("\n").length, + // filepath: helper.filepath, completionId: helper.input.completionId, gitRepo: await this.ide.getRepoName(helper.filepath), uniqueId: await this.ide.getUniqueId(), timestamp: Date.now(), + fileUri: helper.filepath, + workspaceDirUri: + helper.workspaceUris[0] ?? path.dirname(helper.filepath), + prompt: prompts.join("\n"), + userEdits: "", + userExcerpts: "", + originalEditableRange: "", + completion: nextCompletion, + cursorPosition: helper.pos, + finetunedOn: "zetaDataset", ...helper.options, }; return outcomeNext; @@ -306,163 +338,65 @@ export class NextEditProvider { // const diffLines = myersDiff(helper.fileContents, nextCompletion); // const diff = getRenderableDiff(diffLines); - const outcomeNext: AutocompleteOutcome = { - time: Date.now() - startTime, - completion: nextCompletion, - prefix: "", - suffix: "", - prompt: "", + // const outcomeNext: AutocompleteOutcome = { + // time: Date.now() - startTime, + // completion: nextCompletion, + // prefix: "", + // suffix: "", + // prompt: "", + // modelProvider: llm.underlyingProviderName, + // modelName: llm.model, + // completionOptions: null, + // cacheHit: false, + // filepath: helper.filepath, + // numLines: nextCompletion.split("\n").length, + // completionId: helper.input.completionId, + // gitRepo: await this.ide.getRepoName(helper.filepath), + // uniqueId: await this.ide.getUniqueId(), + // timestamp: Date.now(), + // ...helper.options, + // }; + const currCursorPos = helper.pos; + const editableRegionStartLine = Math.max( + currCursorPos.line - NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN, + 0, + ); + const editableRegionEndLine = Math.min( + currCursorPos.line + NEXT_EDIT_EDITABLE_REGION_BOTTOM_MARGIN, + helper.fileLines.length - 1, + ); + const oldEditRangeSlice = helper.fileContents + .split("\n") + .slice(editableRegionStartLine, editableRegionEndLine + 1) + .join("\n"); + + const outcomeNext: NextEditOutcome = { + elapsed: Date.now() - startTime, modelProvider: llm.underlyingProviderName, modelName: llm.model, completionOptions: null, - cacheHit: false, - filepath: helper.filepath, - numLines: nextCompletion.split("\n").length, + // filepath: helper.filepath, completionId: helper.input.completionId, gitRepo: await this.ide.getRepoName(helper.filepath), uniqueId: await this.ide.getUniqueId(), timestamp: Date.now(), + fileUri: helper.filepath, + workspaceDirUri: + helper.workspaceUris[0] ?? path.dirname(helper.filepath), + prompt: this.promptMetadata!.prompt.content, + userEdits: this.promptMetadata!.userEdits, + userExcerpts: this.promptMetadata!.userExcerpts, + originalEditableRange: oldEditRangeSlice, + completion: nextCompletion, + cursorPosition: helper.pos, + finetunedOn: "zetaDataset", ...helper.options, }; return outcomeNext; } else { return undefined; } - // const body = { - // model: fineTunedModel, - // messages: prompts, - // max_tokens: 15000, - // stop: ["<|editable_region_end|>"], - // }; - // - // const resp = await fetch(fineTunedEndpoint, { - // method: "POST", - // headers: { - // Authorization: `Bearer ${mercuryToken} `, - // "Content-Type": "application/json", - // }, - // body: JSON.stringify(body), - // }); - // - // const respJson = await resp.json(); - // - // const nextCompletion = respJson.choices[0].message.content - // .split("<|editable_region_start|>\n")[1] - // .split("<|editable_region_end|>")[0] - // .slice(1) - // .slice(0, -1) - // .replaceAll("\\n", "\n") - // .replaceAll('\\"', '"'); - // - // const outcomeNext: AutocompleteOutcome = { - // time: Date.now() - startTime, - // completion: nextCompletion, - // prefix: "", - // suffix: "", - // prompt: "", - // modelProvider: llm.underlyingProviderName, - // modelName: llm.model, - // completionOptions: null, - // cacheHit: false, - // filepath: helper.filepath, - // numLines: nextCompletion.split("\n").length, - // completionId: helper.input.completionId, - // gitRepo: await this.ide.getRepoName(helper.filepath), - // uniqueId: await this.ide.getUniqueId(), - // timestamp: Date.now(), - // ...helper.options, - // }; - // return outcomeNext; } - - // // Completion - // let completion: string | undefined = ""; - - // const cache = await autocompleteCache; - // const cachedCompletion = helper.options.useCache - // ? await cache.get(helper.prunedPrefix) - // : undefined; - // let cacheHit = false; - // if (cachedCompletion) { - // // Cache - // cacheHit = true; - // completion = cachedCompletion; - // } else { - // const multiline = - // !helper.options.transform || shouldCompleteMultiline(helper); - - // const completionStream = - // this.completionStreamer.streamCompletionWithFilters( - // token, - // llm, - // prefix, - // suffix, - // prompt, - // multiline, - // completionOptions, - // helper, - // ); - - // for await (const update of completionStream) { - // completion += update; - // } - - // // Don't postprocess if aborted - // if (token.aborted) { - // return undefined; - // } - - // const processedCompletion = helper.options.transform - // ? postprocessCompletion({ - // completion, - // prefix: helper.prunedPrefix, - // suffix: helper.prunedSuffix, - // llm, - // }) - // : completion; - - // completion = processedCompletion; - // } - - // if (!completion) { - // return undefined; - // } - - // const outcome: AutocompleteOutcome = { - // time: Date.now() - startTime, - // completion, - // prefix, - // suffix, - // prompt, - // modelProvider: llm.underlyingProviderName, - // modelName: llm.model, - // completionOptions, - // cacheHit, - // filepath: helper.filepath, - // numLines: completion.split("\n").length, - // completionId: helper.input.completionId, - // gitRepo: await this.ide.getRepoName(helper.filepath), - // uniqueId: await this.ide.getUniqueId(), - // timestamp: Date.now(), - // ...helper.options, - // }; - - // ////////// - - // // Save to cache - // if (!outcome.cacheHit && helper.options.useCache) { - // (await this.autocompleteCache) - // .put(outcome.prefix, outcome.completion) - // .catch((e) => console.warn(`Failed to save to cache: ${e.message}`)); - // } - - // // When using the JetBrains extension, Mark as displayed - // const ideType = (await this.ide.getIdeInfo()).ideType; - // if (ideType === "jetbrains") { - // this.markDisplayed(input.completionId, outcome); - // } - - // return outcome; } catch (e: any) { this.onError(e); } finally { diff --git a/core/nextEdit/templating/NextEditPromptEngine.ts b/core/nextEdit/templating/NextEditPromptEngine.ts index 7b21232d6..1a9ea38eb 100644 --- a/core/nextEdit/templating/NextEditPromptEngine.ts +++ b/core/nextEdit/templating/NextEditPromptEngine.ts @@ -9,28 +9,13 @@ import { NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN, USER_CURSOR_IS_HERE_TOKEN, } from "../constants"; - -export type Prompt = SystemPrompt | UserPrompt; - -interface SystemPrompt { - role: "system"; - content: string; -} - -interface UserPrompt { - role: "user"; - content: string; -} - -export interface NextEditTemplate { - template: string; -} - -export interface TemplateVars { - userEdits: string; - languageShorthand: string; - userExcerpts: string; -} +import { + NextEditTemplate, + PromptMetadata, + SystemPrompt, + TemplateVars, + UserPrompt, +} from "../types"; type TemplateRenderer = (vars: TemplateVars) => string; @@ -64,13 +49,17 @@ function templateRendererOfModel( export function renderPrompt( helper: HelperVars, userEdits: string, -): UserPrompt { +): PromptMetadata { let modelName = helper.modelName as NextEditModelName; if (modelName === "this field is not used") { return { - role: "user", - content: "NEXT_EDIT", + prompt: { + role: "user", + content: "NEXT_EDIT", + }, + userEdits, + userExcerpts: helper.fileContents, }; } @@ -103,8 +92,12 @@ export function renderPrompt( }; return { - role: "user", - content: renderer(tv), + prompt: { + role: "user", + content: renderer(tv), + }, + userEdits, + userExcerpts: editedCodeWithTokens, }; } diff --git a/core/nextEdit/types.ts b/core/nextEdit/types.ts index 5fdd293a9..4a47951f2 100644 --- a/core/nextEdit/types.ts +++ b/core/nextEdit/types.ts @@ -26,20 +26,62 @@ export interface AutocompleteInput { } export interface NextEditOutcome extends TabAutocompleteOptions { - accepted?: boolean; - time: number; - prefix: string; - suffix: string; - prompt: string; - completion: string; + // Originally from Autocomplete. + // accepted?: boolean; + elapsed: number; + // prefix: string; + // suffix: string; + // prompt: string; + // completion: string; modelProvider: string; modelName: string; completionOptions: any; - cacheHit: boolean; - numLines: number; - filepath: string; - gitRepo?: string; + // cacheHit: boolean; + // numLines: number; + // filepath: string; completionId: string; + gitRepo?: string; uniqueId: string; timestamp: number; + + // New for Next Edit. + fileUri: string; + workspaceDirUri: string; + prompt: string; + userEdits: string; + userExcerpts: string; + originalEditableRange: string; + completion: string; + cursorPosition: { line: number; character: number }; + accepted?: boolean; + // model: string; + finetunedOn: string; +} + +export interface PromptMetadata { + prompt: UserPrompt; + userEdits: string; + userExcerpts: string; +} + +export type Prompt = SystemPrompt | UserPrompt; + +export interface SystemPrompt { + role: "system"; + content: string; +} + +export interface UserPrompt { + role: "user"; + content: string; +} + +export interface NextEditTemplate { + template: string; +} + +export interface TemplateVars { + userEdits: string; + languageShorthand: string; + userExcerpts: string; } diff --git a/extensions/vscode/src/activation/NextEditWindowManager.ts b/extensions/vscode/src/activation/NextEditWindowManager.ts index 25cd64acc..8f79e0489 100644 --- a/extensions/vscode/src/activation/NextEditWindowManager.ts +++ b/extensions/vscode/src/activation/NextEditWindowManager.ts @@ -10,6 +10,7 @@ import { NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN, } from "core/nextEdit/constants"; import { getOffsetPositionAtLastNewLine } from "core/nextEdit/diff/diff"; +import { NextEditLoggingService } from "core/nextEdit/NextEditLoggingService"; import { getThemeString } from "../util/getTheme"; export interface TextApplier { @@ -93,6 +94,9 @@ export class NextEditWindowManager { private activeEditor: vscode.TextEditor | null = null; // Store the current tooltip text for accepting private currentTooltipText: string | null = null; + // Track for logging purposes. + private loggingService: NextEditLoggingService; + private mostRecentCompletionId: string | null = null; // Disposables private disposables: vscode.Disposable[] = []; @@ -136,6 +140,8 @@ export class NextEditWindowManager { const editorConfig = vscode.workspace.getConfiguration("editor"); this.fontSize = editorConfig.get("fontSize") ?? 14; this.fontFamily = editorConfig.get("fontFamily") ?? "monospace"; + + this.loggingService = NextEditLoggingService.getInstance(); } public static async reserveTabAndEsc() { @@ -192,6 +198,14 @@ export class NextEditWindowManager { await this.codeRenderer.setTheme(this.theme); } + /** + * Update the most recent completion id. + * @param completionId The id of current completion request. + */ + public updateCurrentCompletionId(completionId: string) { + this.mostRecentCompletionId = completionId; + } + /** * Registers our two custom commands to the extension context. * @param commandId Custom commands to help set up next edit. @@ -295,6 +309,14 @@ export class NextEditWindowManager { } await NextEditWindowManager.freeTabAndEsc(); + + // TODO: Log with accept = false. + await vscode.commands.executeCommand( + "continue.logNextEditOutcomeReject", + this.mostRecentCompletionId, + this.loggingService, + ); + this.mostRecentCompletionId = null; } /** @@ -362,6 +384,14 @@ export class NextEditWindowManager { await this.hideAllNextEditWindows(); } } + + // Log with accept = true. + await vscode.commands.executeCommand( + "continue.logNextEditOutcomeAccept", + this.mostRecentCompletionId, + this.loggingService, + ); + this.mostRecentCompletionId = null; } /** diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts index 24bd86fa0..73a7ba0c1 100644 --- a/extensions/vscode/src/autocomplete/completionProvider.ts +++ b/extensions/vscode/src/autocomplete/completionProvider.ts @@ -21,7 +21,9 @@ import { NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN, } from "core/nextEdit/constants"; import { checkFim } from "core/nextEdit/diff/diff"; +import { NextEditLoggingService } from "core/nextEdit/NextEditLoggingService"; import { NextEditProvider } from "core/nextEdit/NextEditProvider"; +import { NextEditOutcome } from "core/nextEdit/types"; import { NextEditWindowManager } from "../activation/NextEditWindowManager"; import { getDefinitionsFromLsp } from "./lsp"; import { RecentlyEditedTracker } from "./recentlyEdited"; @@ -63,6 +65,7 @@ export class ContinueCompletionProvider private completionProvider: CompletionProvider; private nextEditProvider: NextEditProvider; + private nextEditLoggingService: NextEditLoggingService; public recentlyVisitedRanges: RecentlyVisitedRangesService; public recentlyEditedTracker: RecentlyEditedTracker; @@ -98,6 +101,8 @@ export class ContinueCompletionProvider getDefinitionsFromLsp, ); + // Logging service must be created first. + this.nextEditLoggingService = NextEditLoggingService.getInstance(); this.nextEditProvider = NextEditProvider.initialize( this.configHandler, this.ide, @@ -110,7 +115,7 @@ export class ContinueCompletionProvider this.recentlyVisitedRanges = new RecentlyVisitedRangesService(ide); } - _lastShownCompletion: AutocompleteOutcome | undefined; + _lastShownCompletion: AutocompleteOutcome | NextEditOutcome | undefined; public async provideInlineCompletionItems( document: vscode.TextDocument, @@ -231,7 +236,9 @@ export class ContinueCompletionProvider setupStatusBar(undefined, true); - const outcome = this.isNextEditActive + // TODO: fix type of outcome to be a union between NextEditOutcome and AutocompleteOutcome. + const outcome: AutocompleteOutcome | NextEditOutcome | undefined = this + .isNextEditActive ? await this.nextEditProvider.provideInlineCompletionItems( input, signal, @@ -272,8 +279,19 @@ export class ContinueCompletionProvider return null; } - // Mark displayed - this.completionProvider.markDisplayed(input.completionId, outcome); + // Marking the outcome as displayed saves + // the current outcome as a value of the key completionId. + if (this.isNextEditActive) { + this.nextEditProvider.markDisplayed( + input.completionId, + outcome as NextEditOutcome, + ); + } else { + this.completionProvider.markDisplayed( + input.completionId, + outcome as AutocompleteOutcome, + ); + } this._lastShownCompletion = outcome; // Construct the range/text to show @@ -283,6 +301,8 @@ export class ContinueCompletionProvider let range = new vscode.Range(startPos, startPos); // let range = new vscode.Range(startPos, endPos); let completionText = outcome.completion; + + // NOTE: This seems like an autocomplete logic. const isSingleLineCompletion = outcome.completion.split("\n").length <= 1; if (isSingleLineCompletion) { @@ -313,7 +333,7 @@ export class ContinueCompletionProvider range = new vscode.Range(startPos, document.lineAt(startPos).range.end); } - const completionItem = new vscode.InlineCompletionItem( + const autocompleteCompletionItem = new vscode.InlineCompletionItem( completionText, range, { @@ -323,7 +343,7 @@ export class ContinueCompletionProvider }, ); - (completionItem as any).completeBracketPairs = true; + (autocompleteCompletionItem as any).completeBracketPairs = true; if (this.isNextEditActive) { const editor = vscode.window.activeTextEditor; @@ -367,37 +387,41 @@ export class ContinueCompletionProvider currCursorPos, ); if (isFim) { - const completionItem = new vscode.InlineCompletionItem( + const nextEditCompletionItem = new vscode.InlineCompletionItem( fimText, new vscode.Range( new vscode.Position(currCursorPos.line, currCursorPos.character), new vscode.Position(currCursorPos.line, currCursorPos.character), ), { - title: "Log Autocomplete Outcome", - command: "continue.logAutocompleteOutcome", - arguments: [input.completionId, this.completionProvider], + title: "Log Next Edit Outcome", + command: "continue.logNextEditOutcomeAccept", + arguments: [input.completionId, this.nextEditLoggingService], // TODO: this may have to be this.completionProvider. }, ); - return [completionItem]; + return [nextEditCompletionItem]; } // Else, render a next edit window. const diffLines = myersDiff(oldEditRangeSlice, newEditRangeSlice); if (NextEditWindowManager.isInstantiated()) { + NextEditWindowManager.getInstance().updateCurrentCompletionId( + input.completionId, + ); + await NextEditWindowManager.getInstance().showNextEditWindow( editor, currCursorPos, editableRegionStartLine, - completionText, + newEditRangeSlice, diffLines, ); } return undefined; } else { - return [completionItem]; + return [autocompleteCompletionItem]; } } finally { stopStatusBarLoading(); @@ -408,7 +432,7 @@ export class ContinueCompletionProvider document: vscode.TextDocument, selectedCompletionInfo: vscode.SelectedCompletionInfo | undefined, abortSignal: AbortSignal, - outcome: AutocompleteOutcome, + outcome: AutocompleteOutcome | NextEditOutcome, ): boolean { if (selectedCompletionInfo) { const { text, range } = selectedCompletionInfo; diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index c1f3aacbe..0b061755f 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -17,6 +17,7 @@ import * as YAML from "yaml"; import { convertJsonToYamlConfig } from "../../../packages/config-yaml/dist"; +import { NextEditLoggingService } from "core/nextEdit/NextEditLoggingService"; import { getAutocompleteStatusBarDescription, getAutocompleteStatusBarTitle, @@ -543,6 +544,18 @@ const getCommandsMap: ( ) => { completionProvider.accept(completionId); }, + "continue.logNextEditOutcomeAccept": ( + completionId: string, + nextEditLoggingService: NextEditLoggingService, + ) => { + nextEditLoggingService.accept(completionId); + }, + "continue.logNextEditOutcomeReject": ( + completionId: string, + nextEditLoggingService: NextEditLoggingService, + ) => { + nextEditLoggingService.reject(completionId); + }, "continue.toggleTabAutocompleteEnabled": () => { captureCommandTelemetry("toggleTabAutocompleteEnabled"); diff --git a/packages/config-yaml/src/schemas/data/index.ts b/packages/config-yaml/src/schemas/data/index.ts index 1353d9c54..a1fad8cae 100644 --- a/packages/config-yaml/src/schemas/data/index.ts +++ b/packages/config-yaml/src/schemas/data/index.ts @@ -37,6 +37,11 @@ import { nextEditEventSchema_0_2_0, nextEditEventSchema_0_2_0_noCode, } from "./nextEdit/v0.2.0.js"; +import { nextEditOutcomeEventAllSchema } from "./nextEditOutcome/index.js"; +import { + nextEditOutcomeEventSchema_0_2_0, + nextEditOutcomeEventSchema_0_2_0_noCode, +} from "./nextEditOutcome/v0.2.0.js"; import { quickEditEventAllSchema } from "./quickEdit/index.js"; import { quickEditEventSchema_0_1_0, @@ -82,6 +87,7 @@ const devEventAllVersionDataSchemas = z.object({ chatInteraction: chatInteractionEventAllSchema, editInteraction: editInteractionEventAllSchema, nextEdit: nextEditEventAllSchema, + nextEditOutcome: nextEditOutcomeEventAllSchema, }); // Version and level specific schemas are organized here @@ -109,6 +115,7 @@ export const devDataVersionedSchemas = { editInteraction: editInteractionEventSchema_0_2_0, editOutcome: editOutcomeEventSchema_0_2_0, nextEdit: nextEditEventSchema_0_2_0, + nextEditOutcome: nextEditOutcomeEventSchema_0_2_0, }, noCode: { autocomplete: autocompleteEventSchema_0_2_0_noCode, @@ -118,6 +125,7 @@ export const devDataVersionedSchemas = { editInteraction: editInteractionEventSchema_0_2_0_noCode, editOutcome: editOutcomeEventSchema_0_2_0_noCode, nextEdit: nextEditEventSchema_0_2_0_noCode, + nextEditOutcome: nextEditOutcomeEventSchema_0_2_0_noCode, }, }, }; diff --git a/packages/config-yaml/src/schemas/data/nextEditOutcome/index.ts b/packages/config-yaml/src/schemas/data/nextEditOutcome/index.ts new file mode 100644 index 000000000..34901b21d --- /dev/null +++ b/packages/config-yaml/src/schemas/data/nextEditOutcome/index.ts @@ -0,0 +1,23 @@ +import { z } from "zod"; +import { baseDevDataAllSchema } from "../base.js"; + +export const nextEditOutcomeEventAllSchema = baseDevDataAllSchema.extend({ + elapsed: z.number(), + completionOptions: z.any(), + completionId: z.string(), + gitRepo: z.string().optional(), + uniqueId: z.string(), + timestamp: z.number(), + fileUri: z.string(), + workspaceDirUri: z.string(), + prompt: z.string(), + userEdits: z.string(), + userExcerpts: z.string(), + originalEditableRange: z.string(), + completion: z.string(), + cursorPosition: z.object({ line: z.number(), character: z.number() }), + accepted: z.boolean().optional(), + modelProvider: z.string(), + modelName: z.string(), + finetunedOn: z.string(), +}); diff --git a/packages/config-yaml/src/schemas/data/nextEditOutcome/v0.2.0.ts b/packages/config-yaml/src/schemas/data/nextEditOutcome/v0.2.0.ts new file mode 100644 index 000000000..b5acae398 --- /dev/null +++ b/packages/config-yaml/src/schemas/data/nextEditOutcome/v0.2.0.ts @@ -0,0 +1,43 @@ +import { nextEditOutcomeEventAllSchema } from "./index.js"; + +export const nextEditOutcomeEventSchema_0_2_0 = + nextEditOutcomeEventAllSchema.pick({ + // base + timestamp: true, + userId: true, + userAgent: true, + selectedProfileId: true, + eventName: true, + schema: true, + + // nextEditOutcome-specific + elapsed: true, + completionOptions: true, + completionId: true, + gitRepo: true, + uniqueId: true, + // timestamp: z.number(), + fileUri: true, + workspaceDirUri: true, + prompt: true, + userEdits: true, + userExcerpts: true, + originalEditableRange: true, + completion: true, + cursorPosition: true, + accepted: true, + modelProvider: true, + modelName: true, + finetunedOn: true, + }); + +export const nextEditOutcomeEventSchema_0_2_0_noCode = + nextEditOutcomeEventSchema_0_2_0.omit({ + fileUri: true, + workspaceDirUri: true, + prompt: true, + userEdits: true, + userExcerpts: true, + originalEditableRange: true, + completion: true, + }); From cbd54b291475f765f3a22fcbbe1f71cf745e29c9 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Thu, 3 Jul 2025 14:15:47 -0700 Subject: [PATCH 2/8] reset completion id only on esc --- extensions/vscode/src/activation/NextEditWindowManager.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/extensions/vscode/src/activation/NextEditWindowManager.ts b/extensions/vscode/src/activation/NextEditWindowManager.ts index 8f79e0489..fd8aa3f3d 100644 --- a/extensions/vscode/src/activation/NextEditWindowManager.ts +++ b/extensions/vscode/src/activation/NextEditWindowManager.ts @@ -181,7 +181,7 @@ export class NextEditWindowManager { // Register HIDE_TOOLTIP_COMMAND and ACCEPT_NEXT_EDIT_COMMAND with their corresponding callbacks. this.registerCommandSafely( HIDE_NEXT_EDIT_SUGGESTION_COMMAND, - async () => await this.hideAllNextEditWindows(), + async () => await this.hideAllNextEditWindowsAndResetCompletionId(), ); this.registerCommandSafely( ACCEPT_NEXT_EDIT_SUGGESTION_COMMAND, @@ -309,8 +309,12 @@ export class NextEditWindowManager { } await NextEditWindowManager.freeTabAndEsc(); + } - // TODO: Log with accept = false. + public async hideAllNextEditWindowsAndResetCompletionId() { + this.hideAllNextEditWindows(); + + // Log with accept = false. await vscode.commands.executeCommand( "continue.logNextEditOutcomeReject", this.mostRecentCompletionId, From e8d182b6e4c3e32885b8adb034f73df632f78b72 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Thu, 3 Jul 2025 14:22:43 -0700 Subject: [PATCH 3/8] move finetuned dataset annotation to modelName --- core/nextEdit/NextEditProvider.ts | 79 +------------------ core/nextEdit/types.ts | 2 - .../src/schemas/data/nextEditOutcome/index.ts | 1 - .../schemas/data/nextEditOutcome/v0.2.0.ts | 1 - 4 files changed, 3 insertions(+), 80 deletions(-) diff --git a/core/nextEdit/NextEditProvider.ts b/core/nextEdit/NextEditProvider.ts index a46ee2b70..fba86df33 100644 --- a/core/nextEdit/NextEditProvider.ts +++ b/core/nextEdit/NextEditProvider.ts @@ -244,45 +244,17 @@ export class NextEditProvider { } else { const promptMetadata = renderPrompt(helper, this.diffContext); this.promptMetadata = promptMetadata; - prompts.push( - // await renderFineTunedUserPrompt(snippetPayload, this.ide, helper), - // await renderFineTunedBasicUserPrompt( - // snippetPayload, - // this.ide, - // helper, - // this.diffContext, - // ), - promptMetadata.prompt, - ); + prompts.push(promptMetadata.prompt); } if (this.endpointType === "default") { const msg: ChatMessage = await llm.chat(prompts, token); if (typeof msg.content === "string") { const nextCompletion = JSON.parse(msg.content).newCode; - // const outcomeNext: AutocompleteOutcome = { - // time: Date.now() - startTime, - // completion: nextCompletion, - // prefix: "", - // suffix: "", - // prompt: "", - // modelProvider: llm.underlyingProviderName, - // modelName: llm.model, - // completionOptions: null, - // cacheHit: false, - // filepath: helper.filepath, - // numLines: nextCompletion.split("\n").length, - // completionId: helper.input.completionId, - // gitRepo: await this.ide.getRepoName(helper.filepath), - // uniqueId: await this.ide.getUniqueId(), - // timestamp: Date.now(), - // ...helper.options, - // }; - // TODO: clean this up, or delete. const outcomeNext: NextEditOutcome = { elapsed: Date.now() - startTime, modelProvider: llm.underlyingProviderName, - modelName: llm.model, + modelName: llm.model + ":zetaDataset", completionOptions: null, // filepath: helper.filepath, completionId: helper.input.completionId, @@ -298,36 +270,13 @@ export class NextEditProvider { originalEditableRange: "", completion: nextCompletion, cursorPosition: helper.pos, - finetunedOn: "zetaDataset", ...helper.options, }; return outcomeNext; } else { return undefined; } - // const body = { - // model: defaultModel, - // messages: prompts, - // // max_tokens: 15000, - // // stop: ["<|editable_region_end|>"], - // }; - // - // const resp = await fetch(defaultEndpoint, { - // method: "POST", - // headers: { - // Authorization: `Bearer ${mercuryToken} `, - // "Content-Type": "application/json", - // }, - // body: JSON.stringify(body), - // }); - // - // const respJson = await resp.json(); - - // TODO: Do some zod schema validation here if needed. } else { - // const testController = new AbortController(); - // const msg: ChatMessage = await llm.chat(prompts, testController.signal); - // const testToken = testController.signal; const msg: ChatMessage = await llm.chat(prompts, token); if (typeof msg.content === "string") { // TODO: There are cases where msg.conetnt.split("<|start|>")[1] is undefined @@ -335,27 +284,6 @@ export class NextEditProvider { msg.content.split("<|editable_region_start|>\n")[1], ).replace(/\n$/, ""); - // const diffLines = myersDiff(helper.fileContents, nextCompletion); - - // const diff = getRenderableDiff(diffLines); - // const outcomeNext: AutocompleteOutcome = { - // time: Date.now() - startTime, - // completion: nextCompletion, - // prefix: "", - // suffix: "", - // prompt: "", - // modelProvider: llm.underlyingProviderName, - // modelName: llm.model, - // completionOptions: null, - // cacheHit: false, - // filepath: helper.filepath, - // numLines: nextCompletion.split("\n").length, - // completionId: helper.input.completionId, - // gitRepo: await this.ide.getRepoName(helper.filepath), - // uniqueId: await this.ide.getUniqueId(), - // timestamp: Date.now(), - // ...helper.options, - // }; const currCursorPos = helper.pos; const editableRegionStartLine = Math.max( currCursorPos.line - NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN, @@ -373,7 +301,7 @@ export class NextEditProvider { const outcomeNext: NextEditOutcome = { elapsed: Date.now() - startTime, modelProvider: llm.underlyingProviderName, - modelName: llm.model, + modelName: llm.model + ":zetaDataset", completionOptions: null, // filepath: helper.filepath, completionId: helper.input.completionId, @@ -389,7 +317,6 @@ export class NextEditProvider { originalEditableRange: oldEditRangeSlice, completion: nextCompletion, cursorPosition: helper.pos, - finetunedOn: "zetaDataset", ...helper.options, }; return outcomeNext; diff --git a/core/nextEdit/types.ts b/core/nextEdit/types.ts index 4a47951f2..0837c5494 100644 --- a/core/nextEdit/types.ts +++ b/core/nextEdit/types.ts @@ -54,8 +54,6 @@ export interface NextEditOutcome extends TabAutocompleteOptions { completion: string; cursorPosition: { line: number; character: number }; accepted?: boolean; - // model: string; - finetunedOn: string; } export interface PromptMetadata { diff --git a/packages/config-yaml/src/schemas/data/nextEditOutcome/index.ts b/packages/config-yaml/src/schemas/data/nextEditOutcome/index.ts index 34901b21d..f294b1068 100644 --- a/packages/config-yaml/src/schemas/data/nextEditOutcome/index.ts +++ b/packages/config-yaml/src/schemas/data/nextEditOutcome/index.ts @@ -19,5 +19,4 @@ export const nextEditOutcomeEventAllSchema = baseDevDataAllSchema.extend({ accepted: z.boolean().optional(), modelProvider: z.string(), modelName: z.string(), - finetunedOn: z.string(), }); diff --git a/packages/config-yaml/src/schemas/data/nextEditOutcome/v0.2.0.ts b/packages/config-yaml/src/schemas/data/nextEditOutcome/v0.2.0.ts index b5acae398..82e4edbea 100644 --- a/packages/config-yaml/src/schemas/data/nextEditOutcome/v0.2.0.ts +++ b/packages/config-yaml/src/schemas/data/nextEditOutcome/v0.2.0.ts @@ -28,7 +28,6 @@ export const nextEditOutcomeEventSchema_0_2_0 = accepted: true, modelProvider: true, modelName: true, - finetunedOn: true, }); export const nextEditOutcomeEventSchema_0_2_0_noCode = From 43ed26f351ac45f5a717af728ad13a8c3c56350b Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Thu, 3 Jul 2025 15:55:45 -0700 Subject: [PATCH 4/8] add a method to cancel the timeout without deleting the current completion context --- core/nextEdit/NextEditLoggingService.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/nextEdit/NextEditLoggingService.ts b/core/nextEdit/NextEditLoggingService.ts index 8000b4d94..266d114af 100644 --- a/core/nextEdit/NextEditLoggingService.ts +++ b/core/nextEdit/NextEditLoggingService.ts @@ -78,6 +78,12 @@ export class NextEditLoggingService { } } + public cancelRejectionTimeoutButKeepCompletionId(completionId: string) { + if (this._logRejectionTimeouts.has(completionId)) { + clearTimeout(this._logRejectionTimeouts.get(completionId)!); + } + } + public markDisplayed(completionId: string, outcome: NextEditOutcome) { const logRejectionTimeout = setTimeout(() => { // Wait 10 seconds, then assume it wasn't accepted From 4fe21ede2e7f3fb12be493f942067a169f46f351 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Thu, 3 Jul 2025 15:56:08 -0700 Subject: [PATCH 5/8] stop logging current completion if we decide not to show the svg --- extensions/vscode/src/autocomplete/completionProvider.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts index 73a7ba0c1..3f3995878 100644 --- a/extensions/vscode/src/autocomplete/completionProvider.ts +++ b/extensions/vscode/src/autocomplete/completionProvider.ts @@ -356,6 +356,9 @@ export class ContinueCompletionProvider // We don't need to show the next edit window if the predicted edits is empty. if (newEditRangeSlice === "") { + this.nextEditLoggingService.cancelRejectionTimeout( + input.completionId, + ); return undefined; } @@ -377,6 +380,9 @@ export class ContinueCompletionProvider // We don't need to show the next edit window if the predicted edits are identical to the previous version. if (oldEditRangeSlice === newEditRangeSlice) { + this.nextEditLoggingService.cancelRejectionTimeout( + input.completionId, + ); return undefined; } From 24e55cbd49102e2df4f6c4112fc6b6de774d0bc3 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Thu, 3 Jul 2025 15:57:20 -0700 Subject: [PATCH 6/8] stop logging when we move away, clear timeout while svg is alive. --- .../src/activation/NextEditWindowManager.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/extensions/vscode/src/activation/NextEditWindowManager.ts b/extensions/vscode/src/activation/NextEditWindowManager.ts index fd8aa3f3d..86168fc32 100644 --- a/extensions/vscode/src/activation/NextEditWindowManager.ts +++ b/extensions/vscode/src/activation/NextEditWindowManager.ts @@ -90,6 +90,9 @@ export class NextEditWindowManager { // Current active decoration private currentDecoration: vscode.TextEditorDecorationType | null = null; + // A short-lived checker to determine if the cursor moved because of us accepting the next edit, or not. + // Distinguishing the two is necessary to determine if we should log it as an accepted or rejected. + private accepted: boolean = false; // Track which editor has the active decoration private activeEditor: vscode.TextEditor | null = null; // Store the current tooltip text for accepting @@ -330,6 +333,7 @@ export class NextEditWindowManager { if (!this.activeEditor || !this.currentTooltipText) { return; } + this.accepted = true; const editor = this.activeEditor; const text = this.currentTooltipText; @@ -396,6 +400,9 @@ export class NextEditWindowManager { this.loggingService, ); this.mostRecentCompletionId = null; + + // Reset to false for future logging. + this.accepted = false; } /** @@ -459,6 +466,10 @@ export class NextEditWindowManager { this.activeEditor && !vscode.window.visibleTextEditors.includes(this.activeEditor) ) { + if (this.mostRecentCompletionId) + this.loggingService.cancelRejectionTimeout( + this.mostRecentCompletionId, + ); await this.hideAllNextEditWindows(); } }); @@ -467,6 +478,11 @@ export class NextEditWindowManager { vscode.window.onDidChangeTextEditorSelection(async (e) => { // If the selection changed in our active editor, hide the tooltip. if (this.activeEditor && e.textEditor === this.activeEditor) { + // If the cursor moved because of something other than accepting next edit, stop logging it. + if (!this.accepted && this.mostRecentCompletionId) + this.loggingService.cancelRejectionTimeout( + this.mostRecentCompletionId, + ); await this.hideAllNextEditWindows(); } }); @@ -719,6 +735,12 @@ export class NextEditWindowManager { hoverMessage: [this.buildHideTooltipHoverMsg()], }, ]); + + // Clear the timeout while SVG is on the editor. + if (this.currentDecoration && this.mostRecentCompletionId) + this.loggingService.cancelRejectionTimeoutButKeepCompletionId( + this.mostRecentCompletionId, + ); } } From 589c9b4e76c89d260bc50aa2c69b250ea0634ed2 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Thu, 3 Jul 2025 18:04:15 -0700 Subject: [PATCH 7/8] add posthog telemetry --- core/nextEdit/NextEditLoggingService.ts | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/core/nextEdit/NextEditLoggingService.ts b/core/nextEdit/NextEditLoggingService.ts index 266d114af..7c448f2d7 100644 --- a/core/nextEdit/NextEditLoggingService.ts +++ b/core/nextEdit/NextEditLoggingService.ts @@ -1,6 +1,7 @@ import { COUNT_COMPLETION_REJECTED_AFTER } from "../util/parameters"; import { DataLogger } from "../data/log"; +import { Telemetry } from "../util/posthog"; import { NextEditOutcome } from "./types"; export class NextEditLoggingService { @@ -133,24 +134,6 @@ export class NextEditLoggingService { }); // const { prompt, completion, prefix, suffix, ...restOfOutcome } = outcome; - // void Telemetry.capture( - // "autocomplete", - // { - // accepted: restOfOutcome.accepted, - // cacheHit: restOfOutcome.cacheHit, - // completionId: restOfOutcome.completionId, - // completionOptions: restOfOutcome.completionOptions, - // debounceDelay: restOfOutcome.debounceDelay, - // fileExtension: getUriFileExtension(restOfOutcome.filepath), - // maxPromptTokens: restOfOutcome.maxPromptTokens, - // modelName: restOfOutcome.modelName, - // modelProvider: restOfOutcome.modelProvider, - // multilineCompletions: restOfOutcome.multilineCompletions, - // time: restOfOutcome.time, - // useRecentlyEdited: restOfOutcome.useRecentlyEdited, - // numLines: restOfOutcome.numLines, - // }, - // true, - // ); + void Telemetry.capture("nextEditOutcome", outcome, true); } } From 24f706dc65f1c48cdf8ba47342a9d0b7c80e20a9 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Thu, 3 Jul 2025 18:31:29 -0700 Subject: [PATCH 8/8] fix imports --- packages/config-yaml/src/schemas/data/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/config-yaml/src/schemas/data/index.ts b/packages/config-yaml/src/schemas/data/index.ts index d7192931c..1b3d3cb19 100644 --- a/packages/config-yaml/src/schemas/data/index.ts +++ b/packages/config-yaml/src/schemas/data/index.ts @@ -39,6 +39,10 @@ import { nextEditEventSchema_0_2_0_noCode, } from "./nextEdit/v0.2.0.js"; import { nextEditOutcomeEventAllSchema } from "./nextEditOutcome/index.js"; +import { + nextEditOutcomeEventSchema_0_2_0, + nextEditOutcomeEventSchema_0_2_0_noCode, +} from "./nextEditOutcome/v0.2.0.js"; import { quickEditEventAllSchema } from "./quickEdit/index.js"; import { quickEditEventSchema_0_1_0, @@ -54,6 +58,10 @@ import { tokensGeneratedEventSchema_0_2_0_noCode, } from "./tokensGenerated/v0.2.0.js"; import { toolUsageEventAllSchema } from "./toolUsage/index.js"; +import { + toolUsageEventSchema_0_2_0, + toolUsageEventSchema_0_2_0_noCode, +} from "./toolUsage/v0.2.0.js"; const semverRegex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/; @@ -126,6 +134,8 @@ export const devDataVersionedSchemas = { editInteraction: editInteractionEventSchema_0_2_0_noCode, editOutcome: editOutcomeEventSchema_0_2_0_noCode, nextEdit: nextEditEventSchema_0_2_0_noCode, + nextEditOutcome: nextEditOutcomeEventSchema_0_2_0_noCode, + toolUsage: toolUsageEventSchema_0_2_0_noCode, }, }, };