summaryrefslogtreecommitdiff
path: root/continuedev/src
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-06-12 13:18:16 -0700
committerNate Sesti <sestinj@gmail.com>2023-06-12 13:18:16 -0700
commit25262703573e79fc436c32f48b8df428bfeb4c97 (patch)
treeb3f67f4628b8aeedbb08d9ea6ba32a6692f09267 /continuedev/src
parentaf350f5e70f20d14c361684e361b1e64e5e0b2c3 (diff)
downloadsncontinue-25262703573e79fc436c32f48b8df428bfeb4c97.tar.gz
sncontinue-25262703573e79fc436c32f48b8df428bfeb4c97.tar.bz2
sncontinue-25262703573e79fc436c32f48b8df428bfeb4c97.zip
clear history and delete step buttons
Diffstat (limited to 'continuedev/src')
-rw-r--r--continuedev/src/continuedev/core/autopilot.py10
-rw-r--r--continuedev/src/continuedev/libs/util/calculate_diff.py14
-rw-r--r--continuedev/src/continuedev/server/gui.py10
-rw-r--r--continuedev/src/continuedev/server/gui_protocol.py8
-rw-r--r--continuedev/src/continuedev/steps/core/core.py2
5 files changed, 43 insertions, 1 deletions
diff --git a/continuedev/src/continuedev/core/autopilot.py b/continuedev/src/continuedev/core/autopilot.py
index c979d53a..1642003c 100644
--- a/continuedev/src/continuedev/core/autopilot.py
+++ b/continuedev/src/continuedev/core/autopilot.py
@@ -40,6 +40,12 @@ class Autopilot(ContinueBaseModel):
def get_full_state(self) -> FullState:
return FullState(history=self.history, active=self._active, user_input_queue=self._main_user_input_queue)
+ async def clear_history(self):
+ self.history = History.from_empty()
+ self._main_user_input_queue = []
+ self._active = False
+ await self.update_subscribers()
+
def on_update(self, callback: Coroutine["FullState", None, None]):
"""Subscribe to changes to state"""
self._on_update_callbacks.append(callback)
@@ -88,6 +94,10 @@ class Autopilot(ContinueBaseModel):
async def retry_at_index(self, index: int):
self._retry_queue.post(str(index), None)
+ async def delete_at_index(self, index: int):
+ self.history.timeline[index].step.hide = True
+ await self.update_subscribers()
+
async def _run_singular_step(self, step: "Step", is_future_step: bool = False) -> Coroutine[Observation, None, None]:
capture_event(
'step run', {'step_name': step.name, 'params': step.dict()})
diff --git a/continuedev/src/continuedev/libs/util/calculate_diff.py b/continuedev/src/continuedev/libs/util/calculate_diff.py
index d778891b..ff0a135f 100644
--- a/continuedev/src/continuedev/libs/util/calculate_diff.py
+++ b/continuedev/src/continuedev/libs/util/calculate_diff.py
@@ -67,6 +67,20 @@ def calculate_diff(filepath: str, original: str, updated: str) -> List[FileEdit]
def calculate_diff2(filepath: str, original: str, updated: str) -> List[FileEdit]:
+ # original_lines = original.splitlines()
+ # updated_lines = updated.splitlines()
+ # offset = 0
+ # while len(original_lines) and len(updated_lines) and original_lines[0] == updated_lines[0]:
+ # original_lines = original_lines[1:]
+ # updated_lines = updated_lines[1:]
+
+ # while len(original_lines) and len(updated_lines) and original_lines[-1] == updated_lines[-1]:
+ # original_lines = original_lines[:-1]
+ # updated_lines = updated_lines[:-1]
+
+ # original = "\n".join(original_lines)
+ # updated = "\n".join(updated_lines)
+
edits = []
max_iterations = 1000
i = 0
diff --git a/continuedev/src/continuedev/server/gui.py b/continuedev/src/continuedev/server/gui.py
index b873a88f..e8b52004 100644
--- a/continuedev/src/continuedev/server/gui.py
+++ b/continuedev/src/continuedev/server/gui.py
@@ -77,6 +77,10 @@ class GUIProtocolServer(AbstractGUIProtocolServer):
self.on_reverse_to_index(data["index"])
elif message_type == "retry_at_index":
self.on_retry_at_index(data["index"])
+ elif message_type == "clear_history":
+ self.on_clear_history()
+ elif message_type == "delete_at_index":
+ self.on_delete_at_index(data["index"])
except Exception as e:
print(e)
@@ -106,6 +110,12 @@ class GUIProtocolServer(AbstractGUIProtocolServer):
asyncio.create_task(
self.session.autopilot.retry_at_index(index))
+ def on_clear_history(self):
+ asyncio.create_task(self.session.autopilot.clear_history())
+
+ def on_delete_at_index(self, index: int):
+ asyncio.create_task(self.session.autopilot.delete_at_index(index))
+
@router.websocket("/ws")
async def websocket_endpoint(websocket: WebSocket, session: Session = Depends(websocket_session)):
diff --git a/continuedev/src/continuedev/server/gui_protocol.py b/continuedev/src/continuedev/server/gui_protocol.py
index 287f9e3b..889c6761 100644
--- a/continuedev/src/continuedev/server/gui_protocol.py
+++ b/continuedev/src/continuedev/server/gui_protocol.py
@@ -30,3 +30,11 @@ class AbstractGUIProtocolServer(ABC):
@abstractmethod
def on_retry_at_index(self, index: int):
"""Called when the user requests a retry at a previous index"""
+
+ @abstractmethod
+ def on_clear_history(self):
+ """Called when the user requests to clear the history"""
+
+ @abstractmethod
+ def on_delete_at_index(self, index: int):
+ """Called when the user requests to delete a step at a given index"""
diff --git a/continuedev/src/continuedev/steps/core/core.py b/continuedev/src/continuedev/steps/core/core.py
index 4288ffd2..dacf0e7b 100644
--- a/continuedev/src/continuedev/steps/core/core.py
+++ b/continuedev/src/continuedev/steps/core/core.py
@@ -193,7 +193,7 @@ class Gpt35EditCodeStep(Step):
edit.range.end.line += rif.range.start.line
edit.range.end.character += rif.range.start.character if edit.range.end.line == 0 else 0
- for line in range(edit.range.start.line, edit.range.end.line + 1):
+ for line in range(edit.range.start.line, edit.range.end.line + 1 + len(edit.replacement.splitlines()) - (edit.range.end.line - edit.range.start.line + 1)):
lines_to_highlight.add(line)
await sdk.ide.applyFileSystemEdit(edit)