Elffuss BraidHub

kikocis/continue public

Merge pull request #6358 from continuedev/edit-outcome

Add edit outcome tracking to record accept/reject
Changeset44309e42d7966f56c41e8f35c221ce65dece8b2f1f0d0c0be12e8ddfd8a72995
AuthorNate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-06-30 23:14 -07:00
CommitterGitHub <noreply@github.com> · 2025-06-30 23:14 -07:00
Parents0999e1dfd2e1, 4f6ee13bd815

Browse the files at this changeset

9 files changed

modified core/package-lock.json +0 −0

Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.

modified extensions/vscode/package.json +1 −1
@@ -2,7 +2,7 @@
22 "name": "continue",
33 "icon": "media/icon.png",
44 "author": "Continue Dev, Inc",
5- "version": "1.1.52",
5+ "version": "1.1.53",
66 "repository": {
77 "type": "git",
88 "url": "https://github.com/continuedev/continue"
modified extensions/vscode/src/apply/ApplyManager.ts +4 −4
@@ -42,7 +42,7 @@
4242
4343 const { activeTextEditor } = vscode.window;
4444 if (!activeTextEditor) {
45- vscode.window.showErrorMessage("No active editor to apply edits to");
45+ void vscode.window.showErrorMessage("No active editor to apply edits to");
4646 return;
4747 }
4848
@@ -116,14 +116,14 @@
116116 ) {
117117 const { config } = await this.configHandler.loadConfig();
118118 if (!config) {
119- vscode.window.showErrorMessage("Config not loaded");
119+ void vscode.window.showErrorMessage("Config not loaded");
120120 return;
121121 }
122122
123123 const llm =
124124 config.selectedModelByRole.apply ?? config.selectedModelByRole.chat;
125125 if (!llm) {
126- vscode.window.showErrorMessage(
126+ void vscode.window.showErrorMessage(
127127 `No model with roles "apply" or "chat" found in config.`,
128128 );
129129 return;
@@ -177,7 +177,7 @@
177177 ) {
178178 const { config } = await this.configHandler.loadConfig();
179179 if (!config) {
180- vscode.window.showErrorMessage("Config not loaded");
180+ void vscode.window.showErrorMessage("Config not loaded");
181181 return;
182182 }
183183
modified extensions/vscode/src/diff/processDiff.ts +14 −0
@@ -1,5 +1,7 @@
11 import { Core } from "core/core";
2+import { DataLogger } from "core/data/log";
23 import { ContinueGUIWebviewViewProvider } from "../ContinueGUIWebviewViewProvider";
4+import { editOutcomeTracker } from "../extension/EditOutcomeTracker";
35 import { VsCodeIde } from "../VsCodeIde";
46 import { VerticalDiffManager } from "./vertical/manager";
57
@@ -27,6 +29,11 @@
2729
2830 await ide.openFile(newOrCurrentUri);
2931
32+ // If streamId is not provided, try to get it from the VerticalDiffManager
33+ if (!streamId) {
34+ streamId = verticalDiffManager.getStreamIdForFile(newOrCurrentUri);
35+ }
36+
3037 // Clear vertical diffs depending on action
3138 verticalDiffManager.clearForfileUri(newOrCurrentUri, action === "accept");
3239 if (action === "reject") {
@@ -37,6 +44,13 @@
3744 if (streamId) {
3845 const fileContent = await ide.readFile(newOrCurrentUri);
3946
47+ // Record the edit outcome before updating the apply state
48+ await editOutcomeTracker.recordEditOutcome(
49+ streamId,
50+ action === "accept",
51+ DataLogger.getInstance(),
52+ );
53+
4054 await sidebar.webviewProtocol.request("updateApplyState", {
4155 fileContent,
4256 filepath: newOrCurrentUri,
modified extensions/vscode/src/diff/vertical/handler.ts +8 −17
@@ -9,8 +9,8 @@
99 indexDecorationType,
1010 } from "./decorations";
1111
12-import type { VerticalDiffCodeLens } from "./manager";
1312 import type { ApplyState, DiffLine } from "core";
13+import type { VerticalDiffCodeLens } from "./manager";
1414
1515 export interface VerticalDiffHandlerOptions {
1616 input?: string;
@@ -20,10 +20,12 @@
2020 numDiffs?: ApplyState["numDiffs"],
2121 fileContent?: ApplyState["fileContent"],
2222 ) => void;
23+ streamId?: string;
2324 }
2425
2526 export class VerticalDiffHandler implements vscode.Disposable {
2627 public insertedInCurrentBlock = 0;
28+ public streamId?: string;
2729 disposables: vscode.Disposable[] = [];
2830 private currentLineIndex: number;
2931 private cancelled = false;
@@ -50,6 +52,7 @@
5052 public options: VerticalDiffHandlerOptions,
5153 ) {
5254 this.currentLineIndex = startLine;
55+ this.streamId = options.streamId;
5356
5457 this.removedLineDecorations = new RemovedLineDecorationManager(this.editor);
5558 this.addedLineDecorations = new AddedLineDecorationManager(this.editor);
@@ -330,10 +333,7 @@
330333 // Then, we insert our diff lines
331334 await this.editor.edit((editBuilder) => {
332335 editBuilder.replace(this.range, replaceContent),
333- {
334- undoStopAfter: false,
335- undoStopBefore: false,
336- };
336+ { undoStopAfter: false, undoStopBefore: false };
337337 });
338338
339339 // Lastly, we apply decorations
@@ -446,10 +446,7 @@
446446 editBuilder.insert(new vscode.Position(index, 0), `${text}\n`);
447447 }
448448 },
449- {
450- undoStopAfter: false,
451- undoStopBefore: false,
452- },
449+ { undoStopAfter: false, undoStopBefore: false },
453450 );
454451 }
455452
@@ -467,10 +464,7 @@
467464 new vscode.Range(startLine, startLine.translate(numLines)),
468465 );
469466 },
470- {
471- undoStopAfter: false,
472- undoStopBefore: false,
473- },
467+ { undoStopAfter: false, undoStopBefore: false },
474468 );
475469 }
476470
@@ -486,10 +480,7 @@
486480 );
487481 }
488482 },
489- {
490- undoStopAfter: false,
491- undoStopBefore: false,
492- },
483+ { undoStopAfter: false, undoStopBefore: false },
493484 );
494485 }
495486
modified extensions/vscode/src/diff/vertical/manager.ts +63 −7
@@ -1,4 +1,4 @@
1-import { ChatMessage, DiffLine, ILLM, RuleWithSource } from "core";
1+import { ChatMessage, DiffLine, IDE, ILLM, RuleWithSource } from "core";
22 import { streamDiffLines } from "core/edit/streamDiffLines";
33 import { pruneLinesFromBottom, pruneLinesFromTop } from "core/llm/countTokens";
44 import { getMarkdownLanguageTagForFile } from "core/util";
@@ -11,6 +11,9 @@
1111 import { VsCodeWebviewProtocol } from "../../webviewProtocol";
1212
1313 import { ApplyAbortManager } from "core/edit/applyAbortManager";
14+import { EDIT_MODE_STREAM_ID } from "core/edit/constants";
15+import { stripImages } from "core/util/messageContent";
16+import { editOutcomeTracker } from "../../extension/EditOutcomeTracker";
1417 import { VerticalDiffHandler, VerticalDiffHandlerOptions } from "./handler";
1518
1619 export interface VerticalDiffCodeLens {
@@ -23,7 +26,6 @@
2326 public refreshCodeLens: () => void = () => {};
2427
2528 private fileUriToHandler: Map<string, VerticalDiffHandler> = new Map();
26-
2729 fileUriToCodeLens: Map<string, VerticalDiffCodeLens[]> = new Map();
2830
2931 private userChangeListener: vscode.Disposable | undefined;
@@ -33,6 +35,7 @@
3335 constructor(
3436 private readonly webviewProtocol: VsCodeWebviewProtocol,
3537 private readonly editDecorationManager: EditDecorationManager,
38+ private readonly ide: IDE,
3639 ) {
3740 this.userChangeListener = undefined;
3841 }
@@ -69,6 +72,10 @@
6972 return this.fileUriToHandler.get(fileUri);
7073 }
7174
75+ getStreamIdForFile(fileUri: string): string | undefined {
76+ return this.fileUriToHandler.get(fileUri)?.streamId;
77+ }
78+
7279 // Creates a listener for document changes by user.
7380 private enableDocumentChangeListener(): vscode.Disposable | undefined {
7481 if (this.userChangeListener) {
@@ -229,6 +236,7 @@
229236 filepath: fileUri,
230237 toolCallId,
231238 }),
239+ streamId,
232240 },
233241 );
234242
@@ -296,7 +304,11 @@
296304 toolCallId?: string;
297305 rulesToInclude: undefined | RuleWithSource[];
298306 }): Promise<string | undefined> {
299- vscode.commands.executeCommand("setContext", "continue.diffVisible", true);
307+ void vscode.commands.executeCommand(
308+ "setContext",
309+ "continue.diffVisible",
310+ true,
311+ );
300312
301313 let editor = vscode.window.activeTextEditor;
302314
@@ -373,6 +385,7 @@
373385 filepath: fileUri,
374386 toolCallId,
375387 }),
388+ streamId,
376389 },
377390 );
378391
@@ -430,7 +443,7 @@
430443 );
431444 }
432445
433- vscode.commands.executeCommand(
446+ void vscode.commands.executeCommand(
434447 "setContext",
435448 "continue.streamingDiff",
436449 true,
@@ -472,10 +485,18 @@
472485 this.enableDocumentChangeListener();
473486
474487 if (abortController.signal.aborted) {
475- vscode.commands.executeCommand("continue.rejectDiff");
488+ void vscode.commands.executeCommand("continue.rejectDiff");
476489 }
477490
478- return `${prefix}${streamedLines.join("\n")}${suffix}`;
491+ const fileAfterEdit = `${prefix}${streamedLines.join("\n")}${suffix}`;
492+ await this.trackEditInteraction({
493+ model: llm,
494+ filepath: fileUri,
495+ prompt: input,
496+ fileAfterEdit,
497+ });
498+
499+ return fileAfterEdit;
479500 } catch (e) {
480501 this.disableDocumentChangeListener();
481502 const handled = await handleLLMError(e);
@@ -487,11 +508,46 @@
487508 throw new Error(message);
488509 }
489510 } finally {
490- vscode.commands.executeCommand(
511+ void vscode.commands.executeCommand(
491512 "setContext",
492513 "continue.streamingDiff",
493514 false,
494515 );
495516 }
496517 }
518+
519+ async trackEditInteraction({
520+ model,
521+ filepath,
522+ prompt,
523+ fileAfterEdit,
524+ }: {
525+ model: ILLM;
526+ filepath: string;
527+ prompt: string;
528+ fileAfterEdit: string | undefined;
529+ }) {
530+ // Get previous code content for outcome tracking
531+ const previousCode = await this.ide.readFile(filepath);
532+ const newCode = fileAfterEdit ?? "";
533+ const previousCodeLines = previousCode.split("\n").length;
534+ const newCodeLines = newCode.split("\n").length;
535+ const lineChange = newCodeLines - previousCodeLines;
536+
537+ // Store pending edit data for outcome tracking
538+ editOutcomeTracker.trackEditInteraction({
539+ streamId: EDIT_MODE_STREAM_ID,
540+ timestamp: new Date().toISOString(),
541+ modelProvider: model.underlyingProviderName,
542+ modelTitle: model.title ?? "",
543+ prompt: stripImages(prompt),
544+ completion: newCode,
545+ previousCode,
546+ newCode,
547+ filepath: filepath,
548+ previousCodeLines,
549+ newCodeLines,
550+ lineChange,
551+ });
552+ }
497553 }
added extensions/vscode/src/extension/EditOutcomeTracker.ts +96 −0
@@ -0,0 +1,96 @@
1+/**
2+ * Tracks pending edit interactions until they are accepted or rejected,
3+ * then emits editOutcome events with the final result.
4+ */
5+export interface PendingEditData {
6+ streamId: string;
7+ timestamp: string;
8+ modelProvider: string;
9+ modelTitle: string;
10+ prompt: string;
11+ completion: string;
12+ previousCode: string;
13+ newCode: string;
14+ filepath: string;
15+ previousCodeLines: number;
16+ newCodeLines: number;
17+ lineChange: number;
18+}
19+
20+class EditOutcomeTracker {
21+ private static instance: EditOutcomeTracker;
22+ private pendingEdits: Map<string, PendingEditData> = new Map();
23+
24+ private constructor() {}
25+
26+ public static getInstance(): EditOutcomeTracker {
27+ if (!EditOutcomeTracker.instance) {
28+ EditOutcomeTracker.instance = new EditOutcomeTracker();
29+ }
30+ return EditOutcomeTracker.instance;
31+ }
32+
33+ /**
34+ * Store a pending edit interaction for later outcome tracking
35+ */
36+ public trackEditInteraction(data: PendingEditData): void {
37+ this.pendingEdits.set(data.streamId, data);
38+ }
39+
40+ /**
41+ * Record the outcome of an edit interaction and emit the editOutcome event
42+ */
43+ public async recordEditOutcome(
44+ streamId: string,
45+ accepted: boolean,
46+ dataLogger: any,
47+ ): Promise<void> {
48+ const pendingEdit = this.pendingEdits.get(streamId);
49+ if (!pendingEdit) {
50+ console.warn(`No pending edit found for streamId: ${streamId}`);
51+ return;
52+ }
53+
54+ // Emit the editOutcome event
55+ await dataLogger.logDevData({
56+ name: "editOutcome",
57+ data: {
58+ modelProvider: pendingEdit.modelProvider,
59+ modelTitle: pendingEdit.modelTitle,
60+ prompt: pendingEdit.prompt,
61+ completion: pendingEdit.completion,
62+ previousCode: pendingEdit.previousCode,
63+ newCode: pendingEdit.newCode,
64+ previousCodeLines: pendingEdit.previousCodeLines,
65+ newCodeLines: pendingEdit.newCodeLines,
66+ lineChange: pendingEdit.lineChange,
67+ accepted,
68+ },
69+ });
70+
71+ // Clean up the pending edit
72+ this.pendingEdits.delete(streamId);
73+ }
74+
75+ /**
76+ * Clean up pending edits that might have been abandoned
77+ */
78+ public cleanupOldPendingEdits(maxAgeMs: number = 30 * 60 * 1000): void {
79+ const now = Date.now();
80+ for (const [streamId, edit] of this.pendingEdits.entries()) {
81+ const editTime = new Date(edit.timestamp).getTime();
82+ if (now - editTime > maxAgeMs) {
83+ this.pendingEdits.delete(streamId);
84+ }
85+ }
86+ }
87+
88+ /**
89+ * Get count of pending edits (for debugging/monitoring)
90+ */
91+ public getPendingEditCount(): number {
92+ return this.pendingEdits.size;
93+ }
94+}
95+
96+export const editOutcomeTracker = EditOutcomeTracker.getInstance();
modified extensions/vscode/src/extension/VsCodeExtension.ts +10 −9
@@ -36,6 +36,7 @@
3636 } from "../stubs/WorkOsAuthProvider";
3737 import { Battery } from "../util/battery";
3838 import { FileSearch } from "../util/FileSearch";
39+import { VsCodeIdeUtils } from "../util/ideUtils";
3940 import { VsCodeIde } from "../VsCodeIde";
4041
4142 import { ConfigYamlDocumentLinkProvider } from "./ConfigYamlDocumentLinkProvider";
@@ -46,7 +47,6 @@
4647 } from "../activation/NextEditWindowManager";
4748 import { getDefinitionsFromLsp } from "../autocomplete/lsp";
4849 import { handleTextDocumentChange } from "../util/editLoggingUtils";
49-import { VsCodeIdeUtils } from "../util/ideUtils";
5050 import type { VsCodeWebviewProtocol } from "../webviewProtocol";
5151
5252 export class VsCodeExtension {
@@ -72,7 +72,7 @@
7272 constructor(context: vscode.ExtensionContext) {
7373 // Register auth provider
7474 this.workOsAuthProvider = new WorkOsAuthProvider(context, this.uriHandler);
75- this.workOsAuthProvider.refreshSessions();
75+ void this.workOsAuthProvider.refreshSessions();
7676 context.subscriptions.push(this.workOsAuthProvider);
7777
7878 this.editDecorationManager = new EditDecorationManager(context);
@@ -138,19 +138,20 @@
138138 this.configHandler = this.core.configHandler;
139139 resolveConfigHandler?.(this.configHandler);
140140
141- this.configHandler.loadConfig();
141+ void this.configHandler.loadConfig();
142142
143143 this.verticalDiffManager = new VerticalDiffManager(
144144 this.sidebar.webviewProtocol,
145145 this.editDecorationManager,
146+ this.ide,
146147 );
147148 resolveVerticalDiffManager?.(this.verticalDiffManager);
148149
149- setupRemoteConfigSync(
150+ void setupRemoteConfigSync(
150151 this.configHandler.reloadConfig.bind(this.configHandler),
151152 );
152153
153- this.configHandler.loadConfig().then(({ config }) => {
154+ void this.configHandler.loadConfig().then(({ config }) => {
154155 const { verticalDiffCodeLens } = registerAllCodeLensProviders(
155156 context,
156157 this.verticalDiffManager.fileUriToCodeLens,
@@ -301,7 +302,7 @@
301302 if (stats.size === 0) {
302303 return;
303304 }
304- this.configHandler.reloadConfig();
305+ void this.configHandler.reloadConfig();
305306 });
306307
307308 vscode.workspace.onDidChangeTextDocument(async (event) => {
@@ -344,7 +345,7 @@
344345 vscode.authentication.onDidChangeSessions(async (e) => {
345346 const env = await getControlPlaneEnv(this.ide.getIdeSettings());
346347 if (e.provider.id === env.AUTH_TYPE) {
347- vscode.commands.executeCommand(
348+ void vscode.commands.executeCommand(
348349 "setContext",
349350 "continue.isSignedInToControlPlane",
350351 true,
@@ -355,7 +356,7 @@
355356 sessionInfo,
356357 });
357358 } else {
358- vscode.commands.executeCommand(
359+ void vscode.commands.executeCommand(
359360 "setContext",
360361 "continue.isSignedInToControlPlane",
361362 false,
@@ -368,7 +369,7 @@
368369 });
369370
370371 // Refresh index when branch is changed
371- this.ide.getWorkspaceDirs().then((dirs) =>
372+ void this.ide.getWorkspaceDirs().then((dirs) =>
372373 dirs.forEach(async (dir) => {
373374 const repo = await this.ide.getRepo(dir);
374375 if (repo) {
modified packages/config-yaml/src/schemas/data/index.ts +6 −0
@@ -28,6 +28,10 @@
2828 editInteractionEventSchema_0_2_0,
2929 editInteractionEventSchema_0_2_0_noCode,
3030 } from "./editInteraction/v0.2.0.js";
31+import {
32+ editOutcomeEventSchema_0_2_0,
33+ editOutcomeEventSchema_0_2_0_noCode,
34+} from "./editOutcome/v0.2.0.js";
3135 import { nextEditEventAllSchema } from "./nextEdit/index.js";
3236 import {
3337 nextEditEventSchema_0_2_0,
@@ -103,6 +107,7 @@
103107 tokensGenerated: tokensGeneratedEventSchema_0_2_0,
104108 chatInteraction: chatInteractionEventSchema_0_2_0,
105109 editInteraction: editInteractionEventSchema_0_2_0,
110+ editOutcome: editOutcomeEventSchema_0_2_0,
106111 nextEdit: nextEditEventSchema_0_2_0,
107112 },
108113 noCode: {
@@ -111,6 +116,7 @@
111116 tokensGenerated: tokensGeneratedEventSchema_0_2_0_noCode,
112117 chatInteraction: chatInteractionEventSchema_0_2_0_noCode,
113118 editInteraction: editInteractionEventSchema_0_2_0_noCode,
119+ editOutcome: editOutcomeEventSchema_0_2_0_noCode,
114120 nextEdit: nextEditEventSchema_0_2_0_noCode,
115121 },
116122 },