diff options
-rw-r--r-- | continuedev/src/continuedev/core/autopilot.py | 2 | ||||
-rw-r--r-- | continuedev/src/continuedev/core/sdk.py | 10 | ||||
-rw-r--r-- | continuedev/src/continuedev/recipes/TemplateRecipe/main.py | 4 | ||||
-rw-r--r-- | continuedev/src/continuedev/recipes/WritePytestsRecipe/main.py | 2 | ||||
-rw-r--r-- | continuedev/src/continuedev/server/ide.py | 8 | ||||
-rw-r--r-- | continuedev/src/continuedev/server/ide_protocol.py | 4 | ||||
-rw-r--r-- | continuedev/src/continuedev/steps/main.py | 18 | ||||
-rw-r--r-- | continuedev/src/continuedev/steps/welcome.py | 2 | ||||
-rw-r--r-- | extension/react-app/src/components/StepContainer.tsx | 4 | ||||
-rw-r--r-- | extension/src/bridge.ts | 2 | ||||
-rw-r--r-- | extension/src/continueIdeClient.ts | 11 |
11 files changed, 40 insertions, 27 deletions
diff --git a/continuedev/src/continuedev/core/autopilot.py b/continuedev/src/continuedev/core/autopilot.py index ac00e4f0..1b074435 100644 --- a/continuedev/src/continuedev/core/autopilot.py +++ b/continuedev/src/continuedev/core/autopilot.py @@ -208,6 +208,8 @@ class Autopilot(ContinueBaseModel): async def delete_at_index(self, index: int): self.history.timeline[index].step.hide = True self.history.timeline[index].deleted = True + self.history.timeline[index].active = False + await self.update_subscribers() async def delete_context_at_indices(self, indices: List[int]): diff --git a/continuedev/src/continuedev/core/sdk.py b/continuedev/src/continuedev/core/sdk.py index a3441ad9..aa2d8892 100644 --- a/continuedev/src/continuedev/core/sdk.py +++ b/continuedev/src/continuedev/core/sdk.py @@ -204,14 +204,14 @@ class ContinueSDK(AbstractContinueSDK): preface = "The following code is highlighted" + # If no higlighted ranges, use first file as context if len(highlighted_code) == 0: preface = "The following file is open" - # Get the full contents of all open files - files = await self.ide.getOpenFiles() - if len(files) > 0: - content = await self.ide.readFile(files[0]) + visible_files = await self.ide.getVisibleFiles() + if len(visible_files) > 0: + content = await self.ide.readFile(visible_files[0]) highlighted_code = [ - RangeInFileWithContents.from_entire_file(files[0], content)] + RangeInFileWithContents.from_entire_file(visible_files[0], content)] for rif in highlighted_code: msg = ChatMessage(content=f"{preface} ({rif.filepath}):\n```\n{rif.contents}\n```", diff --git a/continuedev/src/continuedev/recipes/TemplateRecipe/main.py b/continuedev/src/continuedev/recipes/TemplateRecipe/main.py index 94675725..16132cfd 100644 --- a/continuedev/src/continuedev/recipes/TemplateRecipe/main.py +++ b/continuedev/src/continuedev/recipes/TemplateRecipe/main.py @@ -20,8 +20,8 @@ class TemplateRecipe(Step): # The code executed when the recipe is run async def run(self, sdk: ContinueSDK) -> Coroutine[Observation, None, None]: - open_files = await sdk.ide.getOpenFiles() + visible_files = await sdk.ide.getVisibleFiles() await sdk.edit_file( - filename=open_files[0], + filename=visible_files[0], prompt=f"Append a statement to print `Hello, {self.name}!` at the end of the file." ) diff --git a/continuedev/src/continuedev/recipes/WritePytestsRecipe/main.py b/continuedev/src/continuedev/recipes/WritePytestsRecipe/main.py index 6e1244b3..c7a65fa6 100644 --- a/continuedev/src/continuedev/recipes/WritePytestsRecipe/main.py +++ b/continuedev/src/continuedev/recipes/WritePytestsRecipe/main.py @@ -14,7 +14,7 @@ class WritePytestsRecipe(Step): async def run(self, sdk: ContinueSDK): if self.for_filepath is None: - self.for_filepath = (await sdk.ide.getOpenFiles())[0] + self.for_filepath = (await sdk.ide.getVisibleFiles())[0] filename = os.path.basename(self.for_filepath) dirname = os.path.dirname(self.for_filepath) diff --git a/continuedev/src/continuedev/server/ide.py b/continuedev/src/continuedev/server/ide.py index 400ad740..4645b49e 100644 --- a/continuedev/src/continuedev/server/ide.py +++ b/continuedev/src/continuedev/server/ide.py @@ -52,6 +52,8 @@ class FileEditsUpdate(BaseModel): class OpenFilesResponse(BaseModel): openFiles: List[str] +class VisibleFilesResponse(BaseModel): + visibleFiles: List[str] class HighlightedCodeResponse(BaseModel): highlightedCode: List[RangeInFile] @@ -180,7 +182,7 @@ class IdeProtocolServer(AbstractIdeProtocolServer): self.onMainUserInput(data["input"]) elif message_type == "deleteAtIndex": self.onDeleteAtIndex(data["index"]) - elif message_type in ["highlightedCode", "openFiles", "readFile", "editFile", "getUserSecret", "runCommand", "uniqueId"]: + elif message_type in ["highlightedCode", "openFiles", "visibleFiles", "readFile", "editFile", "getUserSecret", "runCommand", "uniqueId"]: self.sub_queue.post(message_type, data) elif message_type == "workspaceDirectory": self.workspace_directory = data["workspaceDirectory"] @@ -302,6 +304,10 @@ class IdeProtocolServer(AbstractIdeProtocolServer): async def getOpenFiles(self) -> List[str]: resp = await self._send_and_receive_json({}, OpenFilesResponse, "openFiles") return resp.openFiles + + async def getVisibleFiles(self) -> List[str]: + resp = await self._send_and_receive_json({}, VisibleFilesResponse, "visibleFiles") + return resp.visibleFiles async def get_unique_id(self) -> str: resp = await self._send_and_receive_json({}, UniqueIdResponse, "uniqueId") diff --git a/continuedev/src/continuedev/server/ide_protocol.py b/continuedev/src/continuedev/server/ide_protocol.py index 69cb6c10..2783dc61 100644 --- a/continuedev/src/continuedev/server/ide_protocol.py +++ b/continuedev/src/continuedev/server/ide_protocol.py @@ -52,6 +52,10 @@ class AbstractIdeProtocolServer(ABC): """Get a list of open files""" @abstractmethod + async def getVisibleFiles(self) -> List[str]: + """Get a list of visible files""" + + @abstractmethod async def getHighlightedCode(self) -> List[RangeInFile]: """Get a list of highlighted code""" diff --git a/continuedev/src/continuedev/steps/main.py b/continuedev/src/continuedev/steps/main.py index e6ef9281..ce7cbc60 100644 --- a/continuedev/src/continuedev/steps/main.py +++ b/continuedev/src/continuedev/steps/main.py @@ -99,8 +99,8 @@ class FasterEditHighlightedCodeStep(Step): async def run(self, sdk: ContinueSDK) -> Coroutine[Observation, None, None]: range_in_files = await sdk.get_code_context(only_editing=True) if len(range_in_files) == 0: - # Get the full contents of all open files - files = await sdk.ide.getOpenFiles() + # Get the full contents of all visible files + files = await sdk.ide.getVisibleFiles() contents = {} for file in files: contents[file] = await sdk.ide.readFile(file) @@ -191,8 +191,8 @@ class StarCoderEditHighlightedCodeStep(Step): range_in_files = await sdk.get_code_context(only_editing=True) found_highlighted_code = len(range_in_files) > 0 if not found_highlighted_code: - # Get the full contents of all open files - files = await sdk.ide.getOpenFiles() + # Get the full contents of all visible files + files = await sdk.ide.getVisibleFiles() contents = {} for file in files: contents[file] = await sdk.ide.readFile(file) @@ -275,16 +275,6 @@ class EditHighlightedCodeStep(Step): await sdk.run_step(DefaultModelEditCodeStep(user_input=self.user_input, range_in_files=range_in_files)) -class FindCodeStep(Step): - prompt: str - - async def describe(self, models: Models) -> Coroutine[str, None, None]: - return "Finding code" - - async def run(self, sdk: ContinueSDK) -> Coroutine[Observation, None, None]: - return await sdk.ide.getOpenFiles() - - class UserInputStep(Step): user_input: str diff --git a/continuedev/src/continuedev/steps/welcome.py b/continuedev/src/continuedev/steps/welcome.py index 32ebc3ba..2dece649 100644 --- a/continuedev/src/continuedev/steps/welcome.py +++ b/continuedev/src/continuedev/steps/welcome.py @@ -29,4 +29,4 @@ class WelcomeStep(Step): - Ask about how the class works, how to write it in another language, etc. \"\"\""""))) - await sdk.ide.setFileOpen(filepath=filepath) + # await sdk.ide.setFileOpen(filepath=filepath) diff --git a/extension/react-app/src/components/StepContainer.tsx b/extension/react-app/src/components/StepContainer.tsx index d480c565..d1a8a46a 100644 --- a/extension/react-app/src/components/StepContainer.tsx +++ b/extension/react-app/src/components/StepContainer.tsx @@ -158,7 +158,7 @@ function StepContainer(props: StepContainerProps) { > <StepContainerDiv open={props.open}> <GradientBorder - loading={props.historyNode.active as boolean | false} + loading={props.historyNode.active as boolean || false} isFirst={props.isFirst} isLast={props.isLast} borderColor={ @@ -178,7 +178,7 @@ function StepContainer(props: StepContainerProps) { }} > <HeaderDiv - loading={props.historyNode.active as boolean | false} + loading={props.historyNode.active as boolean || false} error={props.historyNode.observation?.error ? true : false} > <div className="m-2"> diff --git a/extension/src/bridge.ts b/extension/src/bridge.ts index 55c4cc3b..7e6398be 100644 --- a/extension/src/bridge.ts +++ b/extension/src/bridge.ts @@ -50,7 +50,7 @@ export function getContinueServerUrl() { extensionContext && extensionContext.extensionMode === vscode.ExtensionMode.Development ) { - // return "http://localhost:8001"; + return "http://localhost:8001"; } return ( vscode.workspace.getConfiguration("continue").get<string>("serverUrl") || diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts index 304c592b..b728833f 100644 --- a/extension/src/continueIdeClient.ts +++ b/extension/src/continueIdeClient.ts @@ -131,6 +131,11 @@ class IdeProtocolClient { openFiles: this.getOpenFiles(), }); break; + case "visibleFiles": + messenger.send("visibleFiles", { + visibleFiles: this.getVisibleFiles(), + }); + break; case "readFile": messenger.send("readFile", { contents: this.readFile(data.filepath), @@ -330,6 +335,12 @@ class IdeProtocolClient { }); } + getVisibleFiles(): string[] { + return vscode.window.visibleTextEditors.map((editor) => { + return editor.document.uri.fsPath; + }); + } + saveFile(filepath: string) { vscode.window.visibleTextEditors.forEach((editor) => { if (editor.document.uri.fsPath === filepath) { |