diff options
author | Nate Sesti <33237525+sestinj@users.noreply.github.com> | 2023-07-11 15:14:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-11 15:14:53 -0700 |
commit | 9adfb8bf5b9f44be82488e37bc32cbd9a8817b53 (patch) | |
tree | 8399d02483267ec024034a923475bd6eaf397154 /extension | |
parent | 3f9e7a1fa59c4f684aef544436062f8825d77b31 (diff) | |
parent | 9846f4769ff33a346d76e26ad730d19770fe7e02 (diff) | |
download | sncontinue-9adfb8bf5b9f44be82488e37bc32cbd9a8817b53.tar.gz sncontinue-9adfb8bf5b9f44be82488e37bc32cbd9a8817b53.tar.bz2 sncontinue-9adfb8bf5b9f44be82488e37bc32cbd9a8817b53.zip |
Merge pull request #237 from continuedev/bug-squashing
Bug squashing
Diffstat (limited to 'extension')
-rw-r--r-- | extension/package-lock.json | 4 | ||||
-rw-r--r-- | extension/package.json | 2 | ||||
-rw-r--r-- | extension/react-app/src/components/ComboBox.tsx | 33 | ||||
-rw-r--r-- | extension/react-app/src/tabs/gui.tsx | 11 | ||||
-rw-r--r-- | extension/src/activation/activate.ts | 22 | ||||
-rw-r--r-- | extension/src/activation/environmentSetup.ts | 46 | ||||
-rw-r--r-- | extension/src/diffs.ts | 24 |
7 files changed, 97 insertions, 45 deletions
diff --git a/extension/package-lock.json b/extension/package-lock.json index 71f4d974..b6147b2c 100644 --- a/extension/package-lock.json +++ b/extension/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.0.147", + "version": "0.0.151", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.0.147", + "version": "0.0.151", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extension/package.json b/extension/package.json index d9f155df..a57f6065 100644 --- a/extension/package.json +++ b/extension/package.json @@ -14,7 +14,7 @@ "displayName": "Continue", "pricing": "Free", "description": "The open-source coding autopilot", - "version": "0.0.147", + "version": "0.0.151", "publisher": "Continue", "engines": { "vscode": "^1.67.0" diff --git a/extension/react-app/src/components/ComboBox.tsx b/extension/react-app/src/components/ComboBox.tsx index 801c3a03..ac994b0a 100644 --- a/extension/react-app/src/components/ComboBox.tsx +++ b/extension/react-app/src/components/ComboBox.tsx @@ -180,6 +180,26 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { useImperativeHandle(ref, () => downshiftProps, [downshiftProps]); + const [metaKeyPressed, setMetaKeyPressed] = useState(false); + useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + if (e.key === "Meta") { + setMetaKeyPressed(true); + } + }; + const handleKeyUp = (e: KeyboardEvent) => { + if (e.key === "Meta") { + setMetaKeyPressed(false); + } + }; + window.addEventListener("keydown", handleKeyDown); + window.addEventListener("keyup", handleKeyUp); + return () => { + window.removeEventListener("keydown", handleKeyDown); + window.removeEventListener("keyup", handleKeyUp); + }; + }); + useEffect(() => { if (!inputRef.current) { return; @@ -272,7 +292,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { <div className="flex px-2" ref={divRef} hidden={!downshiftProps.isOpen}> <MainTextInput disabled={props.disabled} - placeholder="Ask a question, give instructions, or type '/' to see slash commands" + placeholder="Ask a question, give instructions, or type '/' to see slash commands. ⌘⏎ to edit." {...getInputProps({ onChange: (e) => { const target = e.target as HTMLTextAreaElement; @@ -357,10 +377,13 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { ))} </Ul> </div> - {/* <span className="text-trueGray-400 ml-auto m-auto text-xs text-right"> - Highlight code to include as context. Currently open file included by - default. {highlightedCodeSections.length === 0 && ""} - </span> */} + {highlightedCodeSections.length === 0 && + (downshiftProps.inputValue?.startsWith("/edit") || + (metaKeyPressed && downshiftProps.inputValue?.length > 0)) && ( + <div className="text-trueGray-400 pr-4 text-xs text-right"> + Inserting at cursor + </div> + )} <ContextDropdown onMouseEnter={() => { setHoveringContextDropdown(true); diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx index 0e60e05c..619b91e1 100644 --- a/extension/react-app/src/tabs/gui.tsx +++ b/extension/react-app/src/tabs/gui.tsx @@ -170,6 +170,7 @@ function GUI(props: GUIProps) { const waitingForSteps = state.active && state.history.current_index < state.history.timeline.length && + state.history.timeline[state.history.current_index] && state.history.timeline[ state.history.current_index ].step.description?.trim() === ""; @@ -236,14 +237,14 @@ function GUI(props: GUIProps) { history.current_index < history.timeline.length ) { if ( - history.timeline[history.current_index].step.name === + history.timeline[history.current_index]?.step.name === "Waiting for user input" ) { if (input.trim() === "") return; onStepUserInput(input, history!.current_index); return; } else if ( - history.timeline[history.current_index].step.name === + history.timeline[history.current_index]?.step.name === "Waiting for user confirmation" ) { onStepUserInput("ok", history!.current_index); @@ -350,12 +351,6 @@ function GUI(props: GUIProps) { </div> <ComboBox - // disabled={ - // history?.timeline.length - // ? history.timeline[history.current_index].step.name === - // "Waiting for user confirmation" - // : false - // } ref={mainTextInputRef} onEnter={(e) => { onMainTextInput(e); diff --git a/extension/src/activation/activate.ts b/extension/src/activation/activate.ts index 18650561..2c5ba58c 100644 --- a/extension/src/activation/activate.ts +++ b/extension/src/activation/activate.ts @@ -7,9 +7,16 @@ import IdeProtocolClient from "../continueIdeClient"; import { getContinueServerUrl } from "../bridge"; import { CapturedTerminal } from "../terminal/terminalEmulator"; import { setupDebugPanel, ContinueGUIWebviewViewProvider } from "../debugPanel"; -import { startContinuePythonServer } from "./environmentSetup"; +import { + getExtensionVersion, + startContinuePythonServer, +} from "./environmentSetup"; +import fetch from "node-fetch"; // import { CapturedTerminal } from "../terminal/terminalEmulator"; +const PACKAGE_JSON_RAW_GITHUB_URL = + "https://raw.githubusercontent.com/continuedev/continue/main/extension/package.json"; + export let extensionContext: vscode.ExtensionContext | undefined = undefined; export let ideProtocolClient: IdeProtocolClient; @@ -20,6 +27,19 @@ export async function activateExtension( ) { extensionContext = context; + // Before anything else, check whether this is an out-of-date version of the extension + // Do so by grabbing the package.json off of the GitHub respository for now. + fetch(PACKAGE_JSON_RAW_GITHUB_URL) + .then(async (res) => res.json()) + .then((packageJson) => { + if (packageJson.version !== getExtensionVersion()) { + vscode.window.showInformationMessage( + `You are using an out-of-date version of the Continue extension. Please update to the latest version.` + ); + } + }) + .catch((e) => console.log("Error checking for extension updates: ", e)); + await new Promise((resolve, reject) => { vscode.window.withProgress( { diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts index 02118501..c277a539 100644 --- a/extension/src/activation/environmentSetup.ts +++ b/extension/src/activation/environmentSetup.ts @@ -22,7 +22,7 @@ async function retryThenFail( if (retries > 0) { return await retryThenFail(fn, retries - 1); } - vscode.window.showErrorMessage( + vscode.window.showInformationMessage( "Failed to set up Continue extension. Please email nate@continue.dev and we'll get this fixed ASAP!" ); sendTelemetryEvent(TelemetryEvent.ExtensionSetupError, { @@ -156,10 +156,7 @@ async function checkRequirementsInstalled() { activateCmd, `${pipCmd} uninstall -y continuedev`, ].join(" ; "); - const [, stderr] = await runCommand(removeOldVersionCommand); - if (stderr) { - throw new Error(stderr); - } + await runCommand(removeOldVersionCommand); return false; } } @@ -224,6 +221,9 @@ async function setupPythonEnv() { // First, try to run the command to install python3-venv let [stdout, stderr] = await runCommand(`${pythonCmd} --version`); if (stderr) { + await vscode.window.showErrorMessage( + "Python3 is not installed. Please install from https://www.python.org/downloads, reload VS Code, and try again." + ); throw new Error(stderr); } const version = stdout.split(" ")[1].split(".")[1]; @@ -351,7 +351,7 @@ function requirementsVersionPath(): string { return path.join(serverPath(), "requirements_version.txt"); } -function getExtensionVersion() { +export function getExtensionVersion() { const extension = vscode.extensions.getExtension("continue.continue"); return extension?.packageJSON.version || ""; } @@ -366,24 +366,26 @@ export async function startContinuePythonServer() { setupServerPath(); return await retryThenFail(async () => { - if (await checkServerRunning(serverUrl)) { - // Kill the server if it is running an old version - if (fs.existsSync(serverVersionPath())) { - const serverVersion = fs.readFileSync(serverVersionPath(), "utf8"); - if (serverVersion === getExtensionVersion()) { - return; - } - } - console.log("Killing old server..."); - try { - await fkill(":65432"); - } catch (e) { - console.log( - "Failed to kill old server, likely because it didn't exist:", - e - ); + // Kill the server if it is running an old version + if (fs.existsSync(serverVersionPath())) { + const serverVersion = fs.readFileSync(serverVersionPath(), "utf8"); + if ( + serverVersion === getExtensionVersion() && + (await checkServerRunning(serverUrl)) + ) { + // The current version is already up and running, no need to continue + return; } } + console.log("Killing old server..."); + try { + await fkill(":65432"); + } catch (e) { + console.log( + "Failed to kill old server, likely because it didn't exist:", + e + ); + } // Do this after above check so we don't have to waste time setting up the env await setupPythonEnv(); diff --git a/extension/src/diffs.ts b/extension/src/diffs.ts index b9ef8384..3ea6b4f8 100644 --- a/extension/src/diffs.ts +++ b/extension/src/diffs.ts @@ -132,11 +132,18 @@ class DiffManager { console.log("No corresponding diffInfo found for newFilepath"); return; } - fs.writeFileSync( - diffInfo.originalFilepath, - fs.readFileSync(diffInfo.newFilepath) - ); - this.cleanUpDiff(diffInfo); + + // Save the right-side file, then copy over to original + vscode.workspace.textDocuments + .find((doc) => doc.uri.fsPath === newFilepath) + ?.save() + .then(() => { + fs.writeFileSync( + diffInfo.originalFilepath, + fs.readFileSync(diffInfo.newFilepath) + ); + this.cleanUpDiff(diffInfo); + }); } rejectDiff(newFilepath?: string) { @@ -157,7 +164,12 @@ class DiffManager { // Stop the step at step_index in case it is still streaming ideProtocolClient.deleteAtIndex(diffInfo.step_index); - this.cleanUpDiff(diffInfo); + vscode.workspace.textDocuments + .find((doc) => doc.uri.fsPath === newFilepath) + ?.save() + .then(() => { + this.cleanUpDiff(diffInfo); + }); } } |