diff --git a/gptme/tools/patch.py b/gptme/tools/patch.py index daad7caf..1bad2349 100644 --- a/gptme/tools/patch.py +++ b/gptme/tools/patch.py @@ -234,7 +234,9 @@ def execute_patch( return # Get potentially edited content - code = get_editable_text() + edited_code = get_editable_text() + was_edited = edited_code != code + code = edited_code try: with open(path) as f: @@ -256,8 +258,10 @@ def execute_patch( "Note: The patch was big and larger than the file. In the future, try writing smaller patches or use the save tool instead." ) warnings_str = ("\n".join(warnings) + "\n") if warnings else "" - - yield Message("system", f"{warnings_str}Patch successfully applied to {fn}") + edit_msg = " (edited by user)" if was_edited else "" + yield Message( + "system", f"{warnings_str}Patch successfully applied to {fn}{edit_msg}" + ) except (ValueError, FileNotFoundError) as e: yield Message("system", f"Patch failed: {e.args[0]}") diff --git a/gptme/tools/save.py b/gptme/tools/save.py index 7d7a2b5b..f2bc2376 100644 --- a/gptme/tools/save.py +++ b/gptme/tools/save.py @@ -115,7 +115,9 @@ def execute_save( return # Get potentially edited content - content = get_editable_text() + edited_content = get_editable_text() + was_edited = edited_content != content + content = edited_content finally: clear_editable_text() @@ -137,7 +139,8 @@ def execute_save( print("Saving to " + fn) with open(path, "w") as f: f.write(content) - yield Message("system", f"Saved to {fn}") + edit_msg = " (edited by user)" if was_edited else "" + yield Message("system", f"Saved to {fn}{edit_msg}") def execute_append(