fix: Add debug logging to patch endpoints
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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":
|
||||
|
||||
Reference in New Issue
Block a user