many fixes

This commit is contained in:
Nate Sesti 2023-07-04 13:43:09 -07:00
parent 6d535c02e5
commit 67e70b868f
10 changed files with 37 additions and 25 deletions

View file

@ -144,9 +144,7 @@ class Autopilot(ContinueBaseModel):
async def handle_highlighted_code(self, range_in_files: List[RangeInFileWithContents]):
workspace_path = self.continue_sdk.ide.workspace_directory
for rif in range_in_files:
rif.filepath = os.path.relpath(rif.filepath, workspace_path)
if rif.filepath.startswith(".."):
rif.filepath = os.path.basename(rif.filepath)
rif.filepath = os.path.basename(rif.filepath)
# If current range overlaps with any others, delete them and only keep the new range
new_ranges = []
@ -156,6 +154,13 @@ class Autopilot(ContinueBaseModel):
if rif.filepath == new_rif.filepath and rif.range.overlaps_with(new_rif.range):
found_overlap = True
break
# Also don't allow multiple ranges in same file with same content. This is useless to the model, and avoids
# the bug where cmd+f causes repeated highlights
if rif.filepath == new_rif.filepath and rif.contents == new_rif.contents:
found_overlap = True
break
if not found_overlap:
new_ranges.append(rif)

View file

@ -107,11 +107,9 @@ class HistoryNode(ContinueBaseModel):
return self.step.chat_context
return self.step.chat_context + [
ChatMessage(
role="function",
role="assistant",
name=self.step.__class__.__name__,
content=json.dumps({
"description": self.step.description or "Function complete",
}),
content=self.step.description or f"Ran function {self.step.name}",
summary=f"Called function {self.step.name}"
)]
@ -200,6 +198,7 @@ class SlashCommandDescription(ContinueBaseModel):
name: str
description: str
class FullState(ContinueBaseModel):
"""A full state of the program, including the history"""
history: History

View file

@ -97,7 +97,18 @@ class ContinueSDK(AbstractContinueSDK):
async def _ensure_absolute_path(self, path: str) -> str:
if os.path.isabs(path):
return path
return os.path.join(self.ide.workspace_directory, path)
# Else if in workspace
workspace_path = os.path.join(self.ide.workspace_directory, path)
if os.path.exists(workspace_path):
return workspace_path
else:
# Check if it matches any of the open files, then use that absolute path
open_files = await self.ide.getOpenFiles()
for open_file in open_files:
if os.path.basename(open_file) == os.path.basename(path):
return open_file
raise Exception(f"Path {path} does not exist")
async def run_step(self, step: Step) -> Coroutine[Observation, None, None]:
return await self.__autopilot._run_singular_step(step)

View file

@ -149,6 +149,7 @@ class ChatWithFunctions(Step):
name: str = "Input"
manage_own_chat_context: bool = True
description: str = ""
hide: bool = True
async def run(self, sdk: ContinueSDK):
await sdk.update_ui()

View file

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

View file

@ -14,7 +14,7 @@
"displayName": "Continue",
"pricing": "Free",
"description": "The open-source coding autopilot",
"version": "0.0.106",
"version": "0.0.107",
"publisher": "Continue",
"engines": {
"vscode": "^1.67.0"
@ -55,7 +55,7 @@
},
"continue.OPENAI_API_KEY": {
"type": "password",
"default": "",
"default": null,
"description": "The OpenAI API key to use for code generation."
},
"continue.dataSwitch": {

View file

@ -279,13 +279,9 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
)}
{highlightedCodeSections.map((section, idx) => (
<PillButton
title={
hoveringButton
? `${section.filepath} (${section.range.start.line + 1}-${
section.range.end.line + 1
})`
: section.filepath
}
title={`${section.filepath} (${section.range.start.line + 1}-${
section.range.end.line + 1
})`}
onDelete={() => {
if (props.deleteContextItems) {
props.deleteContextItems([idx]);

View file

@ -50,7 +50,6 @@ const PillButton = (props: PillButtonProps) => {
borderRight: "1px solid black",
paddingRight: "4px",
}}
hidden={!isHovered}
onClick={() => {
props.onDelete?.();
props.onHover?.(false);

View file

@ -6,10 +6,12 @@ import HeaderButtonWithText from "./HeaderButtonWithText";
import { Play, XMark } from "@styled-icons/heroicons-outline";
import { RootStore } from "../redux/store";
import { useSelector } from "react-redux";
import { HistoryNode } from "../../../schema/HistoryNode";
interface UserInputContainerProps {
onDelete: () => void;
children: string;
historyNode: HistoryNode;
}
const StyledDiv = styled.div`
@ -26,7 +28,7 @@ const StyledDiv = styled.div`
const UserInputContainer = (props: UserInputContainerProps) => {
return (
<StyledDiv>
<StyledDiv hidden={props.historyNode.step.hide as any}>
{props.children}
<div style={{ marginLeft: "auto" }}>
<HeaderButtonWithText
@ -36,7 +38,7 @@ const UserInputContainer = (props: UserInputContainerProps) => {
}}
text="Delete"
>
<XMark size="1.6em" onClick={props.onDelete} />
<XMark size="1.6em" />
</HeaderButtonWithText>
</div>
</StyledDiv>

View file

@ -70,9 +70,7 @@ function GUI(props: GUIProps) {
const [usingFastModel, setUsingFastModel] = useState(false);
const [waitingForSteps, setWaitingForSteps] = useState(false);
const [userInputQueue, setUserInputQueue] = useState<string[]>([]);
const [highlightedRanges, setHighlightedRanges] = useState([
{ filepath: "abc.txt", range: { start: { line: 2 }, end: { line: 4 } } },
]);
const [highlightedRanges, setHighlightedRanges] = useState([]);
const [availableSlashCommands, setAvailableSlashCommands] = useState<
{ name: string; description: string }[]
>([]);
@ -296,6 +294,7 @@ function GUI(props: GUIProps) {
onDelete={() => {
client?.deleteAtIndex(index);
}}
historyNode={node}
>
{node.step.description as string}
</UserInputContainer>