Private
Public Access
0
0

fix: Robustness improvements for RAG tests and GUI stability

- Added import sys to src/api_hook_client.py.
- Fixed App.__getattr__ to use direct attribute access on controller to avoid recursion.
- Simplified _get_app_attr and _has_app_attr in src/api_hooks.py.
- Centralized RAG and symbol enrichment in AppController._handle_request_event.
- Updated 	ests/test_symbol_parsing.py to match the new enrichment flow.
- Removed redundant task appending from i_status and mma_status setters.
- Improved _sync_rag_engine to only set 'ready' status after indexing is confirmed.
- Updated 	est_status_encapsulation.py to reflect setter changes.
This commit is contained in:
2026-05-15 17:17:05 -04:00
parent a2a6d4cb65
commit 7f2f9c1989
8 changed files with 130 additions and 91 deletions
+9 -16
View File
@@ -43,28 +43,19 @@ See Also:
def _get_app_attr(app: Any, name: str, default: Any = None) -> Any:
"""Retrieves an attribute from the App or its Controller."""
if hasattr(app, name):
try:
val = getattr(app, name)
return val
if hasattr(app, 'controller') and hasattr(app.controller, name):
val = getattr(app.controller, name)
return val
return default
except AttributeError:
return default
def _has_app_attr(app: Any, name: str) -> bool:
"""Checks if an attribute exists on the App or its Controller."""
if hasattr(app, name): return True
if hasattr(app, 'controller') and hasattr(app.controller, name): return True
return False
return hasattr(app, name)
def _set_app_attr(app: Any, name: str, value: Any) -> None:
"""Sets an attribute on the App or its Controller."""
if hasattr(app, name):
setattr(app, name, value)
elif hasattr(app, 'controller'):
setattr(app.controller, name, value)
else:
setattr(app, name, value)
setattr(app, name, value)
class HookServerInstance(ThreadingHTTPServer):
"""Custom HTTPServer that carries a reference to the main App instance."""
@@ -93,6 +84,7 @@ class HookHandler(BaseHTTPRequestHandler):
"""Handles GET requests by routing to the appropriate state provider."""
try:
app = self.server.app
print(f'[HOOKS] GET {self.path}')
session_logger.log_api_hook("GET", self.path, "")
if self.path == "/status":
self.send_response(200)
@@ -152,9 +144,10 @@ class HookHandler(BaseHTTPRequestHandler):
combined = {**settable, **gettable}
if field_tag in combined:
attr = combined[field_tag]
result["value"] = _get_app_attr(app, attr, None)
val = _get_app_attr(app, attr, None)
result["value"] = _serialize_for_api(val)
else:
sys.stderr.write(f"[DEBUG] Hook API: field {field_tag} not found in settable or gettable\n")
sys.stderr.write(f"Hook API: field {field_tag} not found in settable or gettable\n")
sys.stderr.flush()
finally: event.set()
lock = _get_app_attr(app, "_pending_gui_tasks_lock")