Skip to content

Commit

Permalink
✨ feedback mechanism for autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
sestinj committed Jun 12, 2024
1 parent 2ac8a46 commit d25b866
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 1 deletion.
19 changes: 19 additions & 0 deletions core/continueServer/stubs/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,23 @@ export class ContinueServerClient implements IContinueServerClient {
): Promise<EmbeddingsCacheResponse<T>> {
return { files: {} };
}

public async sendFeedback(feedback: string, data: string): Promise<void> {
if (!this.url) {
return;
}

const url = new URL("feedback", this.url);

const response = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${await this.userToken}`,
},
body: JSON.stringify({
feedback,
data,
}),
});
}
}
9 changes: 9 additions & 0 deletions extensions/vscode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions extensions/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@
"posthog-node": "^3.6.3",
"react-markdown": "^8.0.7",
"react-redux": "^8.0.5",
"read-last-lines": "^1.8.0",
"request": "^2.88.2",
"socket.io-client": "^4.7.2",
"strip-ansi": "^7.1.0",
Expand Down
26 changes: 25 additions & 1 deletion extensions/vscode/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import * as vscode from "vscode";
import { ContextMenuConfig, IDE } from "core";
import { CompletionProvider } from "core/autocomplete/completionProvider";
import { ConfigHandler } from "core/config/handler";
import { ContinueServerClient } from "core/continueServer/stubs/client";
import { fetchwithRequestOptions } from "core/util/fetchWithOptions";
import { GlobalContext } from "core/util/GlobalContext";
import { getConfigJsonPath } from "core/util/paths";
import { getConfigJsonPath, getDevDataFilePath } from "core/util/paths";
import readLastLines from "read-last-lines";
import { ContinueGUIWebviewViewProvider } from "./debugPanel";
import { DiffManager } from "./diff/horizontal";
import { VerticalPerLineDiffManager } from "./diff/verticalPerLine/manager";
Expand Down Expand Up @@ -142,13 +144,15 @@ const commandsMap: (
configHandler: ConfigHandler,
diffManager: DiffManager,
verticalDiffManager: VerticalPerLineDiffManager,
continueServerClientPromise: Promise<ContinueServerClient>,
) => { [command: string]: (...args: any) => any } = (
ide,
extensionContext,
sidebar,
configHandler,
diffManager,
verticalDiffManager,
continueServerClientPromise,
) => {
async function streamInlineEdit(
promptName: keyof ContextMenuConfig,
Expand Down Expand Up @@ -552,6 +556,9 @@ const commandsMap: (
{
label: "$(gear) Configure autocomplete options",
},
{
label: "$(feedback) Give feedback",
},
{
kind: vscode.QuickPickItemKind.Separator,
label: "Switch model",
Expand Down Expand Up @@ -585,11 +592,26 @@ const commandsMap: (
selectedOption,
);
configHandler.reloadConfig();
} else if (selectedOption === "$(feedback) Give feedback") {
vscode.commands.executeCommand("continue.giveAutocompleteFeedback");
}
quickPick.dispose();
});
quickPick.show();
},
"continue.giveAutocompleteFeedback": async () => {
const feedback = await vscode.window.showInputBox({
prompt:
"Please share what went wrong with the last completion. The details of the completion as well as this message will be sent to the Continue team in order to improve.",
});
if (feedback) {
const client = await continueServerClientPromise;
const completionsPath = getDevDataFilePath("autocomplete");

const lastLines = await readLastLines.read(completionsPath, 2);
client.sendFeedback(feedback, lastLines);
}
},
};
};

Expand All @@ -601,6 +623,7 @@ export function registerAllCommands(
configHandler: ConfigHandler,
diffManager: DiffManager,
verticalDiffManager: VerticalPerLineDiffManager,
continueServerClientPromise: Promise<ContinueServerClient>,
) {
for (const [command, callback] of Object.entries(
commandsMap(
Expand All @@ -610,6 +633,7 @@ export function registerAllCommands(
configHandler,
diffManager,
verticalDiffManager,
continueServerClientPromise,
),
)) {
context.subscriptions.push(
Expand Down
1 change: 1 addition & 0 deletions extensions/vscode/src/extension/vscodeExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export class VsCodeExtension {
this.configHandler,
this.diffManager,
this.verticalDiffManager,
this.core.continueServerClientPromise,
);

registerDebugTracker(this.sidebar.webviewProtocol, this.ide);
Expand Down

0 comments on commit d25b866

Please sign in to comment.