Enhance error handling and state management in access card and session modules

- Updated the `render_access_panel` function to conditionally hide LLM errors when the Ollama model is operational, improving user experience by reducing unnecessary error visibility.
- Introduced a new `_notes_from_disk` function to streamline the retrieval of notes from disk, enhancing state management during GPU environment checks.
- Refactored error handling in the `_bind_access` function to ensure that stack and GPU environment errors are accurately recorded and managed, improving robustness in session state updates.
- Added tests to validate the new behavior of error handling and state management, ensuring that LLM errors are appropriately suppressed when conditions are met.
This commit is contained in:
Leonid Pershin
2026-08-21 20:20:49 +03:00
parent f8f8dcc93e
commit 79cb0a7e25
6 changed files with 156 additions and 22 deletions
+24
View File
@@ -42,3 +42,27 @@ def test_access_panel_red_when_killer_failed(monkeypatch):
)
panel = render_access_panel(_Cfg(), tunneled=True)
assert panel.border_style == "red"
def test_access_panel_hides_stale_llm_error_when_ollama_ok(monkeypatch):
monkeypatch.setattr(
"gpu_rent.access_card.load_state",
lambda: type(
"S",
(),
{
"notes": {
"llm_error": "Ollama /api/tags без моделей",
"stack_vm": [
{
"name": "ollama",
"ok": True,
"detail": "1 models (huihui_ai/qwen2.5-vl-abliterated:7b)",
}
],
}
},
)(),
)
panel = render_access_panel(_Cfg(), tunneled=True)
assert panel.border_style != "red"