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:
1 parent
817a5cba5d
commit
738c977e7d
2 files changed
+5
-1
No files matched your search
@@ -132,7 +132,10 @@ class WecomAibotChannel:
|
|||||||
if raw is None:
|
if raw is None:
|
||||||
continue
|
continue
|
||||||
msg = json.loads(raw)
|
msg = json.loads(raw)
|
||||||
self._dispatch(msg, ws)
|
try:
|
||||||
|
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()
|
||||||
|
|||||||
@@ -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)}
|
||||||
|
|||||||
Reference in new issue
Block a user