polishing

This commit is contained in:
Nate Sesti 2023-06-16 23:42:10 -07:00
parent a1c3251308
commit 1ea00ebe40
15 changed files with 90 additions and 20 deletions

View file

@ -52,6 +52,11 @@ class ContinueConfig(BaseModel):
name="feedback",
description="Send feedback to improve Continue",
step_name="FeedbackStep",
),
SlashCommand(
name="clear",
description="Clear step history",
step_name="ClearHistoryStep",
)
]
on_traceback: Optional[List[OnTracebackSteps]] = [
@ -68,10 +73,16 @@ def load_config(config_file: str) -> ContinueConfig:
_, ext = os.path.splitext(config_file)
if ext == '.yaml':
with open(config_file, 'r') as f:
config_dict = yaml.safe_load(f)
try:
config_dict = yaml.safe_load(f)
except:
return ContinueConfig()
elif ext == '.json':
with open(config_file, 'r') as f:
config_dict = json.load(f)
try:
config_dict = json.load(f)
except:
return ContinueConfig()
else:
raise ValueError(f'Unknown config file extension: {ext}')
return ContinueConfig(**config_dict)

View file

@ -192,3 +192,6 @@ class ContinueSDK(AbstractContinueSDK):
async def update_ui(self):
await self.__autopilot.update_subscribers()
async def clear_history(self):
await self.__autopilot.clear_history()

View file

@ -18,7 +18,7 @@ CHAT_MODELS = {
}
# SERVER_URL = "http://127.0.0.1:8080"
SERVER_URL = "https://proxy-server-l6vsfbzhba-uc.a.run.app"
SERVER_URL = "https://proxy-server-l6vsfbzhba-uw.a.run.app"
class ProxyServer(LLM):

View file

@ -11,6 +11,7 @@ from ...recipes.CreatePipelineRecipe.main import CreatePipelineRecipe
from ...recipes.DDtoBQRecipe.main import DDtoBQRecipe
from ...recipes.DeployPipelineAirflowRecipe.main import DeployPipelineAirflowRecipe
from ...steps.on_traceback import DefaultOnTracebackStep
from ...steps.clear_history import ClearHistoryStep
# This mapping is used to convert from string in ContinueConfig json to corresponding Step class.
# Used for example in slash_commands and steps_on_startup
@ -25,6 +26,7 @@ step_name_to_step_class = {
"DDtoBQRecipe": DDtoBQRecipe,
"DeployPipelineAirflowRecipe": DeployPipelineAirflowRecipe,
"DefaultOnTracebackStep": DefaultOnTracebackStep,
"ClearHistoryStep": ClearHistoryStep,
}

View file

@ -0,0 +1,10 @@
from ..core.main import Step
from ..core.sdk import ContinueSDK
class ClearHistoryStep(Step):
name: str = "Clear History"
hide: bool = True
async def run(self, sdk: ContinueSDK):
await sdk.clear_history()

View file

@ -186,6 +186,8 @@ class DefaultModelEditCodeStep(Step):
completion = completion.removesuffix(eot_token)
# Remove tags and If it accidentally includes prefix or suffix, remove it
if completion.strip().startswith("```"):
completion = completion.strip().removeprefix("```").removesuffix("```")
completion = completion.replace("<file_prefix>", "").replace("<file_suffix>", "").replace(
"<commit_before>", "").replace("<commit_msg>", "").replace("<commit_after>", "")
completion = completion.removeprefix(segs[0])

View file

@ -1,12 +1,12 @@
{
"name": "continue",
"version": "0.0.47",
"version": "0.0.50",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "continue",
"version": "0.0.47",
"version": "0.0.50",
"license": "Apache-2.0",
"dependencies": {
"@electron/rebuild": "^3.2.10",

View file

@ -14,7 +14,7 @@
"displayName": "Continue",
"pricing": "Free",
"description": "Refine code 10x faster",
"version": "0.0.47",
"version": "0.0.50",
"publisher": "Continue",
"engines": {
"vscode": "^1.74.0"
@ -86,8 +86,8 @@
"activitybar": [
{
"id": "continue",
"title": "Continue",
"icon": "media/continue-gradient.png"
"title": "Continue ",
"icon": "react-app/dist/continue_arrow.png"
}
]
},
@ -96,7 +96,7 @@
{
"type": "webview",
"id": "continue.continueGUIView",
"name": ")",
"name": " )",
"visibility": "visible"
}
]

View file

@ -68,6 +68,9 @@ interface ComboBoxProps {
}
const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
const [history, setHistory] = React.useState<string[]>([]);
// The position of the current command you are typing now, so the one that will be appended to history once you press enter
const [positionInHistory, setPositionInHistory] = React.useState<number>(0);
const [items, setItems] = React.useState(props.items);
const {
isOpen,
@ -113,9 +116,27 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
(event.nativeEvent as any).preventDownshiftDefault = true;
if (props.onEnter) props.onEnter(event);
setInputValue("");
const value = event.currentTarget.value;
if (value !== "") {
setPositionInHistory(history.length + 1);
setHistory([...history, value]);
}
} else if (event.key === "Tab" && items.length > 0) {
setInputValue(items[0].name);
event.preventDefault();
} else if (event.key === "ArrowUp" && !isOpen) {
if (positionInHistory == 0) return;
setInputValue(history[positionInHistory - 1]);
setPositionInHistory((prev) => prev - 1);
} else if (event.key === "ArrowDown" && !isOpen) {
if (positionInHistory >= history.length - 1) {
setInputValue("");
} else {
setInputValue(history[positionInHistory + 1]);
}
setPositionInHistory((prev) =>
Math.min(prev + 1, history.length)
);
}
},
ref: ref as any,

View file

@ -15,9 +15,7 @@ const HeaderButtonWithText = (props: HeaderButtonWithTextProps) => {
style={{ padding: "3px" }}
onMouseEnter={() => setHover(true)}
onMouseLeave={() => {
setTimeout(() => {
setHover(false);
}, 100);
setHover(false);
}}
onClick={props.onClick}
>

View file

@ -63,7 +63,6 @@ const HeaderDiv = styled.div<{ error: boolean }>`
const ContentDiv = styled.div`
padding: 8px;
padding-left: 16px;
background-color: ${vscBackground};
`;
const OnHoverDiv = styled.div`

View file

@ -1,5 +1,5 @@
// Write a component that displays a dialog box with a text field and a button.
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import styled from "styled-components";
import { Button, buttonColor, secondaryDark, vscBackground } from ".";
@ -28,6 +28,10 @@ const TextArea = styled.textarea`
padding: 8px;
outline: 1px solid black;
font-family: Arial, Helvetica, sans-serif;
&:focus {
outline: 1px solid orange;
}
`;
const P = styled.p`
@ -38,19 +42,39 @@ const P = styled.p`
const TextDialog = (props: {
showDialog: boolean;
onEnter: (text: string) => void;
onClose: () => void;
}) => {
const [text, setText] = useState("");
const textAreaRef = React.createRef<HTMLTextAreaElement>();
useEffect(() => {
if (textAreaRef.current) {
textAreaRef.current.focus();
}
}, [props.showDialog]);
return (
<DialogContainer hidden={!props.showDialog}>
<Dialog>
<P>Thanks for your feedback. We'll get back to you soon!</P>
<TextArea cols={50} rows={10} ref={textAreaRef}></TextArea>
<TextArea
cols={50}
rows={10}
ref={textAreaRef}
onKeyDown={(e) => {
if (e.key === "Enter" && e.metaKey && textAreaRef.current) {
props.onEnter(textAreaRef.current.value);
setText("");
} else if (e.key === "Escape") {
props.onClose();
}
}}
/>
<Button
onClick={() => {
if (textAreaRef.current) {
props.onEnter(textAreaRef.current.value);
setText("");
}
}}
>

View file

@ -297,6 +297,9 @@ function GUI(props: GUIProps) {
client?.sendMainInput(`/feedback ${text}`);
setShowFeedbackDialog(false);
}}
onClose={() => {
setShowFeedbackDialog(false);
}}
></TextDialog>
<TopGUIDiv

View file

@ -61,12 +61,9 @@ const commandsMap: { [command: string]: (...args: any) => any } = {
"continue.suggestionUp": suggestionUpCommand,
"continue.acceptSuggestion": acceptSuggestionCommand,
"continue.rejectSuggestion": rejectSuggestionCommand,
"continue.openContinueGUI": () => {
ideProtocolClient.openGUI();
},
"continue.focusContinueInput": async () => {
if (!debugPanelWebview) {
await ideProtocolClient.openGUI();
vscode.commands.executeCommand("continue.continueGUIView.focus");
}
debugPanelWebview?.postMessage({
type: "focusContinueInput",

View file

@ -192,7 +192,7 @@ class IdeProtocolClient {
async getUserSecret(key: string) {
// Check if secret already exists in VS Code settings (global)
let secret = vscode.workspace.getConfiguration("continue").get(key);
if (typeof secret !== "undefined") return secret;
if (typeof secret !== "undefined" && secret !== null) return secret;
// If not, ask user for secret
secret = await vscode.window.showInputBox({