diff --git a/src/app_controller.py b/src/app_controller.py index 02342559..e2e6f8ae 100644 --- a/src/app_controller.py +++ b/src/app_controller.py @@ -3954,6 +3954,18 @@ class AppController: self.temperature = 0.0 self.top_p = 1.0 self.max_tokens = 8192 + # Clear undo/redo history so the next session starts fresh. Without + # this, prior tests in the same live_gui session leave stale entries + # that interfere with tests like tests/test_undo_redo_sim.py that + # assume btn_reset provides a clean history baseline. + if hasattr(self, 'hook_server') and self.hook_server and getattr(self.hook_server, 'app', None) is not None: + app = self.hook_server.app + if hasattr(app, 'history'): + app.history._undo_stack.clear() + app.history._redo_stack.clear() + if hasattr(app, '_last_ui_snapshot'): app._last_ui_snapshot = None + if hasattr(app, '_pending_snapshot'): app._pending_snapshot = False + if hasattr(app, '_state_to_push'): app._state_to_push = None def _handle_compress_discussion(self) -> None: def worker() -> "Result[None]":