From 41d98cad88d12af9938f7463f098940ae02fac0b Mon Sep 17 00:00:00 2001 From: markov Date: Tue, 24 Feb 2026 23:40:17 +0100 Subject: [PATCH] =?UTF-8?q?refactor:=20=D0=B2=D1=81=D1=8F=20=D1=84=D0=B8?= =?UTF-8?q?=D0=BB=D1=8C=D1=82=D1=80=D0=B0=D1=86=D0=B8=D1=8F=20=D1=81=D0=BE?= =?UTF-8?q?=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=81=D1=82=D0=BE=D1=80=D0=BE=D0=BD=D0=B5=20Tracker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - System messages: агенты получают только если @slug в content - Убрана дублирующая фильтрация из Picogent Router --- src/tracker/ws/manager.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/tracker/ws/manager.py b/src/tracker/ws/manager.py index 43cf900..33cd6fe 100644 --- a/src/tracker/ws/manager.py +++ b/src/tracker/ws/manager.py @@ -77,8 +77,18 @@ class ConnectionManager: await self.disconnect(client.session_id) async def broadcast_message(self, project_id: str, message: dict, author_slug: str): - """Broadcast message.new. Humans get everything, agents filtered.""" + """Broadcast message.new. Humans get everything, agents filtered. + + Filtering for agents: + - Skip own messages (author_slug == client slug) + - Skip if not subscribed to project + - Skip if chat_listen == "none" + - If chat_listen == "mentions": only if @slug in mentions + - System messages: only if @slug mentioned in content + """ mentions = message.get("mentions", []) + content = message.get("content", "") + author_type = message.get("author_type", "") payload = {"type": "message.new", "data": message} for session_id, client in list(self.sessions.items()): @@ -88,11 +98,18 @@ class ConnectionManager: if client.member_type in ("human", "bridge"): await self.send_to_session(session_id, payload) continue - # Agents: subscription + chat_listen + # Agents: subscription check if project_id not in client.subscribed_projects: continue if client.chat_listen == "none": continue + # System messages: only if agent is mentioned in content + if author_type == "system": + if f"@{client.member_slug}" not in content: + continue + await self.send_to_session(session_id, payload) + continue + # Regular messages: chat_listen filter if client.chat_listen == "mentions" and client.member_slug not in mentions: continue await self.send_to_session(session_id, payload)