From d520d5d6c28075ebde0c2fe908aa883dce0bd920 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sat, 7 Mar 2026 00:45:07 -0500 Subject: [PATCH] fix: Add debug logging to patch endpoints --- manualslop_layout.ini | 46 +++++++++++++++++------------------ src/api_hooks.py | 14 +++++++++++ src/app_controller.py | 14 +++++++++-- tests/test_patch_modal_gui.py | 4 ++- 4 files changed, 52 insertions(+), 26 deletions(-) diff --git a/manualslop_layout.ini b/manualslop_layout.ini index 29a8bcb..5a19674 100644 --- a/manualslop_layout.ini +++ b/manualslop_layout.ini @@ -74,7 +74,7 @@ DockId=0xAFC85805,2 [Window][Theme] Pos=0,17 -Size=517,960 +Size=32,960 Collapsed=0 DockId=0x00000005,1 @@ -84,14 +84,14 @@ Size=900,700 Collapsed=0 [Window][Diagnostics] -Pos=2989,1760 -Size=851,377 +Pos=829,990 +Size=851,210 Collapsed=0 DockId=0x00000002,0 [Window][Context Hub] Pos=0,17 -Size=517,960 +Size=32,960 Collapsed=0 DockId=0x00000005,0 @@ -102,26 +102,26 @@ Collapsed=0 DockId=0x0000000D,0 [Window][Discussion Hub] -Pos=1750,17 -Size=1237,1142 +Pos=430,17 +Size=397,637 Collapsed=0 DockId=0x00000013,0 [Window][Operations Hub] -Pos=519,17 -Size=1229,1142 +Pos=34,17 +Size=394,637 Collapsed=0 DockId=0x00000012,0 [Window][Files & Media] Pos=0,979 -Size=517,1158 +Size=32,221 Collapsed=0 DockId=0x00000006,1 [Window][AI Settings] Pos=0,979 -Size=517,1158 +Size=32,221 Collapsed=0 DockId=0x00000006,0 @@ -131,14 +131,14 @@ Size=416,325 Collapsed=0 [Window][MMA Dashboard] -Pos=2989,17 -Size=851,1741 +Pos=829,17 +Size=851,971 Collapsed=0 DockId=0x00000001,0 [Window][Log Management] -Pos=2989,17 -Size=851,1741 +Pos=829,17 +Size=851,971 Collapsed=0 DockId=0x00000001,1 @@ -148,26 +148,26 @@ Size=262,209 Collapsed=0 [Window][Tier 1: Strategy] -Pos=519,1161 -Size=513,976 +Pos=34,656 +Size=165,544 Collapsed=0 DockId=0x00000014,0 [Window][Tier 2: Tech Lead] -Pos=1034,1161 -Size=714,976 +Pos=201,656 +Size=228,544 Collapsed=0 DockId=0x00000016,0 [Window][Tier 4: QA] -Pos=2576,1161 -Size=411,976 +Pos=696,656 +Size=131,544 Collapsed=0 DockId=0x00000019,0 [Window][Tier 3: Workers] -Pos=1750,1161 -Size=824,976 +Pos=431,656 +Size=263,544 Collapsed=0 DockId=0x00000018,0 @@ -258,7 +258,7 @@ Column 3 Width=100 DockNode ID=0x00000008 Pos=3125,170 Size=593,1157 Split=Y DockNode ID=0x00000009 Parent=0x00000008 SizeRef=1029,147 Selected=0x0469CA7A DockNode ID=0x0000000A Parent=0x00000008 SizeRef=1029,145 Selected=0xDF822E02 -DockSpace ID=0xAFC85805 Window=0x079D3A04 Pos=0,17 Size=3840,2120 Split=X +DockSpace ID=0xAFC85805 Window=0x079D3A04 Pos=0,17 Size=1680,1183 Split=X DockNode ID=0x00000003 Parent=0xAFC85805 SizeRef=2987,1183 Split=X DockNode ID=0x0000000B Parent=0x00000003 SizeRef=404,1186 Split=X Selected=0xF4139CA2 DockNode ID=0x00000007 Parent=0x0000000B SizeRef=517,858 Split=Y Selected=0x8CA2375C diff --git a/src/api_hooks.py b/src/api_hooks.py index df35c85..8b72ace 100644 --- a/src/api_hooks.py +++ b/src/api_hooks.py @@ -289,17 +289,27 @@ class HookHandler(BaseHTTPRequestHandler): self.send_response(504) self.end_headers() elif self.path == "/api/patch/trigger": + sys.stderr.write(f"[DEBUG] /api/patch/trigger called with data: {data}\n") + sys.stderr.flush() patch_text = data.get("patch_text", "") file_paths = data.get("file_paths", []) + sys.stderr.write(f"[DEBUG] patch_text length: {len(patch_text)}, files: {file_paths}\n") + sys.stderr.flush() event = threading.Event() result = {"status": "queued"} def trigger_patch(): try: + sys.stderr.write(f"[DEBUG] trigger_patch callback executing...\n") + sys.stderr.flush() app._pending_patch_text = patch_text app._pending_patch_files = file_paths app._show_patch_modal = True + sys.stderr.write(f"[DEBUG] Set patch modal: show={app._show_patch_modal}, text={'yes' if app._pending_patch_text else 'no'}\n") + sys.stderr.flush() result["status"] = "ok" except Exception as e: + sys.stderr.write(f"[DEBUG] trigger_patch error: {e}\n") + sys.stderr.flush() result["status"] = "error" result["error"] = str(e) finally: @@ -368,9 +378,13 @@ class HookHandler(BaseHTTPRequestHandler): self.send_response(504) self.end_headers() elif self.path == "/api/patch/status": + sys.stderr.write(f"[DEBUG] /api/patch/status called\n") + sys.stderr.flush() show_modal = _get_app_attr(app, "_show_patch_modal", False) patch_text = _get_app_attr(app, "_pending_patch_text", None) patch_files = _get_app_attr(app, "_pending_patch_files", []) + sys.stderr.write(f"[DEBUG] patch status: show_modal={show_modal}, patch_text={patch_text is not None}, files={patch_files}\n") + sys.stderr.flush() self.send_response(200) self.send_header("Content-Type", "application/json") self.end_headers() diff --git a/src/app_controller.py b/src/app_controller.py index a01c35b..aae02ce 100644 --- a/src/app_controller.py +++ b/src/app_controller.py @@ -518,11 +518,21 @@ class AppController: self._ask_request_id = None self._ask_tool_data = None elif action == "custom_callback": + sys.stderr.write(f"[DEBUG] Processing custom_callback task\n") + sys.stderr.flush() cb = task.get("callback") args = task.get("args", []) if callable(cb): - try: cb(*args) - except Exception as e: print(f"Error in direct custom callback: {e}") + try: + sys.stderr.write(f"[DEBUG] Calling callable callback\n") + sys.stderr.flush() + cb(*args) + sys.stderr.write(f"[DEBUG] Callback completed\n") + sys.stderr.flush() + except Exception as e: + sys.stderr.write(f"[DEBUG] Error in direct custom callback: {e}\n") + sys.stderr.flush() + print(f"Error in direct custom callback: {e}") elif cb in self._predefined_callbacks: self._predefined_callbacks[cb](*args) elif action == "mma_step_approval": diff --git a/tests/test_patch_modal_gui.py b/tests/test_patch_modal_gui.py index 4b5ae84..de13a8c 100644 --- a/tests/test_patch_modal_gui.py +++ b/tests/test_patch_modal_gui.py @@ -31,12 +31,14 @@ def test_patch_modal_appears_on_trigger(live_gui) -> None: return True""" result = client.trigger_patch(sample_patch, ["test_file.py"]) + print(f"[DEBUG] trigger_patch result: {result}") assert result.get("status") == "ok", f"Failed to trigger patch: {result}" time.sleep(2) status = client.get_patch_status() - assert status.get("show_modal") == True, "Patch modal should be visible" + print(f"[DEBUG] get_patch_status result: {status}") + assert status.get("show_modal") == True, f"Patch modal should be visible but got {status}" assert status.get("patch_text") == sample_patch assert "test_file.py" in status.get("file_paths", [])