fix(session): switch() persists binding; wecom dispatch errors logged

- switch() (admin UI bind + /switch) never called _persist_binding —
  UI-created bindings were lost on restart and invisible in the db
- wecom ws recv loop swallowed dispatch exceptions silently; now logs
  msg preview on dispatch failure (inbound blind spot)
This commit is contained in:
openbot committed 2026-10-13 17:25:01 +08:00
1 parent 817a5cba5d
commit 738c977e7d
2 files changed
+4

No files matched your search

+3
View File
@@ -132,7 +132,10 @@ class WecomAibotChannel:
if raw is None: if raw is None:
continue continue
msg = json.loads(raw) msg = json.loads(raw)
try:
self._dispatch(msg, ws) self._dispatch(msg, ws)
except Exception as e: # noqa: BLE001
self._logger.error(f"[wecom] dispatch failed: {e}; msg={raw[:200]}")
finally: finally:
try: try:
ws.close() ws.close()
+1
View File
@@ -244,6 +244,7 @@ class SessionManager:
self._bindings[self.key(channel, chat_id)] = Binding( self._bindings[self.key(channel, chat_id)] = Binding(
channel=channel, chat_id=chat_id, agent=agent_name, acp_session_id=session_id channel=channel, chat_id=chat_id, agent=agent_name, acp_session_id=session_id
) )
self._persist_binding(self._bindings[self.key(channel, chat_id)])
for entry in migrated: for entry in migrated:
self._append_text(key, agent_name, session_id, entry) self._append_text(key, agent_name, session_id, entry)
return {"agent": agent_name, "acp_session_id": session_id, "migrated": len(migrated)} return {"agent": agent_name, "acp_session_id": session_id, "migrated": len(migrated)}