TIER-2 READ conductor/code_styleguides/error_handling.md end-to-end before Phase 10: refactor(gui_2): migrate L1647 render_main_interface focus_response to Result[T] (Phase 10 site 8)

Extracted _focus_response_window_result() -> Result[None] helper above
the call site in render_main_interface.
ANTI-SLIMING: full Result[T] propagation (NO bare-except+pass). The
helper returns Result(data=None) on success or Result(data=None,
errors=[ErrorInfo]) on exception (logging NOT a drain per the user's
principle 2026-06-17).

The legacy render_main_interface code preserves its behavior, calls
the helper, drains errors to app._last_request_errors.

Tests: 2 new tests verify both paths (success and RuntimeError).

Audit: L1647 reclassified from INTERNAL_SILENT_SWALLOW (6 sites remaining,
was 7). New helper L1647 is INTERNAL_COMPLIANT.
This commit is contained in:
ed
2026-06-20 00:53:35 -04:00
parent 24191c827d
commit 9188e548ff
2 changed files with 62 additions and 4 deletions
+26 -4
View File
@@ -1644,10 +1644,32 @@ def render_main_interface(app: App) -> None:
if app.controller._process_pending_tool_calls(): app._tool_log_dirty = True
if app._pending_focus_response:
app._pending_focus_response = False
try:
imgui.set_window_focus("Response") # type: ignore[call-arg]
except:
pass
focus_result = _focus_response_window_result()
if not focus_result.ok:
if not hasattr(app, '_last_request_errors'): app._last_request_errors = []
app._last_request_errors.append(("render_main_interface.focus_response", focus_result.errors[0]))
def _focus_response_window_result() -> Result[None]:
"""Drain-aware variant of render_main_interface imgui.set_window_focus try block (L1647 INTERNAL_SILENT_SWALLOW).
Extracts the thirdparty imgui.set_window_focus("Response") try/except from
render_main_interface into a Result-returning helper. On exception (native
bundle error, IM_ASSERT), converts to ErrorInfo (logging NOT a drain per
the user's principle 2026-06-17). The caller drains to
app._last_request_errors.
[C: src/gui_2.py:render_main_interface (L1647 legacy wrapper)]
"""
try:
imgui.set_window_focus("Response") # type: ignore[call-arg]
return Result(data=None)
except Exception as e:
return Result(data=None, errors=[ErrorInfo(
kind=ErrorKind.INTERNAL,
message=f"imgui.set_window_focus('Response') failed: {e}",
source="gui_2._focus_response_window_result",
original=e,
)])
#endregion: Process GUI task queue
render_track_proposal_modal(app)