From 24ba249901dbd008b28ae8329408b1463a6d52a8 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Mon, 15 Jun 2026 09:22:47 -0400 Subject: [PATCH] fix(ai_loop): route send_result() errors to Discussion Hub as error entries (FR1, Bug #2) Replaces deprecated ai_client.send() in _handle_request_event with send_result() and branches on result.ok. On error, the first ErrorInfo is routed to the event_queue as a 'response' with status='error', allowing _on_comms_entry to add it to the discussion history. The previous code called the @deprecated send() shim which silently returns '' on error. The empty string was then filtered out by _on_comms_entry (text_content.strip() check at line 3801), so users saw no discussion entry for failed AI requests. This also removes the dead 'except ai_client.ProviderError' clause at line 3692 (the class was removed in commit 64b787b8). The 2 remaining dead clauses at lines 305, 313 are fixed in the next commit (FR2). --- src/app_controller.py | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/app_controller.py b/src/app_controller.py index 070eed66..1062b81e 100644 --- a/src/app_controller.py +++ b/src/app_controller.py @@ -3673,28 +3673,26 @@ class AppController: ai_client.set_model_params(self.temperature, self.max_tokens, self.history_trunc_limit, self.top_p) ai_client.set_agent_tools(self.ui_agent_tools) # Force update adapter path right before send to bypass potential duplication issues self._update_gcli_adapter(self.ui_gemini_cli_path) - try: - resp = ai_client.send( - event.stable_md, - user_msg, - event.base_dir, - event.file_items, - event.disc_text, - stream=True, - stream_callback=lambda text: self._on_ai_stream(text), - pre_tool_callback=self._confirm_and_run, - qa_callback=ai_client.run_tier4_analysis, - patch_callback=ai_client.run_tier4_patch_callback, - rag_engine=None # Already handled above - ) - self.event_queue.put("response", {"text": resp, "status": "done", "role": "AI"}) + result = ai_client.send_result( + event.stable_md, + user_msg, + event.base_dir, + event.file_items, + event.disc_text, + stream=True, + stream_callback=lambda text: self._on_ai_stream(text), + pre_tool_callback=self._confirm_and_run, + qa_callback=ai_client.run_tier4_analysis, + patch_callback=ai_client.run_tier4_patch_callback, + rag_engine=None, # Already handled above + ) + if result.ok: + self.event_queue.put("response", {"text": result.data, "status": "done", "role": "AI"}) self._ai_status = "done" - except ai_client.ProviderError as e: - self.event_queue.put("response", {"text": e.ui_message(), "status": "error", "role": "Vendor API"}) - self._ai_status = f"error: {e.ui_message()}" - except Exception as e: - self.event_queue.put("response", {"text": f"ERROR: {e}", "status": "error", "role": "System"}) - self._ai_status = f"error: {e}" + else: + err = result.errors[0] + self.event_queue.put("response", {"text": err.ui_message(), "status": "error", "role": "Vendor API"}) + self._ai_status = f"error: {err.ui_message()}" def _on_tool_log(self, script: str, result: str) -> None: """