fix(app): log hub masks dotted tokens, keeps worker errors and drops the oldest lines by time

- redact: a token with sentence dots around it is masked too.
- Worker error messages are always logged (code and id), so the log screen
  and the error report show them without debug logging.
- The voice worker logs with stt, llm and tts categories, so its lines land
  in those tabs.
- The zip leaves out the oldest lines by the time they were logged, across
  every tab's file, not by file name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-12 13:43:01 +09:00
parent 390f6f0b86
commit eb0fa2f159
13 changed files with 143 additions and 37 deletions

View File

@@ -272,7 +272,7 @@ class Session:
self._partial_cb(speaker, st, ev.utt))
elif isinstance(ev, Final):
debug_log(f"utterance end speaker={speaker} utt={ev.utt} reason={ev.reason} "
f"ms={len(ev.audio) * 1000 // SR}", "voice_worker")
f"ms={len(ev.audio) * 1000 // SR}", "stt")
# Where, when and by whom it was said, fixed now: decoding can take a while, and a
# move or a late joiner meanwhile must not change who heard it.
said = (self.voice_channel, self.names.get(speaker, speaker),
@@ -546,7 +546,7 @@ class Session:
try:
await asyncio.to_thread(self.worker.brain.prepare, user, text, bool(self.chat_channels))
except Exception as e: # the brain must never take the session down
debug_log(f"brain prepare failed: {type(e).__name__}", "voice_worker")
debug_log(f"brain prepare failed: {type(e).__name__}", "llm")
newer, self.preparing[user] = self.preparing[user], None
text = newer if newer is not None and not similar(newer, self.last_prepared.get(user, "")) else None
finally:
@@ -565,9 +565,9 @@ class Session:
try:
yes = await asyncio.to_thread(self.worker.brain.addressed, user, text, list(self.settings.hotwords))
except Exception as e: # the brain must never take the session down
debug_log(f"brain addressed {qid} failed: {type(e).__name__}", "voice_worker")
debug_log(f"brain addressed {qid} failed: {type(e).__name__}", "llm")
yes = None
debug_log(f"brain addressed {qid} -> {yes}", "voice_worker")
debug_log(f"brain addressed {qid} -> {yes}", "llm")
self.send({"type": "addressed_result", "id": qid, "addressed": bool(yes), "failed": yes is None})
asyncio.get_running_loop().create_task(judge())
@@ -587,11 +587,11 @@ class Session:
try:
order = await asyncio.to_thread(self.worker.brain.rank, cands)
except Exception as e:
debug_log(f"brain rank {qid} failed: {type(e).__name__}", "voice_worker")
debug_log(f"brain rank {qid} failed: {type(e).__name__}", "llm")
order = None
known = {c["id"] for c in cands}
order = [i for i in (order or []) if i in known] if order is not None else None
debug_log(f"brain rank {qid} candidates={len(cands)} ok={order is not None}", "voice_worker")
debug_log(f"brain rank {qid} candidates={len(cands)} ok={order is not None}", "llm")
self.send({"type": "rank_result", "id": qid, "order": order or [], "failed": order is None})
asyncio.get_running_loop().create_task(rank())
@@ -622,7 +622,7 @@ class Session:
# They never got this answer, so nothing it asked can be confirmed next.
w = self.worker
w.reply_turns[user] = max(w.reply_turns.get(user, 0), turn + 1)
debug_log(f"brain reply {rid} did not reach the asker", "voice_worker")
debug_log(f"brain reply {rid} did not reach the asker", "llm")
self._reached(user)
def _on_reply_delivered(self, msg: dict) -> None:
@@ -653,14 +653,14 @@ class Session:
turn = w.reply_turns[user] = w.reply_turns.get(user, 0) + (2 if early else 1)
if early:
debug_log(f"brain reply {rid} arrived before the previous answer: a turn is skipped",
"voice_worker")
"llm")
from .chat_bridge import ChatBridge
chat = ChatBridge(self, asyncio.get_running_loop(), turn, w.pending_deletes.setdefault(user, {})) \
if self.chat_channels else None
try:
answer = await asyncio.to_thread(w.brain.reply, user, text, history, chat=chat)
except Exception as e: # the brain must never take the session down
debug_log(f"brain reply {rid} failed: {type(e).__name__}", "voice_worker")
debug_log(f"brain reply {rid} failed: {type(e).__name__}", "llm")
answer = None
answer = (answer or "").strip()
self.send({"type": "reply_text", "id": rid, "text": answer, "failed": not answer})
@@ -680,7 +680,7 @@ class Session:
if via == "voice" and channel and w.history is not None:
w.history.add_reply(channel, user, answer, time.time())
if speak and rid in self.cancelled_replies:
debug_log(f"brain reply {rid} not spoken: cancelled while answering", "voice_worker")
debug_log(f"brain reply {rid} not spoken: cancelled while answering", "llm")
self.send({"type": "tts_done", "id": rid, "chunks": 0, "cancelled": True, "failed": False})
elif speak:
self._on_tts({"type": "tts", "id": rid, "text": answer, "more": False})