Skip to content

The agent that grows with you

refactor(tui_gateway): W4 wave2 pass 20 — voice.record + roster row folds

Tekniumf1d6a198733e
diff --git a/tui_gateway/methods_profiles.py b/tui_gateway/methods_profiles.py
index ad5377e06d3..65165ce0b40 100644
--- a/tui_gateway/methods_profiles.py
+++ b/tui_gateway/methods_profiles.py
@@ -162,21 +162,18 @@ def _latest_profile_session_rows(db):
try:
human = worker = None
for s in db.list_sessions_rich(source=None, limit=20, order_by_last_active=True, compact_rows=True):
- title = s.get("title") or ""
- last_active = s.get("last_active") or s.get("started_at") or 0
+ title, last_active = s.get("title") or "", s.get("last_active") or s.get("started_at") or 0
if _denied_source(s):
if worker is None:
- src = (s.get("source") or "").strip().lower()
- worker = {"id": s["id"], "source": src, "title": title, "last_active": last_active}
- elif human is None:
- # Rosters want "where the conversation IS": prefer the newest text.
- human = {
- "id": s["id"], "title": title,
- "preview": _latest_message_preview(db, s["id"]) or s.get("preview") or "",
- "started_at": s.get("started_at") or 0, "last_active": last_active,
- "message_count": s.get("message_count") or 0}
- if worker is not None:
- break
+ worker = {"id": s["id"], "source": (s.get("source") or "").strip().lower(),
+ "title": title, "last_active": last_active}
+ elif human is None: # rosters want "where the conversation IS": prefer the newest text
+ human = {"id": s["id"], "title": title,
+ "preview": _latest_message_preview(db, s["id"]) or s.get("preview") or "",
+ "started_at": s.get("started_at") or 0, "last_active": last_active,
+ "message_count": s.get("message_count") or 0}
+ if human is not None and worker is not None:
+ break
return human, worker
except Exception:
return None, None
diff --git a/tui_gateway/methods_voice.py b/tui_gateway/methods_voice.py
index 99e32ac326e..00b2395917e 100644
--- a/tui_gateway/methods_voice.py
+++ b/tui_gateway/methods_voice.py
@@ -716,21 +716,19 @@ def _(rid, params: dict) -> dict:
_resume_voice_wake()
return _ok(rid, {"status": "stopped"})
from hermes_cli.voice import start_continuous
- # Busy probe holds the no-speech counter during long agent turns.
- # Safe to re-register every start; older wrappers lack the setter.
+ # Busy probe holds the no-speech counter during long agent turns; safe to re-register every
+ # start (older wrappers lack the setter).
with contextlib.suppress(Exception):
from hermes_cli.voice import set_voice_busy_probe
set_voice_busy_probe(_any_session_running)
- # Shape-safe: malformed voice YAML falls back to documented defaults.
- # max_recording_seconds: explicit numeric <= 0 disables the cap (0.0).
+ # Shape-safe: malformed voice YAML falls back to documented defaults; an explicit numeric
+ # max_recording_seconds <= 0 disables the cap (0.0).
voice_cfg = _voice_cfg_dict()
max_rec = _voice_cfg_number(voice_cfg.get("max_recording_seconds"), 120.0)
# Hand the mic to STT if the wake detector holds it; a terminal capture event resumes it.
- try:
+ with contextlib.suppress(Exception):
from tools.wake_word import pause_listening
wake_paused = pause_listening(owner=transport)
- except Exception:
- wake_paused = False
if wake_paused:
with _voice_sid_lock:
_voice_wake_owner = transport
@@ -743,8 +741,7 @@ def _(rid, params: dict) -> dict:
on_stop_phrase=_vr_on_stop_phrase)
if started is False:
_resume_voice_wake()
- return _ok(rid, {"status": "busy"})
- return _ok(rid, {"status": "recording"})
+ return _ok(rid, {"status": "busy" if started is False else "recording"})
except Exception as e:
if wake_paused or action == "stop":
_resume_voice_wake()