track editOutcome for apply as well
This commit is contained in:
parent
965e5d554e
commit
35d9ba55d9
4 changed files with 71 additions and 43 deletions
|
|
@ -42,7 +42,7 @@ export class ApplyManager {
|
|||
|
||||
const { activeTextEditor } = vscode.window;
|
||||
if (!activeTextEditor) {
|
||||
vscode.window.showErrorMessage("No active editor to apply edits to");
|
||||
void vscode.window.showErrorMessage("No active editor to apply edits to");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -116,14 +116,14 @@ export class ApplyManager {
|
|||
) {
|
||||
const { config } = await this.configHandler.loadConfig();
|
||||
if (!config) {
|
||||
vscode.window.showErrorMessage("Config not loaded");
|
||||
void vscode.window.showErrorMessage("Config not loaded");
|
||||
return;
|
||||
}
|
||||
|
||||
const llm =
|
||||
config.selectedModelByRole.apply ?? config.selectedModelByRole.chat;
|
||||
if (!llm) {
|
||||
vscode.window.showErrorMessage(
|
||||
void vscode.window.showErrorMessage(
|
||||
`No model with roles "apply" or "chat" found in config.`,
|
||||
);
|
||||
return;
|
||||
|
|
@ -177,7 +177,7 @@ export class ApplyManager {
|
|||
) {
|
||||
const { config } = await this.configHandler.loadConfig();
|
||||
if (!config) {
|
||||
vscode.window.showErrorMessage("Config not loaded");
|
||||
void vscode.window.showErrorMessage("Config not loaded");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ChatMessage, DiffLine, ILLM, RuleWithSource } from "core";
|
||||
import { ChatMessage, DiffLine, IDE, ILLM, RuleWithSource } from "core";
|
||||
import { streamDiffLines } from "core/edit/streamDiffLines";
|
||||
import { pruneLinesFromBottom, pruneLinesFromTop } from "core/llm/countTokens";
|
||||
import { getMarkdownLanguageTagForFile } from "core/util";
|
||||
|
|
@ -11,6 +11,9 @@ import { handleLLMError } from "../../util/errorHandling";
|
|||
import { VsCodeWebviewProtocol } from "../../webviewProtocol";
|
||||
|
||||
import { ApplyAbortManager } from "core/edit/applyAbortManager";
|
||||
import { EDIT_MODE_STREAM_ID } from "core/edit/constants";
|
||||
import { stripImages } from "core/util/messageContent";
|
||||
import { EditOutcomeTracker } from "../../extension/EditOutcomeTracker";
|
||||
import { VerticalDiffHandler, VerticalDiffHandlerOptions } from "./handler";
|
||||
|
||||
export interface VerticalDiffCodeLens {
|
||||
|
|
@ -32,6 +35,7 @@ export class VerticalDiffManager {
|
|||
constructor(
|
||||
private readonly webviewProtocol: VsCodeWebviewProtocol,
|
||||
private readonly editDecorationManager: EditDecorationManager,
|
||||
private readonly ide: IDE,
|
||||
) {
|
||||
this.userChangeListener = undefined;
|
||||
}
|
||||
|
|
@ -300,7 +304,11 @@ export class VerticalDiffManager {
|
|||
toolCallId?: string;
|
||||
rulesToInclude: undefined | RuleWithSource[];
|
||||
}): Promise<string | undefined> {
|
||||
vscode.commands.executeCommand("setContext", "continue.diffVisible", true);
|
||||
void vscode.commands.executeCommand(
|
||||
"setContext",
|
||||
"continue.diffVisible",
|
||||
true,
|
||||
);
|
||||
|
||||
let editor = vscode.window.activeTextEditor;
|
||||
|
||||
|
|
@ -435,7 +443,7 @@ export class VerticalDiffManager {
|
|||
);
|
||||
}
|
||||
|
||||
vscode.commands.executeCommand(
|
||||
void vscode.commands.executeCommand(
|
||||
"setContext",
|
||||
"continue.streamingDiff",
|
||||
true,
|
||||
|
|
@ -477,10 +485,18 @@ export class VerticalDiffManager {
|
|||
this.enableDocumentChangeListener();
|
||||
|
||||
if (abortController.signal.aborted) {
|
||||
vscode.commands.executeCommand("continue.rejectDiff");
|
||||
void vscode.commands.executeCommand("continue.rejectDiff");
|
||||
}
|
||||
|
||||
return `${prefix}${streamedLines.join("\n")}${suffix}`;
|
||||
const fileAfterEdit = `${prefix}${streamedLines.join("\n")}${suffix}`;
|
||||
await this.trackEditInteraction({
|
||||
model: llm,
|
||||
filepath: fileUri,
|
||||
prompt: input,
|
||||
fileAfterEdit,
|
||||
});
|
||||
|
||||
return fileAfterEdit;
|
||||
} catch (e) {
|
||||
this.disableDocumentChangeListener();
|
||||
const handled = await handleLLMError(e);
|
||||
|
|
@ -492,11 +508,46 @@ export class VerticalDiffManager {
|
|||
throw new Error(message);
|
||||
}
|
||||
} finally {
|
||||
vscode.commands.executeCommand(
|
||||
void vscode.commands.executeCommand(
|
||||
"setContext",
|
||||
"continue.streamingDiff",
|
||||
false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async trackEditInteraction({
|
||||
model,
|
||||
filepath,
|
||||
prompt,
|
||||
fileAfterEdit,
|
||||
}: {
|
||||
model: ILLM;
|
||||
filepath: string;
|
||||
prompt: string;
|
||||
fileAfterEdit: string | undefined;
|
||||
}) {
|
||||
// Get previous code content for outcome tracking
|
||||
const previousCode = await this.ide.readFile(filepath);
|
||||
const newCode = fileAfterEdit ?? "";
|
||||
const previousCodeLines = previousCode.split("\n").length;
|
||||
const newCodeLines = newCode.split("\n").length;
|
||||
const lineChange = newCodeLines - previousCodeLines;
|
||||
|
||||
// Store pending edit data for outcome tracking
|
||||
EditOutcomeTracker.getInstance().trackEditInteraction({
|
||||
streamId: EDIT_MODE_STREAM_ID,
|
||||
timestamp: new Date().toISOString(),
|
||||
modelProvider: model.underlyingProviderName,
|
||||
modelTitle: model.title ?? "",
|
||||
prompt: stripImages(prompt),
|
||||
completion: newCode,
|
||||
previousCode,
|
||||
newCode,
|
||||
filepath: filepath,
|
||||
previousCodeLines,
|
||||
newCodeLines,
|
||||
lineChange,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,12 +36,12 @@ import {
|
|||
} from "../stubs/WorkOsAuthProvider";
|
||||
import { Battery } from "../util/battery";
|
||||
import { FileSearch } from "../util/FileSearch";
|
||||
import { VsCodeIdeUtils } from "../util/ideUtils";
|
||||
import { VsCodeIde } from "../VsCodeIde";
|
||||
|
||||
import { ConfigYamlDocumentLinkProvider } from "./ConfigYamlDocumentLinkProvider";
|
||||
import { VsCodeMessenger } from "./VsCodeMessenger";
|
||||
|
||||
import { VsCodeIdeUtils } from "../util/ideUtils";
|
||||
import type { VsCodeWebviewProtocol } from "../webviewProtocol";
|
||||
|
||||
export class VsCodeExtension {
|
||||
|
|
@ -66,7 +66,7 @@ export class VsCodeExtension {
|
|||
constructor(context: vscode.ExtensionContext) {
|
||||
// Register auth provider
|
||||
this.workOsAuthProvider = new WorkOsAuthProvider(context, this.uriHandler);
|
||||
this.workOsAuthProvider.refreshSessions();
|
||||
void this.workOsAuthProvider.refreshSessions();
|
||||
context.subscriptions.push(this.workOsAuthProvider);
|
||||
|
||||
this.editDecorationManager = new EditDecorationManager(context);
|
||||
|
|
@ -130,19 +130,20 @@ export class VsCodeExtension {
|
|||
this.configHandler = this.core.configHandler;
|
||||
resolveConfigHandler?.(this.configHandler);
|
||||
|
||||
this.configHandler.loadConfig();
|
||||
void this.configHandler.loadConfig();
|
||||
|
||||
this.verticalDiffManager = new VerticalDiffManager(
|
||||
this.sidebar.webviewProtocol,
|
||||
this.editDecorationManager,
|
||||
this.ide,
|
||||
);
|
||||
resolveVerticalDiffManager?.(this.verticalDiffManager);
|
||||
|
||||
setupRemoteConfigSync(
|
||||
void setupRemoteConfigSync(
|
||||
this.configHandler.reloadConfig.bind(this.configHandler),
|
||||
);
|
||||
|
||||
this.configHandler.loadConfig().then(({ config }) => {
|
||||
void this.configHandler.loadConfig().then(({ config }) => {
|
||||
const { verticalDiffCodeLens } = registerAllCodeLensProviders(
|
||||
context,
|
||||
this.verticalDiffManager.fileUriToCodeLens,
|
||||
|
|
@ -280,7 +281,7 @@ export class VsCodeExtension {
|
|||
if (stats.size === 0) {
|
||||
return;
|
||||
}
|
||||
this.configHandler.reloadConfig();
|
||||
void this.configHandler.reloadConfig();
|
||||
});
|
||||
|
||||
vscode.workspace.onDidSaveTextDocument(async (event) => {
|
||||
|
|
@ -311,7 +312,7 @@ export class VsCodeExtension {
|
|||
vscode.authentication.onDidChangeSessions(async (e) => {
|
||||
const env = await getControlPlaneEnv(this.ide.getIdeSettings());
|
||||
if (e.provider.id === env.AUTH_TYPE) {
|
||||
vscode.commands.executeCommand(
|
||||
void vscode.commands.executeCommand(
|
||||
"setContext",
|
||||
"continue.isSignedInToControlPlane",
|
||||
true,
|
||||
|
|
@ -322,7 +323,7 @@ export class VsCodeExtension {
|
|||
sessionInfo,
|
||||
});
|
||||
} else {
|
||||
vscode.commands.executeCommand(
|
||||
void vscode.commands.executeCommand(
|
||||
"setContext",
|
||||
"continue.isSignedInToControlPlane",
|
||||
false,
|
||||
|
|
@ -335,7 +336,7 @@ export class VsCodeExtension {
|
|||
});
|
||||
|
||||
// Refresh index when branch is changed
|
||||
this.ide.getWorkspaceDirs().then((dirs) =>
|
||||
void this.ide.getWorkspaceDirs().then((dirs) =>
|
||||
dirs.forEach(async (dir) => {
|
||||
const repo = await this.ide.getRepo(dir);
|
||||
if (repo) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import {
|
|||
import { handleLLMError } from "../util/errorHandling";
|
||||
import { showTutorial } from "../util/tutorial";
|
||||
import { getExtensionUri } from "../util/vscode";
|
||||
import { EditOutcomeTracker } from "./EditOutcomeTracker";
|
||||
import { VsCodeIde } from "../VsCodeIde";
|
||||
import { VsCodeWebviewProtocol } from "../webviewProtocol";
|
||||
|
||||
|
|
@ -231,29 +230,6 @@ export class VsCodeMessenger {
|
|||
rulesToInclude: config.rules,
|
||||
});
|
||||
|
||||
// Get previous code content for outcome tracking
|
||||
const previousCode = await ide.readFile(msg.data.range.filepath);
|
||||
const newCode = fileAfterEdit ?? "";
|
||||
const previousCodeLines = previousCode.split('\n').length;
|
||||
const newCodeLines = newCode.split('\n').length;
|
||||
const lineChange = newCodeLines - previousCodeLines;
|
||||
|
||||
// Store pending edit data for outcome tracking
|
||||
EditOutcomeTracker.getInstance().trackEditInteraction({
|
||||
streamId: EDIT_MODE_STREAM_ID,
|
||||
timestamp: new Date().toISOString(),
|
||||
modelProvider: model.underlyingProviderName,
|
||||
modelTitle: model.title ?? "",
|
||||
prompt: stripImages(prompt),
|
||||
completion: newCode,
|
||||
previousCode,
|
||||
newCode,
|
||||
filepath: msg.data.range.filepath,
|
||||
previousCodeLines,
|
||||
newCodeLines,
|
||||
lineChange,
|
||||
});
|
||||
|
||||
// Log dev data
|
||||
await DataLogger.getInstance().logDevData({
|
||||
name: "editInteraction",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue