diff --git a/core/state/state_manager.py b/core/state/state_manager.py index 0e3c16adc2..1633742959 100644 --- a/core/state/state_manager.py +++ b/core/state/state_manager.py @@ -495,13 +495,13 @@ class StateManager: 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. """ @@ -517,25 +517,29 @@ class StateManager: 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 919fd54133..39941b644a 100644 --- a/core/ui/base.py +++ b/core/ui/base.py @@ -230,16 +230,18 @@ class UIBase: :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. diff --git a/core/ui/ipc_client.py b/core/ui/ipc_client.py index ff9634f1f3..07a6e79800 100644 --- a/core/ui/ipc_client.py +++ b/core/ui/ipc_client.py @@ -312,15 +312,14 @@ class IPCClientUI(UIBase): "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(