fix: Add debug logging to patch endpoints

This commit is contained in:
2026-03-07 00:45:07 -05:00
parent 14dab8e67f
commit d520d5d6c2
4 changed files with 52 additions and 26 deletions

View File

@@ -74,7 +74,7 @@ DockId=0xAFC85805,2
[Window][Theme] [Window][Theme]
Pos=0,17 Pos=0,17
Size=517,960 Size=32,960
Collapsed=0 Collapsed=0
DockId=0x00000005,1 DockId=0x00000005,1
@@ -84,14 +84,14 @@ Size=900,700
Collapsed=0 Collapsed=0
[Window][Diagnostics] [Window][Diagnostics]
Pos=2989,1760 Pos=829,990
Size=851,377 Size=851,210
Collapsed=0 Collapsed=0
DockId=0x00000002,0 DockId=0x00000002,0
[Window][Context Hub] [Window][Context Hub]
Pos=0,17 Pos=0,17
Size=517,960 Size=32,960
Collapsed=0 Collapsed=0
DockId=0x00000005,0 DockId=0x00000005,0
@@ -102,26 +102,26 @@ Collapsed=0
DockId=0x0000000D,0 DockId=0x0000000D,0
[Window][Discussion Hub] [Window][Discussion Hub]
Pos=1750,17 Pos=430,17
Size=1237,1142 Size=397,637
Collapsed=0 Collapsed=0
DockId=0x00000013,0 DockId=0x00000013,0
[Window][Operations Hub] [Window][Operations Hub]
Pos=519,17 Pos=34,17
Size=1229,1142 Size=394,637
Collapsed=0 Collapsed=0
DockId=0x00000012,0 DockId=0x00000012,0
[Window][Files & Media] [Window][Files & Media]
Pos=0,979 Pos=0,979
Size=517,1158 Size=32,221
Collapsed=0 Collapsed=0
DockId=0x00000006,1 DockId=0x00000006,1
[Window][AI Settings] [Window][AI Settings]
Pos=0,979 Pos=0,979
Size=517,1158 Size=32,221
Collapsed=0 Collapsed=0
DockId=0x00000006,0 DockId=0x00000006,0
@@ -131,14 +131,14 @@ Size=416,325
Collapsed=0 Collapsed=0
[Window][MMA Dashboard] [Window][MMA Dashboard]
Pos=2989,17 Pos=829,17
Size=851,1741 Size=851,971
Collapsed=0 Collapsed=0
DockId=0x00000001,0 DockId=0x00000001,0
[Window][Log Management] [Window][Log Management]
Pos=2989,17 Pos=829,17
Size=851,1741 Size=851,971
Collapsed=0 Collapsed=0
DockId=0x00000001,1 DockId=0x00000001,1
@@ -148,26 +148,26 @@ Size=262,209
Collapsed=0 Collapsed=0
[Window][Tier 1: Strategy] [Window][Tier 1: Strategy]
Pos=519,1161 Pos=34,656
Size=513,976 Size=165,544
Collapsed=0 Collapsed=0
DockId=0x00000014,0 DockId=0x00000014,0
[Window][Tier 2: Tech Lead] [Window][Tier 2: Tech Lead]
Pos=1034,1161 Pos=201,656
Size=714,976 Size=228,544
Collapsed=0 Collapsed=0
DockId=0x00000016,0 DockId=0x00000016,0
[Window][Tier 4: QA] [Window][Tier 4: QA]
Pos=2576,1161 Pos=696,656
Size=411,976 Size=131,544
Collapsed=0 Collapsed=0
DockId=0x00000019,0 DockId=0x00000019,0
[Window][Tier 3: Workers] [Window][Tier 3: Workers]
Pos=1750,1161 Pos=431,656
Size=824,976 Size=263,544
Collapsed=0 Collapsed=0
DockId=0x00000018,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=0x00000008 Pos=3125,170 Size=593,1157 Split=Y
DockNode ID=0x00000009 Parent=0x00000008 SizeRef=1029,147 Selected=0x0469CA7A DockNode ID=0x00000009 Parent=0x00000008 SizeRef=1029,147 Selected=0x0469CA7A
DockNode ID=0x0000000A Parent=0x00000008 SizeRef=1029,145 Selected=0xDF822E02 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=0x00000003 Parent=0xAFC85805 SizeRef=2987,1183 Split=X
DockNode ID=0x0000000B Parent=0x00000003 SizeRef=404,1186 Split=X Selected=0xF4139CA2 DockNode ID=0x0000000B Parent=0x00000003 SizeRef=404,1186 Split=X Selected=0xF4139CA2
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=517,858 Split=Y Selected=0x8CA2375C DockNode ID=0x00000007 Parent=0x0000000B SizeRef=517,858 Split=Y Selected=0x8CA2375C

View File

@@ -289,17 +289,27 @@ class HookHandler(BaseHTTPRequestHandler):
self.send_response(504) self.send_response(504)
self.end_headers() self.end_headers()
elif self.path == "/api/patch/trigger": 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", "") patch_text = data.get("patch_text", "")
file_paths = data.get("file_paths", []) 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() event = threading.Event()
result = {"status": "queued"} result = {"status": "queued"}
def trigger_patch(): def trigger_patch():
try: try:
sys.stderr.write(f"[DEBUG] trigger_patch callback executing...\n")
sys.stderr.flush()
app._pending_patch_text = patch_text app._pending_patch_text = patch_text
app._pending_patch_files = file_paths app._pending_patch_files = file_paths
app._show_patch_modal = True 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" result["status"] = "ok"
except Exception as e: except Exception as e:
sys.stderr.write(f"[DEBUG] trigger_patch error: {e}\n")
sys.stderr.flush()
result["status"] = "error" result["status"] = "error"
result["error"] = str(e) result["error"] = str(e)
finally: finally:
@@ -368,9 +378,13 @@ class HookHandler(BaseHTTPRequestHandler):
self.send_response(504) self.send_response(504)
self.end_headers() self.end_headers()
elif self.path == "/api/patch/status": 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) show_modal = _get_app_attr(app, "_show_patch_modal", False)
patch_text = _get_app_attr(app, "_pending_patch_text", None) patch_text = _get_app_attr(app, "_pending_patch_text", None)
patch_files = _get_app_attr(app, "_pending_patch_files", []) 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_response(200)
self.send_header("Content-Type", "application/json") self.send_header("Content-Type", "application/json")
self.end_headers() self.end_headers()

View File

@@ -518,11 +518,21 @@ class AppController:
self._ask_request_id = None self._ask_request_id = None
self._ask_tool_data = None self._ask_tool_data = None
elif action == "custom_callback": elif action == "custom_callback":
sys.stderr.write(f"[DEBUG] Processing custom_callback task\n")
sys.stderr.flush()
cb = task.get("callback") cb = task.get("callback")
args = task.get("args", []) args = task.get("args", [])
if callable(cb): if callable(cb):
try: cb(*args) try:
except Exception as e: print(f"Error in direct custom callback: {e}") 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: elif cb in self._predefined_callbacks:
self._predefined_callbacks[cb](*args) self._predefined_callbacks[cb](*args)
elif action == "mma_step_approval": elif action == "mma_step_approval":

View File

@@ -31,12 +31,14 @@ def test_patch_modal_appears_on_trigger(live_gui) -> None:
return True""" return True"""
result = client.trigger_patch(sample_patch, ["test_file.py"]) 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}" assert result.get("status") == "ok", f"Failed to trigger patch: {result}"
time.sleep(2) time.sleep(2)
status = client.get_patch_status() 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 status.get("patch_text") == sample_patch
assert "test_file.py" in status.get("file_paths", []) assert "test_file.py" in status.get("file_paths", [])