From f6105101d3b6763804b1f20267422800cc0c7c31 Mon Sep 17 00:00:00 2001 From: aashankhan2981 Date: Mon, 12 Aug 2024 18:08:29 +0500 Subject: [PATCH 1/5] added a new event for "modifiedFiles" which sends the list of modified files on project load --- core/agents/base.py | 10 +++++++++ core/agents/orchestrator.py | 4 ++-- core/state/state_manager.py | 40 ++++++++++++++++++++++++++++++++++++ core/ui/base.py | 9 ++++++++ core/ui/ipc_client.py | 11 ++++++++++ pythagora.db-journal | Bin 0 -> 45656 bytes 6 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 pythagora.db-journal diff --git a/core/agents/base.py b/core/agents/base.py index 242d25585..3a8dd05b1 100644 --- a/core/agents/base.py +++ b/core/agents/base.py @@ -61,6 +61,16 @@ async def send_message(self, message: str): """ await self.ui.send_message(message + "\n", source=self.ui_source) + async def send_modified_files(self, files: dict[str, str, str]): + """ + Send modified files to the user. + + Convenience method, uses `UIBase.send_modified_files()` to send the files, + setting the correct files. + :param files: Files to send. + """ + await self.ui.send_modified_files(files) + async def ask_question( self, question: str, diff --git a/core/agents/orchestrator.py b/core/agents/orchestrator.py index 2b6bdc439..457eb83e7 100644 --- a/core/agents/orchestrator.py +++ b/core/agents/orchestrator.py @@ -86,7 +86,7 @@ async def offline_changes_check(self): """ log.info("Checking for offline changes.") - modified_files = await self.state_manager.get_modified_files() + modified_files = await self.state_manager.get_modified_files_with_content() if self.state_manager.workspace_is_empty(): # NOTE: this will currently get triggered on a new project, but will do @@ -95,7 +95,7 @@ async def offline_changes_check(self): await self.state_manager.restore_files() elif modified_files: await self.send_message(f"We found {len(modified_files)} new and/or modified files.") - + await self.send_modified_files(modified_files) hint = "".join( [ "If you would like Pythagora to import those changes, click 'Yes'.\n", diff --git a/core/state/state_manager.py b/core/state/state_manager.py index a7eac3a98..0e3c16adc 100644 --- a/core/state/state_manager.py +++ b/core/state/state_manager.py @@ -495,7 +495,47 @@ async def get_modified_files(self) -> list[str]: modified_files.append(db_file.path) return modified_files + + async def get_modified_files_with_content(self) -> list[dict]: + """ + Return a list of new or modified files from the file system, + including their paths, old content, and new content. + + :return: List of dictionaries containing paths, old content, + and new content for new or modified files. + """ + + modified_files = [] + files_in_workspace = self.file_system.list() + + for path in files_in_workspace: + content = self.file_system.read(path) + saved_file = self.current_state.get_file_by_path(path) + # If there's a saved file, serialize its content; otherwise, set it to None + saved_file_content = saved_file.content.content if saved_file else None + + if saved_file_content == content: + continue + + modified_files.append({ + "path": path, + "file_old": saved_file_content, # Serialized content + "file_new": content + }) + + # Handle files removed from disk + await self.current_state.awaitable_attrs.files + for db_file in self.current_state.files: + if db_file.path not in files_in_workspace: + modified_files.append({ + "path": db_file.path, + "file_old": db_file.content.content, # Serialized content + "file_new": "" # Empty string as the file is removed + }) + + return modified_files + def workspace_is_empty(self) -> bool: """ Returns whether the workspace has any files in them or is empty. diff --git a/core/ui/base.py b/core/ui/base.py index 3f92c9546..919fd5413 100644 --- a/core/ui/base.py +++ b/core/ui/base.py @@ -230,7 +230,16 @@ async def send_step_progress( :param task_source: Source of the task, one of: 'app', 'feature', 'debugger', 'troubleshooting', 'review'. """ raise NotImplementedError() + async def send_modified_files( + self, + modified_files: dict[str, str,str], + ): + """ + Send a list of modified files to the UI. + :param modified_files: List of modified files. + """ + raise NotImplementedError() async def send_run_command(self, run_command: str): """ Send a run command to the UI. diff --git a/core/ui/ipc_client.py b/core/ui/ipc_client.py index a3d09b9ac..ff9634f1f 100644 --- a/core/ui/ipc_client.py +++ b/core/ui/ipc_client.py @@ -44,6 +44,7 @@ class MessageType(str, Enum): FEATURE_FINISHED = "featureFinished" GENERATE_DIFF = "generateDiff" CLOSE_DIFF = "closeDiff" + MODIFIED_FILES = "modifiedFiles" class Message(BaseModel): @@ -311,6 +312,16 @@ async def send_task_progress( "all_tasks": tasks, }, ) + async def send_modified_files( + self, + modified_files: dict[str, str, str], + ): + await self._send( + MessageType.MODIFIED_FILES, + content={ + "files": modified_files + }, + ) async def send_step_progress( self, diff --git a/pythagora.db-journal b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XI>a`-Bg@xwSllKjEpm!W*(@LZH1Kb%AP z=0ng+a_SIHK_u@z^eU9M9fDqx;-Qr&=N*DxdVX^Vdg=M;p^H&|@z4uVzV#4JE%f~U zL3;G&wFkGOJaljiO79?K+cR(wvhA@BLbg4N4lY1hICvgH=YMt(@=1L80A!o^(t!z- ze|o@0`HlmSPh#r8btrcoxDq8fuo&en2Oyus`U8+pV(EbtN@+ikkSOopfrBDX?T38g zf4P4n%E$JvK=~*8frR*b_5%s=x9_^i;QS95(KvC?&(>NCsd-wD; zDBm&-B*ack0|~L6(?CLOcp4*(y>bdjh^?9eied|=Fw)oyr*QO1_~q0pl+R8 Date: Tue, 13 Aug 2024 21:59:52 +0500 Subject: [PATCH 2/5] fixed intendations --- core/agents/base.py | 1 + 1 file changed, 1 insertion(+) diff --git a/core/agents/base.py b/core/agents/base.py index 3a8dd05b1..fe46607f4 100644 --- a/core/agents/base.py +++ b/core/agents/base.py @@ -69,6 +69,7 @@ async def send_modified_files(self, files: dict[str, str, str]): setting the correct files. :param files: Files to send. """ + await self.ui.send_modified_files(files) async def ask_question( From 92becce57d92bc06d572eb6a2185679f9a9c81e9 Mon Sep 17 00:00:00 2001 From: aashankhan2981 Date: Tue, 13 Aug 2024 22:00:10 +0500 Subject: [PATCH 3/5] fixed intendations --- core/agents/base.py | 1 - 1 file changed, 1 deletion(-) diff --git a/core/agents/base.py b/core/agents/base.py index fe46607f4..3a8dd05b1 100644 --- a/core/agents/base.py +++ b/core/agents/base.py @@ -69,7 +69,6 @@ async def send_modified_files(self, files: dict[str, str, str]): setting the correct files. :param files: Files to send. """ - await self.ui.send_modified_files(files) async def ask_question( From 97fafdf5d58dcea587015af323f8f43437996f05 Mon Sep 17 00:00:00 2001 From: aashankhan2981 Date: Tue, 13 Aug 2024 22:03:41 +0500 Subject: [PATCH 4/5] fixed intendations --- core/agents/orchestrator.py | 1 + core/state/state_manager.py | 35 +++++++++++++++++++---------------- core/ui/base.py | 15 +++++++++------ core/ui/ipc_client.py | 5 ++--- 4 files changed, 31 insertions(+), 25 deletions(-) diff --git a/core/agents/orchestrator.py b/core/agents/orchestrator.py index 457eb83e7..c9ebc25c6 100644 --- a/core/agents/orchestrator.py +++ b/core/agents/orchestrator.py @@ -102,6 +102,7 @@ async def offline_changes_check(self): "Clicking 'No' means Pythagora will restore (overwrite) all files to the last stored state.\n", ] ) + use_changes = await self.ask_question( question="Would you like to keep your changes?", buttons={ diff --git a/core/state/state_manager.py b/core/state/state_manager.py index 0e3c16adc..8d15b4964 100644 --- a/core/state/state_manager.py +++ b/core/state/state_manager.py @@ -495,13 +495,13 @@ async def get_modified_files(self) -> list[str]: modified_files.append(db_file.path) return modified_files - + async def get_modified_files_with_content(self) -> list[dict]: """ - Return a list of new or modified files from the file system, + Return a list of new or modified files from the file system, including their paths, old content, and new content. - :return: List of dictionaries containing paths, old content, + :return: List of dictionaries containing paths, old content, and new content for new or modified files. """ @@ -514,28 +514,31 @@ async def get_modified_files_with_content(self) -> list[dict]: # If there's a saved file, serialize its content; otherwise, set it to None saved_file_content = saved_file.content.content if saved_file else None - if saved_file_content == content: continue - - modified_files.append({ - "path": path, - "file_old": saved_file_content, # Serialized content - "file_new": content - }) + + modified_files.append( + { + "path": path, + "file_old": saved_file_content, # Serialized content + "file_new": content, + } + ) # Handle files removed from disk await self.current_state.awaitable_attrs.files for db_file in self.current_state.files: if db_file.path not in files_in_workspace: - modified_files.append({ - "path": db_file.path, - "file_old": db_file.content.content, # Serialized content - "file_new": "" # Empty string as the file is removed - }) + modified_files.append( + { + "path": db_file.path, + "file_old": db_file.content.content, # Serialized content + "file_new": "", # Empty string as the file is removed + } + ) return modified_files - + def workspace_is_empty(self) -> bool: """ Returns whether the workspace has any files in them or is empty. diff --git a/core/ui/base.py b/core/ui/base.py index 919fd5413..86b438d4d 100644 --- a/core/ui/base.py +++ b/core/ui/base.py @@ -230,16 +230,18 @@ async def send_step_progress( :param task_source: Source of the task, one of: 'app', 'feature', 'debugger', 'troubleshooting', 'review'. """ raise NotImplementedError() + async def send_modified_files( self, - modified_files: dict[str, str,str], + modified_files: dict[str, str, str], ): - """ - Send a list of modified files to the UI. + """ + Send a list of modified files to the UI. + + :param modified_files: List of modified files. + """ + raise NotImplementedError() - :param modified_files: List of modified files. - """ - raise NotImplementedError() async def send_run_command(self, run_command: str): """ Send a run command to the UI. @@ -299,6 +301,7 @@ async def send_project_description(self, description: str): :param description: Project description. """ + raise NotImplementedError() async def send_features_list(self, features: list[str]): diff --git a/core/ui/ipc_client.py b/core/ui/ipc_client.py index ff9634f1f..07a6e7980 100644 --- a/core/ui/ipc_client.py +++ b/core/ui/ipc_client.py @@ -312,15 +312,14 @@ async def send_task_progress( "all_tasks": tasks, }, ) + async def send_modified_files( self, modified_files: dict[str, str, str], ): await self._send( MessageType.MODIFIED_FILES, - content={ - "files": modified_files - }, + content={"files": modified_files}, ) async def send_step_progress( From 68257d1e9c013fca5015e0c093d6de56438a719f Mon Sep 17 00:00:00 2001 From: aashankhan2981 Date: Tue, 13 Aug 2024 22:04:49 +0500 Subject: [PATCH 5/5] fixed intendations --- core/agents/orchestrator.py | 1 - core/ui/base.py | 1 - 2 files changed, 2 deletions(-) diff --git a/core/agents/orchestrator.py b/core/agents/orchestrator.py index c9ebc25c6..457eb83e7 100644 --- a/core/agents/orchestrator.py +++ b/core/agents/orchestrator.py @@ -102,7 +102,6 @@ async def offline_changes_check(self): "Clicking 'No' means Pythagora will restore (overwrite) all files to the last stored state.\n", ] ) - use_changes = await self.ask_question( question="Would you like to keep your changes?", buttons={ diff --git a/core/ui/base.py b/core/ui/base.py index 86b438d4d..39941b644 100644 --- a/core/ui/base.py +++ b/core/ui/base.py @@ -301,7 +301,6 @@ async def send_project_description(self, description: str): :param description: Project description. """ - raise NotImplementedError() async def send_features_list(self, features: list[str]):