explain accept/reject, better edit summaries

This commit is contained in:
Nate Sesti 2023-07-11 16:40:11 -07:00
parent a6c2490bc3
commit 72ade10802
2 changed files with 41 additions and 7 deletions

View file

@ -152,7 +152,8 @@ class DefaultModelEditCodeStep(Step):
Main task:
""")
_previous_contents: str = ""
_new_contents: str = ""
_prompt_and_completion: str = ""
def _cleanup_output(self, output: str) -> str:
@ -167,13 +168,19 @@ class DefaultModelEditCodeStep(Step):
return output
async def describe(self, models: Models) -> Coroutine[str, None, None]:
if self._prompt_and_completion == "":
if self._previous_contents.strip() == self._new_contents.strip():
description = "No edits were made"
else:
description = await models.gpt3516k.complete(dedent(f"""\
{self._prompt_and_completion}
Please give brief a description of the changes made above using markdown bullet points. Be concise and only mention changes made to the commit before, not prefix or suffix:"""))
```original
{self._previous_contents}
```
```new
{self._new_contents}
```
Please give brief a description of the changes made above using markdown bullet points. Be concise:"""))
name = await models.gpt3516k.complete(f"Write a very short title to describe this requested change (no quotes): '{self.user_input}'. This is the title:")
self.name = self._cleanup_output(name)
@ -573,6 +580,8 @@ Please output the code to be inserted at the cursor in order to fulfill the user
# Record the completion
completion = "\n".join(lines)
self._previous_contents = "\n".join(original_lines)
self._new_contents = completion
self._prompt_and_completion += prompt + completion
async def run(self, sdk: ContinueSDK) -> Coroutine[Observation, None, None]:

View file

@ -2,7 +2,7 @@ import * as os from "os";
import * as path from "path";
import * as fs from "fs";
import * as vscode from "vscode";
import { ideProtocolClient } from "./activation/activate";
import { extensionContext, ideProtocolClient } from "./activation/activate";
interface DiffInfo {
originalFilepath: string;
@ -70,6 +70,28 @@ class DiffManager {
.getConfiguration("diffEditor", editor.document.uri)
.update("codeLens", true, vscode.ConfigurationTarget.Global);
if (
extensionContext?.globalState.get<boolean>(
"continue.showDiffInfoMessage"
) !== false
) {
vscode.window
.showInformationMessage(
"Accept (⌘⇧↩) or reject (⌘⇧⌫) at the top of the file.",
"Got it",
"Don't show again"
)
.then((selection) => {
if (selection === "Don't show again") {
// Get the global state
extensionContext?.globalState.update(
"continue.showDiffInfoMessage",
false
);
}
});
}
return editor;
}
@ -152,7 +174,10 @@ class DiffManager {
newFilepath = Array.from(this.diffs.keys())[0];
}
if (!newFilepath) {
console.log("No newFilepath provided to reject the diff");
console.log(
"No newFilepath provided to reject the diff, diffs.size was",
this.diffs.size
);
return;
}
const diffInfo = this.diffs.get(newFilepath);